In practice all compilation systems provide a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 files, to create the executable object file 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 file 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 files and command line arguments and generate as output a fully linked executable object file that can be loaded and run. The input relocatable object files 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

Ask a homework question - tutors are online