[lld] r250423 - Revert "r250372 - [ELF2/PPC64] Remove now-dead weak/undef check"

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 09:12:35 PDT 2015


Author: hfinkel
Date: Thu Oct 15 11:12:35 2015
New Revision: 250423

URL: http://llvm.org/viewvc/llvm-project?rev=250423&view=rev
Log:
Revert "r250372 - [ELF2/PPC64] Remove now-dead weak/undef check"

Unfortunately, the check was not as dead as I had thought, and adjusting the
starting VA again exposed the problem. We end up trying to relocate the bl
(using a 24-bit relative offset) to a symbol address of zero, and in general,
that does not fit.

Thus, reverting for now, and adding a test case.

Added:
    lld/trunk/test/elf2/ppc64-weak-undef-call.s
Modified:
    lld/trunk/ELF/Target.cpp

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=250423&r1=250422&r2=250423&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Oct 15 11:12:35 2015
@@ -416,7 +416,7 @@ bool PPC64TargetInfo::relocNeedsPlt(uint
     return false;
 
   // These are function calls that need to be redirected through a PLT stub.
-  return S.isShared();
+  return S.isShared() || (S.isUndefined() && S.isWeak());
 }
 
 bool PPC64TargetInfo::isRelRelative(uint32_t Type) const {

Added: lld/trunk/test/elf2/ppc64-weak-undef-call.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/ppc64-weak-undef-call.s?rev=250423&view=auto
==============================================================================
--- lld/trunk/test/elf2/ppc64-weak-undef-call.s (added)
+++ lld/trunk/test/elf2/ppc64-weak-undef-call.s Thu Oct 15 11:12:35 2015
@@ -0,0 +1,23 @@
+# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t
+# RUN: ld.lld2 %t -o %t2
+# RUN: llvm-objdump -d %t2 | FileCheck %s
+# REQUIRES: ppc
+
+# CHECK: Disassembly of section .text:
+
+.section        ".opd","aw"
+.global _start
+_start:
+.quad   .Lfoo,.TOC. at tocbase,0
+
+.text
+.Lfoo:
+  bl weakfunc
+  nop
+  blr
+
+.weak weakfunc
+
+# It does not really matter how we fixup the bl, if at all, because it needs to
+# be unreachable. But, we should link successfully.
+# CHECK: 10010008:       4e 80 00 20     blr




More information about the llvm-commits mailing list