Download presentation
Presentation is loading. Please wait.
Published byMuriel Lewis Modified over 8 years ago
1
Object Files & Linking
2
Object Sections Compiled code store as object files – Linux : ELF : Extensible Linking Format – Windows : PE : Portable Execution
3
Object Sections ELF sections.text : Executable code read/executable.rodata : Read Only Data read.data : Data read/write.bss : Uninitialized Data read/write
4
Object at Runtime At runtime segments loaded into process address space
5
Object at Runtime Addresses need to be relocatable – Linker needs to move as it combines objects
6
Relocation Addresses stored as offset in section Address = section start + offset Mov instruction = Code start + Offset = 0xXXXXF000 + 0xXXXX0080
7
Relocation Code sample: – Array in.data – getNum accesses – getBiggerNum calls others
8
Relocation Offsets
9
Relocation Do not have final addresses for branches & loads
10
Relocation Table Relocation Table stores addresses that need fixing at link time: Offset of item Address it needs
11
Relocation Linker fixes up
12
Static Libraries Static Libraries: – Collection of 1+ object files designed to bake into executable at compile time – Windows : mylibrary.lib – Linux mylibrary.a
13
Static Libraries Static Issues: – All library code included in every executable – Every running program has own copies of in memory – Need to recompile to use new library code
14
Static Libraries Dynamic Libraries: – Collection of 1+ object files designed to be linked at run time – Windows : mylibrary.dll (dynamically linked library) – Linux mylibrary.so (shared object)
15
Static Libraries Dynamic Wins: – Executable does not need lib code – Every running program can share one copy of library – May not need to recompile to use new library code
16
Static Libraries Dynamic Wins: – Every running program can share one copy of library Library code must not be modifiable in.text
17
Static Libraries Dynamic Wins: – May not need to recompile to use new library code As long as no features removed/reordered
18
Dynamic Sample Program to make use of dynamic library:
19
Dynamic Sample Program to make use of dynamic library: – Function calls now go to ___@plt
20
Dynamic Sample Program to make use of dynamic library: – Function calls now go to ___@plt
21
PLT Procedure Linkage Table Jump table in.data used to look up dynamic functions
22
PLT First call, Global Offset Table points back to code to dynamic loader
23
PLT Loader replaces GOT record with
24
Other Dynamic Tricks Can load library at run time:
25
Other Dynamic Tricks Can load library at run time:
26
Other Dynamic Tricks Can hijack dynamic library calls – Hacking – Debugging
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.