[llvm-branch-commits] [lld] r361921 - Merging r354184:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 28 20:26:49 PDT 2019


Author: tstellar
Date: Tue May 28 20:26:49 2019
New Revision: 361921

URL: http://llvm.org/viewvc/llvm-project?rev=361921&view=rev
Log:
Merging r354184:

------------------------------------------------------------------------
r354184 | ruiu | 2019-02-15 15:11:18 -0800 (Fri, 15 Feb 2019) | 10 lines

[PPC64] Preserve LocalEntry when linking

On PowerPC64, it is necessary to keep the LocalEntry bits in st_other,
especially when -r is used. Otherwise, when the resulting object is used
in a posterior linking, LocalEntry info will be unavailable and
functions may be called through the wrong entrypoint.

Patch by Leandro Lupori.

Differential Revision: https://reviews.llvm.org/D56782
------------------------------------------------------------------------

Added:
    lld/branches/release_80/test/ELF/ppc64-local-entry.s
Modified:
    lld/branches/release_80/ELF/SyntheticSections.cpp

Modified: lld/branches/release_80/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/ELF/SyntheticSections.cpp?rev=361921&r1=361920&r2=361921&view=diff
==============================================================================
--- lld/branches/release_80/ELF/SyntheticSections.cpp (original)
+++ lld/branches/release_80/ELF/SyntheticSections.cpp Tue May 28 20:26:49 2019
@@ -2001,6 +2001,11 @@ template <class ELFT> void SymbolTableSe
       ESym->setVisibility(Sym->Visibility);
     }
 
+    // The 3 most significant bits of st_other are used by OpenPOWER ABI.
+    // See getPPC64GlobalEntryToLocalEntryOffset() for more details.
+    if (Config->EMachine == EM_PPC64)
+      ESym->st_other |= Sym->StOther & 0xe0;
+
     ESym->st_name = Ent.StrTabOffset;
     ESym->st_shndx = getSymSectionIndex(Ent.Sym);
 

Added: lld/branches/release_80/test/ELF/ppc64-local-entry.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/test/ELF/ppc64-local-entry.s?rev=361921&view=auto
==============================================================================
--- lld/branches/release_80/test/ELF/ppc64-local-entry.s (added)
+++ lld/branches/release_80/test/ELF/ppc64-local-entry.s Tue May 28 20:26:49 2019
@@ -0,0 +1,47 @@
+# REQUIRES: ppc
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t
+# RUN: ld.lld -r %t -o %t2
+# RUN: llvm-objdump -s -section=.symtab %t2 | FileCheck %s
+
+.text
+.abiversion 2
+.globl  _start
+.p2align	2
+.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
+	# The code below is not important, it just needs to access some
+	# global data or function, in order to use the TOC.
+	# In this case, it performs the following:
+	# g += 10;
+	# Also note that this code is not intended to be run, but only
+	# to check if the linker will preserve the localentry info.
+	addis 3, 2, g at toc@ha
+	addi 3, 3, g at toc@l
+	lwz 4, 0(3)
+	addi 4, 4, 10
+	stw 4, 0(3)
+	blr
+	.long	0
+	.quad	0
+.Lfunc_end0:
+	.size   _start, .Lfunc_end0-.Lfunc_begin0
+
+	.type	g, at object               # @g
+	.lcomm	g,4,4
+
+// We expect the st_other byte to be 0x60:
+// localentry = 011 (gep + 2 instructions), reserved = 000,
+// visibility = 00 (STV_DEFAULT)
+// Currently, llvm-objdump does not support displaying
+// st_other's PPC64 specific flags, thus we check the
+// result of the hexdump of .symtab section.
+
+// CHECK: 0070 00000000 00000000 00000009 12600001




More information about the llvm-branch-commits mailing list