If a file has no symbols, perhaps because it is a linked executable,
synthesize some symbols by walking the code section. Otherwise the
disassembler will try to treat the whole code section as a function,
which won't parse. Fixes https://bugs.llvm.org/show_bug.cgi?id=50957.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for look into this! I've been meaning fix this forever but didn't realize the solution could be this simple. I'm excited to starting objdump in more of our test code once this lands.
Do you think it would make sense to do this at the libObject level rather than at the objdump level? i.e. have libObject guarantee that each function has a symbol? Or is it really only objdump and benefits from these fake symbols?
llvm/test/tools/llvm-objdump/wasm/executable-without-symbols.test | ||
---|---|---|
2 | If we can we should try to find a way to avoid checking in the binary here. Also, it would be good to have a test for a file that also lacks a name sections, in which case I would expect to see either empty names, or synthetic/fake names (which do you think make the most sense). | |
llvm/tools/llvm-objdump/llvm-objdump.cpp | ||
724 | Can we keep this function as is, and call it from addFallbackSymbols instead? This would keep the diff smaller and avoid extra nesting. | |
749 | Perhaps assert Function->SymbolName.empty() then? | |
751 | Looking at createSymbolInfo it looks like we always use STT_NOTYPE for wasm symbols. | |
1165 | I think maybe we should leave these two lines alone and add a separate block: if (Obj->isWam()) addMissingWasmCodeSymbols(..); The reasons is because we want to ensure that every function has a symbol don't we? So we might want to handle the case where some functions have symbols and some don't? |
There's an awful lot of WebAssembly test failures in pre-merge. Are they related (they might not be)?
llvm/test/tools/llvm-objdump/wasm/executable-without-symbols.test | ||
---|---|---|
2 | Would yaml2obj allow you to avoid the canned binary? Alternatively, presumably there's some way of building this from assembly? | |
4 | Nit: not looked at wasm tests, but in most other llvm-objdump tests, we usually add comment markers (i.e. '#') for CHECK and RUN lines, even if they're not strictly necessary. May be moot if you switch to yaml2obj or similar, as you'll need them anyway in that case. |
Thanks all for the feedback! I think the updated patch addresses the feedback; PTAL :)
Great! This will allow for far more use of objdump in our testing elsewhere. Thanks for working on this.
If we can we should try to find a way to avoid checking in the binary here.
Also, it would be good to have a test for a file that also lacks a name sections, in which case I would expect to see either empty names, or synthetic/fake names (which do you think make the most sense).