PIC is wasteful

Agner Fog agner@agner.org
Wed Jun 29 18:35:00 GMT 2011


When a shared object is shared between two processes, there will be two 
instances of the writable data sections, but both mapped to the same 
logical address, as I understand it.

If I compile a shared object with -fno-pic in 32-bit x86 there will be 
absolute addresses in the code section needing relocation. What happens 
if this library is shared between two processes? Will I get two 
instances of the code section, or will the system recognize that these 
relocated references are identical in all processes because they refer 
to data sections that are all mapped to the same logical address?

In 64 bit mode, I have to compile with -fpie which makes relative 
addresses in the code section. All absolute references are in data 
sections and exception handler tables, so I guess there is no issue here.



More information about the Gcc-help mailing list