Solaris elfedit:Linux 有类似的东西吗? (共享库编辑器)?

发布于 2024-08-19 17:34:38 字数 977 浏览 5 评论 0原文

Linux:有没有办法编辑已编译的共享库?

具体来说,我正在搜索如何在已编译的二进制共享库上添加 DT_SYMBOLIC 标志?

这就是我问这个的原因

组成

  • 我们的应用程序由我们自己的库(静态 libXXX.a)
  • 和一些第三方库(仅二进制共享) strong> 库 libYYY.so)

到目前为止,应用程序一切正常。

现在我已经用共享库版本 (libXXX.so) 替换了我们自己的 static* libXXX.a 库。

一切都编译和链接良好。

但是,当我现在运行该应用程序时,它会启动并执行大量预期的处理 - 然后它在中途某个地方崩溃。 gdb 回溯显示崩溃发生在某些第 3 方共享库中。

我在 SOF 上搜索了一下,发现了一篇有趣的文章 这里< /a>.

我指的是

... add the DT_SYMBOLIC flag to the dynamic section ...

虽然我怀疑它是否真的有帮助,但我认为它可能值得一试。

有什么想法可以在已编译/链接的共享库上添加 DT_SYMBOLIC 标志吗?

环境:debian lenny 64 位,带有 g++ v4.2.4 和 binutils v20。

编辑:solaris上有一个名为elfedit的程序。 linux 有类似的东西吗?

Linux: It there a way to edit a compiled shared library ?

specifically I am searching on how to add the DT_SYMBOLIC flag on an already compiled binary shared library?

Here is why I am asking this:

our application is composed of

  • our own libraries (static libXXX.a)
  • some 3rd party libs (binary-only shared libraries libYYY.so)

Everything is fine with the application so far.

Now I have replaced our own static* libXXX.a libraries with shared libraries versions (libXXX.so).

Everything compiles and links fine.

But when I run the application now it starts up and does a lot of expected processing - and then it crashes somewhere on half the way. A gdb backtrace shows that the crash occurs in some of the 3rd party shared libraries.

I searched around on SOF and found an interesting article here.

The tip I am referring to is

... add the DT_SYMBOLIC flag to the dynamic section ...

Although I doubt that it would really help I think it might be worth a try.

Any ideas how I can add the DT_SYMBOLIC flag on an already compiled/linked shared library ?

environment: debian lenny 64bit with g++ v4.2.4 and binutils v20.

EDIT: on solaris there is a program called elfedit. Is there something similar for linux ?

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

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

发布评论

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

评论(2

棒棒糖 2024-08-26 17:34:38

同时我发现了一个名为elfsh的工具。它是一个交互式 shell,用于检查和编辑 ELF 对象、二进制文件和共享库。

请参阅此处的项目页面: http://www.eresi-project.org

不幸的是,它没有看起来很稳定。我在 elfsh 本身中经历过很多崩溃。

meanwhile l have found a tool called elfsh. It is an interactive shell for examining and editing ELF objects, binaries and shared libraries.

see here for the project page: http://www.eresi-project.org

Unfortunately it doesn't seem to be very stable. I have experienced a lot of crashes within elfsh itself.

余生一个溪 2024-08-26 17:34:38

如果它只是一个标志,痛苦的方法是使用十六进制编辑器调整你的精灵头。

但是,如果第 3 方库崩溃,我个人会看看事情的另一端:由于您转向共享,库加载顺序发生了哪些变化。

ldd

导出 LD_DEBUG=libs

是你的朋友。

在运行时加载器加载第 3 方库后,dlopen() 处理您的共享库可能就足够了。

If it's just a flag the painful approach is to tweak your elf header with a hex editor.

But if the 3rd party lib is crashing I'd personally look at the other end of things: what has changed about the library loading order because of you moving to shared.

ldd

and

export LD_DEBUG=libs

are your friends here.

dlopen()ing your shared libs after the runtime loader loads your 3rd party libs might be enough.

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