Skip to content

fix(debuginfo): name size-0 asm labels instead of raw addresses - #37

Open
not-matthias wants to merge 1 commit into
masterfrom
cod-3270-exec-cli-benchmarks-in-e2e-tests-fail-to-parse-_dl_init
Open

fix(debuginfo): name size-0 asm labels instead of raw addresses#37
not-matthias wants to merge 1 commit into
masterfrom
cod-3270-exec-cli-benchmarks-in-e2e-tests-fail-to-parse-_dl_init

Conversation

@not-matthias

@not-matthias not-matthias commented Aug 20, 2026

Copy link
Copy Markdown
Member

TLDR: Hand-written ASM stubs symbols' were not resolved. This PR fixes it

Hand-written assembly entry points often carry no .size directive, so they
appear as size-0 STT_NOTYPE symtab labels with no covering DWARF
subprogram. get_elf_symbol_info rejected them twice (STT_NOTYPE isn't
plausible, and size-0 symbols are dropped outside Android), leaving those
addresses unnamed. Callgrind then falls back to printing the raw address,
which is how the root frame of exec'd CLI benchmarks turned from _dl_init
into 0x000000000001f59f: the true caller is glibc's _dl_start_user, a
size-0 label in ld.so.

Before:
image

After:
image

The ASM func from the screenshots: https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/or1k/dl-start.S#L53

@not-matthias

Copy link
Copy Markdown
Member Author

@greptileai review

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

The PR recognizes non-empty, size-zero STT_NOTYPE labels in executable sections and gives them synthetic ranges while preserving precedence for real symbols.

  • Propagates synthetic-label metadata through ELF symbol loading.
  • Drops synthetic labels covered by real symbols and trims remaining overlaps during canonicalization.
  • Adds an amd64 assembly regression test for standalone and interior labels.

Confidence Score: 4/5

The PR is not yet safe to merge because an oversized executable section can still make synthetic-label sizing abort debug-information loading.

The current assignment narrows an address-sized section remainder into a signed symbol size without enforcing the existing signed-size bound, and that value is subsequently used to construct a range whose ordering is asserted.

Files Needing Attention: coregrind/m_debuginfo/readelf.c

Important Files Changed

Filename Overview
coregrind/m_debuginfo/readelf.c Admits size-zero text labels and assigns synthetic sizes, but the previously reported unchecked narrowing into Int remains.
coregrind/m_debuginfo/storage.c Prioritizes real symbols, removes covered synthetic labels, and preserves synthetic metadata during overlap resolution.
coregrind/m_debuginfo/priv_storage.h Adds the isSynthLabel marker to DiSym.
none/tests/amd64/synth_label_asm.S Defines standalone and interior size-zero assembly labels for regression coverage.
none/tests/amd64/synth_label.c Exercises backtrace symbolization through synthetic and conventionally sized assembly entries.
none/tests/amd64/Makefile.am Registers the new amd64 regression test, its sources, and filtering assets.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Read ELF symbol] --> B{Size-zero STT_NOTYPE label\nin text section?}
    B -- No --> C[Existing symbol handling]
    B -- Yes --> D[Assign synthetic remaining-section size]
    D --> E[Add symbol with isSynthLabel]
    E --> F[Sort symbol table]
    F --> G{Starts inside real symbol?}
    G -- Yes --> H[Drop synthetic label]
    G -- No --> I[Trim against successor]
    I --> J[Use label for symbolization]
Loading

Reviews (2): Last reviewed commit: "fix(debuginfo): name size-0 asm labels i..." | Re-trigger Greptile

Comment thread coregrind/m_debuginfo/readelf.c Outdated
@not-matthias
not-matthias marked this pull request as ready for review August 20, 2026 14:35
@codspeed-hq

codspeed-hq Bot commented Aug 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 84 untouched benchmarks
⏩ 60 skipped benchmarks1


Comparing cod-3270-exec-cli-benchmarks-in-e2e-tests-fail-to-parse-_dl_init (4d00230) with master (ae6bf15)

Open in CodSpeed

Footnotes

  1. 60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Comment thread none/tests/amd64/synth_label.c Outdated
Comment thread coregrind/m_debuginfo/readelf.c Outdated

Copy link
Copy Markdown
Contributor

If it's not possible, then I'll approve the current implem

Hand-written assembly entry points often carry no .size directive, so
they appear as size-0 STT_NOTYPE symtab labels with no covering DWARF
subprogram. get_elf_symbol_info rejected them twice (STT_NOTYPE is not
plausible, and size-0 symbols are dropped outside Android), leaving
those addresses unnamed. Callgrind then falls back to printing the
address, which is how the root frame of exec'd CLI benchmarks turned
from _dl_init into 0x000000000001f59f: the caller is glibc's
_dl_start_user, a size-0 label in ld.so.

Admit size-0 STT_NOTYPE labels that lie inside a known text section and
invent a size for them, like the existing ppc64be escape hatch does for
sized ones. ARM/AArch64 '$'-prefixed mapping symbols stay excluded.

An invented size is a guess, so mark such symbols isSynthLabel and make
canonicaliseSymtab drop any label starting inside a real symbol's range:
the overlap resolver truncates the earlier of two overlapping symbols, so
an oversized label sitting inside a real function would otherwise steal
its tail and rename every address in it. Order real symbols before
labels at equal address so that pass sees the real symbol first. Labels
starting in genuine gaps are kept and clamped by the normal overlap
handling.

Add none/tests/amd64/synth_label, asserting a backtrace through a size-0
asm label resolves to its name.

Fixes COD-3270
@not-matthias
not-matthias force-pushed the cod-3270-exec-cli-benchmarks-in-e2e-tests-fail-to-parse-_dl_init branch from f1f2adc to 4d00230 Compare August 21, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants