Page MenuHomePhabricator

[llvm-readelf/obj] - Stop printing invalid names for unnamed section symbols.
ClosedPublic

Authored by grimar on Wed, Sep 16, 7:43 AM.

Details

Summary

We have an issue with ELFDumper<ELFT>::getSymbolSectionName:

  1. It is used deeply for both LLVM/GNU styles and might return LLVM-style only values to describe symbols: "Undefined", "Processor Specific", "Absolute", etc.
  1. getSymbolSectionName is used by getFullSymbolName and these special values might appear instead of symbol names in many places. This occurs for unnamed section symbols currently.

This patch extracts the LLVM specific logic to LLVMStyle<ELFT>::printSymbolSection,
which seems to be the only place where we want to print the special values mentioned.

Depends on D87763

Diff Detail

Event Timeline

grimar created this revision.Wed, Sep 16, 7:43 AM
Herald added a project: Restricted Project. · View Herald Transcript
jhenderson added inline comments.Thu, Sep 17, 1:47 AM
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
338–340

Am I right in thinking these warnings are coming out because SHN_ABS isn't a valid section index? That doesn't seem right to me - a st_shndx of SHN_ABS is perfectly normal. You just wouldn't normally have a section symbol to them. What happens if there are many sections and section index 65521 is actually a valid section?

I'd be inclined to produce a warning saying "section symbols shouldn't be absolute" (or whatever), and then print <?>, in this case.

MaskRay added inline comments.Thu, Sep 17, 11:45 PM
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
338–340

"shouldn't be absolute" is too specific. Having a generic message for all these special indices should suffice.

grimar updated this revision to Diff 292711.Fri, Sep 18, 12:15 AM
grimar marked 2 inline comments as done.
  • Addressed review comments.
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
338–340

Am I right in thinking these warnings are coming out because SHN_ABS isn't a valid section index? That doesn't seem right to me - a st_shndx of SHN_ABS is perfectly normal

You are right, implementation was wrong. So, we should not be able to take a section index for symbols which have sh_shndx >= SHN_LORESERVE (SHN_XINDEX is an exception).

I've updated the logic and now reporting a better message.

jhenderson added inline comments.Fri, Sep 18, 1:42 AM
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
342

I'm thinking the warning/<?> output would probably make sense for undefined STT_SECTION symbols too. Those shouldn't really be a thing after all.

grimar updated this revision to Diff 292732.Fri, Sep 18, 2:46 AM
grimar marked an inline comment as done.
  • Addressed review comment about SHN_UNDEF section symbols.
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
342

Probably reasonable. Done.

jhenderson accepted this revision.Mon, Sep 21, 12:45 AM

LGTM, thanks!

This revision is now accepted and ready to land.Mon, Sep 21, 12:45 AM