如何重新映射符号以调用不同的函数

发布于 2024-09-16 20:18:58 字数 287 浏览 4 评论 0原文

我有一个 ELF 共享对象,我想修改它,以便对系统函数 memcpy 的调用实际上路由到 memcpy 的自定义版本代码>.

我一直在研究并阅读了有关 PLT 重定向和 ELF 感染的内容,但我仍然不确定如何实现我的目标。

谁能给我一些提示和技巧,或者详细说明 PLT 重定向和 ELF 感染?

问候,

保罗

I have an ELF shared object, and I want to modify it so that calls to the system function memcpy are actually routed through to a custom version of memcpy.

I've been researching and I have read about PLT Redirection and ELF Infection, but I'm still not sure how I can accomplish my goal.

Can anyone give me some hint and tips, or elaborate on the PLT Redirection and ELF Infection?

Regards,

Paul

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆那么伤 2024-09-23 20:18:58

当您链接可执行文件时,您是否尝试过 ld 的 -wrap 选项?它应该重定向符号,以便对原始函数的所有调用(包括库内的函数)都将转到您的替换函数。

请参阅此示例

[编辑:上述评论者正确地指出,如果库内联调用 memcpy,则除了重建库之外,您别无选择。]

Have you tried the -wrap option to ld when you link your executable? It should redirect the symbol so that all calls to the original function, including those inside libraries, will go to your replacement.

See this example.

[Edit: The above commenter is correct in pointing out that if the library inlined calls to memcpy, you have no recourse short of rebuilding the library.]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文