Mehdi Akiki

Posts tagged "memory layout"

  • Published on

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

    Reading /proc/self/maps Line by Line

    I printed the memory map of a small C program and of a Rust program and explained every column and every line, then watched the addresses move with ASLR, stop moving with setarch -R, and go back to 0x400000 with -no-pie.
  • Published on

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

    What Is on the Stack When a Process Starts: argv, envp and auxv

    Before the first instruction, the kernel writes argc, argv, envp and 22 pairs of numbers for the loader at the top of the stack. I read them from a C program, compared them with LD_SHOW_AUXV, and saw 4,000 bytes of environment move every local variable of main.
  • Published on

    Investigation · Part 6 of 10 · Types under the hood

    Where a Type Becomes a Layout: Fields, Padding, and Reordering

    The same three fields take 8 bytes in Rust and 12 in C, because rustc reorders them and C does not. I measured both, plus repr(C) and repr(packed), and this is the one place where a type leaves a physical trace the processor can touch.
  • 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.