[PATCH] D75349: [LLD][ELF][ARM] Implement ARM pc-relative relocations for adr and ldr

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 28 06:40:22 PST 2020


psmith created this revision.
psmith added reviewers: MaskRay, ruiu, grimar.
Herald added subscribers: kristof.beyls, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

MC will noe output the R_ARM_ALU_PC_G0 and R_ARM_LDR_PC_G0 relocations. These are short-ranged relocations that are used to implement the adr rd, literal and the ldr rd, literal pseudo instructions.

      

R_ARM_LDR_PC_G0 is fairly straightforward and is very similar to the Thumb2 equivalent R_ARM_THM_PC12.

      

R_ARM_ALU_PC_G0 is much more complicated as the add/sub instruction uses a modified immediate encoding of an 8-bit immediate rotated right by an even 4-bit field. This means that the range of representable immediates is sparse. We extract the encoding and decoding functions for the modified immediate from llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h as this header file is not accessible from LLD. Duplication of code isn't ideal, but as these are well-defined mathematical functions they are unlikely to change.

      

Depends on D75347 <https://reviews.llvm.org/D75347>


https://reviews.llvm.org/D75349

Files:
  lld/ELF/Arch/ARM.cpp
  lld/test/ELF/arm-adr-err.s
  lld/test/ELF/arm-adr-long.s
  lld/test/ELF/arm-adr.s
  lld/test/ELF/arm-ldrlit-err.s
  lld/test/ELF/arm-ldrlit.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75349.247245.patch
Type: text/x-patch
Size: 14684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200228/70f976e6/attachment.bin>


More information about the llvm-commits mailing list