Get Started

Recovering Data and Types: Structs, Arrays, C++ Objects, and DWARF

A decompiler prints a->balance when it has a type table and *(int *)(param_1 + 4) when it does not. This lesson builds the table from the accesses, reads the real one from DWARF 5, and shows where the two agree.

140 minutesBuildPython, C, C++, x86-64 assemblyMembers

Learning Objectives

  • Read a struct member access as base register plus displacement, and an array access as base plus index times stride, from the Intel SDM addressing rules.
  • Apply the System V alignment rules by hand to struct account and explain each padding byte.
  • Build a type-recovery pass that turns the accesses in a listing into field offsets, widths, kinds, a stride, and a size, with the evidence for each.
  • Write a DWARF 5 reader for .debug_info.debug_abbrev.debug_str_offsetsand .debug_addr of a relocatable object, and check it against llvm-dwarfdump.
  • Compare the recovered layout with the DWARF layout and name every difference as missing evidence, a merged access, or an unprovable kind.
  • Read an Itanium C++ vtable, its typeinfo, and its mangled names from relocations, and resolve a virtual call to a slot.