]> granicus.if.org Git - llvm/commit
[ARM, ELF] Don't shift movt relocation offsets
authorMartin Storsjo <martin@martin.st>
Tue, 11 Jul 2017 21:07:10 +0000 (21:07 +0000)
committerMartin Storsjo <martin@martin.st>
Tue, 11 Jul 2017 21:07:10 +0000 (21:07 +0000)
commit847573ba4ef69d91b1795e22f49f49cb285b4c43
tree94f5fe3d8ca4cff7ad8c2190037fb17f5fa4205e
parent827143c4dfe98bee8df111e5d031690a775128dd
[ARM, ELF] Don't shift movt relocation offsets

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.

Differential Revision: https://reviews.llvm.org/D35242

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307713 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
test/MC/ARM/elf-movt.s