mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 21:31:03 +00:00
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
This commit is contained in:
parent
5e136c0f37
commit
ec740e325c
@ -49,6 +49,13 @@ namespace {
|
|||||||
|
|
||||||
cl::opt<std::string>
|
cl::opt<std::string>
|
||||||
TargetTriple("mtriple", cl::desc("Override target triple for module"));
|
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>
|
cl::opt<std::string>
|
||||||
FakeArgv0("fake-argv0",
|
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
|
// using the contents of Args to determine argc & argv, and the contents of
|
||||||
// EnvVars to determine envp.
|
// EnvVars to determine envp.
|
||||||
//
|
//
|
||||||
Function *MainFn = Mod->getFunction("main");
|
Function *EntryFn = Mod->getFunction(EntryFunc);
|
||||||
if (!MainFn) {
|
if (!EntryFn) {
|
||||||
std::cerr << "'main' function not found in module.\n";
|
std::cerr << '\'' << EntryFunc << "\' function not found in module.\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,13 +167,13 @@ int main(int argc, char **argv, char * const *envp) {
|
|||||||
if (NoLazyCompilation) {
|
if (NoLazyCompilation) {
|
||||||
for (Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
|
for (Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
|
||||||
Function *Fn = &*I;
|
Function *Fn = &*I;
|
||||||
if (Fn != MainFn && !Fn->isDeclaration())
|
if (Fn != EntryFn && !Fn->isDeclaration())
|
||||||
EE->getPointerToFunction(Fn);
|
EE->getPointerToFunction(Fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run main.
|
// Run main.
|
||||||
int Result = EE->runFunctionAsMain(MainFn, InputArgv, envp);
|
int Result = EE->runFunctionAsMain(EntryFn, InputArgv, envp);
|
||||||
|
|
||||||
// Run static destructors.
|
// Run static destructors.
|
||||||
EE->runStaticConstructorsDestructors(true);
|
EE->runStaticConstructorsDestructors(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user