[PATCH] D88945: [ELF] Don't change binding to STB_WEAK for an undefined specified by -u

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 08:31:41 PDT 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb1988f03884: [ELF] Don't change binding to STB_WEAK for an undefined specified by -u (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88945

Files:
  lld/ELF/Driver.cpp
  lld/test/ELF/weak-undef-lib.s


Index: lld/test/ELF/weak-undef-lib.s
===================================================================
--- lld/test/ELF/weak-undef-lib.s
+++ lld/test/ELF/weak-undef-lib.s
@@ -17,6 +17,17 @@
 # CHECK-NEXT: Other: 0
 # CHECK-NEXT: Section: Undefined
 
+## -u specifies a STB_DEFAULT undefined symbol, so the definition from %t2.o is
+## fetched.
+# RUN: ld.lld -u foo %t1.o --start-lib %t2.o -o %t1
+# RUN: llvm-readobj --syms %t1 | FileCheck %s --check-prefix=CHECK-U
+
+# CHECK-U:      Name: foo
+# CHECK-U:      Binding:
+# CHECK-U-SAME:          Global
+# CHECK-U:      Section:
+# CHECK-U-SAME:          .text
+
 .weak foo
 call foo at PLT
 
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1992,7 +1992,7 @@
   // Handle -u/--undefined before input files. If both a.a and b.so define foo,
   // -u foo a.a b.so will fetch a.a.
   for (StringRef name : config->undefined)
-    addUnusedUndefined(name);
+    addUnusedUndefined(name)->referenced = true;
 
   // Add all files to the symbol table. This will add almost all
   // symbols that we need to the symbol table. This process might


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88945.296979.patch
Type: text/x-patch
Size: 1185 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201008/1649ad8c/attachment.bin>


More information about the llvm-commits mailing list