STT_OBJECT and STT_COMMON are dumped as data, not disassembled.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 33517 Build 33516: arc lint + arc unit
Event Timeline
The test doesn't have a dynamic symbole table (.dynsym) so the source change seems irrelevant.
I think we have the current output without the source change.
See not_func is misaligned, so something goes wrong.
0000000000001001 both_dyn: 1001: 90 nop 1002: 90 nop 0000000000001003 not_func: 1003: 90 .
STT_SECTION exists primarily for relocations are they normally have STB_LOCAL binding.
None of ld.bfd/gold/lld places STB_LOCAL symbols in .dynsym (I am less confident with the statement regarding ld.bfd) so the updated test may not be used in practice.
@MaskRay, the test DOES have a dynamic symbol table. Line 61 in the updated test starts the DynamicSymbols list, which causes one to be implicitly generated.
I think the code change is mostly just to bring things into line with static symbol dumping, but I could see an argument for deleting the if statement entirely. In that case, I'd just confirm against GNU objdump behaviour to see if it really matters.
Thanks for the review, MaskRay.
See not_func is misaligned, so something goes wrong.
I think it might be better to take care of the formatting issue (dumpELFData emits extra tab) in a separate patch. And this one focuses on which symbols should be included in the disassembly output?
STT_SECTION exists primarily for relocations are they normally have STB_LOCAL binding.
None of ld.bfd/gold/lld places STB_LOCAL symbols in .dynsym (I am less confident with the statement regarding ld.bfd) so the updated test may not be used in practice.
@MaskRay @jhenderson @grimar @rupprecht I'm not sure if this has been discussed before, I think it comes down to whether we want llvm-objdump to be compatible with GNU objdump on:
- well-formed object files (definitely yes)
- well-formed object files with something not usually produced by static linker etc.. and not explicitly disallowed by ABI (like STT_SECTION symbol in .dynsym in this case)
- ill-formed object files (maybe not?)
What's your thought?
deleting the if statement entirely
@jhenderson this seems to assume 1. The patch in its current shape assumes 2?
My personal thought is definitely 1), and no need for 3), as long as the error/output makes sense (note that if GNU produces something sensible and doesn't error for 3), we should do the same). I'm in two minds about 2), mostly because we can't be certain that every case we think is unusual applies to every use case out there for downstream users. Ultimately, I'm okay with 2) going either way. I'd plump for matching GNU, but if there's general opinions from others against it, I don't mind.
How about only addressing what PR41947 need (STT_OBJECT and STT_FUNC) in this patch and have a separate patch addressing matching with GNU on what other types of symbols should show up in output? Additionally, a patch for matching GNU on output format for these symbols got shown.
PR41947 only used a STT_OBJECT as an example, so we shouldn't just limit this patch to the two types. Note that STT_NOTYPE, as well as symbols with processor etc specific types, can also appear in dynamic symbol tables.
Additionally, a patch for matching GNU on output format for these symbols got shown.
Sorry, I'm not sure I understand what you mean.
Aside from one test comment, this looks good to me.
llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test | ||
---|---|---|
91 | I'm not sure I follow what the purpose of this particular symbol is beyond what func_dyn gives us? |
- update
llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test | ||
---|---|---|
91 | I think it is not needed. It was in the test file but I'm not sure its purpose so I left it here. Deleted. |
llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test | ||
---|---|---|
63 | I think you may have gone overboard with the symbol renaming. These first two are deliberately named so that they clearly clash/don't clash with a corresponding static symbol (only_[static|dyn] means only the static/dynamic symbol respectively is present at that address whilst the both_[static|dyn] means both symbols have that value). | |
86 | This value is bad, because the test case was supposed to be for just a static symbol at this address. See the symbol name comments. | |
91 | I don't think you need to rename this symbol from zero_sized. |
llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test | ||
---|---|---|
63 | Thank you. Now I see the point. |
llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test | ||
---|---|---|
25–27 | This looks wrong, and I'm surprised this test isn't failing now. As things stand 0x1002 isn't being checked for at all in dynamic output, but there's no reason it shouldn't be there. | |
74 | You can reduce the diff by making this symbol the STT_FUNC one and the func symbol the STT_NOTYPE one. |
llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test | ||
---|---|---|
25–27 | both_dyn is STT_OBJECT, dumped as data in one line until the next symbol regardless of its size. |
LGTM, with the suggested change, but please wait for the other reviewers to confirm too.
llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test | ||
---|---|---|
25–27 | Ah, okay. Probably worth making both_dyn the STT_NOTYPE symbol then and making what is currently notype the STT_OBJECT one. That'll be less confusing. |
This looks wrong, and I'm surprised this test isn't failing now. As things stand 0x1002 isn't being checked for at all in dynamic output, but there's no reason it shouldn't be there.