[PATCH] D38053: [AArch64] Implement R_AARCH64_ LD_PREL_LO19

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 16:51:33 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL313841: [AArch64] Implement R_AARCH64_ LD_PREL_LO19. (authored by davide).

Changed prior to commit:
  https://reviews.llvm.org/D38053?vs=115907&id=116117#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38053

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


Index: lld/trunk/test/ELF/pr34660.s
===================================================================
--- lld/trunk/test/ELF/pr34660.s
+++ lld/trunk/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: lld/trunk/test/ELF/aarch64-undefined-weak.s
===================================================================
--- lld/trunk/test/ELF/aarch64-undefined-weak.s
+++ lld/trunk/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: lld/trunk/ELF/Arch/AArch64.cpp
===================================================================
--- lld/trunk/ELF/Arch/AArch64.cpp
+++ lld/trunk/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;
Index: lld/trunk/ELF/InputSection.cpp
===================================================================
--- lld/trunk/ELF/InputSection.cpp
+++ lld/trunk/ELF/InputSection.cpp
@@ -487,6 +487,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");


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


More information about the llvm-commits mailing list