Mehdi Akiki

Posts tagged "c"

  • 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 1 of 10 · Types under the hood

    What Is a Type? A Set of Values, a Promise About Operations, or Both

    I took one small type, Human = man or woman, and compiled it in TypeScript, Rust, and C to see what stays of it. A type is a set of allowed values plus a set of allowed operations, both checked once, and neither reaches the processor.
  • 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 4 of 20 · When the benchmark lies

    Why the First Run Is Slower

    The first iteration of my loop took 145 microseconds and the steady state 12. I separated the causes I could show on my laptop: page faults, cold caches, a pause of 300 ms, lazy binding in C, and the start of the process itself.
  • 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.