Unformatted text preview: alls member functions in the static libvector.a library. 364 CHAPTER 7. LINKING any further linking at load time. When the linker runs, it determines that the addvec symbol deﬁned by addvec.o is referenced by main.o, so it copies addvec.o into the executable. Since the program doesn’t reference any symbols deﬁned by multvec.o, the linker does not copy this module into the executable. The linker also copies the printf.o module from libc.a, along with a number of other modules from the C run-time system.
main2.c vector.h Translators (cpp, cc1, as) libvector.a libc.a static libraries relocatable object files main2.o addvec.o Linker (ld) printf.o and any other modules called by printf. o p2 fully linked executable object file Figure 7.7: Linking with static libraries. 7.6.3 How Linkers Use Static Libraries to Resolve References
While static libraries are useful and essential tools, they are also a source of confusion to programmers because of the way the Unix linker uses them to resolve external references. During the symbol resolution phase, the linker scans the relocatable object ﬁles and archives left to right in the sam...
View Full Document