[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 19:29:33 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL253007: [ELF2/AArch64] Add support for R_AARCH64_CALL26 and R_AARCH64_JUMP26. (authored by ikudrin).

Changed prior to commit:
  http://reviews.llvm.org/D14606?vs=40023&id=40104#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14606

Files:
  lld/trunk/ELF/Target.cpp
  lld/trunk/test/elf2/aarch64-call26-error.s
  lld/trunk/test/elf2/aarch64-jump26-error.s
  lld/trunk/test/elf2/aarch64-relocs.s

Index: lld/trunk/test/elf2/aarch64-call26-error.s
===================================================================
--- lld/trunk/test/elf2/aarch64-call26-error.s
+++ lld/trunk/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: lld/trunk/test/elf2/aarch64-relocs.s
===================================================================
--- lld/trunk/test/elf2/aarch64-relocs.s
+++ lld/trunk/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: lld/trunk/test/elf2/aarch64-jump26-error.s
===================================================================
--- lld/trunk/test/elf2/aarch64-jump26-error.s
+++ lld/trunk/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: lld/trunk/ELF/Target.cpp
===================================================================
--- lld/trunk/ELF/Target.cpp
+++ lld/trunk/ELF/Target.cpp
@@ -665,6 +665,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)) {
+      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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14606.40104.patch
Type: text/x-patch
Size: 3058 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151113/4b2770c7/attachment-0001.bin>


More information about the llvm-commits mailing list