[PATCH] [lld][Core] Allow weak symbols in shared library when linking.
Rui Ueyama
ruiu at google.com
Fri Apr 19 01:13:41 PDT 2013
Hi kledzik,
Currently lld always shows an error message when it finds an undefined
symbol in a shared library, even if the symbol is weak. That is, I think,
a wrong behavior.
Glibc has a weak symbol "_dl_starting_up". So the current lld always fails
to link an object when making an executable because of the error.
http://llvm-reviews.chandlerc.com/D694
Files:
lib/Core/Resolver.cpp
Index: lib/Core/Resolver.cpp
===================================================================
--- lib/Core/Resolver.cpp
+++ lib/Core/Resolver.cpp
@@ -315,19 +315,21 @@
bool foundUndefines = false;
for (const UndefinedAtom *undefAtom : undefinedAtoms) {
const File &f = undefAtom->file();
- bool isAtomUndefined = false;
- if (isa<SharedLibraryFile>(f)) {
- if (!_targetInfo.allowShlibUndefines()) {
- foundUndefines = true;
- isAtomUndefined = true;
- }
- } else if (undefAtom->canBeNull() == UndefinedAtom::canBeNullNever) {
- foundUndefines = true;
- isAtomUndefined = true;
- }
- if (isAtomUndefined && _targetInfo.printRemainingUndefines()) {
- llvm::errs() << "Undefined Symbol: " << undefAtom->file().path()
- << " : " << undefAtom->name() << "\n";
+
+ // Skip over a weak symbol.
+ if (undefAtom->canBeNull() != UndefinedAtom::canBeNullNever)
+ continue;
+
+ // If this is a library and undefined symbols are allowed on the
+ // target platform, skip over it.
+ if (isa<SharedLibraryFile>(f) && _targetInfo.allowShlibUndefines())
+ continue;
+
+ // Seems like this symbol is undefined. Warn that.
+ foundUndefines = true;
+ if (_targetInfo.printRemainingUndefines()) {
+ llvm::errs() << "Undefined Symbol: " << undefAtom->file().path()
+ << " : " << undefAtom->name() << "\n";
}
}
if (foundUndefines) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D694.1.patch
Type: text/x-patch
Size: 1530 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130419/e4b2bede/attachment.bin>
More information about the llvm-commits
mailing list