Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xdl_addr查找了错误的符号信息 #25

Open
XMDS opened this issue Oct 11, 2024 · 3 comments
Open

xdl_addr查找了错误的符号信息 #25

XMDS opened this issue Oct 11, 2024 · 3 comments

Comments

@XMDS
Copy link

XMDS commented Oct 11, 2024

代码:

__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
@XMDS
Copy link
Author

XMDS commented Oct 11, 2024

上面的代码是我使用InlineHook的部分代码。
可以看出xdl_addr查找Test函数的符号信息,查找到了错误的proxy_Test函数的符号信息

@XMDS
Copy link
Author

XMDS commented Oct 11, 2024

我经过了其它测试 如果我定义多个短函数,在查找时也会查到其它函数的符号信息

@caikelun
Copy link
Member

感谢反馈~

应该是ELF中保存的“thumb符号st_value值是奇数“导致的,在最新的master和dev分支中修复了:790ad1a

很些奇怪,看了下 bionic linker 中 dladdr 的实现,以及实际用 dladdr 验证了下,也存在这个问题。难道这也是个一直隐藏在 bionic linker dladdr 中的 bug。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants