I'm new to writing pintool programs. I want to find the main function of target program with PIN. But I always got just an UnNamedImageEntryPoint
with SYM_Name() and RTN_Name. I guess the lack of symbols caused this. So is there any solution for me to find main function when there's no symbols?
This is My main function:
int main(int argc, char *argv[]) {
PIN_InitSymbols();
init_all();
if (PIN_Init(argc, argv)) return Usage();
INS_AddInstrumentFunction(Instructions, 0);
IMG_AddInstrumentFunction(ImageLoad, 0);
PIN_AddFiniFunction(Fini, 0);
PIN_StartProgram();
return 0;
}
And this is how I look for main function:
VOID ImageLoad(IMG img, VOID *v) {
if (IMG_IsMainExecutable(img)) {
for (SYM sym = IMG_RegsymHead(img); SYM_Valid(sym); sym = SYM_Next(sym)) {
string undFuncName = PIN_UndecorateSymbolName(SYM_Name(sym), UNDECORATION_NAME_ONLY);
output<<undFuncName<<endl;
if (undFuncName == "main") {
RTN_InsertCall(rtn, IPOINT_BEFORE,(AFUNPTR)onMainStarted, IARG_END);
}
}
}
}
This is all undFuncName I got.
unnamedImageEntryPoint
.text