diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-28 22:51:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-28 22:51:44 +0000 |
commit | e69671d65b45b6a1bbbdc1b215b8c0f943171c29 (patch) | |
tree | aaf76743cafabfe899bc18b55514042541875d6d /tools | |
parent | d09bef4d46224d4f8283033ed79903c7a7d01111 (diff) | |
download | external_llvm-e69671d65b45b6a1bbbdc1b215b8c0f943171c29.zip external_llvm-e69671d65b45b6a1bbbdc1b215b8c0f943171c29.tar.gz external_llvm-e69671d65b45b6a1bbbdc1b215b8c0f943171c29.tar.bz2 |
Add the ability for users to specify a specific argv[0] to pass into the
program
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9565 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lli/lli.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 299b18b..87fe461 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -42,6 +42,11 @@ namespace { cl::opt<bool> ForceInterpreter("force-interpreter", cl::desc("Force interpretation: disable JIT"), cl::init(false)); + + cl::opt<std::string> + FakeArgv0("fake-argv0", + cl::desc("Override the 'argv[0]' value passed into the executing" + " program"), cl::value_desc("executable")); } static std::vector<std::string> makeStringVector(char * const *envp) { @@ -138,14 +143,18 @@ int main(int argc, char **argv, char * const *envp) { ExecutionEngine::create(MP, ForceInterpreter); assert(EE && "Couldn't create an ExecutionEngine, not even an interpreter?"); - // Add the module's name to the start of the vector of arguments to main(). - // But delete .bc first, since programs (and users) might not expect to - // see it. - const std::string ByteCodeFileSuffix(".bc"); - if (InputFile.rfind(ByteCodeFileSuffix) == - InputFile.length() - ByteCodeFileSuffix.length()) { - InputFile.erase (InputFile.length() - ByteCodeFileSuffix.length()); + // If the user specifically requested an argv[0] to pass into the program, do + // it now. + if (!FakeArgv0.empty()) { + InputFile = FakeArgv0; + } else { + // Otherwise, if there is a .bc suffix on the executable strip it off, it + // might confuse the program. + if (InputFile.rfind(".bc") == InputFile.length() - 3) + InputFile.erase(InputFile.length() - 3); } + + // Add the module's name to the start of the vector of arguments to main(). InputArgv.insert(InputArgv.begin(), InputFile); // Run the main function! |