Hasty Briefsbeta

Bilingual

Load-time relocation of shared libraries (2011)

6 months ago
  • #load-time-relocation
  • #shared-libraries
  • #linux
  • Explains how modern operating systems use shared libraries with load-time relocation, focusing on Linux OS running on 32-bit x86.
  • Shared libraries are also known as shared objects, dynamic shared objects (DSOs), or dynamically linked libraries (DLLs).
  • Linux loads executables to a fixed memory address, with the ELF header specifying an entry point address.
  • Linker resolves internal symbol references to fixed locations, but shared libraries require additional relocations.
  • Demonstrates load-time relocation using a shared library and a driver executable, showing how symbols like 'myglob' are relocated.
  • Address space layout randomization (ASLR) in Linux makes tracking relocation addresses challenging but manageable.
  • Uses 'dl_iterate_phdr' to inspect loaded shared libraries and their segments at runtime.
  • Explains relocation of function calls, using 'ml_util_func' as an example, and the role of 'R_386_PC32' relocation type.
  • Discusses why call relocations are needed for global symbols but not for static functions.
  • Load-time relocation is simpler to understand than position-independent code (PIC) and has performance advantages on some systems.
  • Concludes that understanding load-time relocation is foundational for grasping more complex concepts like PIC.