检查 /usr/bin/ldd 的源代码,我发现它使用 ld-linux 来查找可执行文件的依赖项,尽管它首先使用 --verify 参数调用 ld-linux 。然后,脚本根据 ld-linux --verify 调用的退出代码采取不同的行为。
ld-linux 的手册页没有提供任何有关退出代码的信息,Google 搜索也没有找到任何有价值的信息。是否有一些文档(除了查看 ld-linux 的源代码之外)提供了 ld-linux --verfify 的退出代码列表及其各自的含义?
我没有找到任何文档,但是...
if (__builtin_expect (mode, normal) == verify)
{
/* We were called just to verify that this is a dynamic
executable using us as the program interpreter. Exit with an
error if we were not able to load the binary or no interpreter
is specified (i.e., this is no dynamically linked binary. */
if (main_map->l_ld == NULL)
_exit (1);
/* We allow here some platform specific code. */
#ifdef DISTINGUISH_LIB_VERSIONS
DISTINGUISH_LIB_VERSIONS;
#endif
_exit (has_interp ? 0 : 2);
}
So...
- 0 表示成功,即“程序是动态链接的,并且此
动态链接器可以处理它”
- 1 表示 ld-linux “无法加载二进制文件”(我得到
这是当我使用不存在的、非二进制或静态二进制文件运行 ld-linux 时的情况)
- 2 表示“未指定解释器”。更具体地说,程序头表中没有 p_type 等于 PT_INTERP 的元素(当我使用共享库运行 ld-linux 时得到这个)
没有其他代码。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)