about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Module/KModule.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index 74d91a8f..07f3572e 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -142,14 +142,16 @@ static Function *getStubFunctionForCtorList(Module *m,
   return fn;
 }
 
-static void injectStaticConstructorsAndDestructors(Module *m) {
+static void
+injectStaticConstructorsAndDestructors(Module *m,
+                                       llvm::StringRef entryFunction) {
   GlobalVariable *ctors = m->getNamedGlobal("llvm.global_ctors");
   GlobalVariable *dtors = m->getNamedGlobal("llvm.global_dtors");
 
   if (!ctors && !dtors)
     return;
 
-  Function *mainFn = m->getFunction("main");
+  Function *mainFn = m->getFunction(entryFunction);
   if (!mainFn)
     klee_error("Could not find main() function.");
 
@@ -239,7 +241,7 @@ void KModule::optimiseAndPrepare(
 
   // Needs to happen after linking (since ctors/dtors can be modified)
   // and optimization (since global optimization can rewrite lists).
-  injectStaticConstructorsAndDestructors(module.get());
+  injectStaticConstructorsAndDestructors(module.get(), opts.EntryPoint);
 
   // Finally, run the passes that maintain invariants we expect during
   // interpretation. We run the intrinsic cleaner just in case we