Static linking Input a relocatable object files and command line arguments Output Fully linked executable object file that can be loaded and run
11 Static linking • Input – A relocatable object files and command line arguments • Output – Fully linked executable object file that can be loaded and run
Static linking Symbol resolution resolves externa references external reference: reference to a symbol defined in another object file 12
12 Static linking • Symbol resolution – resolves external references. • external reference: reference to a symbol defined in another object file
Static linking Relocation relocates symbols from their relative locations in the. o files to new absolute positions in the e× ecutable updates all references to these symbols to reflect their new positions references can be in either code or data code: a();/* ref to symbol a * data: int *xp=&x; / ref to symbol
13 Static linking • Relocation – relocates symbols from their relative locations in the .o files to new absolute positions in the executable. – updates all references to these symbols to reflect their new positions. • references can be in either code or data – code: a(); /* ref to symbol a */ – data: int *xp=&x; /* ref to symbol x */
7.4 Relocatable Ob ject Files
14 7.4 Relocatable Object Files
Executable and Linkable Format(ELF) Standard binary format for ob ject files Derives from a T&t system V Unix later adopted by BSD Unix variants and Linux One unified format for relocatable object files(.o), executable object files, and shared object files (. so) generic name: ELF binaries Better support for shared libraries than old a out formats 15
15 Executable and Linkable Format (ELF) • Standard binary format for object files • Derives from AT&T System V Unix – later adopted by BSD Unix variants and Linux • One unified format for relocatable object files (.o), executable object files, and shared object files (.so) – generic name: ELF binaries • Better support for shared libraries than old a.out formats