linux - ld-linux --验证退出码

标签 linux

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

ld-linux 的手册页没有提供有关退出代码的任何信息,Google 搜索也没有任何值(value)。是否有任何文档(除了查看 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 时得到这个)

没有其他代码。

关于linux - ld-linux --验证退出码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1256145/

相关文章:

linux - 如何用awk计算文件中的所有数字?

linux - 使用 Linux Centos 一次保存多个 URL

linux - sles12 docker 上的语言环境命令失败

linux - 在 Linux 中进程终止时文件描述符是否关闭?

linux - iperf3:无法识别的选项'--sctp'

linux - 在 vim 中打开 100 个文件

c++ - __attribute__((constructor)) 调用顺序困惑

c++ - 在 Linux 上使用 CUDA 支持编译 OpenCv

linux - 在 .bashrc 中测试 GUI

linux - 将 vFrabric tc 服务器(与 STS 捆绑在一起)安装到 Linux EC2 实例中?