[PATCH] D35791: [COFF, ARM64] Fix symbol offsets in ADRP/ADD/LDR/STR relocations

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 04:07:07 PDT 2017


mstorsjo created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

In COFF, a symbol offset can't be stored in the relocation (as is done in ELF or MachO), but is stored as the immediate in the instruction itself. The immediate in the ADRP thus is the symbol offset in bytes, not in pages. For the PAGEOFFSET_12A/L relocations, ignore any offset outside of the lowest 12 bits; they won't have any effect on the ADD/LDR/STR instruction itself but only on the associated ADRP.

This is similar to how the same issue is handled for MOVW/MOVT instructions in ELF (see e.g. SVN r307713, and r307728 in lld).

This fixes "fixup out of range" errors while building larger object files, where temporary symbols end up as a plain section symbol and an offset, and fixes any cases where the symbol offset mean that the actual target ended up on a different page than the symbol itself.


https://reviews.llvm.org/D35791

Files:
  lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  test/MC/AArch64/coff-relocations.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35791.107879.patch
Type: text/x-patch
Size: 8037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170724/97d9866e/attachment.bin>


More information about the llvm-commits mailing list