CSE451 Linking and Loading Autumn 2002: Gary Kimura Lecture #21 December 9, 2002
CSE451 Linking and Loading Autumn 2002: Gary Kimura Lecture #21 December 9, 2002
Autumn 2002
Gary Kimura
Lecture #21
December 9, 2002
Todays Topic
How do programs actually get loaded into memory
The Windows executable image format
From source to execution
A programmer writes a
Source file (helloworld.c file)
A compiler then translates it into an
Object module (helloworld.obj file)
The linker combines various object modules it an
Executable image (helloworld.exe file)
The loader does the final work in getting the image
executing on the system
But what does a .obj or a .exe file really contain?
First, a little theory then the real stuff
Three ways a program can get loaded
Absolute loading Load program at the same address
(virtual and/or physical) every time
Relocatable loading Load program at different
addresses based on what is available
Dynamic run-time loading Load and reload the
program at different addresses while the program is
running
Address Binding
Where a symbolic label/name is translated (bound) to
an actual address
The actual binding can be specified in the program, or
resolved at compile time, link time, load time, or run
time.
COFF and PE Files
Common Object File Format (COFF)
Portable Executable (PE) File Format
We are going to concentrate on the PE File format for
executable images. Roughly the same format is used for
object modules and dynamic link libraries.
The PE file closely resembles what is needed in memory to
run the program.
The PE file itself is divided into various sections
representing code, data, etc.