[PATCH] D38053: [AArch64] Implement R_AARCH64_ LD_PREL_LO19

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 14:47:01 PDT 2017


davide updated this revision to Diff 115907.
davide added a comment.

Rafael's comments.


https://reviews.llvm.org/D38053

Files:
  ELF/Arch/AArch64.cpp
  ELF/InputSection.cpp
  test/ELF/aarch64-undefined-weak.s
  test/ELF/pr34660.s


Index: test/ELF/pr34660.s
===================================================================
--- /dev/null
+++ test/ELF/pr34660.s
@@ -0,0 +1,25 @@
+# REQUIRES: aarch64
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o
+# RUN: ld.lld -shared %t.o -o %t
+# RUN: llvm-objdump %t -d | FileCheck %s --check-prefix=DISASM
+# RUN: llvm-readobj -elf-output-style=GNU %t -t | FileCheck %s --check-prefix=SYM
+
+# It would be much easier to understand/read this test if llvm-objdump would print
+# the immediates in hex.
+# IMM = hex(65540) = 0x10004
+# PC = 0x10000
+# As the relocation is PC-relative, IMM + PC = 0x20004 which is the VA of the
+# correct symbol.
+
+# DISASM: Disassembly of section .text:
+# DISASM-NEXT: $x.0:
+# DISASM-NEXT:   10000:       28 00 08 58     ldr     x8, #65540
+
+# SYM: Symbol table '.symtab'
+# SYM:  0000000000020004     0 NOTYPE  LOCAL  DEFAULT    5 patatino
+
+  ldr x8, patatino
+  .data
+  .zero 4
+patatino:
Index: test/ELF/aarch64-undefined-weak.s
===================================================================
--- test/ELF/aarch64-undefined-weak.s
+++ test/ELF/aarch64-undefined-weak.s
@@ -30,6 +30,8 @@
  .xword target - .
 // R_AARCH64_PREL16
  .hword target - .
+// R_AARCH64_LD_PREL_LO19
+ ldr x8, target
 
 // CHECK: Disassembly of section .text:
 // 131076 = 0x20004
@@ -43,3 +45,5 @@
 // CHECK-NEXT:    2001c: {{.*}} .word   0x00000000
 // CHECK-NEXT:    20020: {{.*}} .word   0x00000000
 // CHECK-NEXT:    20024: {{.*}} .short  0x0000
+// CHECK:         $x.2:
+// CHECK-NEXT:    20026: {{.*}} ldr     x8, #0
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -471,6 +471,7 @@
   case R_AARCH64_PREL32:
   case R_AARCH64_PREL64:
   case R_AARCH64_ADR_PREL_LO21:
+  case R_AARCH64_LD_PREL_LO19:
     return P + A;
   }
   llvm_unreachable("AArch64 pc-relative relocation expected\n");
Index: ELF/Arch/AArch64.cpp
===================================================================
--- ELF/Arch/AArch64.cpp
+++ ELF/Arch/AArch64.cpp
@@ -92,6 +92,7 @@
   case R_AARCH64_PREL32:
   case R_AARCH64_PREL64:
   case R_AARCH64_ADR_PREL_LO21:
+  case R_AARCH64_LD_PREL_LO19:
     return R_PC;
   case R_AARCH64_ADR_PREL_PG_HI21:
     return R_PAGE_PC;
@@ -247,6 +248,7 @@
     or32le(Loc, (Val & 0x0FFFFFFC) >> 2);
     break;
   case R_AARCH64_CONDBR19:
+  case R_AARCH64_LD_PREL_LO19:
     checkInt<21>(Loc, Val, Type);
     or32le(Loc, (Val & 0x1FFFFC) << 3);
     break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38053.115907.patch
Type: text/x-patch
Size: 2531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170919/cca696da/attachment.bin>


More information about the llvm-commits mailing list