LOGBOOK

HELP

Quiz Entry - updated: 2026.11.10

GDB is started as xtensa-esp32-elf-gdb -x gdbinit build/hello_world.elf. Why the .elf file and not the .bin image that was flashed?

The .bin is only the raw bytes that go into flash. The .elf contains the same code plus the symbol table and debug information that map addresses to function names, variables and source lines. Without it GDB could stop the chip but could only show raw addresses.

The build produces both from the same compile. The ELF (Executable and Linkable Format) file is the complete output of the linker. It has the machine code and data, and when compiled with debug information (-g, which ESP-IDF enables by default) it also carries DWARF debug information: which address range belongs to which function, which line of hello_world_main.c each instruction came from, where each local variable lives and what type it has. esptool then strips all of that away and keeps only the bytes needed in flash, which become the .bin image.

GDB loads the ELF and uses it in both directions:

  • break hello_world_main.c:18 or thb app_main: the name or line becomes an address.
  • When the CPU halts at 0x400d4474, the address becomes "app_main at hello_world_main.c:17", shown with the source line.

Two practical consequences follow:

  • The ELF has to come from the same build that is running on the chip. After changing code, rebuild and reflash before debugging; otherwise breakpoints land in the wrong place and source lines do not match.
  • A project that ships only .bin files to production devices keeps its symbols in-house, which makes an extracted firmware image harder to reverse-engineer.

Go deeper:

From Quiz: SIOT / JTAG Debugging with OpenOCD and GDB | Updated: Nov 10, 2026