aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lli
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-11-05 23:21:52 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-11-05 23:21:52 +0000
commitd229424d1514ecc9eae5daafe8dee31b891b9790 (patch)
tree9298650efa0241876db1e468bafa3099468279b0 /tools/lli
parent17d8b54dc7a73e667e769b7581b4d608b9af15a7 (diff)
downloadexternal_llvm-d229424d1514ecc9eae5daafe8dee31b891b9790.zip
external_llvm-d229424d1514ecc9eae5daafe8dee31b891b9790.tar.gz
external_llvm-d229424d1514ecc9eae5daafe8dee31b891b9790.tar.bz2
Add command line option -entry-funcion to override entry function (default is main).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58779 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lli')
-rw-r--r--tools/lli/lli.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 74ea3dd..fee48ed 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -49,6 +49,13 @@ namespace {
cl::opt<std::string>
TargetTriple("mtriple", cl::desc("Override target triple for module"));
+
+ cl::opt<std::string>
+ EntryFunc("entry-function",
+ cl::desc("Specify the entry function (default = 'main') "
+ "of the executable"),
+ cl::value_desc("function"),
+ cl::init("main"));
cl::opt<std::string>
FakeArgv0("fake-argv0",
@@ -140,9 +147,9 @@ int main(int argc, char **argv, char * const *envp) {
// using the contents of Args to determine argc & argv, and the contents of
// EnvVars to determine envp.
//
- Function *MainFn = Mod->getFunction("main");
- if (!MainFn) {
- std::cerr << "'main' function not found in module.\n";
+ Function *EntryFn = Mod->getFunction(EntryFunc);
+ if (!EntryFn) {
+ std::cerr << '\'' << EntryFunc << "\' function not found in module.\n";
return -1;
}
@@ -160,13 +167,13 @@ int main(int argc, char **argv, char * const *envp) {
if (NoLazyCompilation) {
for (Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
Function *Fn = &*I;
- if (Fn != MainFn && !Fn->isDeclaration())
+ if (Fn != EntryFn && !Fn->isDeclaration())
EE->getPointerToFunction(Fn);
}
}
// Run main.
- int Result = EE->runFunctionAsMain(MainFn, InputArgv, envp);
+ int Result = EE->runFunctionAsMain(EntryFn, InputArgv, envp);
// Run static destructors.
EE->runStaticConstructorsDestructors(true);