Chapter 23 Further Reading: Linking, Loading, and ELF


1. "Linkers and Loaders" by John R. Levine Morgan Kaufmann — free draft at http://linker.iecc.com

The definitive book on linking. Covers object file formats (ELF, COFF, Mach-O, a.out), symbol resolution, relocation, shared libraries, dynamic linking, and position-independent code in comprehensive detail. Chapter 3 on object files, Chapter 4 on storage allocation, and Chapter 10 on dynamic linking are directly relevant to this chapter's topics. Levine's treatment of symbol resolution algorithms (strong/weak, archive scanning) is the clearest available.


2. ELF-64 Object File Format Specification Version 1.5 Draft 2 — https://www.uclibc.org/docs/elf-64-gen.pdf

The primary specification for ELF64 structures. The Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, Elf64_Sym, Elf64_Rela structures in this document define exactly what every field means. Should be read alongside <elf.h> on a Linux system. Essential reference when writing the ELF parser challenge exercise from the exercises section.


3. System V ABI, AMD64 Architecture Processor Supplement https://github.com/hjl-tools/x86-psABI

Chapter 4 covers "Object Files" — ELF sections, symbol tables, and relocation types specific to x86-64. Chapter 5 covers "Program Loading and Dynamic Linking" — how the loader processes PT_LOAD segments, the .dynamic section structure, and the GOT/PLT mechanism. This is the authoritative reference for x86-64 ELF behavior.


4. "Shared Libraries" — Drepper, Brendan Gregg, and others https://www.akkadia.org/drepper/dsohowto.pdf — "How To Write Shared Libraries" by Ulrich Drepper

Ulrich Drepper (glibc maintainer) wrote the definitive guide to writing correct, efficient shared libraries. Covers PIC requirements, visibility attributes (__attribute__((visibility("hidden")))), symbol versioning, DT_RPATH vs. DT_RUNPATH, the PLT/GOT mechanism, and optimization techniques. This is required reading before writing any non-trivial shared library.


5. GNU LD Manual — "Linker Scripts" https://sourceware.org/binutils/docs/ld/Scripts.html

The complete reference for GNU ld linker scripts. Covers all SECTIONS commands, MEMORY regions, ENTRY, KEEP, AT (load address vs. virtual address for ROM/RAM split), ALIGN, PROVIDE, and the full language specification. The "Simple Linker Script Example" section is the best starting point; the "Location Counter" section explains the . operator used throughout MinOS's linker script.


6. OSDev Wiki — "Bare Bones" Tutorial https://wiki.osdev.org/Bare_Bones

The canonical starting point for OS development. Shows exactly the Multiboot header, boot assembly, linker script, and minimal C kernel structure used in Case Study 23-2. The wiki also covers GDT setup, long mode activation, interrupt handling, and paging — the next steps after the MinOS case study. Comprehensive community-maintained resource with examples verified on real hardware and QEMU.


7. "Position Independent Executables (PIE)" — Exec Shield Documentation https://en.wikipedia.org/wiki/Position-independent_code — and Fedora/Red Hat security docs

Background on why PIE was introduced, the performance overhead (now minimal on x86-64 due to RIP-relative addressing), and how ASLR interacts with PIE. Covers the difference between ET_EXEC (non-randomized) and ET_DYN (randomized) and explains why -fPIE -pie are two separate flags (compiler generates PIC code; linker marks the output as position-independent).


8. "Blog: Anatomy of a Linux ELF Binary" — Various Authors https://lwn.net/Articles/631631/ — "How programs get run: ELF binaries" by David Drysdale

LWN's detailed article on how the Linux kernel processes execve() with ELF binaries: binfmt_elf.c load_elf_binary(), PT_LOAD mapping with do_mmap(), PT_INTERP handling, and the auxiliary vector. Reading this makes the "kernel phase" of loading concrete. The follow-up article "How programs get run: ELF shared libraries" covers the dynamic linker side.


9. Binutils Source Code — bfd/elf64-x86-64.c https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git

The actual implementation of x86-64 ELF relocation handling in GNU binutils. The elf_x86_64_relocate_section function implements every relocation type (R_X86_64_PC32, R_X86_64_PLT32, R_X86_64_GOTPCREL, etc.) with the precise formula. Reading this source makes the relocation formulas concrete — you can see exactly what S + A - P means in production code.


10. "Twenty Years of ELF ABI Stability" — Various https://www.slideshare.net — numerous conference talks on ELF ABI evolution

ELF has been the standard Unix binary format since the early 1990s. This stability has costs and benefits: new architectures must map their calling conventions and binary interfaces onto the existing ELF framework. Talks by Mark Mitchell, Ian Lance Taylor (gold linker author), and others at the GNU Tools Cauldron and EuroLLVM conferences cover how ELF evolves (e.g., GNU_PROPERTY notes for x86 CET, RISC-V ELF ABI definition, AArch64 MTE support) while maintaining backward compatibility.