加入收藏 | 设为首页 | 会员中心 | 我要投稿 拼字网 - 核心网 (https://www.hexinwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

ld-linux – 验证退出代码

发布时间:2020-12-31 01:16:12 所属栏目:Linux 来源:网络整理
导读:检查来自/usr/bin/ldd的源代码,我看到它使用ld- linux查找可执行文件的依赖项,尽管它首先使用–verify参数调用ld-linux.然后根据ld-linux –verify调用的退出代码,脚本的行为会有所不同. ld-linux的手册页没有提供退出代码的任何信息,谷歌搜索没有任何价值.

检查来自/usr/bin/ldd的源代码,我看到它使用ld- linux查找可执行文件的依赖项,尽管它首先使用–verify参数调用ld-linux.然后根据ld-linux –verify调用的退出代码,脚本的行为会有所不同.

ld-linux的手册页没有提供退出代码的任何信息,谷歌搜索没有任何价值.是否有任何文档(除了通过查看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);
    }

所以…

> 0表示成功,即“程序是动态链接的,这是
动态链接器可以处理它“
> 1表示ld-linux“无法加载二进制文件”(我得到了
当我用不存在的,非二进制或静态二进制文件运行ld-linux时)
> 2表示“未指定解释器”.更具体地说,程序头表中没有p_type等于PT_INTERP的元素(当我使用共享库运行ld-linux时,我得到了这个)

没有其他代码.

(编辑:拼字网 - 核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!