fix(debuginfo): name size-0 asm labels instead of raw addresses - #37
fix(debuginfo): name size-0 asm labels instead of raw addresses#37not-matthias wants to merge 1 commit into
Conversation
|
@greptileai review |
Greptile SummaryThe PR recognizes non-empty, size-zero
Confidence Score: 4/5The 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
|
| 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]
Reviews (2): Last reviewed commit: "fix(debuginfo): name size-0 asm labels i..." | Re-trigger Greptile
Merging this PR will not alter performance
Comparing Footnotes
|
|
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
f1f2adc to
4d00230
Compare
TLDR: Hand-written ASM stubs symbols' were not resolved. This PR fixes it
Hand-written assembly entry points often carry no
.sizedirective, so theyappear as size-0
STT_NOTYPEsymtab labels with no covering DWARFsubprogram.
get_elf_symbol_inforejected them twice (STT_NOTYPEisn'tplausible, 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_initinto
0x000000000001f59f: the true caller is glibc's_dl_start_user, asize-0 label in
ld.so.Before:

After:

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