This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ond, a single copy of the .text section of a shared library in memory can be shared by different running processes. We will explore this in more detail when we study virtual memory in Chapter 10. Figure 7.15 summarizes the dynamic linking process for the example program in Figure 7.6. To build a shared library libvector.so of our example vector arithmetic routines in Figure 7.5, we would invoke the compiler driver with a special directive to the linker:
unix> gcc -shared -fPIC -o libvector.so addvec.c multvec.c The -fPIC ﬂag directs the compiler to generate position independent code (more on this in the next section). The -shared ﬂag directs the linker to create a shared object ﬁle.
main2.c vector.h Translators (cpp, cc1, as) libc.so libvector.so relocatable main2.o Linker (ld) relocation and symbol table info partially linked executable object file p2 Loader (execve) libc.so libvector.so code and data fully linked executable in memory
Dynamic linker (ld-linux.so) Figure 7.15: Dynam...
View Full Document