From dc67f9b7e8ab9e3ff3f3d8f35aa9cd7b5e58a1ad Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Fri, 20 Nov 2015 21:35:38 +0000 Subject: [PATCH] [ELF/AArch64] Add support for LDST8_ABS_LO12_NC/LDST64_ABS_LO12_NC. These two relocations where the only missing step to get a dynamically linked (with libc) "hello world" on FreeBSD. llvm-svn: 253714 --- lld/ELF/Target.cpp | 8 ++++++++ lld/test/ELF/aarch64-relocs.s | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 4a8dc9fa5008..6584f6399771 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -742,10 +742,18 @@ void AArch64TargetInfo::relocateOne(uint8_t *Loc, uint8_t *BufEnd, or32le(Loc, (X & 0x0FFFFFFC) >> 2); break; } + case R_AARCH64_LDST32_ABS_LO12_NC: + // No overflow check needed. + or32le(Loc, (SA & 0xFFC) << 8); + break; case R_AARCH64_LDST64_ABS_LO12_NC: // No overflow check needed. or32le(Loc, (SA & 0xFF8) << 7); break; + case R_AARCH64_LDST8_ABS_LO12_NC: + // No overflow check needed. + or32le(Loc, (SA & 0xFFF) << 10); + break; case R_AARCH64_PREL16: if (!isInt<16>(SA)) error("Relocation R_AARCH64_PREL16 out of range"); diff --git a/lld/test/ELF/aarch64-relocs.s b/lld/test/ELF/aarch64-relocs.s index 827b1228b97c..56b04a679111 100644 --- a/lld/test/ELF/aarch64-relocs.s +++ b/lld/test/ELF/aarch64-relocs.s @@ -92,3 +92,31 @@ jump26: # CHECK: Disassembly of section .R_AARCH64_JUMP26: # CHECK-NEXT: jump26: # CHECK-NEXT: 11038: fe ff ff 17 b #-8 + +.section .R_AARCH64_LDST32_ABS_LO12_NC,"ax",@progbits +ldst32: + ldr s4, [x5, :lo12:foo32] +foo32: + .asciz "foo" + .size mystr, 3 + +# S = 0x1103c, A = 0x4 +# R = ((S + A) & 0xFFC) << 8 = 0x00004000 +# 0x00004000 | 0xbd4000a4 = 0xbd4040a4 +# CHECK: Disassembly of section .R_AARCH64_LDST32_ABS_LO12_NC: +# CHECK-NEXT: ldst32: +# CHECK-NEXT: 1103c: a4 40 40 bd ldr s4, [x5, #64] + +.section .R_AARCH64_LDST8_ABS_LO12_NC,"ax",@progbits +ldst8: + ldrsb x11, [x13, :lo12:foo8] +foo8: + .asciz "foo" + .size mystr, 3 + +# S = 0x11044, A = 0x4 +# R = ((S + A) & 0xFFF) << 10 = 0x00012000 +# 0x00012000 | 0x398001ab = 0x398121ab +# CHECK: Disassembly of section .R_AARCH64_LDST8_ABS_LO12_NC: +# CHECK-NEXT: ldst8: +# CHECK-NEXT: 11044: ab 21 81 39 ldrsb x11, [x13, #72]