Thursday, September 17, 2009

Linkers and Loaders


== Linkers and Loaders ==
By John R. Levine. 2000. ISBN 1-55860-496-0

- linkers and loaders are part of the software toolkit for almost
as long as there have been computers.
- This book is for:
students, programmers, computer language designers and developers.
- All the linker writers in the world could probably fit in one room,
and half of them would already have this book because they reviewed
the manuscript.

Chapter 1. Linking and Loading

1.1 What do linkers and loaders do?
- Basic job of linker/loader: binds more abstract names to more
concrete names. (name management, address binding)

1.2 Address binding: A historical perspective
- Linker and Loader divides the job: Linker do part of address binding,
assign relative addresses. Loader do final step of assigning actual addresses.

1.3 Linking and Loading
- linker does 1) symbol resolution, loader does 2) program loading.
Either can do 3) relocation.
- There are linking loaders that do all 3 functions
- Both patch object code

- Two-pass linking: linking is fundamentally a 2-pass process:
step 1) collecting info, step 2) linking
object files + shared lib + normal lib + linker control files + cmd line args -->
(linker) -->
Debug symbol file + Executable file + link/load map
- Object code libraries
- Relocation and code modification

1.4 Compiler drivers
- assembly code --> object code --> link object code and library together
- Linker command languages. Ways of passing commands to a linker:
1) command line, 2) intermixed with obj files,
3) embedded in obj files, 4) separate config language.

1.5 Linking: A true-life example

Chapter 2. Architecture issues

- Architecture: 1) hardward (program addressing, instruction formats), 2) OS.

2.1 ABI (Application Binary Interfaces)
- procedure call etc.

2.2 Memory addresses
- Byte order & alignment
IBM/Motorola: big endian
Intel/DEC: little endian
- misalignment: fault, or loss of performance
- register. size: program address

2.3 Address formation
- clean: 360/370/390
- simple: SPARC (RISC): v8 (32-bit), v9 (64-bit)
similar to other RISC arch: MIPS, Alpha
- irregular: x86

2.4 Instruction formats
- opcode operand
- direct/register addressing, base/indexed addressing
- fixed/variable length instruction
SPARC: all 4 bytes
370: 2/4/6 bytes
x86: 1-14 bytes

2.5 Procedure calls and addressibility
- abandon direct addressing for shorter instructions at the cost of
more complicated programming.
- bootstrapping for non-direct addressing
- procedure calls
- stack frame
arguments/local variables - on stack
local/global static variables - on heap

No comments:

Blog Archive

Followers