diff options
author | John Criswell <criswell@uiuc.edu> | 2003-08-21 21:12:30 +0000 |
---|---|---|
committer | John Criswell <criswell@uiuc.edu> | 2003-08-21 21:12:30 +0000 |
commit | 69582b35b6aa4e48cbbad7f6f1193c967da96b25 (patch) | |
tree | 0578d58ee787e1028f92db05ff4c1a821478a9fc /lib/ExecutionEngine/JIT/JIT.cpp | |
parent | 7d8fab9ecaabc726c340d26b62f9b0cc3f18b62a (diff) |
The JIT now passes the environment pointer to the main() function when it
starts a program. This allows the GNU env program to compile and JIT under
LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT/JIT.cpp')
-rw-r--r-- | lib/ExecutionEngine/JIT/JIT.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 127c6579ca..d4726f0d35 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -11,6 +11,8 @@ #include "llvm/Module.h" #include "Support/CommandLine.h" +#include "Config/stdlib.h" + // FIXME: REMOVE THIS #include "llvm/PassManager.h" @@ -101,21 +103,43 @@ VM::VM(Module *M, TargetMachine *tm) : ExecutionEngine(M), TM(*tm) { emitGlobals(); } -int VM::run(const std::string &FnName, const std::vector<std::string> &Args) { +// +// Method: run() +// +// Description: +// This method begins the execution of a program beginning at the +// specified function name. The function is called with the +// specified arguments and array of environment variables (a la main()). +// +// Inputs: +// FnName - The name of the function as a C++ string. +// Args - A vector of C++ strings containing the arguments. +// envp - An array of C strings containing the environment. +// +// Outputs: +// None. +// +// Return value: +// 1 - An error occurred. +// Otherwise, the return value from the specified function is returned. +// +int VM::run(const std::string &FnName, + const std::vector<std::string> &Args, + const char ** envp) { Function *F = getModule().getNamedFunction(FnName); if (F == 0) { std::cerr << "Could not find function '" << FnName << "' in module!\n"; return 1; } - int(*PF)(int, char**) = (int(*)(int, char**))getPointerToFunction(F); + int(*PF)(int, char**, const char**) = (int(*)(int, char**, const char**))getPointerToFunction(F); assert(PF != 0 && "Null pointer to function?"); // Build an argv vector... char **Argv = (char**)CreateArgv(Args); // Call the main function... - int Result = PF(Args.size(), Argv); + int Result = PF(Args.size(), Argv, envp); // Run any atexit handlers now! runAtExitHandlers(); |