可以使用LD_PRELOAD加载不同版本的glibc吗? [英] Can LD_PRELOAD be used to load different versions of glibc?

查看:176
本文介绍了可以使用LD_PRELOAD加载不同版本的glibc吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • big-old-app 链接到旧版本的 glibc ,例如 glibc-2.12 .我无能为力.
  • cute-new-addon.o 已链接到更新版本 glibc-2.23 .此 glibc-2.23 位于非标准路径中(因为我没有sudo权限).
  • big-old-app is linked to an old version of glibc, say glibc-2.12. I cannot do anything to change this.
  • cute-new-addon.o is linked to a newer version, glibc-2.23. This glibc-2.23 is in a nonstandard path (because I don't have sudo powers).

我想在 big-old-app 中使用 cute-new-addon.o .我通常会编写一个脚本来执行 big-old-app ,然后调用 cute-new-addon.o 来执行技巧.在命令行中,它看起来像:

I want to use cute-new-addon.o inside big-old-app. I would normally write a script for big-old-app to execute, which then calls cute-new-addon.o to perform its tricks. From the command line, it would look like:

$ big-old-app script.txt

但是,当我这样做时, big-old-app 会抱怨 cute-new-addon.o 无法找到 glibc-2.23 .这是可以理解的,因为我没有指定任何标准路径.如果我该怎么办:

However, when I do that, big-old-app would complain that cute-new-addon.o cannot find glibc-2.23. That's understandable, because I have not specified any standard paths. What if I do:

$ LD_LIBRARY_PATH=/path/to/mylibs:$LD_LIBRARY_PATH big-old-app script.txt

发生段错误!:(

我认为这是因为 big-old-app 引用了更新的 mylibc.so.6 .这样做时,实现不再是 big-old-app 所习惯的,因此它会出现段错误.

I think this is because big-old-app references a newer mylibc.so.6. When doing so, the implementations are no longer what big-old-app is used to, so it segfaults.

关于 script.txt ,我认为我无法在调用 cute-new-addon之前指定更新的 mylibc.so.6 .o . big-old-app cute-new-addon.o 紧密地交织在一起,我无法知道它们何时需要它们相应的 glibc .

Regarding script.txt, I don't think I have the ability to specify the newer mylibc.so.6 before invoking cute-new-addon.o. big-old-app and cute-new-addon.o are tightly intertwined that I have no way of knowing when either of them need their corresponding glibc.

是的, cute-new-addon.o rpath 指向/path/to/mylibs ,我可以通过 ldd 所需的所有库,它将在/path/to/mylibs 中查找.

And yes, cute-new-addon.o rpath is pointed to /path/to/mylibs and I can confirm via ldd that all the libraries it needs, it looks for in /path/to/mylibs.

我可以使用 LD_PRELOAD 加载两个不同版本的 glibc 吗?然后让 big-old-app cute-new-addon.o 查找所需的内容吗?

Can I use LD_PRELOAD to load two different versions of glibc? And let big-old-app and cute-new-addon.o look for what they need as they please?

推荐答案

LD_PRELOAD 不能使用,因为glibc动态链接器(有时称为 ld.so 或程序解释器);磁盘上的位置是平台特定的)仅与同一glibc构建中的 libc.so.6 (以及其余库)兼容.

LD_PRELOAD cannot be used because the glibc dynamic linker (sometimes called ld.so or the program interpreter; the location on disk is platform-specific) is only compatible with libc.so.6 (and the rest of the libraries) from the same glibc build.

您可以使用其他glibc的显式加载程序调用,以及使加载程序从单独目录而非系统目录加载glibc对象的库路径设置. glibc Wiki 提供了如何执行此操作的示例.

You can use an explicit loader invocation of the other glibc, along with library path settings that cause the loader to load the glibc objects from a separate directory, and not the system directories. The glibc wiki has an example how to do this.

这篇关于可以使用LD_PRELOAD加载不同版本的glibc吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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