[lld] r313841 - [AArch64] Implement R_AARCH64_ LD_PREL_LO19.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 16:49:50 PDT 2017
Author: davide
Date: Wed Sep 20 16:49:50 2017
New Revision: 313841
URL: http://llvm.org/viewvc/llvm-project?rev=313841&view=rev
Log:
[AArch64] Implement R_AARCH64_ LD_PREL_LO19.
Fixes PR34660.
Differential Revision: https://reviews.llvm.org/D38053
Added:
lld/trunk/test/ELF/pr34660.s
Modified:
lld/trunk/ELF/Arch/AArch64.cpp
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/aarch64-undefined-weak.s
Modified: lld/trunk/ELF/Arch/AArch64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/AArch64.cpp?rev=313841&r1=313840&r2=313841&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/AArch64.cpp (original)
+++ lld/trunk/ELF/Arch/AArch64.cpp Wed Sep 20 16:49:50 2017
@@ -92,6 +92,7 @@ RelExpr AArch64::getRelExpr(uint32_t Typ
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 @@ void AArch64::relocateOne(uint8_t *Loc,
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;
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=313841&r1=313840&r2=313841&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Sep 20 16:49:50 2017
@@ -487,6 +487,7 @@ static uint64_t getAArch64UndefinedRelat
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");
Modified: lld/trunk/test/ELF/aarch64-undefined-weak.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-undefined-weak.s?rev=313841&r1=313840&r2=313841&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-undefined-weak.s (original)
+++ lld/trunk/test/ELF/aarch64-undefined-weak.s Wed Sep 20 16:49:50 2017
@@ -30,6 +30,8 @@ _start:
.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 @@ _start:
// CHECK-NEXT: 2001c: {{.*}} .word 0x00000000
// CHECK-NEXT: 20020: {{.*}} .word 0x00000000
// CHECK-NEXT: 20024: {{.*}} .short 0x0000
+// CHECK: $x.2:
+// CHECK-NEXT: 20026: {{.*}} ldr x8, #0
Added: lld/trunk/test/ELF/pr34660.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/pr34660.s?rev=313841&view=auto
==============================================================================
--- lld/trunk/test/ELF/pr34660.s (added)
+++ lld/trunk/test/ELF/pr34660.s Wed Sep 20 16:49:50 2017
@@ -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:
More information about the llvm-commits
mailing list