This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj/elf] - Stop reporting invalid extended indexes in warnings for unnamed section symbols.
ClosedPublic

Authored by grimar on Sep 18 2020, 5:37 AM.

Details

Summary

We have an issue with getFullSymbolName: it assumes that the symbol passed is
always in the .symtab, what is wrong. We might calculate and report a wrong index currently.
I've added a test case revealing that.

This patch adds the "symbol index" argument to getFullSymbolName signature,
what fixes the issue.

Diff Detail

Event Timeline

grimar created this revision.Sep 18 2020, 5:37 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar requested review of this revision.Sep 18 2020, 5:37 AM
jhenderson added inline comments.Sep 18 2020, 6:14 AM
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
365–370

Do we need all these checks for the test purpose? If so, why do we need comparatively fewer in the GNU version?

llvm/tools/llvm-readobj/ELFDumper.cpp
5845

Maybe just get the Elf_Sym here, and pass that in? I also think you should do [0] as it's more explicit than .data().

6391

For the same reason.

6778–6779

Ditto.

grimar added inline comments.Sep 18 2020, 6:16 AM
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
365–370

GNU version shows the index of symbol (Num: 2). All I wanted is to demostrate that the warning is reported for symbol with index 2.

grimar updated this revision to Diff 293009.Sep 20 2020, 1:37 AM
grimar marked 4 inline comments as done.
  • Addressed review comments.

All the passing of FirstSym is for &Sym - &FirstSym in ELF.h getExtendedSymbolTableIndex. If we only care about the index, passing around the index rather than the first symbol probably makes more sense?

All the passing of FirstSym is for &Sym - &FirstSym in ELF.h getExtendedSymbolTableIndex. If we only care about the index, passing around the index rather than the first symbol probably makes more sense?

+1 - this makes sense to me too. Everything else looks good.

All the passing of FirstSym is for &Sym - &FirstSym in ELF.h getExtendedSymbolTableIndex. If we only care about the index, passing around the index rather than the first symbol probably makes more sense?

+1 - this makes sense to me too. Everything else looks good.

I've prepared an independent NFCI patch for getExtendedSymbolTableIndex and other API: D88016

grimar updated this revision to Diff 293157.Sep 21 2020, 6:39 AM
grimar edited the summary of this revision. (Show Details)
  • Addressed review comment.
jhenderson accepted this revision.Sep 21 2020, 6:54 AM

Looks good.

This revision is now accepted and ready to land.Sep 21 2020, 6:54 AM
MaskRay accepted this revision.Sep 21 2020, 1:29 PM

Looks great!