[lld] r309605 - Never export weak undefined from executable.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 11:52:47 PDT 2017
Author: rafael
Date: Mon Jul 31 11:52:47 2017
New Revision: 309605
URL: http://llvm.org/viewvc/llvm-project?rev=309605&view=rev
Log:
Never export weak undefined from executable.
Before we were doing it with --export-dynamic. That seems incorrect.
The intention of --export-dynamic is to export symbols *defined* in
the executable.
Modified:
lld/trunk/ELF/Symbols.cpp
lld/trunk/test/ELF/weak-undef-export.s
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=309605&r1=309604&r2=309605&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Mon Jul 31 11:52:47 2017
@@ -357,8 +357,9 @@ uint8_t Symbol::computeBinding() const {
bool Symbol::includeInDynsym() const {
if (computeBinding() == STB_LOCAL)
return false;
- return ExportDynamic || body()->isShared() ||
- (body()->isUndefined() && Config->Shared);
+ if (body()->isUndefined())
+ return Config->Shared;
+ return ExportDynamic || body()->isShared();
}
// Print out a log message for --trace-symbol.
Modified: lld/trunk/test/ELF/weak-undef-export.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/weak-undef-export.s?rev=309605&r1=309604&r2=309605&view=diff
==============================================================================
--- lld/trunk/test/ELF/weak-undef-export.s (original)
+++ lld/trunk/test/ELF/weak-undef-export.s Mon Jul 31 11:52:47 2017
@@ -4,6 +4,19 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld --export-dynamic %t.o -o %t
+# RUN: llvm-readobj -dyn-symbols %t | FileCheck %s
+
+# CHECK: DynamicSymbols [
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: @ (0)
+# 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: ]
.weak foo
.quad foo
More information about the llvm-commits
mailing list