[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:19:27 PST 2018
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325849: Make undefined symbol in DSO to pull out object files from archive files. (authored by ruiu, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43658?vs=135569&id=135570#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43658
Files:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/test/ELF/shlib-undefined-archive.s
Index: lld/trunk/test/ELF/shlib-undefined-archive.s
===================================================================
--- lld/trunk/test/ELF/shlib-undefined-archive.s
+++ lld/trunk/test/ELF/shlib-undefined-archive.s
@@ -0,0 +1,19 @@
+# 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: rm -f %t.a
+# 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/trunk/ELF/SymbolTable.cpp
===================================================================
--- lld/trunk/ELF/SymbolTable.cpp
+++ lld/trunk/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.135570.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180223/99c951c0/attachment.bin>
More information about the llvm-commits
mailing list