GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
debug

DWARF: Fix bit extraction shifts by using bit-based address size

Corrects DWARF generation by using address size in bits, not bytes, for shift calculations.

This commit fixes a bug in DWARF generation where bit extraction shifts were calculated incorrectly. The issue stemmed from mixing the address size in bytes with bit offsets. The fix converts the address size to bits before calculating the shift counts in dwarf2out.cc, ensuring accurate debug information. A new test case is added to verify the fix.

In Details

The dwarf2out.cc module, responsible for generating DWARF debug information, had a bug in mem_loc_descriptor where address size in bytes was incorrectly used in bit-shift calculations for extracting location information. This commit rectifies this by ensuring the address size is converted to bits prior to calculating the shift amounts, resolving an issue related to PR128392.

For Context
DWARF
A debugging data format used by many Unix-like systems. It provides information to debuggers about variables, types, and code locations.
bit extraction
The process of isolating specific bits within a larger data word.
shift count
The number of positions to shift bits left or right in a bitwise shift operation.
Filed Under: debugdwarfbugfix