Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 626 of 9368. Advanced Debugging and Hardware VerificationFree lesson

Mapping Binary Dumps to Source Code Symbols

Use linker map files and debug symbols to translate raw hex memory addresses back into human-readable function names and variable offsets.

In this lesson, you will learn how to bridge the gap between raw, cryptic hex dumps and your original source code by utilizing linker map files and debug symbols.

When a device crashes in the field, you are often left with a non-volatile memory dump—a raw array of hexadecimal bytes. Without context, these are just numbers. To make sense of them, you must perform "symbol resolution."

The Role of the Linker Map

When you compile your firmware, the linker generates a .map file. This is your "Rosetta Stone." It contains a comprehensive list of every function and variable, along with its designated memory address in the final binary. If your crash dump reveals that the Program Counter (PC) was at 0x08004A20, you can search your map file for an address range that encompasses that value:

.text.system_fault_handler
                0x08004A00       0x40  ./src/fault.o
.text.data_processor
                0x08004A40       0x80  ./src/process.o

By seeing that 0x08004A20 falls within the system_fault_handler block, you instantly know exactly which function was executing at the time of the failure.

Using Debug Symbols (DWARF)

While map files provide global addresses, debug symbols (often embedded in your .elf file in DWARF format) provide the "how" and "where." Tools like addr2line allow you to automate this:

arm-none-eabi-addr2line -e firmware.elf 0x08004A20

This command parses the DWARF metadata to return the exact source file and line number: C:/project/src/fault.c:42

Why This Matters

Raw memory dumps are just snapshots of hardware state. By mapping these addresses to symbols, you transform a generic "device reset" into a specific report of a line-number-accurate software bug. This allows you to differentiate between transient hardware glitches (which you’ve studied in previous modules) and actual software logic errors. When you can pinpoint the exact line of code causing an illegal memory access or a stack overflow, your debugging time drops from hours to minutes.

Key Takeaway: Linker map files provide the memory layout context, while DWARF debug symbols bridge the gap between raw binary addresses and your human-readable source code line numbers.