xDL
xDL copied to clipboard
xdl_addr查找了错误的符号信息
代码:
__attribute__((target("arm"))) __attribute__((noinline)) void Test()
{
LOGI("Test called");
}
static void (*old_Test)() = nullptr;
__attribute__((target("arm"))) void proxy_Test()
{
LOG(INFO, "proxy_Test1 called");
return old_Test();
}
__attribute__((constructor)) void Init()
{
xdl_info_t i;
void* c = nullptr;
xdl_addr((void*)Test, &i, &c);
LOGI("Test addr: %p, name: %s, size: %d\n",i.dli_saddr, i.dli_sname, i.dli_ssize);
xdl_addr_clean(&c);
}
输出:
10-11 13:21:44.744 8898 8898 I HookTest: Test addr: 0xb8c70225, name: _Z12proxy_mallocj, size: 80
上面的代码是我使用InlineHook的部分代码。 可以看出xdl_addr查找Test函数的符号信息,查找到了错误的proxy_Test函数的符号信息
我经过了其它测试 如果我定义多个短函数,在查找时也会查到其它函数的符号信息
感谢反馈~
应该是ELF中保存的“thumb符号st_value值是奇数“导致的,在最新的master和dev分支中修复了:https://github.com/hexhacking/xDL/commit/790ad1ab9a50dff70678e9741fa033da07c2fd8c
很些奇怪,看了下 bionic linker 中 dladdr 的实现,以及实际用 dladdr 验证了下,也存在这个问题。难道这也是个一直隐藏在 bionic linker dladdr 中的 bug。