This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Rewrite gnuhash.test test to stop using precompiled objects.
ClosedPublic

Authored by grimar on Jan 21 2020, 5:08 AM.

Details

Summary

This rewrites the test to use YAML and removes 4 precomipled object.

Diff Detail

Event Timeline

grimar created this revision.Jan 21 2020, 5:08 AM

I've also added tests for llvm-readelf to document the behavior,
though I do not understand why it accepts --gnu-hash-table.
GNU readelf does not. Is it a bug?

jhenderson accepted this revision.Jan 21 2020, 7:24 AM

LGTM.

I've also added tests for llvm-readelf to document the behavior,
though I do not understand why it accepts --gnu-hash-table.
GNU readelf does not. Is it a bug?

I wouldn't call it a bug. Rather, it's a feature. If you just want to dump the contents of the .gnu.hash section (and not the .hash section), you need this sort of switch. I think it's okay for us to have switches that are not accepted in GNU readelf, as long as the switch names are (relatively) unlikely to be used by GNU for something else in the future. I do however find it weird that the GNU and LLVM styles match.

llvm/test/tools/llvm-readobj/ELF/gnuhash.test
47

Are the dynamic symbols needed for the test?

This revision is now accepted and ready to land.Jan 21 2020, 7:24 AM
MaskRay accepted this revision.Jan 21 2020, 11:38 AM
grimar marked 2 inline comments as done.Jan 22 2020, 1:21 AM
grimar added inline comments.
llvm/test/tools/llvm-readobj/ELF/gnuhash.test
47

Yes, because the current implementation uses the information about number of them:

template <typename ELFT> void ELFDumper<ELFT>::printGnuHashTable() {
....
   Elf_Sym_Range Syms = dynamic_symbols();
   unsigned NumSyms = std::distance(Syms.begin(), Syms.end());
   if (!NumSyms)
     reportError(createError("No dynamic symbol section"), ObjF->getFileName());
   W.printHexList("Values", GnuHashTable->values(NumSyms));
 }

Such implementation implies, that if I add a one more - a garbage will be dumped:

Values: [0x8, 0x9, 0xA, 0xB, 0x6FFFFEF5]

I think it is a bug. We should either error out or don't print garbage values and warn this case instead.
I am going to fix this.

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.