}
// Make a shared library
- std::string SharedObject;
- BD.compileSharedObject(SafeModuleBC, SharedObject);
+ std::string SharedObject = compileSharedObject(SafeModuleBC);
delete SafeModule;
delete TestModule;
for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
std::cout << " " << InputArgv[i];
std::cout << "\n";
- std::cout << "The shared object was created with:\ndis -c " << SafeModuleBC
- << "-o " << SharedObject << "\n";
+ std::cout << "The shared object was created with:\n llvm-dis -c "
+ << SafeModuleBC << " -o temporary.c\n"
+ << " gcc -xc temporary.c -O2 -o " << SharedObject
+#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
+ << " -G" // Compile a shared library, `-G' for Sparc
+#else
+ << " -shared" // `-shared' for Linux/X86, maybe others
+#endif
+ << "\n";
} else {
removeFile(TestModuleBC);
removeFile(SafeModuleBC);
// Call the old main function and return its result
BasicBlock *BB = new BasicBlock("entry", newMain);
std::vector<Value*> args;
- for (Function::aiterator I=newMain->abegin(), E=newMain->aend(); I!=E; ++I)
+ for (Function::aiterator I = newMain->abegin(), E = newMain->aend(),
+ OI = oldMain->abegin(); I != E; ++I, ++OI) {
+ I->setName(OI->getName()); // Copy argument names from oldMain
args.push_back(I);
+ }
CallInst *call = new CallInst(oldMain, args);
BB->getInstList().push_back(call);