binutils Newspaper
NOVEMBER 30, 2026
gas — Proposed

gas: Mark weak functions as external in DWARF

Adds new test cases to verify that weak functions are correctly marked as external in DWARF debugging information.

This patch introduces new test cases for the GNU Assembler (gas) to ensure weak functions are properly marked as external in DWARF debugging information. The new tests specifically verify the behavior when only a weak function is present, distinguishing it from existing tests that cover mixed global and local functions. This ensures correct handling of DW_AT_external attribute generation for weak symbols.

In the Thread 2 participants
  1. Longjun Luo proposer

    Explains that new test cases are needed to specifically test the scenario where only a weak function is present, which is not covered by existing tests that include mixed global and local functions. The new tests verify that the DWARF emission correctly sets 'have_efunc' without 'have_lfunc' for weak functions.

    “The new tests contain only a weak function, verifying that out_debug_abbrev() sets have_efunc without setting have_lfunc. With have_efunc && !have_lfunc, the DWARF 3 case exercises the DWARF2_VERSION < 4 (DW_FORM_flag) path, while the DWARF 5 case checks DW_FORM_flag_present. So the mixed tests cover the out_debug_info() hunk, and only the new ones fail without the out_debug_abbrev() hunk (DW_AT…”
  2. Jan Beulich reviewer

    Questions the necessity of new test cases, asking if the existing test cases already cover the functionality being tested by the new ones.

    “This part certainly is okay, but ... ... what does this new testcase test which ... ... this adjustment to the existing one doesn't cover? (Same for the Dwarf5 ones below then, obviously.)”

Technical Tradeoffs

  • Adds complexity to the test suite to cover a specific edge case.
  • Ensures more accurate debugging information for weak functions.

In Details

This patch addresses DWARF debugging information generation in the GNU Assembler (gas). Specifically, it concerns how weak symbols, which have different linkage characteristics than normal global or local symbols, are represented. The change ensures that the DW_AT_external attribute is correctly emitted for weak functions, which is crucial for debuggers to accurately represent symbol visibility and scope, especially in complex linking scenarios.

For Context
DWARF
A debugging data format used by many compilers and debuggers to store information about variables, functions, and types in compiled programs.
Weak functions
Functions with special linkage properties that allow them to be overridden by other symbols of the same name. They are often used for optional features or optimizations.
DW_AT_external
A DWARF attribute that indicates a symbol is external, meaning it is defined in another compilation unit or object file.
Filed Under: gasdwarfdebuggingweak symbols