mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Don't pass too many arguments into runFunction
llvm-svn: 15801
This commit is contained in:
parent
da6d019fbb
commit
923c3d3594
@ -102,14 +102,21 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
|
||||
std::vector<GenericValue> GVArgs;
|
||||
GenericValue GVArgc;
|
||||
GVArgc.IntVal = argv.size();
|
||||
GVArgs.push_back(GVArgc); // Arg #0 = argc.
|
||||
GVArgs.push_back(PTOGV(CreateArgv(this, argv))); // Arg #1 = argv.
|
||||
assert(((char **)GVTOP(GVArgs[1]))[0] && "argv[0] was null after CreateArgv");
|
||||
|
||||
std::vector<std::string> EnvVars;
|
||||
for (unsigned i = 0; envp[i]; ++i)
|
||||
EnvVars.push_back(envp[i]);
|
||||
GVArgs.push_back(PTOGV(CreateArgv(this, EnvVars))); // Arg #2 = envp.
|
||||
unsigned NumArgs = Fn->getFunctionType()->getNumParams();
|
||||
if (NumArgs) {
|
||||
GVArgs.push_back(GVArgc); // Arg #0 = argc.
|
||||
if (NumArgs > 1) {
|
||||
GVArgs.push_back(PTOGV(CreateArgv(this, argv))); // Arg #1 = argv.
|
||||
assert(((char **)GVTOP(GVArgs[1]))[0] &&
|
||||
"argv[0] was null after CreateArgv");
|
||||
if (NumArgs > 2) {
|
||||
std::vector<std::string> EnvVars;
|
||||
for (unsigned i = 0; envp[i]; ++i)
|
||||
EnvVars.push_back(envp[i]);
|
||||
GVArgs.push_back(PTOGV(CreateArgv(this, EnvVars))); // Arg #2 = envp.
|
||||
}
|
||||
}
|
||||
}
|
||||
return runFunction(Fn, GVArgs).IntVal;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user