Page MenuHomePhabricator

[llvm-readobj/elf] - Introduce Relocation<ELFT> helper.

Authored by grimar on Sep 4 2020, 6:22 AM.



It removes templating for Elf_Rel[a] handling that we
introduced earlier and introduces a helper class instead.

It was briefly discussed in D87087, which showed,
why having templates is probably not ideal for the generalization
of dumpers code.

Diff Detail

Event Timeline

grimar created this revision.Sep 4 2020, 6:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 4 2020, 6:22 AM
Herald added a subscriber: rupprecht. · View Herald Transcript
grimar requested review of this revision.Sep 4 2020, 6:22 AM
jhenderson added inline comments.Sep 7 2020, 12:33 AM

I'd rather avoid this, for reasons which I think were previously discussed when you first tried something like this - it essentially lies about the underlying relocation type. Furthermore, I don't think it is necessary - you can store the relocation's properties in the class itself, derived at construction time when you already have a "real" relocation. In other words, your members might become something like this:

uint64_t Offset;
Optional<int64_t> Addend;
uint32_t SymIndex;
uint32_t Type;

You might need the odd new function elsewhere, to replace where you do things like getRelocationSymbol, to take an index, but I don't think any of them will be that complex.

grimar updated this revision to Diff 290236.Sep 7 2020, 3:50 AM
grimar marked an inline comment as done.
  • Addressed review comment.


jhenderson accepted this revision.Sep 7 2020, 4:49 AM

LGTM, thanks for the work.


Registering that I am not particularly keen on casting from Rela -> Rel like this (a person in the future could decide to change the Rel constructor to do something with the assumption that it really is always an Elf_Rel here). I don't have any great alternative currently though, without duplicating logic, so am not asking this to change.

This revision is now accepted and ready to land.Sep 7 2020, 4:49 AM
This revision was automatically updated to reflect the committed changes.