如何在 pintool 中按名称查找 RTN?

How to find RTN by name in pintool?

我使用 RTN_FindByName() 来搜索特定的 RTN,但它对我不起作用,而且我试图强制编译器不内联 RTN,但仍然无法正常工作,
测试代码:

void __attribute__ ((noinline)) MyFunInApp() 
{
  printf(" function inside application environmental \n");
}

pintool 中的代码:

VOID ImageLoad(IMG img, VOID *v)
 {
   RTN MyRtn = RTN_FindByName(img,"MyFunInApp");
   if (RTN_Valid(MyRtn))
    {
      cout<< "Found RTN"<< endl;
    }
    else
    {
      cout<< "Not Found RTN"<< endl;
    }
}

我该如何解决这个问题,或者通过其他方式解决这个问题?

编译器:gcc 4.8 版
C++ 语言
O.S : Ubuntu 14.04 LTS,64 位
输出(测试代码):
未找到 RTN
未找到 RTN
未找到 RTN

你看到的(用字符包裹的函数名)叫做函数名decoration/mangling。这是 C++ 原生实现重载的方式。不幸的是,重整不是标准化的,每个编译器的处理方式都不一样。

您可以查找损坏的名称,或者遍历图像中的 rtns(您可以在工具包中查看有关如何执行此操作的示例)并使用 Pin 的 PIN_UndecorateSymbolName API获取干净的函数名称。请记住,由于重整,您可能会得到不止一个这样的符号。