bool PathList::function_pointer_analysis() { // add by wh // for add the global function pointer table command_table // to the CallGraph // get the global function table GlobalVariable *func_table = module->getGlobalVariable("command_table"); if (func_table && func_table->getNumUses() > 0) { errs()<<"[Global]: get command_table.\n"; } else { errs()<<"[Global]: miss command_table or command_table isn't used.\n"; return false; } // output the use list of func_table for (Value::use_iterator ui = func_table->use_begin(); ui != func_table->use_end(); ui++) { User *tmpuser = *ui; // int coutn = 0; if (tmpuser) { //errs() << tmpuser->getName() << '\n'; //tmpuser->dump(); // find the function which calls command_table in Module module for (Module::iterator mit = module->begin(); mit != module->end(); mit++) { Function *ff = &*mit; if (ff) { for (inst_iterator fit = inst_begin(ff); fit != inst_end(ff); fit++) { Instruction *tmpfi = &*fit; // the function pointer table must be used in GetElementPtrInst if (isa<GetElementPtrInst>(tmpfi)) { //errs() << "tmpi has " << tmpfi->getNumOperands() << "operands.\n"; //tmpfi->dump(); //tmpfi->getOperand(0)->dump(); extend_calledFunctionMap(tmpfi, tmpuser, func_table, ff); } } } else { errs() << "Error: get function of module failed.\n"; mit->dump(); continue; } } } else { errs() << "get user failed.\n"; continue; } // errs() << "++++++there are " << coutn << " lines call command_table in all.\n"; } return true; // errs()<<"[Global]: "<<func_table->getName()<<"\n"; // errs()<<"[Global]: type ID is "<<func_table->getType()->getTypeID()<<'\n'; }