[PATCH] Extend acceptable undefined symbol handling
Joerg Sonnenberger
joerg at NetBSD.org
Tue Sep 3 16:02:56 PDT 2013
Fix C&P error.
Hi shankarke, ruiu,
http://llvm-reviews.chandlerc.com/D1582
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1582?vs=3986&id=4006#toc
Files:
include/lld/ReaderWriter/MachOLinkingContext.h
include/lld/ReaderWriter/CoreLinkingContext.h
include/lld/ReaderWriter/PECOFFLinkingContext.h
include/lld/ReaderWriter/ELFLinkingContext.h
include/lld/Core/LinkingContext.h
lib/Core/Resolver.cpp
Index: include/lld/ReaderWriter/MachOLinkingContext.h
===================================================================
--- include/lld/ReaderWriter/MachOLinkingContext.h
+++ include/lld/ReaderWriter/MachOLinkingContext.h
@@ -49,6 +49,8 @@
uint32_t outputFileType() const { return _outputFileType; }
+ virtual bool outputIsSharedLibrary() const { return false; }
+
enum Arch {
arch_unknown,
arch_x86,
Index: include/lld/ReaderWriter/CoreLinkingContext.h
===================================================================
--- include/lld/ReaderWriter/CoreLinkingContext.h
+++ include/lld/ReaderWriter/CoreLinkingContext.h
@@ -33,6 +33,8 @@
void addPassNamed(StringRef name) { _passNames.push_back(name); }
+ virtual bool outputIsSharedLibrary() const { return false; }
+
protected:
virtual Writer &writer() const;
Index: include/lld/ReaderWriter/PECOFFLinkingContext.h
===================================================================
--- include/lld/ReaderWriter/PECOFFLinkingContext.h
+++ include/lld/ReaderWriter/PECOFFLinkingContext.h
@@ -116,6 +116,8 @@
return x;
}
+ virtual bool outputIsSharedLibrary() const { return false; }
+
virtual bool hasInputGraph() {
if (_inputGraph)
return true;
Index: include/lld/ReaderWriter/ELFLinkingContext.h
===================================================================
--- include/lld/ReaderWriter/ELFLinkingContext.h
+++ include/lld/ReaderWriter/ELFLinkingContext.h
@@ -57,6 +57,10 @@
bool mergeCommonStrings() const { return _mergeCommonStrings; }
virtual uint64_t getBaseAddress() const { return _baseAddress; }
+ virtual bool outputIsSharedLibrary() const {
+ return getOutputType() == llvm::ELF::ET_DYN;
+ }
+
/// This controls if undefined atoms need to be created for undefines that are
/// present in a SharedLibrary. If this option is set, undefined atoms are
/// created for every undefined symbol that are present in the dynamic table
Index: include/lld/Core/LinkingContext.h
===================================================================
--- include/lld/Core/LinkingContext.h
+++ include/lld/Core/LinkingContext.h
@@ -316,6 +316,9 @@
/// Reference::Kind.
virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind k) const = 0;
+ /// Abstract method to return whether the output is shared for the purpose
+ /// of missing undefind symbols.
+ virtual bool outputIsSharedLibrary() const = 0;
/// @}
protected:
Index: lib/Core/Resolver.cpp
===================================================================
--- lib/Core/Resolver.cpp
+++ lib/Core/Resolver.cpp
@@ -339,11 +339,15 @@
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) && _context.allowShlibUndefines())
- continue;
+ // Ignore undefined symbols from other shared libraries.
+ if (isa<SharedLibraryFile>(f))
+ continue;
+ // If the output is a shared library and undefined symbols are allowed
+ // on the target platform, skip over it.
+ if (_context.outputIsSharedLibrary() && _context.allowShlibUndefines())
+ continue;
+
// Seems like this symbol is undefined. Warn that.
foundUndefines = true;
if (_context.printRemainingUndefines()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1582.3.patch
Type: text/x-patch
Size: 3437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130903/70d2e2a4/attachment.bin>
More information about the llvm-commits
mailing list