aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-rtdyld
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2011-04-13 15:38:30 +0000
committerJim Grosbach <grosbach@apple.com>2011-04-13 15:38:30 +0000
commit6b32e7e213ca14d5d898c84053d6f38a4c360763 (patch)
tree565eaf8845501c519e91c5996656db990f4da743 /tools/llvm-rtdyld
parent69e813282d4aa078102ce058f8269d0c13260061 (diff)
downloadexternal_llvm-6b32e7e213ca14d5d898c84053d6f38a4c360763.zip
external_llvm-6b32e7e213ca14d5d898c84053d6f38a4c360763.tar.gz
external_llvm-6b32e7e213ca14d5d898c84053d6f38a4c360763.tar.bz2
Allow user-specified program entry point for llvm-rtdyld.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129446 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-rtdyld')
-rw-r--r--tools/llvm-rtdyld/llvm-rtdyld.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/llvm-rtdyld/llvm-rtdyld.cpp b/tools/llvm-rtdyld/llvm-rtdyld.cpp
index 812be11..ee398e7 100644
--- a/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -38,6 +38,11 @@ Action(cl::desc("Action to perform:"),
"Load, link, and execute the inputs."),
clEnumValEnd));
+static cl::opt<std::string>
+EntryPoint("entry",
+ cl::desc("Function to call as entry point."),
+ cl::init("_main"));
+
/* *** */
// A trivial memory manager that doesn't do anything fancy, just uses the
@@ -93,10 +98,10 @@ static int executeInput() {
// Resolve all the relocations we can.
Dyld.resolveRelocations();
- // Get the address of "_main".
- void *MainAddress = Dyld.getSymbolAddress("_main");
+ // Get the address of the entry point (_main by default).
+ void *MainAddress = Dyld.getSymbolAddress(EntryPoint);
if (MainAddress == 0)
- return Error("no definition for '_main'");
+ return Error("no definition for '" + EntryPoint + "'");
// Invalidate the instruction cache for each loaded function.
for (unsigned i = 0, e = MemMgr->FunctionMemory.size(); i != e; ++i) {