This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Refine logic of the symbol table locating in printRelocationsHelper().
ClosedPublic

Authored by grimar on Aug 6 2020, 6:05 AM.

Details

Summary

This removes the last unwrapOrError call from the printRelocationsHelper.

There is a little additional complexity because of SHT_RELR/SHT_ANDROID_RELR sections.
Such sections contains only relative relocations and they do not have a
symbol table associated with them, hence we should not try to treat
their sh_link field as a reference to a symbol table.

Diff Detail

Event Timeline

grimar created this revision.Aug 6 2020, 6:05 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar requested review of this revision.Aug 6 2020, 6:05 AM
jhenderson requested changes to this revision.Aug 10 2020, 12:57 AM

I'm not convinced that this is the right approach, although I suppose I can understand it for simplicity. I think the original SHT_RELR proposal was mistaken to say there's an associated symbol table, since as you've already highlighted, it represents relative relocations. In fact, later versions of the proposal dropped this (see e.g. https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Jnz1lgLJAgAJ):

The corresponding sh_link and sh_info values in the section header hold no special information.

I think it is actually therefore a mistake to try to treat sh_link as a symbol table reference, and as such, we shouldn't warn for SHT_RELR.

This revision now requires changes to proceed.Aug 10 2020, 12:57 AM

I think the original SHT_RELR proposal was mistaken to say there's an associated symbol table, since as you've already highlighted, it represents relative relocations. In fact, later versions of the proposal dropped this (see e.g. https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Jnz1lgLJAgAJ):

Ok, I've also supposed there is some mistake, but was not 100% sure. Thanks for the link, I've missed that sh_link description was dropped later.
I'll update the implementation after landing the parent diff (D85303).

grimar updated this revision to Diff 284728.Aug 11 2020, 7:51 AM
grimar edited the summary of this revision. (Show Details)
  • Reimplemented in according to the discussion.
jhenderson accepted this revision.Aug 12 2020, 12:23 AM

LGTM, with nit.

llvm/test/tools/llvm-readobj/ELF/relr-relocs.test
198–201
This revision is now accepted and ready to land.Aug 12 2020, 12:23 AM