[lld] r325152 - Make --export-dynamic-symbol to add undefined symbols even if --export-dynamic is given.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 14 10:38:33 PST 2018
Author: ruiu
Date: Wed Feb 14 10:38:33 2018
New Revision: 325152
URL: http://llvm.org/viewvc/llvm-project?rev=325152&view=rev
Log:
Make --export-dynamic-symbol to add undefined symbols even if --export-dynamic is given.
This patch addresses a minor compatibility issue with GNU linkers.
Previously, --export-dynamic-symbol is completely ignored if you
pass --export-dynamic together.
Differential Revision: https://reviews.llvm.org/D43266
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/export-dynamic-symbol.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=325152&r1=325151&r2=325152&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Feb 14 10:38:33 2018
@@ -803,13 +803,18 @@ void LinkerDriver::readConfigs(opt::Inpu
if (Optional<MemoryBufferRef> Buffer = readFile(Arg->getValue()))
readDynamicList(*Buffer);
- for (auto *Arg : Args.filtered(OPT_export_dynamic_symbol)) {
+ for (auto *Arg : Args.filtered(OPT_export_dynamic_symbol))
Config->DynamicList.push_back(
{Arg->getValue(), /*IsExternCpp*/ false, /*HasWildcard*/ false});
- Config->Undefined.push_back(Arg->getValue());
- }
}
+ // If --export-dynamic-symbol=foo is given and symbol foo is defined in
+ // an object file in an archive file, that object file should be pulled
+ // out and linked. (It doesn't have to behave like that from technical
+ // point of view, but this is needed for compatibility with GNU.)
+ for (auto *Arg : Args.filtered(OPT_export_dynamic_symbol))
+ Config->Undefined.push_back(Arg->getValue());
+
for (auto *Arg : Args.filtered(OPT_version_script))
if (Optional<MemoryBufferRef> Buffer = readFile(Arg->getValue()))
readVersionScript(*Buffer);
Modified: lld/trunk/test/ELF/export-dynamic-symbol.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/export-dynamic-symbol.s?rev=325152&r1=325151&r2=325152&view=diff
==============================================================================
--- lld/trunk/test/ELF/export-dynamic-symbol.s (original)
+++ lld/trunk/test/ELF/export-dynamic-symbol.s Wed Feb 14 10:38:33 2018
@@ -3,11 +3,14 @@
# RUN: rm -f %t.a
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/archive2.s -o %t1.o
# RUN: llvm-ar rcs %t.a %t1.o
-
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o
+
# RUN: ld.lld -shared -o %t.so --export-dynamic-symbol foo %t.a %t2.o
+# RUN: llvm-readelf -dyn-symbols %t.so | FileCheck %s
+# RUN: ld.lld -shared -o %t.so --export-dynamic --export-dynamic-symbol foo %t.a %t2.o
# RUN: llvm-readelf -dyn-symbols %t.so | FileCheck %s
+
# CHECK: foo
.global _start
More information about the llvm-commits
mailing list