This is an archive of the discontinued LLVM Phabricator instance.

[ARM, ELF] Don't shift movt relocation offsets
ClosedPublic

Authored by mstorsjo on Jul 11 2017, 3:50 AM.

Details

Summary

For ELF, a movw+movt pair is handled as two separate relocations. If an offset should be applied to the symbol address, this offset is stored as an immediate in the instruction (as opposed to stored as an offset in the relocation itself).

Even though the actual value stored in the movt immediate after linking is the top half of the value, we need to store the unshifted offset prior to linking. When the relocation is made during linking, the offset gets added to the target symbol value, and the upper half of the value is stored in the instruction.

This makes sure that movw+movt with offset symbols get properly handled, in case the offset addition in the lower half should be carried over to the upper half.

This makes the output from the additions to the test case match the output from GNU binutils.

For COFF and MachO, the movw/movt relocations are handled as a pair, and the overflow from the lower half gets carried over to the movt, so they should keep the shifted offset just as before.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Jul 11 2017, 3:50 AM
This revision is now accepted and ready to land.Jul 11 2017, 10:53 AM
This revision was automatically updated to reflect the committed changes.