Mehdi Akiki

Posts tagged "from source to process"

  • Published on

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

    The Code That Runs Before main: _start, Constructors and init_array

    With gdb I followed what calls main, where constructors are called from, and in which order init_array and fini_array run. A program without libc starts in 56 microseconds instead of 143, and Rust std has its own function in init_array.
  • Published on

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

    How LD_PRELOAD Replaces a Function Without Recompiling

    I wrote a small library that counts malloc calls and preloaded it into C, Rust and ls. The famous dlsym trap did not appear with glibc 2.43, but ls hid my output in a way I did not expect, and the static binary ignored the library completely.
  • 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.