OT: Why -g when compiling

Martin v. Löwis martin at v.loewis.de
Sat Jan 3 16:09:01 EST 2004


Michael Hudson <mwh at python.net> writes:

> That makes sense.  I also guess that as shared libraries are mmaped
> into the applications address space they won't use physical memory
> until referenced anyway.  But relocations probably mess with that.

That's what PIC (position-independent code) is for: The code itself
has no relocations, only centralized tables at the beginning of the
shared library (PLT: procedure linkage table, GOT: global offset
table) have relocations; they are tiny compared to the entire image.

On Windows, each DLL has a "preferred load address"; if the library is
loaded to this address, no relocations are needed (except in the
import stubs).

On OSX, the infamous "optimizing system" process invoked during
software installation precomputes the addresses of all symbols, and
puts updated code segments on disk which then can be mapped without
relocation.

Regards,
Martin



More information about the Python-list mailing list