[PATCH] D71794: [ELF] Don't special case weak symbols for pie with no shared objects

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 09:43:20 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG96e2376d02f0: [ELF] Don't special case weak symbols for pie with no shared objects (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71794/new/

https://reviews.llvm.org/D71794

Files:
  lld/ELF/Symbols.cpp
  lld/test/ELF/ppc32-weak-undef-call.s
  lld/test/ELF/weak-undef-no-shared-libs.s


Index: lld/test/ELF/weak-undef-no-shared-libs.s
===================================================================
--- lld/test/ELF/weak-undef-no-shared-libs.s
+++ /dev/null
@@ -1,28 +0,0 @@
-// REQUIRES: x86
-// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-// RUN: ld.lld -pie %t.o -o %t
-// RUN: llvm-readobj -V --dyn-syms %t | FileCheck %s
-
-        .globl _start
-_start:
-        .type foo, at function
-        .weak foo
-        .long foo at gotpcrel
-
-// Test that an entry for weak undefined symbols is NOT emitted in .dynsym as
-// the PIE was not linked with any shared libraries. There are other tests which
-// ensure that the weak undefined symbols do get emitted in .dynsym for PIEs
-// linked against dynamic libraries.
-
-
-// CHECK:      DynamicSymbols [
-// CHECK-NEXT:   Symbol {
-// CHECK-NEXT:     Name:
-// CHECK-NEXT:     Value: 0x0
-// CHECK-NEXT:     Size: 0
-// CHECK-NEXT:     Binding: Local (0x0)
-// CHECK-NEXT:     Type: None (0x0)
-// CHECK-NEXT:     Other: 0
-// CHECK-NEXT:     Section: Undefined (0x0)
-// CHECK-NEXT:   }
-// CHECK-NEXT: ]
Index: lld/test/ELF/ppc32-weak-undef-call.s
===================================================================
--- lld/test/ELF/ppc32-weak-undef-call.s
+++ lld/test/ELF/ppc32-weak-undef-call.s
@@ -1,19 +1,19 @@
 # REQUIRES: ppc
 # RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
 # RUN: ld.lld %t.o -o %t
-# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=EXE %s
+# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=PDE %s
 # RUN: ld.lld -pie %t.o -o %t
-# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=EXE %s
+# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=PIC %s
 # RUN: ld.lld -shared %t.o -o %t
-# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=SHARED %s
+# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=PIC %s
 
 ## It does not really matter how we fixup it, but we cannot overflow and
 ## should not generate a call stub (this would waste space).
-# EXE: bl .+0
+# PDE: bl .+0
 
-## With -shared, create a call stub. ld.bfd produces bl .+0
-# SHARED: bl .+4
-# SHARED: 00000000.plt_pic32.foo:
+## With -pie or -shared, create a call stub. ld.bfd produces bl .+0
+# PIC: bl .+4
+# PIC: 00000000.plt_pic32.foo:
 
 .weak foo
 bl foo
Index: lld/ELF/Symbols.cpp
===================================================================
--- lld/ELF/Symbols.cpp
+++ lld/ELF/Symbols.cpp
@@ -278,11 +278,6 @@
   if (computeBinding() == STB_LOCAL)
     return false;
 
-  // If a PIE binary was not linked against any shared libraries, then we can
-  // safely drop weak undef symbols from .dynsym.
-  if (isUndefWeak() && config->pie && sharedFiles.empty())
-    return false;
-
   return isUndefined() || isShared() || exportDynamic || inDynamicList;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71794.236849.patch
Type: text/x-patch
Size: 2888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200108/d01a85f9/attachment.bin>


More information about the llvm-commits mailing list