Skip to content

Lesson 1 of 13 · 20m

What the Compiler Actually Throws Away

Instructions, constants, and dynamic symbols survive compilation while names, types, and structure don't — and the xz backdoor proved the binary is sometimes the only truth that exists.

Every binary you open is the fossil record of a program. The compiler took source — intent, names, structure — and kept only the mechanism: instructions, data layouts, and whatever constants and symbols happened to survive. New reversers get the mental model wrong in a specific way: they think the job is reading assembly front to back, the way you'd read a listing. It isn't. The job is reconstructing intent from mechanism, and the first skill is knowing exactly which parts of the fossil are still legible.

What survives compilation

  • Instructions and control flow — the mechanism, faithfully preserved, though rearranged and optimized past any resemblance to the source text.
  • Constants and string literals — format strings, error messages, magic numbers, crypto tables. Often the most legible artifact in the entire file.
  • Dynamic symbols — .dynsym keeps imported and exported names because the runtime linker needs them at load time. strip removes .symtab, not .dynsym: nm can show "no symbols" while the import table still names every libc call the program makes.
  • Sometimes, everything — a -g build embeds DWARF: line numbers, types, struct layouts, local variable names. Check before assuming the worst.

What gets erased

  • Variable names, type declarations, comments — gone entirely.
  • Function boundaries become conventions, not facts: a "function" is just a call target with a prologue-like shape.
  • if, while, for, and switch collapse into one primitive — compare, set flags, conditional jump.
  • Data structures dissolve into pointer arithmetic. user->name becomes mov rax, [rdi+0x18] and nothing in the file records that offset 0x18 was ever called name.
  • Compile-time sizeof knowledge dissolves too — the binary knows a struct is 32 bytes only through the stride of its indexing arithmetic: [rcx+rax*4] is all that remains of int arr[].
  • Dead code vanishes. Anything the optimizer proved unreachable isn't in the file at all — the binary describes only the behavior that can execute.

The binary is the only truth

The wrong mental model isn't "assembly is hard." It's "the source would explain this." Sometimes there is no source that explains the binary in front of you. In March 2024, a backdoored liblzma shipped inside xz 5.6.0 and 5.6.1 — CVE-2024-3094. The payload lived in binary test fixtures in the repository, extracted and linked during the build; the malicious code never existed in the published source tree at all. Andres Freund noticed sshd burning CPU under valgrind, and the people who dissected the mechanism worked from liblzma.so.5.6.1 itself. The binary doesn't merely survive when source is withheld — sometimes it's the only place the truth ever existed.

The ELF, at rest

$ file crackme
crackme: ELF 64-bit LSB pie executable, x86-64, dynamically linked, stripped
$ readelf -S crackme | grep -E "text|rodata|data"
[13] .text     PROGBITS   0000000000001060  001060  0001a3
[15] .rodata   PROGBITS   0000000000002000  002000  000048
[23] .data     PROGBITS   0000000000004010  003010  000010

.text is code, .rodata is constants and strings, .data is initialized globals, .bss is zero-initialized globals that occupy no file space. Sections are bookkeeping for the linker; what the kernel maps comes from the program headers (readelf -l), which is its own lesson. A stripped, PIE, dynamically-linked binary is the default posture — assume it until file says otherwise.

The file also fingerprints its own toolchain. readelf -p .comment crackme prints the compiler's name and version (GCC: (GNU) 13.2.0), and readelf -n shows the Build ID — the hash a distro's debug packages key on. Free provenance before you've read a single instruction; when file says stripped, the Build ID is what lets eu-unstrip marry the matching .debug copy back onto the binary.

What survives compilation

Field notes

  • Run file, strings, and readelf -S before anything else — thirty seconds of triage tells you the architecture, the packing posture, and whether symbols exist.
  • Unstripped symbols are a gift, not the norm. nm -C on a C++ binary even demangles the names for you.
  • A -g build changes the job's category: DWARF means the debugger can show you source-level truth. Load it there, not just in the disassembler.
  • Stripped is not opaque. Imports still have names, strings still have text, and constants still fingerprint algorithms — you lost the labels, not the evidence.

Keep reading

Related articles from the SudoSecurity blog.