References:
Linker/Loader: binds more abstract names to more concrete names.
Example:
getline
–> “the location 612 bytes from the beginning of the executable code in module iosys
”.
“the location 450 bytes beyond the beginning of the static data from this module” –> numberic address.
Overlays by linker: different part of a program to share the same memory, with each overlay loaded on demand when another part of the program called into it.
Overlays faded as virtual memory spreaded.
Object file
section | description |
---|---|
Header | size and positions |
Text Segment | instructions |
Data Segment | static data: local/globals, strings, constants |
Debugging Information | line -> code |
Symbol Table | external (exported) & unresolve (imported) refs |
objdump
--disassemble
/-d
--syms
/-t
Handling forward references
Can be in two passes.
Can also in one pass:
Handling external references
Output object files:
Linkers: binding some symbols to a relative addresses inside a program;
Loaders: binding symbols to actual address (non-relative).
Dynamic linking, or resolving an address for a procedure call can happen:
For shared libraries:
Reads an executable and runs the program: setting up memory, as well as re-doing the linker’s job for some dynamic libraries.
Dynamic libararies are linked when you run the program instead of when you compile the program.
Loaders can map a shared library into the same physical address but with different virtual addresses for different applications that use this library, to save physical memory space.
Run-time loading: link the program to the loader itself and invoker loader’s “load this subroutine from this dynamic library” subroutine as it runs. The mechanics of such run-time loading are the same as execution-time loading. Benefit: can react to missing libs; Penalty: lib is not listed in the binary, thus hard to tell in advance what lib are needed. Common in Windows, almost universal in OS X, and unusual in Linux. Why???
Reference SECTIONS Command Output Section description: section [address] [(type)] : [AT(lma)] [ALIGN(section_align) | ALIGN_WITH_INPUT] [SUBALIGN(subsection_align)] [constraint] { output-section-command output-section-command ... } [>region] [AT>lma_region] [:phdr :phdr ...] [=fillexp] [,] VMA and LMA Every section has a virtual memory address (VMA) and a load memory address (LMA), see baseic script concepts. The address in a linker script is virtual address (VMA). This address is optional, but if it is provided then the output address will be set exactly as specified.
If you could revise
the fundmental principles of
computer system design
to improve security...
... what would you change?