binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gas

GAS: Mark weak functions as external in DWARF debug info

Ensures weak functions are correctly marked as external in DWARF, preventing GDB from misclassifying them as static.

The GNU Assembler (GAS) previously failed to correctly mark weak functions as external in DWARF debug information. This was because the check for external symbols only considered BSF_GLOBAL, which is cleared for weak symbols. This commit updates the DWARF emission logic to also check for weak symbols (S_IS_WEAK), ensuring that weak functions are properly identified as external by debuggers like GDB, resolving a bug where they were incorrectly treated as static.

In Details

This commit modifies gas/dwarf2dbg.c to correct the generation of DWARF subprogram DIEs for weak functions. Previously, the DW_AT_external attribute was omitted or set to false because the check for external symbols relied solely on S_IS_EXTERNAL(symp), which evaluates to false for weak symbols. The change adds S_IS_WEAK(symp) to the condition, ensuring that weak functions are correctly tagged with DW_AT_external=true.

For Context
DWARF
A standardized debugging data format used by many compilers and debuggers to store information about variables, functions, and types.
GAS
The GNU Assembler, a component of the GNU Binutils package responsible for converting assembly code into machine code.
DIE
Debugging Information Entry. A fundamental unit within DWARF that describes a program entity like a function, variable, or type.
DW_AT_external
An attribute in DWARF that indicates whether a symbol is externally visible. This helps debuggers distinguish between global and static symbols.
weak symbol
A symbol that can be overridden by a non-weak symbol of the same name. It allows for default implementations that can be replaced by user-defined ones.
Filed Under: debuggingdwarfgasbugfix