diff options
| author | Rui Ueyama <ruiu@google.com> | 2014-04-03 20:54:47 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2014-04-03 20:54:47 +0000 |
| commit | 9457510abffc07ddfb2d5cf64af49c98654e19e7 (patch) | |
| tree | 547a84db4d25da231e699af694901c0e0466d927 | |
| parent | cb74fa696b2df7b59a3cd1f73600096ee32a60a9 (diff) | |
| download | bcm5719-llvm-9457510abffc07ddfb2d5cf64af49c98654e19e7.tar.gz bcm5719-llvm-9457510abffc07ddfb2d5cf64af49c98654e19e7.zip | |
Fix ELFFileNode::resetNextIndex().
ELFLinkingContext has a method addUndefinedAtomsFromSharedLibrary().
The method is being used to skip a shared library within --start-group
and --end-group if it's not the first iteration of the group.
We have the same, incomplete mechanism to skip a shared library within
a group too. That's implemented in ELFFileNode. It's intended to not
return a shared library on the second or further iterations in the
first place. This mechanism is preferred over
addUndefinedAtomsFromSharedLibrary because the policy is implemented
in Input Graph -- that's what Input Graph is for.
This patch removes the dupluicate feature and fixes ELFFileNode.
Differential Revision: http://llvm-reviews.chandlerc.com/D3280
llvm-svn: 205566
| -rw-r--r-- | lld/include/lld/Core/LinkingContext.h | 5 | ||||
| -rw-r--r-- | lld/include/lld/Driver/GnuLdInputGraph.h | 10 | ||||
| -rw-r--r-- | lld/include/lld/ReaderWriter/ELFLinkingContext.h | 8 | ||||
| -rw-r--r-- | lld/lib/Core/Resolver.cpp | 41 |
4 files changed, 20 insertions, 44 deletions
diff --git a/lld/include/lld/Core/LinkingContext.h b/lld/include/lld/Core/LinkingContext.h index 0e784773925..cd413389fa0 100644 --- a/lld/include/lld/Core/LinkingContext.h +++ b/lld/include/lld/Core/LinkingContext.h @@ -158,11 +158,6 @@ public: /// to be an error. bool allowShlibUndefines() const { return _allowShlibUndefines; } - /// Add undefined symbols from shared libraries ? - virtual bool addUndefinedAtomsFromSharedLibrary(const SharedLibraryFile *) { - return true; - } - /// If true, core linking will write the path to each input file to stdout /// (i.e. llvm::outs()) as it is used. This is used to implement the -t /// linker option. diff --git a/lld/include/lld/Driver/GnuLdInputGraph.h b/lld/include/lld/Driver/GnuLdInputGraph.h index 8473e891b9d..741f43c8033 100644 --- a/lld/include/lld/Driver/GnuLdInputGraph.h +++ b/lld/include/lld/Driver/GnuLdInputGraph.h @@ -74,13 +74,11 @@ public: /// \brief This is used by Group Nodes, when there is a need to reset the /// the file to be processed next. When handling a group node that contains /// Input elements, if the group node has to be reprocessed, the linker needs - /// to start processing files as part of the inputelement from beginning. - /// reset the next file index to 0 only if the node is an archive library or - /// a shared library + /// to start processing files as part of the input element from beginning. + /// Reset the next file index to 0 only if the node is an archive library. void resetNextIndex() override { - if ((!_attributes._isWholeArchive && - (_files[0]->kind() == File::kindArchiveLibrary)) || - (_files[0]->kind() == File::kindSharedLibrary)) { + if (_files[0]->kind() == File::kindArchiveLibrary && + !_attributes._isWholeArchive) { _nextFileIndex = 0; } } diff --git a/lld/include/lld/ReaderWriter/ELFLinkingContext.h b/lld/include/lld/ReaderWriter/ELFLinkingContext.h index 95949030ff7..a7a5a6c9a41 100644 --- a/lld/include/lld/ReaderWriter/ELFLinkingContext.h +++ b/lld/include/lld/ReaderWriter/ELFLinkingContext.h @@ -224,13 +224,6 @@ public: return _rpathLinkList; } - bool addUndefinedAtomsFromSharedLibrary(const SharedLibraryFile *s) override { - if (_undefinedAtomsFromFile.find(s) != _undefinedAtomsFromFile.end()) - return false; - _undefinedAtomsFromFile[s] = true; - return true; - } - const std::map<std::string, uint64_t> &getAbsoluteSymbols() const { return _absoluteSymbols; } @@ -281,7 +274,6 @@ protected: StringRef _soname; StringRefVector _rpathList; StringRefVector _rpathLinkList; - std::map<const SharedLibraryFile *, bool> _undefinedAtomsFromFile; std::map<std::string, uint64_t> _absoluteSymbols; }; } // end namespace lld diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index f51d6887492..6b0c217f995 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -69,40 +69,31 @@ private: } // namespace void Resolver::handleFile(const File &file) { - const SharedLibraryFile *sharedLibraryFile = - dyn_cast<SharedLibraryFile>(&file); - for (const DefinedAtom *atom : file.defined()) doDefinedAtom(*atom); - bool progress = false; - - if (!sharedLibraryFile || - _context.addUndefinedAtomsFromSharedLibrary(sharedLibraryFile)) { - progress = !file.undefined().empty(); - - for (const UndefinedAtom *undefAtom : file.undefined()) { - doUndefinedAtom(*undefAtom); - // If the undefined symbol has an alternative name, try to resolve the - // symbol with the name to give it a second chance. This feature is used - // for COFF "weak external" symbol. - if (!_symbolTable.isDefined(undefAtom->name())) { - if (const UndefinedAtom *fallbackAtom = undefAtom->fallback()) { - doUndefinedAtom(*fallbackAtom); - _symbolTable.addReplacement(undefAtom, fallbackAtom); - } + + for (const UndefinedAtom *undefAtom : file.undefined()) { + doUndefinedAtom(*undefAtom); + // If the undefined symbol has an alternative name, try to resolve the + // symbol with the name to give it a second chance. This feature is used + // for COFF "weak external" symbol. + if (!_symbolTable.isDefined(undefAtom->name())) { + if (const UndefinedAtom *fallbackAtom = undefAtom->fallback()) { + doUndefinedAtom(*fallbackAtom); + _symbolTable.addReplacement(undefAtom, fallbackAtom); } } } - for (const SharedLibraryAtom *shlibAtom : file.sharedLibrary()) - doSharedLibraryAtom(*shlibAtom); - for (const AbsoluteAtom *absAtom : file.absolute()) - doAbsoluteAtom(*absAtom); + for (const SharedLibraryAtom *atom : file.sharedLibrary()) + doSharedLibraryAtom(*atom); + for (const AbsoluteAtom *atom : file.absolute()) + doAbsoluteAtom(*atom); // If we make some progress on linking, notify that fact to the input file // manager, because it may want to know that for --start-group/end-group. - progress = progress || !file.sharedLibrary().empty() || - !file.absolute().empty() || !file.defined().empty(); + bool progress = !file.defined().empty() || !file.sharedLibrary().empty() || + !file.absolute().empty() || !file.undefined().empty(); if (progress) { _context.inputGraph().notifyProgress(); } |

