question about -fPIC and 32-bit x86 (on linux-elf)
Joe Buck
Joe.Buck@synopsys.COM
Thu Aug 12 17:02:00 GMT 2004
On Thu, Aug 12, 2004 at 06:22:29PM +0200, Arkadiusz Pawlik wrote:
> As you say, PIC enables sharing of the text segments of shared
> libraries. I wonder why program binaries are usually compiled
> position-dependant, because this way multiple instances of the same
> program do not share program's code (only shared libraries).
This is off-topic, but your supposition is incorrect (at least for
all Unix-like systems): the text segment is shared by different
instances of the same program. The code does not need to be position
independent, because it is mapped to the same virtual address in each
process. Shared libraries need to be PIC because they will be mapped
to *different* virtual addresses in different processes.
More information about the Gcc
mailing list