This preview shows page 1. Sign up to view the full content.
Unformatted text preview: driver goes through the same process to generate swap.o. Finally it runs the linker program ld, which combines main.o and swap.o, along with the necessary system object ﬁles, to create the executable object ﬁle p:
ld -o p [system object files and args] /tmp/main.o /tmp/swap.o To run the executable p, we type its name on the Unix shell’s command line:
unix> ./p The shell invokes a function in the operating system called the loader, which copies the code and data in the executable ﬁle p into memory, and then transfers control to the beginning of the program. 7.2 Static Linking
Static linkers such as the Unix ld program take as input a collection of relocatable object ﬁles and command line arguments and generate as output a fully linked executable object ﬁle that can be loaded and run. The input relocatable object ﬁles consist of various code and data sections. Instructions are in one section, initialized global variables are in another section, and uninitialized variables ar...
View Full Document
- Spring '10
- The American