From 2dfc5fd1eacb8b642296eb954769d72b83d863d7 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Fri, 15 Jan 2016 01:49:51 +0000 Subject: [PATCH] [ELF/AArch64] Add support for R_AARCH64_LDST16_ABS_LO12_NC relocation. Found while trying to self-host the toolchain that libLTO needs it. llvm-svn: 257854 --- lld/ELF/Target.cpp | 4 ++++ lld/test/ELF/aarch64-relocs.s | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 3597566fe6e6..5d93b8d90606 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -1271,6 +1271,7 @@ bool AArch64TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const { case R_AARCH64_ADR_PREL_LO21: case R_AARCH64_ADR_PREL_PG_HI21: case R_AARCH64_LDST8_ABS_LO12_NC: + case R_AARCH64_LDST16_ABS_LO12_NC: case R_AARCH64_LDST32_ABS_LO12_NC: case R_AARCH64_LDST64_ABS_LO12_NC: case R_AARCH64_LDST128_ABS_LO12_NC: @@ -1384,6 +1385,9 @@ void AArch64TargetInfo::relocateOne(uint8_t *Loc, uint8_t *BufEnd, case R_AARCH64_LDST128_ABS_LO12_NC: or32le(Loc, (SA & 0x0FF8) << 6); break; + case R_AARCH64_LDST16_ABS_LO12_NC: + or32le(Loc, (SA & 0x0FFC) << 9); + break; case R_AARCH64_LDST8_ABS_LO12_NC: or32le(Loc, (SA & 0xFFF) << 10); break; diff --git a/lld/test/ELF/aarch64-relocs.s b/lld/test/ELF/aarch64-relocs.s index bc00679e7e86..90541329587a 100644 --- a/lld/test/ELF/aarch64-relocs.s +++ b/lld/test/ELF/aarch64-relocs.s @@ -136,3 +136,17 @@ foo128: # CHECK: 1104c: 74 16 c0 3d ldr q20, [x19, #80] #foo128: # 11050: 66 6f 6f 00 .word + +.section .R_AARCH64_LDST16_ABS_LO12_NC,"ax",@progbits +ldst16: + ldr h17, [x19, :lo12:foo16] +foo16: + .asciz "foo" + .size mystr, 3 + +# S = 0x11054, A = 0x4 +# R = ((S + A) & 0x0FFC) << 9 = 0xb000 +# 0xb000 | 0x7d400271 = 0x7d40b271 +# CHECK: Disassembly of section .R_AARCH64_LDST16_ABS_LO12_NC: +# CHECK-NEXT: ldst16: +# CHECK-NEXT: 11054: 71 b2 40 7d ldr h17, [x19, #88]