-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llvm-objdump gives wrong line numbers #23717
Comments
This does look wrong. The object file looks fine, but the output of The problem may be in This is an LLVM issue, so it should be filed in the LLVM repo. But @dschuff is probably the right person to ask first. |
So this problem has to do with the way LLVM handles symbols for linked wasm files and debug info. Specifically, symbol addresses in DWARF are always encoded as offsets in the code section, whereas for linked files, LLVM uses the offset in the file as the address for a function (this is to match how engines print code addresses in backtraces). So this is an unfortunate mismatch and not everything works right, as you have seen. Emscripten has a tool emsymbolizer that knows a bunch of ways emscripten can store name/address information (e.g. DWARF, source maps, name sections) and can symbolize addresses. It papers over this problem using the We might be able to improve this situation. Adjusting how symbols are represented in LLVM is tricky, since they are used in various places in assembly, linking, etc. Ideally we also wouldn't need a bunch of special hacks in the tools such as llvm-objdump (although I wouldn't necessarily be above some kind of special case if it wasn't too horrible). We might also be able to do something on the emscripten side beyond emsymbolizer. We had previously imagined a tool that could take e.g. a stack trace, symbolize it by whatever means and re-print it. Maybe that idea could be generalized. |
@dschuff I see. Sounds to me like
Maybe, but I think llvm-objdump also shouldn't give wrong output. Should I file the issue in llvm/llvm-project instead? |
Yeah agreed that this is a bug and that llvm-objdump and llvm-symbolizer should give the correct info without having to adjust the addresses; I just don't know how hard that will be yet, and wanted to mention alternatives. And yes, llvm is probably the proper place for it. |
llvm-objdump
gives wrong line info for a simple WebAssembly file. I'm not 100% sure whether this is a bug in the compiler/linker or in llvm-objdump, but I tend to think the latter as Chrome DevTools with DWARF extension does give the right line numbers. Also idk if this is a bug in Emscripten or LLVM, but if it's the latter, I can report it over there if necessary.Steps to reproduce
main.cpp
:Verbose output
~/emsdk/upstream/bin/llvm-objdump --disassemble-symbols=__original_main --line-numbers a.out.wasm
fflush.c
instead of ourmain.cpp
:Version of emscripten/emsdk
The text was updated successfully, but these errors were encountered: