[llvm-commits] [llvm] r58779 - /llvm/trunk/tools/lli/lli.cpp
Evan Cheng
evan.cheng at apple.com
Wed Nov 5 15:21:52 PST 2008
Author: evancheng
Date: Wed Nov 5 17:21:52 2008
New Revision: 58779
URL: http://llvm.org/viewvc/llvm-project?rev=58779&view=rev
Log:
Add command line option -entry-funcion to override entry function (default is main).
Modified:
llvm/trunk/tools/lli/lli.cpp
Modified: llvm/trunk/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=58779&r1=58778&r2=58779&view=diff
==============================================================================
--- llvm/trunk/tools/lli/lli.cpp (original)
+++ llvm/trunk/tools/lli/lli.cpp Wed Nov 5 17:21:52 2008
@@ -49,6 +49,13 @@
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 @@
// 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 @@
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);
More information about the llvm-commits
mailing list