Correct problem that allows indirect function calls
authorChris Lattner <sabre@nondot.org>
Wed, 7 Nov 2001 20:12:30 +0000 (20:12 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 7 Nov 2001 20:12:30 +0000 (20:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1179 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/Interpreter/Execution.cpp

index 3541eb8228f3249e15c1490d80efd6439c872dcc..41948c5806611107522e9ff72eb1f97773dfcf90 100644 (file)
@@ -806,7 +806,11 @@ void Interpreter::executeCallInst(CallInst *I, ExecutionContext &SF) {
   for (unsigned i = 1; i < I->getNumOperands(); ++i)
     ArgVals.push_back(getOperandValue(I->getOperand(i), SF));
 
-  callMethod(I->getCalledMethod(), ArgVals);
+  // To handle indirect calls, we must get the pointer value from the argument 
+  // and treat it as a method pointer.
+  GenericValue SRC = getOperandValue(I->getCalledValue(), SF);
+  
+  callMethod((Method*)SRC.PointerVal, ArgVals);
 }
 
 static void executePHINode(PHINode *I, ExecutionContext &SF) {