Click here to Skip to main content
15,887,939 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
What is exactly the difference between the position independant code and Relocatable code. Who is responsible for generating the position independant code(PIC) and Relocatable code(say compiler/linker/loader). Does all compiler/linker supports PIC generation and relocation?
Posted

1 solution

"What is exactly the difference between the position independant code and Relocatable code."
If in doubt, ask Wikipedia: https://en.wikipedia.org/wiki/Position-independent_code[^]
" position-independent code (PIC) or position-independent executable (PIE) is a body of machine code that, being placed somewhere in the primary memory, executes properly regardless of its absolute address
...
This differs from relocatable code, in which a link editor or program loader modifies a program before execution so it can be run only from a particular memory location. "


Does all compiler/linker supports PIC generation and relocation?
No.
Modern ones do, but very old ones may not.
 
Share this answer
 
Comments
chandrAN2& 23-Aug-15 13:46pm    
Thanks for your reply. Is both code and data are position independant. I am asking this because, based on pc relative address code may be generated for position independant loading, but for data what is the case? How position independant code come into picture for data section. Because in ARM site, it is mentioned that both code and data may be position independant. Could someone clarify?

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0203g/Bcfbbdec.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900