diff options
author | Chris Lattner <sabre@nondot.org> | 2005-03-15 23:03:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-03-15 23:03:34 +0000 |
commit | c72e57314a0ca7fe35ad45ce86bf074addf79883 (patch) | |
tree | 64878e075d105c8d91b8899a79ab6584057a840d /lib/Linker/LinkArchives.cpp | |
parent | fc82ef67971403c01f19e672b6af8d2a5caf8a30 (diff) |
fix some 80 column violations
Add support for programs that define main in a .a file, such as f2c'd programs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20631 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker/LinkArchives.cpp')
-rw-r--r-- | lib/Linker/LinkArchives.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index fcd2cf8b99..af15e0b1ad 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -21,8 +21,6 @@ #include "llvm/Config/config.h" #include <memory> #include <set> -#include <iostream> - using namespace llvm; /// GetAllDefinedSymbols - Modifies its parameter DefinedSymbols to contain the @@ -33,7 +31,8 @@ GetAllDefinedSymbols(Module *M, std::set<std::string> &DefinedSymbols) { for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) if (I->hasName() && !I->isExternal() && !I->hasInternalLinkage()) DefinedSymbols.insert(I->getName()); - for (Module::global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) + for (Module::global_iterator I = M->global_begin(), E = M->global_end(); + I != E; ++I) if (I->hasName() && !I->isExternal() && !I->hasInternalLinkage()) DefinedSymbols.insert(I->getName()); } @@ -54,6 +53,13 @@ static void GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) { std::set<std::string> DefinedSymbols; UndefinedSymbols.clear(); + + // If the program doesn't define a main, try pulling one in from a .a file. + // This is needed for programs where the main function is defined in an + // archive, such f2c'd programs. + Function *Main = M->getMainFunction(); + if (Main == 0 || Main->isExternal()) + UndefinedSymbols.insert("main"); for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) if (I->hasName()) { @@ -62,7 +68,8 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) { else if (!I->hasInternalLinkage()) DefinedSymbols.insert(I->getName()); } - for (Module::global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) + for (Module::global_iterator I = M->global_begin(), E = M->global_end(); + I != E; ++I) if (I->hasName()) { if (I->isExternal()) UndefinedSymbols.insert(I->getName()); |