GDB 无法加载 so 文件和错误 没有此类文件或目录 [英] GDB failed to load so files and errors No such file or directory

查看:75
本文介绍了GDB 无法加载 so 文件和错误 没有此类文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 alpine linux 将核心文件加载到 docker 容器内的 GDB 中.最初我的 gdb 抱怨找不到二进制文件,然后我跟着这个讨论 gdb 在启动程序以代码 127 退出并安装了 libc6-compat,即使我有 64 位 linux 并且我的二进制解释器是 64 位 [请求程序解释器:/lib64/ld-linux-x86-64.so.2]

I am loading a core file into GDB inside a docker container with alpine linux. Initially my gdb complained about binary not found, then i followed this discussion gdb During startup program exited with code 127 and installed libc6-compat, even though I have a 64-bit linux and my interpreter for the binary is 64-bit [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

这确实有效,但现在我遇到了 .so 文件的相同错误.我可以看到 .so 文件在 solib-search-path 上设置的路径中,但 gdb 没有加载任何库并抱怨没有这样的文件或目录.

That actually worked but now i get the same error for the .so files. I can see that .so files are in the path set on solib-search-path but gdb did not load any of the libraries and complains No such file or directory.

二进制文件在库所在路径的生产主机上运行我通过设置 solib-search-path 在开发主机上运行二进制文件

binary runs on a production host where the libraries are in the path I am running the binary on a development host by setting the solib-search-path

ldd 二进制表示未找到库,这是预期的,因为这是一个开发主机

ldd binary says libraries not found which is expected since this is a development host

推荐答案

二进制文件在生产主机上运行,​​其中库所在的路径我通过设置 solib-search-path 在开发主机上运行二进制文件

binary runs on a production host where the libraries are in the path I am running the binary on a development host by setting the solib-search-path

你的问题就在这里.

solib-search-pathGDB 查找库的路径.

The solib-search-path is the path where GDB will look for libraries.

绝不会该设置会影响二进制文件本身,它使用标准系统库路径、编译入的 DT_RPATHLD_LIBRARY_PATH用于搜索共享库的环境变量.

In no way does that setting affect the binary itself, which uses either standard system library path, compiled-in DT_RPATH, or LD_LIBRARY_PATH environment variable to search for shared libraries.

通常,solib-search-path 应该只在您分析来自其他主机的核心转储时设置(GDB 需要访问准确的库,生成核心转储时使用).在运行本地二进制文件时设置 solib-search-path 永远不是必需的——GDB 可以通过询问运行时加载器的位置来自动推断库的位置.

Usually, solib-search-path should only be set when you are analyzing a core dump that came from some other host (GDB needs access to the exact libraries that were used when the core dump was generated). Setting solib-search-path while running a local binary should never be ncessary -- GDB can automatically deduce where the libraries are by asking the runtime loader where they are.

ldd 二进制表示未找到库,这是预期的,因为这是一个开发主机

ldd binary says libraries not found which is expected since this is a development host

如果 ldd 这么说,那么当然你将无法运行二进制文件(在 GDB 之外).

If ldd says that, then of course you will not be able to run the binary (inside of outside GDB).

这篇关于GDB 无法加载 so 文件和错误 没有此类文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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