[PATCH] D43658: Make undefined symbol in DSO to pull out object files from archive files.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 22 17:09:31 PST 2018
ruiu updated this revision to Diff 135569.
ruiu added a comment.
- updated the test case.
https://reviews.llvm.org/D43658
Files:
lld/ELF/SymbolTable.cpp
lld/test/ELF/shlib-undefined-archive.s
Index: lld/test/ELF/shlib-undefined-archive.s
===================================================================
--- /dev/null
+++ lld/test/ELF/shlib-undefined-archive.s
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+
+# Undefined symbols in a DSO should pull out object files from archives
+# to resolve them.
+
+# RUN: echo '.globl foo' | llvm-mc -filetype=obj -triple=x86_64-linux-gnu -o %t1.o -
+# RUN: ld.lld -shared -o %t.so %t1.o
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-linux-gnu -o %t2.o %s
+# RUN: llvm-ar cru %t.a %t2.o
+# RUN: ld.lld -o %t.exe %t.so %t.a
+# RUN: llvm-nm -D %t.exe | FileCheck %s
+
+# CHECK: T foo
+
+.globl foo
+foo:
+ ret
Index: lld/ELF/SymbolTable.cpp
===================================================================
--- lld/ELF/SymbolTable.cpp
+++ lld/ELF/SymbolTable.cpp
@@ -599,9 +599,14 @@
for (InputFile *F : SharedFiles) {
for (StringRef U : cast<SharedFile<ELFT>>(F)->getUndefinedSymbols()) {
Symbol *Sym = find(U);
- if (!Sym || !Sym->isDefined())
+ if (!Sym)
continue;
- Sym->ExportDynamic = true;
+ if (auto *L = dyn_cast<Lazy>(Sym))
+ if (InputFile *File = L->fetch())
+ addFile<ELFT>(File);
+
+ if (Sym->isDefined())
+ Sym->ExportDynamic = true;
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43658.135569.patch
Type: text/x-patch
Size: 1275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180223/9c96571c/attachment.bin>
More information about the llvm-commits
mailing list