[PATCH] D14606: [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 03:41:03 PST 2015
ikudrin created this revision.
ikudrin added reviewers: davide, ruiu, rafael.
ikudrin added a subscriber: llvm-commits.
ikudrin added a project: lld.
Herald added subscribers: rengolin, aemerson.
This patch covers only the case where no DSO is involved.
http://reviews.llvm.org/D14606
Files:
ELF/Target.cpp
test/elf2/aarch64-call26-error.s
test/elf2/aarch64-jump26-error.s
test/elf2/aarch64-relocs.s
Index: test/elf2/aarch64-relocs.s
===================================================================
--- test/elf2/aarch64-relocs.s
+++ test/elf2/aarch64-relocs.s
@@ -57,3 +57,38 @@
# 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
Index: test/elf2/aarch64-jump26-error.s
===================================================================
--- /dev/null
+++ test/elf2/aarch64-jump26-error.s
@@ -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
Index: test/elf2/aarch64-call26-error.s
===================================================================
--- /dev/null
+++ test/elf2/aarch64-call26-error.s
@@ -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
Index: ELF/Target.cpp
===================================================================
--- ELF/Target.cpp
+++ ELF/Target.cpp
@@ -662,6 +662,17 @@
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))
+ error(Twine("Relocation ") +
+ ((Type == R_AARCH64_CALL26) ? "R_AARCH64_CALL26"
+ : "R_AARCH64_JUMP26") +
+ " out of range");
+ write32le(Loc, read32le(Loc) | ((X & 0x0FFFFFFC) >> 2));
+ break;
+ }
case R_AARCH64_LDST64_ABS_LO12_NC:
// No overflow check needed.
or32le(Loc, (SA & 0xFF8) << 7);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14606.40023.patch
Type: text/x-patch
Size: 2943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151112/f60a21d9/attachment.bin>
More information about the llvm-commits
mailing list