Binary mode carries the previous function's source line into functions with no line info
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 79/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp, typescript
Research direction
Start by reading the function-label handling in the binary-mode objdump parser and compare it with the TypeScript change in compiler-explorer/compiler-explorer#9306. Check how .L labels and function labels appear in the supplied real dump examples or parser tests. Done means clearing the current source at non-.L function labels, preserving source across .L labels, and confirming the mappings no longer leak into functions without line records.
Written by the indexing model from the issue text.
Description
In binary mode ("Link to binary"), a function with no line records of its own, such as statically linked glibc code built without debug info, inherits the last file:line of the function before it. objdump only prints a line record when the line changes, and the parser doesn't clear the current source at a new function label.
Reproduce on godbolt.org with x86-64 gcc 14.2 (cg142), C, with binary output on and the default filters:
int square(int num) {
return num * num;
}
int main() { return square(3); }
- With
-O1 -g, everything is correct: 5 lines map toexample.c, all insquareandmain. - With
-O1 -g -static, 4688 of the 5001 lines map toexample.c, across 76 glibc functions:init_cpu_features.constprop.0810,update_active.constprop.0326,get_common_cache_info.constprop.0321, and so on. Onlysquareandmainshould.
With a normal dynamic link it's hidden, because binaryHideFuncRe hides the CRT functions.
Fix: clear the current source at each function label, except assembler-local .L labels, which are inside a function (RISC-V keeps .Lpcrel_hi* in the symbol table). objdump -l prints a function's first line record after its label, so nothing correct is lost. CE's TypeScript parser got exactly this in compiler-explorer/compiler-explorer#9306:
func = match[2];
if (!func.startsWith('.L')) source = null;
That PR has the details and tests. The reviewer checked it against 24 real dumps (gcc and clang, -O0/-O2, with and without -g, -static, C and C++), and the mappings matched addr2line. Linux prod C/C++ uses this external parser (externalparser=CEAsmParser), so the TypeScript fix doesn't reach it.
🤖 Generated with Claude Code
- Dominant language
- C++
- Stars
- 36
- Forks
- 10
- Avg merge
- 36m
- Merged PRs (30d)
- 6
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from compiler-explorer/asm-parser
-
Branch targets after an immediate (#) aren't label references in binary modePossibly taken @mattgodbolt claimed this 16 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Add aarch64 buildOpen
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Make enum out of the parser states (objdump/parser)May be free again @phyBrackets claimed this 1757 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
compiler-explorer/asm-parser#21 · 2 comments ·
All issues in compiler-explorer/asm-parser
Similar issues
-
good first issue hardware-report help wanted
Difficulty 1/5 Under an hour Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
launcher: settings are never saved on macOS — QSettings SystemScope points to /Library/PreferencesOpen
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
documentation ready
Difficulty 1/5 Under an hour Newbie friendliness 80/100
MartinPTielemans/ilo#3806 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100