[lld] r329006 - [PPC64] Minor changes for Plt relocations.
Sean Fertile via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 2 12:47:21 PDT 2018
Author: sfertile
Date: Mon Apr 2 12:47:21 2018
New Revision: 329006
URL: http://llvm.org/viewvc/llvm-project?rev=329006&view=rev
Log:
[PPC64] Minor changes for Plt relocations.
The Plt relative relocations are R_PPC64_JMP_SLOT in the V2 abi, and we only
reserve 2 double words instead of 3 at the start of the array of PLT entries for
lazy linking.
Differential Revision: https://reviews.llvm.org/D44951
Added:
lld/trunk/test/ELF/ppc64le-dynamic-relocations.s
Modified:
lld/trunk/ELF/Arch/PPC64.cpp
lld/trunk/test/ELF/ppc64le-plt-stub.s
Modified: lld/trunk/ELF/Arch/PPC64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/PPC64.cpp?rev=329006&r1=329005&r2=329006&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/PPC64.cpp (original)
+++ lld/trunk/ELF/Arch/PPC64.cpp Mon Apr 2 12:47:21 2018
@@ -63,7 +63,7 @@ static uint16_t applyPPCHighest(uint64_t
static uint16_t applyPPCHighesta(uint64_t V) { return (V + 0x8000) >> 48; }
PPC64::PPC64() {
- PltRel = GotRel = R_PPC64_GLOB_DAT;
+ GotRel = R_PPC64_GLOB_DAT;
RelativeRel = R_PPC64_RELATIVE;
GotEntrySize = 8;
GotPltEntrySize = 8;
@@ -71,8 +71,14 @@ PPC64::PPC64() {
PltHeaderSize = 0;
GotBaseSymInGotPlt = false;
GotBaseSymOff = 0x8000;
- if (Config->EKind == ELF64LEKind)
+
+ if (Config->EKind == ELF64LEKind) {
GotHeaderEntriesNum = 1;
+ GotPltHeaderEntriesNum = 2;
+ PltRel = R_PPC64_JMP_SLOT;
+ } else {
+ PltRel = R_PPC64_GLOB_DAT;
+ }
// We need 64K pages (at least under glibc/Linux, the loader won't
// set different permissions on a finer granularity than that).
Added: lld/trunk/test/ELF/ppc64le-dynamic-relocations.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ppc64le-dynamic-relocations.s?rev=329006&view=auto
==============================================================================
--- lld/trunk/test/ELF/ppc64le-dynamic-relocations.s (added)
+++ lld/trunk/test/ELF/ppc64le-dynamic-relocations.s Mon Apr 2 12:47:21 2018
@@ -0,0 +1,46 @@
+// REQUIRES: ppc
+// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64le.s -o %t2.o
+// RUN: ld.lld -shared %t2.o -o %t2.so
+// RUN: ld.lld %t.o %t2.so -o %t
+// RUN: llvm-readobj -dyn-relocations %t | FileCheck %s
+// RUN: llvm-objdump -D %t | FileCheck --check-prefix=DIS %s
+// RUN: llvm-readelf -dynamic-table %t | FileCheck --check-prefix=DT %s
+
+// The dynamic relocation for foo should point to 16 bytes past the start of
+// the .got.plt section.
+// CHECK: Dynamic Relocations {
+// CHECK-NEXT: 0x10020010 R_PPC64_JMP_SLOT foo 0x0
+
+// There should be 2 reserved doublewords before the first entry. The dynamic
+// linker will fill those in with the address of the resolver entry point and
+// the dynamic object identifier.
+// DIS: Disassembly of section .got.plt:
+// DIS-NEXT: .got.plt:
+// DIS-NEXT: 10020000: 00 00 00 00 <unknown>
+// DIS-NEXT: 10020004: 00 00 00 00 <unknown>
+// DIS-NEXT: 10020008: 00 00 00 00 <unknown>
+// DIS-NEXT: 1002000c: 00 00 00 00 <unknown>
+// DIS-NEXT: 10020010: 00 00 00 00 <unknown>
+// DIS-NEXT: 10020014: 00 00 00 00 <unknown>
+
+// DT_PLTGOT should point to the start of the .got.plt section.
+// DT: 0x0000000000000003 PLTGOT 0x10020000
+
+ .text
+ .abiversion 2
+ .globl _start
+ .p2align 4
+ .type _start, at function
+_start:
+.Lfunc_begin0:
+.Lfunc_gep0:
+ addis 2, 12, .TOC.-.Lfunc_gep0 at ha
+ addi 2, 2, .TOC.-.Lfunc_gep0 at l
+.Lfunc_lep0:
+ .localentry _start, .Lfunc_lep0-.Lfunc_gep0
+ bl foo
+ nop
+ li 0, 1
+ sc
+ .size _start, .-.Lfunc_begin0
Modified: lld/trunk/test/ELF/ppc64le-plt-stub.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ppc64le-plt-stub.s?rev=329006&r1=329005&r2=329006&view=diff
==============================================================================
--- lld/trunk/test/ELF/ppc64le-plt-stub.s (original)
+++ lld/trunk/test/ELF/ppc64le-plt-stub.s Mon Apr 2 12:47:21 2018
@@ -32,6 +32,6 @@ _start:
// CHECK: .plt:
// CHECK-NEXT: 18 00 41 f8 std 2, 24(1)
// CHECK-NEXT: fe ff 82 3d addis 12, 2, -2
-// CHECK-NEXT: 48 7f 8c e9 ld 12, 32584(12)
+// CHECK-NEXT: 40 7f 8c e9 ld 12, 32576(12)
// CHECK-NEXT: a6 03 89 7d mtctr 12
// CHECK: 20 04 80 4e bctr
More information about the llvm-commits
mailing list