This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj/llvm-readelf] - Simplify the code that dumps versions.
ClosedPublic

Authored by grimar on Nov 29 2019, 6:44 AM.

Details

Summary

After changes introduced in D70495 and D70826 its now possible
to significantly simplify the code we have.

This also fixes an issue: previous code assumed that version strings
should always be read from the dynamic string table. While it is
normally true, the string table should be taken from the corresponding
sh_link field.

Diff Detail

Event Timeline

grimar created this revision.Nov 29 2019, 6:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2019, 6:45 AM
Herald added a subscriber: seiya. · View Herald Transcript
grimar planned changes to this revision.Nov 29 2019, 6:50 AM

Going to add 2 test cases for new errors introduced (I've forgot to add them, sorry).

grimar updated this revision to Diff 231539.Nov 29 2019, 7:22 AM
  • Only one test was missing. I've added it.

If you've added the ability to use the linked string table, it would be good to also have a test that successfully dumps when the sh_link points at a string table other than .dynstr to demonstrate.

llvm/tools/llvm-readobj/ELFDumper.cpp
917–920

Perhaps worth pulling this code out into a small lambda, to reduce duplication, i.e. something like:

auto InsertEntry = [&VersionMap](unsigned N, StringRef Name, bool IsVerdef) { ... }

grimar updated this revision to Diff 231655.Dec 2 2019, 2:44 AM
grimar marked an inline comment as done.
  • Addressed reveiew comments.
jhenderson accepted this revision.Dec 2 2019, 3:06 AM

LGTM, with two minor fixes.

llvm/test/tools/llvm-readobj/elf-verneed-invalid.test
549–550

the custom -> a custom
which name is not ".dynstr" -> which is not called ".dynstr"

588–592

These values aren't aligned with AddressAlign

This revision is now accepted and ready to land.Dec 2 2019, 3:06 AM
This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.