This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho][nfc] Refactor subtractor reloc handling
ClosedPublic

Authored by int3 on Mar 10 2021, 7:42 PM.

Details

Reviewers
thakis
Group Reviewers
Restricted Project
Commits
rGa723db92d87d: [lld-macho][nfc] Refactor subtractor reloc handling
Summary

SUBTRACTOR relocations are always paired with UNSIGNED
relocations to indicate a pair of symbols whose address difference we
want. Functionally they are like a single relocation: only one pointer
gets written / relocated. Previously, we would handle these pairs by
skipping over the SUBTRACTOR relocation and writing the pointer when
handling the UNSIGNED reloc. This diff reverses things, so we write
while handling SUBTRACTORs and skip over the UNSIGNED relocs instead.

Being able to distinguish between SUBTRACTOR and UNSIGNED relocs in the
write phase (i.e. inside relocateOne) is useful for the upcoming range
check diff: we want to check that SUBTRACTOR relocs write signed values,
but UNSIGNED relocs (naturally) write unsigned values.

Diff Detail

Event Timeline

int3 created this revision.Mar 10 2021, 7:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2021, 7:42 PM
int3 requested review of this revision.Mar 10 2021, 7:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2021, 7:42 PM
thakis accepted this revision.Mar 11 2021, 6:05 AM
This revision is now accepted and ready to land.Mar 11 2021, 6:05 AM
This revision was landed with ongoing or failed builds.Mar 11 2021, 10:28 AM
This revision was automatically updated to reflect the committed changes.