有什么办法可以直接更改二进制文件的SONAME? [英] Is there any way to change the SONAME of a binary directly?

查看:728
本文介绍了有什么办法可以直接更改二进制文件的SONAME?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序取决于libcurl.so.3,但是在RHEL6中没有符号链接libcurl.so.3 ⇾ libcurl.so.4(当我创建此链接时,我的程序可以平稳运行).但是,有符号链接libcurl.so ⇾ libcurl.so.4.

My program depends on libcurl.so.3, but in RHEL6 there is no symbolic link libcurl.so.3 ⇾ libcurl.so.4 (my program can run smoothly when I create this link). However, there is symbolic link libcurl.so ⇾ libcurl.so.4.

我想将libcurl.so.3.0.0.0文件中嵌入的SONAMElibcurl.so.3修改为libcurl.so,以便我可以在RHEL 6上运行程序,而无需创建符号链接.

I would like to modify the SONAME embedded in libcurl.so.3.0.0.0 file from libcurl.so.3 to libcurl.so so that I could run my program on RHEL 6 without creating a symbolic link.

我的解决方案可能不是最优的,但我认为学习如何直接修改二进制文件很有价值.

My solution could not be optimal but I think learning how to modify the binary directly is valuable.

$readelf -d libcurl.so.3.0.0 

Dynamic segment at offset 0x303cc contains 25 entries:

  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libssl.so.2]
 0x0000000e (SONAME)                     Library soname: [libcurl.so.3]

我想将上面的libcurl.so.3更改为libcurl.so.

推荐答案

是的,您可以使用 patchelf 这样(从其自述文件):

Yes, you can use patchelf like this (from its Readme):

patchelf --set-soname libnewname.so.3.4.5 path/to/libmylibrary.so.1.2.3

这篇关于有什么办法可以直接更改二进制文件的SONAME?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆