This preview shows page 1. Sign up to view the full content.
Unformatted text preview: given the hundreds of libraries and versions of libraries in a system, it would be difﬁcult to keep the address space from fragmenting into lots of small unused but unusable holes. Even worse, the assignment of libraries to memory would be different for each system, thus creating even more management headaches. A better approach is to compile library code so that it can be loaded and executed at any address without being modiﬁed by the linker. Such code is known as position-independent code (PIC). Users direct GNU compilation systems to generate PIC code with the -fPIC option to GCC. On IA32 systems, calls to procedures in the same object module require no special treatment, since the references are PC-relative, with known offsets, and hence are already PIC (see Problem 7.4). However, calls to externally-deﬁned procedures and references to global variables are not normally PIC, since they require relocation at link time. PIC Data References
Compilers generate PIC references to global variables by exploiting the following interesting fact: No matter where we load an objec...
View Full Document
- Spring '10
- The American