Gravitational plate of three masses and a slashed discABC0Static engraved plate. Three-dimensional view is unavailable or reduced motion is requested.

← back to fieldarchive

archiveAug 16, 2020

Linux Linker Environment Variables

Notes on LD_PRELOAD, LD_SHOW_AUXV, and how linker scripts shape ELF section and segment layout.

LD_PRELOAD

  • Points the dynamic linker at a library path that should load before other libraries.
  • Symbols and functions from that preloaded library override later-linked ones with the same names.
  • Useful for redirecting shared-library calls and applying runtime patches.

LD_SHOW_AUXV

  • Tells the program loader to print the process auxiliary vector while the program runs.
  • The auxiliary vector sits on the program stack (placed by the kernel's ELF loading path) and carries process-specific data into the dynamic linker.
  • That data is useful for reversing and debugging.

./0.png
./0.png

  • For the memory address of the VDSO page in the process image, check AT_SYSINFO.

Linker scripts

  • The linker reads a linker script to decide section layout, memory, and symbols.
  • Dump the default script with ld -verbose.
  • ld interprets the script when it takes inputs such as relocatable objects, shared libraries, and headers.
  • The script says how to build the output (for example an executable).
  • For an ELF executable, it controls placement and which sections land in which segments.
  • .bss always ends up at the end of the data segment because the linker script puts it there.
  • Understanding the link step during compilation matters: gcc leans on the linker and other tools for that work.
  • Being able to steer executable layout is a practical control point, not a curiosity.

related

  1. Aug 16, 2020/archiveDevice Files Useful for ELF Analysis
  2. Aug 16, 2020/archiveELF file format
  3. Aug 16, 2020/archiveELF program headers

graphfeed