binutils Newspaper
OCTOBER 6, 2026
gdb/dwarf — Proposed

gdb/dwarf: fix reading DW_FORM_addrx with address size of 2

Patch fixes a GDB crash when reading DW_FORM_addrx debug info with a 2-byte address size, discovered while investigating AVR binaries.

Simon Marchi submits a patch addressing a GDB crash encountered when processing DWARF debug information, specifically with DW_FORM_addrx entries and a 2-byte address size. The issue was found during an investigation of AVR binaries generated by clang. The crash occurred due to a heap-buffer-overflow in bfd_getl64 when reading address indices, indicating an incorrect handling of address size when decoding this DWARF form.

In the Thread 1 participant
  1. Simon Marchi <simon.marchi@efficios.com> proposer

    Submits a patch to fix GDB's handling of `DW_FORM_addrx` with 2-byte addresses, resolving a heap-buffer-overflow crash.

    “While investigating AVR binaries for bug 34638, I stumbled on a crash of GDB when loading an AVR binary generated by clang: $ cat repro.c volatile int sink; static void helper (int v) { sink = v; } int main (void) { helper (42); return 0; } $ clang --target=avr -mmcu=atmega328p -g -O1 -o repro repro.c”

In Details

This patch targets GDB's DWARF parsing capabilities, specifically addressing a crash related to DW_FORM_addrx when the target architecture uses a 2-byte address size. The DW_FORM_addrx DWARF form is used to represent addresses relative to a base address selected by an addr_index. The issue arises because GDB's read_addr_index_1 function, which handles reading these indices, appears to incorrectly assume a default address size or mishandle the size parameter, leading to an out-of-bounds read (heap-buffer-overflow) in bfd_getl64. This was observed with AVR toolchains, which can genera…

For Context
DWARF
A debugging data format used by many compilers and debuggers to store information about variables, types, and code structure.
DW_FORM_addrx
A DWARF debugging information form that represents an address indexed into an address table. This form is used for optimized address representation.
address size
The number of bytes used to represent a memory address on a particular architecture (e.g., 32-bit or 64-bit).
heap-buffer-overflow
A type of memory corruption bug where a program writes data beyond the allocated buffer on the heap, potentially corrupting adjacent memory.
AVR
A family of microcontrollers developed by Atmel (now Microchip Technology).
Filed Under: GDBDWARFdebuggingAVRbuffer overflow