Mehdi Akiki

Posts tagged "from source to process"

  • 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.
  • Published on

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

    Where Your Variables Live in a Binary: .text, .rodata, .data and .bss

    I printed the address of every kind of variable in a C program and a Rust program and matched them with nm and readelf. A 16 MiB array of zeros costs nothing in the file, the same array with one byte set to 1 costs 16 MiB, and a Rust const has no address at all.
  • Published on

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

    What Is Inside an Executable File: ELF Headers, Segments and Sections

    I opened my three hello worlds with readelf. A program still runs after I delete all its section headers, one changed byte in a segment stops it, and 90% of the Rust file is debug information of the standard library.
  • Published on

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

    What Happens When You Run a Program: From execve to main

    My C hello world makes 32 system calls before it prints its line, the static one 14, the Rust one 61. I followed every call back to the code that made it (the kernel, the loader, libc or the Rust runtime) and I timed one start of each.