[lld] r253007 - [ELF2/AArch64] Add support for R_AARCH64_CALL26 and R_AARCH64_JUMP26.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 19:26:59 PST 2015
Author: ikudrin
Date: Thu Nov 12 21:26:59 2015
New Revision: 253007
URL: http://llvm.org/viewvc/llvm-project?rev=253007&view=rev
Log:
[ELF2/AArch64] Add support for R_AARCH64_CALL26 and R_AARCH64_JUMP26.
This patch covers only the case where no DSO is involved.
Differential Revision: http://reviews.llvm.org/D14606
Added:
lld/trunk/test/elf2/aarch64-call26-error.s
lld/trunk/test/elf2/aarch64-jump26-error.s
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/test/elf2/aarch64-relocs.s
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=253007&r1=253006&r2=253007&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Nov 12 21:26:59 2015
@@ -665,6 +665,17 @@ void AArch64TargetInfo::relocateOne(uint
updateAArch64Adr(Loc, (X >> 12) & 0x1FFFFF); // X[32:12]
break;
}
+ case R_AARCH64_JUMP26:
+ case R_AARCH64_CALL26: {
+ uint64_t X = SA - P;
+ if (!isInt<28>(X)) {
+ if (Type == R_AARCH64_JUMP26)
+ error("Relocation R_AARCH64_JUMP26 out of range");
+ error("Relocation R_AARCH64_CALL26 out of range");
+ }
+ or32le(Loc, (X & 0x0FFFFFFC) >> 2);
+ break;
+ }
case R_AARCH64_LDST64_ABS_LO12_NC:
// No overflow check needed.
or32le(Loc, (SA & 0xFF8) << 7);
Added: lld/trunk/test/elf2/aarch64-call26-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/aarch64-call26-error.s?rev=253007&view=auto
==============================================================================
--- lld/trunk/test/elf2/aarch64-call26-error.s (added)
+++ lld/trunk/test/elf2/aarch64-call26-error.s Thu Nov 12 21:26:59 2015
@@ -0,0 +1,9 @@
+// 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.lld2 -shared %t %tabs -o %t2 2>&1 | FileCheck %s
+// REQUIRES: aarch64
+
+.text
+ bl big
+
+// CHECK: R_AARCH64_CALL26 out of range
Added: lld/trunk/test/elf2/aarch64-jump26-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/aarch64-jump26-error.s?rev=253007&view=auto
==============================================================================
--- lld/trunk/test/elf2/aarch64-jump26-error.s (added)
+++ lld/trunk/test/elf2/aarch64-jump26-error.s Thu Nov 12 21:26:59 2015
@@ -0,0 +1,9 @@
+// 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.lld2 -shared %t %tabs -o %t2 2>&1 | FileCheck %s
+// REQUIRES: aarch64
+
+.text
+ b big
+
+// CHECK: R_AARCH64_JUMP26 out of range
Modified: lld/trunk/test/elf2/aarch64-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/aarch64-relocs.s?rev=253007&r1=253006&r2=253007&view=diff
==============================================================================
--- lld/trunk/test/elf2/aarch64-relocs.s (original)
+++ lld/trunk/test/elf2/aarch64-relocs.s Thu Nov 12 21:26:59 2015
@@ -57,3 +57,38 @@ foo:
# CHECK: Disassembly of section .R_AARCH64_LDST64_ABS_LO12_NC:
# CHECK-NEXT: $x.6:
# CHECK-NEXT: 11024: 7c 17 40 f9 ldr x28, [x27, #40]
+
+.section .SUB,"ax", at progbits
+ nop
+sub:
+ nop
+
+# CHECK: Disassembly of section .SUB:
+# CHECK-NEXT: $x.8:
+# CHECK-NEXT: 1102c: 1f 20 03 d5 nop
+# CHECK: sub:
+# CHECK-NEXT: 11030: 1f 20 03 d5 nop
+
+.section .R_AARCH64_CALL26,"ax", at progbits
+call26:
+ bl sub
+
+# S = 0x1102c, A = 0x4, P = 0x11034
+# R = S + A - P = -0x4 = 0xfffffffc
+# (R & 0x0ffffffc) >> 2 = 0x03ffffff
+# 0x94000000 | 0x03ffffff = 0x97ffffff
+# CHECK: Disassembly of section .R_AARCH64_CALL26:
+# CHECK-NEXT: call26:
+# CHECK-NEXT: 11034: ff ff ff 97 bl #-4
+
+.section .R_AARCH64_JUMP26,"ax", at progbits
+jump26:
+ b sub
+
+# S = 0x1102c, A = 0x4, P = 0x11038
+# R = S + A - P = -0x8 = 0xfffffff8
+# (R & 0x0ffffffc) >> 2 = 0x03fffffe
+# 0x14000000 | 0x03fffffe = 0x17fffffe
+# CHECK: Disassembly of section .R_AARCH64_JUMP26:
+# CHECK-NEXT: jump26:
+# CHECK-NEXT: 11038: fe ff ff 17 b #-8
More information about the llvm-commits
mailing list