[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
This commit is contained in:
Davide Italiano 2015-11-20 21:35:38 +00:00
parent 6220fd8bfd
commit dc67f9b7e8
2 changed files with 36 additions and 0 deletions

View File

@ -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");

View File

@ -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]