[all-commits] [llvm/llvm-project] 2a92fc: [MC][ELF][ARM] Add relocations for some pc-relativ...
Peter Smith via All-commits
all-commits at lists.llvm.org
Fri Feb 28 03:29:49 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 2a92fc9b8e6a079acd53ec3675cfd9bb153ab1ea
https://github.com/llvm/llvm-project/commit/2a92fc9b8e6a079acd53ec3675cfd9bb153ab1ea
Author: Peter Smith <peter.smith at arm.com>
Date: 2020-02-28 (Fri, 28 Feb 2020)
Changed paths:
M llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
M llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
A llvm/test/MC/ARM/pcrel-global-rel.s
M llvm/test/MC/ARM/pcrel-global.s
M llvm/test/MC/ARM/thumb1-relax-adr.s
M llvm/test/MC/ARM/thumb1-relax-ldrlit.s
Log Message:
-----------
[MC][ELF][ARM] Add relocations for some pc-relative fixups
Add ELF relocations for the following fixups:
fixup_thumb_adr_pcrel_10 -> R_ARM_THM_PC8
fixup_thumb_cp -> R_ARM_THM_PC8
fixup_t2_adr_pcrel_12 -> R_ARM_THM_PREL_11_0
fixup_t2_ldst_pcrel_12 -> R_ARM_THM_PC12
While these relocations are short-ranged there is support in the open
source ELF linker's in binutils and soon to be in LLD. MC will no longer
resolve pc-relative fixups to global symbols due to interpositioning
concerns. We can handle these at link time by implementing the relocations.
The R_ARM_THM_PC8 has some extra encoding rules for addends that llvm-mc
sidesteps by not supporting addends for these instructions, using the wide
Thumb 2 instruction if it is available. I think that this is a reasonable
compromise given that these are rare.
This partiall reverts D72892, the Thumb fixups no longer need to be
evaluated at assembly time.
Differential Revision: https://reviews.llvm.org/D75039
Commit: 6b035b607f5f5e4db6f1ca51340d7a87b5807a0c
https://github.com/llvm/llvm-project/commit/6b035b607f5f5e4db6f1ca51340d7a87b5807a0c
Author: Peter Smith <peter.smith at arm.com>
Date: 2020-02-28 (Fri, 28 Feb 2020)
Changed paths:
M lld/ELF/Arch/ARM.cpp
M lld/ELF/InputSection.cpp
M lld/ELF/Relocations.h
A lld/test/ELF/arm-thumb-adr-err.s
A lld/test/ELF/arm-thumb-adr.s
A lld/test/ELF/arm-thumb-ldrlit-err.s
A lld/test/ELF/arm-thumb-ldrlit.s
A lld/test/ELF/arm-thumb-pc8-weak.s
M lld/test/ELF/arm-thumb-undefined-weak.s
A lld/test/ELF/arm-thumb2-adr-err.s
A lld/test/ELF/arm-thumb2-adr.s
A lld/test/ELF/arm-thumb2-ldrlit-err.s
A lld/test/ELF/arm-thumb2-ldrlit.s
Log Message:
-----------
[LLD][ELF][ARM] Implement Thumb pc-relative relocations for adr and ldr
MC will now output the R_ARM_THM_PC8, R_ARM_THM_PC12 and
R_ARM_THM_PREL_11_0 relocations. These are short-ranged relocations that
are used to implement the adr rd, literal and ldr rd, literal pseudo
instructions.
The instructions use a new RelExpr called R_ARM_PCA in order to calculate
the required S + A - Pa expression, where Pa is AlignDown(P, 4) as the
instructions add their immediate to AlignDown(PC, 4). We also do not want
these relocations to generate or resolve against a PLT entry as the range
of these relocations is so short they would never reach.
The R_ARM_THM_PC8 has a special encoding convention for the relocation
addend, the immediate field is unsigned, yet the addend must be -4 to
account for the Thumb PC bias. The ABI (not the architecture) uses the
convention that the 8-byte immediate of 0xff represents -4.
Differential Revision: https://reviews.llvm.org/D75042
Compare: https://github.com/llvm/llvm-project/compare/46bfc2bc01e0...6b035b607f5f
More information about the All-commits
mailing list