This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Refactor getRelocTargetVA(). NFC.
AbandonedPublic

Authored by grimar on Nov 16 2018, 12:51 AM.

Details

Summary

Currently getRelocTargetVA handles relocation expressions
for all targets at once, mixing the common expressions and
target-specific expressions.

This approach has noticeable disadvantages:

  1. When debugging the code for some target, expressions specific

to other targets are unuseful. It is harder to read when logic for all kinds
of target specific code is mixed in one place.

  1. If we do a mistake in code and will use expression specific for target A

for target B, current code would not catch that. It's perhaps unlikely to happen,
but still not as safe/isolated as it could be.

Diff Detail

Event Timeline

grimar created this revision.Nov 16 2018, 12:51 AM
grimar added inline comments.Nov 16 2018, 12:52 AM
ELF/InputSection.cpp
786

Since this code does not use anything target specific, I think
R_HEXAGON_GOT should not have HEXAGON prefix and can be renamed
and moved to the common handlers group.

Rui, what do you think about this? Should we try to group the expressions by target platform like this patch do? (I'll rebase it then)

ruiu added a comment.Nov 27 2018, 9:08 AM

Honestly I don't think the new code is better than the existing one. All target-specific relocation types are clearly prefixed with target names (e.g. R_AARCH64 or R_HEXAGON), and I kind of like the old code as it is just a flat switch-case list.

grimar abandoned this revision.Nov 28 2018, 12:45 AM

OK, abandoning.