如何重新映射符号以调用不同的函数
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您链接可执行文件时,您是否尝试过 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.]