Mehdi Akiki

Posts tagged "linker"

  • Published on

    Investigation · Part 8 of 20 · From source to a running process

    How a Call to printf Finds printf: The PLT and the GOT

    I watched one GOT slot in gdb before and after the first call to puts, measured what lazy binding costs on that first call, and compared it with -z now, LD_BIND_NOW, -fno-plt and a Rust binary that never uses the PLT for libc.
  • Published on

    Investigation · Part 7 of 20 · From source to a running process

    How the Dynamic Loader Finds a Shared Library

    I built a small shared library and a program that needs it, got the famous cannot open shared object file, and fixed it three ways while LD_DEBUG=libs showed every directory the loader tried, including why RPATH and RUNPATH give different answers.
  • Published on

    Investigation · Part 6 of 20 · From source to a running process

    Static or Dynamic Linking: What Changes in the Binary and at Startup

    I built the same programs static and dynamic, in C and Rust, and compared files, system calls, start time and shared memory. Static starts twice as fast here, but a static program that looks up an unknown user loaded the shared libc anyway and crashed.
  • Published on

    Investigation · Part 5 of 20 · From source to a running process

    Relocations: The Holes the Compiler Leaves for the Linker

    An object file is full of zero bytes where addresses should be, with a note for each one. I followed these notes through the linker and the loader, computed the filled bytes by hand, and counted the relative relocations that a PIE still needs at startup: 3 in C, 607 in Rust.
  • Published on

    Investigation · Part 4 of 20 · From source to a running process

    Why "Undefined Reference" Is a Linker Error, Not a Compiler Error

    Two C files compile without any problem and then fail together with undefined reference. I followed the error to the program that really prints it, then made the same mistake in Rust, where three different programs speak in one error message.