[all-commits] [llvm/llvm-project] 28b172: [LLD][ELF][ARM] Implement ARM pc-relative relocati...

Peter Smith via All-commits all-commits at lists.llvm.org
Wed Apr 8 04:46:08 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 28b172e34177fe925ac4f54de2ce073e1d6029d9
      https://github.com/llvm/llvm-project/commit/28b172e34177fe925ac4f54de2ce073e1d6029d9
  Author: Peter Smith <peter.smith at arm.com>
  Date:   2020-04-08 (Wed, 08 Apr 2020)

  Changed paths:
    M lld/ELF/Arch/ARM.cpp
    A lld/test/ELF/arm-adr-err.s
    A lld/test/ELF/arm-adr-long.s
    A lld/test/ELF/arm-adr.s
    A lld/test/ELF/arm-ldrlit-err.s
    A lld/test/ELF/arm-ldrlit.s

  Log Message:
  -----------
  [LLD][ELF][ARM] Implement ARM pc-relative relocations for ADR and LDR

The R_ARM_ALU_PC_G0 and R_ARM_LDR_PC_G0 relocations are used by the
ADR and LDR pseudo instructions, and are the basis of the group
relocations that can load an arbitrary constant via a series of add, sub
and ldr instructions.

The relocations need to be obtained via the .reloc directive.

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.

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




More information about the All-commits mailing list