diff options
author | John Criswell <criswell@uiuc.edu> | 2003-12-23 20:27:14 +0000 |
---|---|---|
committer | John Criswell <criswell@uiuc.edu> | 2003-12-23 20:27:14 +0000 |
commit | 368751f2b721c09f827d73b929ab87969514cc07 (patch) | |
tree | 00f01e13afa3dd7e8bad17f18cc98b6001fee072 /lib/Linker | |
parent | a989b234bdc848ecc220e2c932b7525b579bdfe2 (diff) |
Modified the logic so that library objects with main() are only linked in
if the program currently has main undefined.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10597 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/LinkArchives.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index ec9f89c5e0..7cd440d1d2 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -202,11 +202,14 @@ static bool LinkInArchive(Module *M, bool ObjectRequired = false; // - // If the object defines main(), then it is automatically required. - // Otherwise, look to see if it defines a symbol that is currently - // undefined. + // If the object defines main() and the program currently has main() + // undefined, then automatically link in the module. Otherwise, look to + // see if it defines a symbol that is currently undefined. // - if ((DefSymbols.find ("main")) == DefSymbols.end()) { + if ((M->getMainFunction() == NULL) && + ((DefSymbols.find ("main")) != DefSymbols.end())) { + ObjectRequired = true; + } else { for (std::set<std::string>::iterator I = UndefinedSymbols.begin(), E = UndefinedSymbols.end(); I != E; ++I) if (DefSymbols.count(*I)) { @@ -217,8 +220,6 @@ static bool LinkInArchive(Module *M, ObjectRequired = true; break; } - } else { - ObjectRequired = true; } // We DO need to link this object into the program... |