class AArch64TargetInfo final : public TargetInfo {
public:
AArch64TargetInfo();
+ unsigned getDynReloc(unsigned Type) const override;
unsigned getPltRefReloc(unsigned Type) const override;
void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;
void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,
PltZeroEntrySize = 32;
}
+unsigned AArch64TargetInfo::getDynReloc(unsigned Type) const {
+ if (Type == R_AARCH64_ABS32 || Type == R_AARCH64_ABS64)
+ return Type;
+ StringRef S = getELFRelocationTypeName(EM_AARCH64, Type);
+ error("Relocation " + S + " cannot be used when making a shared object; "
+ "recompile with -fPIC.");
+}
+
unsigned AArch64TargetInfo::getPltRefReloc(unsigned Type) const { return Type; }
void AArch64TargetInfo::writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const {
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
+.globl _start
+_start:
.data
.hword foo + 0xfeff
.hword foo - 0x8100
-// RUN: ld.lld -shared %t.o %t256.o -o %t.so
-// RUN: llvm-objdump -s -section=.data %t.so | FileCheck %s
+// RUN: ld.lld %t.o %t256.o -o %t2
+// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
// CHECK: Contents of section .data:
-// 1090: S = 0x100, A = 0xfeff
-// S + A = 0xffff
-// 1092: S = 0x100, A = -0x8100
-// S + A = 0x8000
-// CHECK-NEXT: 1090 ffff0080
+// 11000: S = 0x100, A = 0xfeff
+// S + A = 0xffff
+// 11002: S = 0x100, A = -0x8100
+// S + A = 0x8000
+// CHECK-NEXT: 11000 ffff0080
-// RUN: not ld.lld -shared %t.o %t255.o -o %t.so
+// RUN: not ld.lld %t.o %t255.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld -shared %t.o %t257.o -o %t.so
+// RUN: not ld.lld %t.o %t257.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
// OVERFLOW: Relocation R_AARCH64_ABS16 out of range
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
+.globl _start
+_start:
.data
.word foo + 0xfffffeff
.word foo - 0x80000100
-// RUN: ld.lld -shared %t.o %t256.o -o %t.so
-// RUN: llvm-objdump -s -section=.data %t.so | FileCheck %s
+// RUN: ld.lld %t.o %t256.o -o %t2
+// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
// CHECK: Contents of section .data:
-// 1090: S = 0x100, A = 0xfffffeff
-// S + A = 0xffffffff
-// 1094: S = 0x100, A = -0x80000100
-// S + A = 0x80000000
-// CHECK-NEXT: 1090 ffffffff 00000080
+// 11000: S = 0x100, A = 0xfffffeff
+// S + A = 0xffffffff
+// 11004: S = 0x100, A = -0x80000100
+// S + A = 0x80000000
+// CHECK-NEXT: 11000 ffffffff 00000080
-// RUN: not ld.lld -shared %t.o %t255.o -o %t.so
+// RUN: not ld.lld %t.o %t255.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld -shared %t.o %t257.o -o %t.so
+// RUN: not ld.lld %t.o %t257.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
// OVERFLOW: Relocation R_AARCH64_ABS32 out of range
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t
-// RUN: ld.lld -shared %t -o %t2
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
+// RUN: ld.lld %t %t256.o -o %t2
// RUN: llvm-objdump -s %t2 | FileCheck %s
// REQUIRES: aarch64
+.globl _start
+_start:
.section .R_AARCH64_ABS64, "ax",@progbits
- .xword sym + 36
+ .xword foo + 0x24
+// S = 0x100, A = 0x24
+// S + A = 0x124
// CHECK: Contents of section .R_AARCH64_ABS64:
-// CHECK-NEXT: 1000 24000000 00000000
-// ^-- A = 0x24
+// CHECK-NEXT: 11000 24010000 00000000
.section .R_AARCH64_PREL64, "ax",@progbits
- .xword sym - . + 36
+ .xword foo - . + 0x24
-// S + A = 0x24
-// P = 0x1008
-// SA - P = 0xfffffffffffff01c
+// S = 0x100, A = 0x24, P = 0x11008
+// S + A - P = 0xfffffffffffef11c
// CHECK: Contents of section .R_AARCH64_PREL64:
-// CHECK-NEXT: 1008 1cf0ffff ffffffff
+// CHECK-NEXT: 11008 1cf1feff ffffffff
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_ABS16 cannot be used when making a shared object; recompile with -fPIC.
+
+.data
+ .hword foo
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_ADD_ABS_LO12_NC cannot be used when making a shared object; recompile with -fPIC.
+
+ add x0, x0, :lo12:dat
+.data
+.globl dat
+dat:
+ .word 0
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_ADR_PREL_LO21 cannot be used when making a shared object; recompile with -fPIC.
+
+ adr x0, dat
+.data
+.globl dat
+dat:
+ .word 0
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_ADR_PREL_PG_HI21 cannot be used when making a shared object; recompile with -fPIC.
+
+ adrp x0, dat
+.data
+.globl dat
+dat:
+ .word 0
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_LDST32_ABS_LO12_NC cannot be used when making a shared object; recompile with -fPIC.
+
+ ldr s4, [x0, :lo12:dat]
+.data
+.globl dat
+dat:
+ .word 0
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_LDST64_ABS_LO12_NC cannot be used when making a shared object; recompile with -fPIC.
+
+ ldr x0, [x0, :lo12:dat]
+.data
+.globl dat
+dat:
+ .word 0
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_LDST8_ABS_LO12_NC cannot be used when making a shared object; recompile with -fPIC.
+
+ ldrsb x0, [x1, :lo12:dat]
+.data
+.globl dat
+dat:
+ .word 0
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_PREL16 cannot be used when making a shared object; recompile with -fPIC.
+
+.data
+ .hword foo - .
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_PREL32 cannot be used when making a shared object; recompile with -fPIC.
+
+.data
+ .word foo - .
--- /dev/null
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_PREL64 cannot be used when making a shared object; recompile with -fPIC.
+
+.data
+ .xword foo - .
// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %S/Inputs/abs.s -o %tabs
// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t
-// RUN: not ld.lld %tabs -shared %t -o %t2 2>&1 | FileCheck %s
+// RUN: not ld.lld %tabs %t -o %t2 2>&1 | FileCheck %s
// REQUIRES: aarch64
+.globl _start
+_start:
adrp x0, big
#CHECK: R_AARCH64_ADR_PREL_PG_HI21 out of range
// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %S/Inputs/abs.s -o %tabs
// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t
-// RUN: not ld.lld %tabs -shared %t -o %t2 2>&1 | FileCheck %s
+// RUN: not ld.lld %tabs %t -o %t2 2>&1 | FileCheck %s
// REQUIRES: aarch64
+.globl _start
+_start:
adr x0, big
#CHECK: R_AARCH64_ADR_PREL_LO21 out of range
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
+.globl _start
+_start:
.data
- .hword foo - . + 0x10f8f
- .hword foo - . - 0x706e
+ .hword foo - . + 0x20eff
+ .hword foo - . + 0x8f02
-// Note: If this test fails, it is probably results from
+// Note: If this test fails, it probably happens because of
// the change of the address of the .data section.
// You may found the correct address in the aarch64_abs16.s test,
-// if it's already fixed. Then, update addends accordingly.
-// RUN: ld.lld -shared %t.o %t256.o -o %t.so
-// RUN: llvm-objdump -s -section=.data %t.so | FileCheck %s
+// if it is already fixed. Then, update addends accordingly.
+// RUN: ld.lld %t.o %t256.o -o %t2
+// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
// CHECK: Contents of section .data:
-// 1090: S = 0x100, A = 0x10f8f, P = 0x1090
-// S + A - P = 0xffff
-// 1092: S = 0x100, A = -0x706e, P = 0x1092
-// S + A - P = 0x8000
-// CHECK-NEXT: 1090 ffff0080
+// 11000: S = 0x100, A = 0x20eff, P = 0x11000
+// S + A - P = 0xffff
+// 11002: S = 0x100, A = 0x8f02, P = 0x11002
+// S + A - P = 0x8000
+// CHECK-NEXT: 11000 ffff0080
-// RUN: not ld.lld -shared %t.o %t255.o -o %t.so
+// RUN: not ld.lld %t.o %t255.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld -shared %t.o %t257.o -o %t.so
+// RUN: not ld.lld %t.o %t257.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
// OVERFLOW: Relocation R_AARCH64_PREL16 out of range
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
+.globl _start
+_start:
.data
- .word foo - . + 0x100000f8f
- .word foo - . - 0x7ffff06c
+ .word foo - . + 0x100010eff
+ .word foo - . - 0x7ffef0fc
-// Note: If this test fails, it is probably results from
+// Note: If this test fails, it probably happens because of
// the change of the address of the .data section.
// You may found the correct address in the aarch64_abs32.s test,
-// if it's already fixed. Then, update addends accordingly.
-// RUN: ld.lld -shared %t.o %t256.o -o %t.so
-// RUN: llvm-objdump -s -section=.data %t.so | FileCheck %s
+// if it is already fixed. Then, update addends accordingly.
+// RUN: ld.lld %t.o %t256.o -o %t2
+// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
// CHECK: Contents of section .data:
-// 1090: S = 0x100, A = 0x100000f8f, P = 0x1090
-// S + A - P = 0xffffffff
-// 1094: S = 0x100, A = -0x7ffff06c, P = 0x1094
-// S + A - P = 0x80000000
-// CHECK-NEXT: 1090 ffffffff 00000080
+// 11000: S = 0x100, A = 0x100010eff, P = 0x11000
+// S + A - P = 0xffffffff
+// 11004: S = 0x100, A = -0x7ffef0fc, P = 0x11004
+// S + A - P = 0x80000000
+// CHECK-NEXT: 11000 ffffffff 00000080
-// RUN: not ld.lld -shared %t.o %t255.o -o %t.so
+// RUN: not ld.lld %t.o %t255.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld -shared %t.o %t257.o -o %t.so
+// RUN: not ld.lld %t.o %t257.o -o %t2
// | FileCheck %s --check-prefix=OVERFLOW
// OVERFLOW: Relocation R_AARCH64_PREL32 out of range