This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Add a generic test for --dyn-relocations and fix an issue.
ClosedPublic

Authored by grimar on Jul 8 2020, 5:10 AM.

Details

Summary

We have an issue currently: --dyn-relocations always prints the following
relocation header when dumping DynPLTRelRegion:

"Offset Info Type Symbol's Value Symbol's Name + Addend"

I.e. even for an empty object, --dyn-relocations still prints this.
It is a easy to fix bug, but we have no dedicated test case for this option.
(we have a dynamic-reloc-no-section-headers.test, which has a slightly different purpose).

This patch adds a test and fixes the behavior.

Diff Detail

Event Timeline

grimar created this revision.Jul 8 2020, 5:10 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar updated this revision to Diff 276385.Jul 8 2020, 5:14 AM
  • Minor fix.
MaskRay added inline comments.Jul 8 2020, 10:35 AM
llvm/test/tools/llvm-readobj/ELF/dynamic-reloc.test
60

Can the test be merged with dynamic-reloc-no-section-headers.test?

We also miss a warning: '[[FILE]]': section header string table index xxx does not exist

jhenderson added inline comments.Jul 9 2020, 12:41 AM
llvm/test/tools/llvm-readobj/ELF/dynamic-reloc.test
6

I'd avoid using -EMPTY as a custom prefix name as that might get confused with -EMPTY as the FileCheck check suffix. Perhaps "LLVM-NONE"?

20

how -> that
relocations -> relocation

105

.relr.dyn?

grimar updated this revision to Diff 276702.Jul 9 2020, 4:28 AM
grimar marked 5 inline comments as done.
  • Addressed review comments.
llvm/test/tools/llvm-readobj/ELF/dynamic-reloc.test
60

Can the test be merged with dynamic-reloc-no-section-headers.test?

Yes, but I think we should merge dynamic-reloc-no-section-headers.test (specific case) -> here (general test) after.

dynamic-reloc-no-section-headers.test tests the case when there are no section headers.
It is a sub-case for --dyn-relocations and it is implemented with:

## We simulate no section header table by
## overriding the ELF header properties.
  SHOff:   0x0
  SHNum:   0x0

But now we have a different way to do this:

SectionHeaderTable:
  NoHeaders: true

So in a follow-up we should be able to remove the dynamic-reloc-no-section-headers.test and just extend this test to do something like:

SectionHeaderTable:
  NoHeaders: [[NOHEADERS]]

We also miss a warning: '[[FILE]]': section header string table index xxx does not exist

Why should we emit it? We have a .shstrtab section in this object (implicitly created).
I've added --implicit-check-not=warning: just in case, to demonstrate that we expect no warnings here.

jhenderson accepted this revision.Jul 13 2020, 12:27 AM

Looks good from my point of view.

This revision is now accepted and ready to land.Jul 13 2020, 12:27 AM
This revision was automatically updated to reflect the committed changes.