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.

- For the memory address of the
VDSOpage in the process image, checkAT_SYSINFO.
Linker scripts
- The linker reads a linker script to decide section layout, memory, and symbols.
- Dump the default script with
ld -verbose. ldinterprets 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.
.bssalways ends up at the end of the data segment because the linker script puts it there.- Understanding the link step during compilation matters:
gccleans on the linker and other tools for that work. - Being able to steer executable layout is a practical control point, not a curiosity.