This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj/readelf] - Don't fail dumping when unable to read the name of the SHT_DYNSYM section.
ClosedPublic

Authored by grimar on Jul 20 2020, 7:43 AM.

Details

Summary

We have an issue currently: we are trying to read the name of the SHT_DYNSYM section
very early and using unwrapOrError call for that.

The name is needed only for the GNU output. Because of the current logic, the tool
fails to dump the whole object when something is wrong with the name of the .dynsym section.

This patch delays reading the name and also allows it to be broken.

Diff Detail

Event Timeline

grimar created this revision.Jul 20 2020, 7:43 AM
Herald added a project: Restricted Project. · View Herald Transcript
jhenderson added inline comments.Jul 21 2020, 1:34 AM
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
93

I'm not convinced we want this warning in the LLVM case - it doesn't actually need the name for anything, so emitting the warning doesn't make much sense.

Looking at the code, it looks like the SHT_SYMTAB name lookup has a similar problem? Could the name not be looked up inside the printSymtabMessage function?

141–142

This doesn't check that the warning is emitted.

grimar updated this revision to Diff 279469.Jul 21 2020, 3:30 AM
grimar marked 3 inline comments as done.
  • Addressed review comments.
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
93

Looking at the code, it looks like the SHT_SYMTAB name lookup has a similar problem?

Yes.

Could the name not be looked up inside the printSymtabMessage function?

Yes. It can be done in GNUStyle<ELFT>::printSymtabMessage instead of printSymbolsHelper.
But it should be fixed in a follow-up, I think, because the possible change relies on the DotDynsymSec
introduced in this patch. I will post the fix soon.

141–142

Fixed.

grimar planned changes to this revision.Jul 21 2020, 3:38 AM
grimar requested review of this revision.Jul 21 2020, 3:40 AM
This revision is now accepted and ready to land.Jul 22 2020, 1:10 AM
This revision was automatically updated to reflect the committed changes.