LD-linux的--verify退出码(ld-linux --verify exit codes)

2019-09-22 22:03发布

检查从/ usr / bin中/ LDD源,我看到它使用LD-linux下找到一个可执行文件的依赖,但它首先调用LD-Linux下--verify说法。 然后脚本根据LD-linux的--verify通话的退出代码的作用是不同的。

为LD-Linux上的man页面不提供退出代码的任何信息,而谷歌搜索变成有价值的东西。 有一些文件(不是通过看LD-Linux的源代码等),提供对LD-Linux的退出代码--verfify及其各自的含义列表的任意位置?

Answer 1:

我没有找到任何文件,但是...

  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没有元件(I得到这个当我运行LD-Linux中共享库)

有没有其他的代码。



Answer 2:

我做了一些实验和退出状态是零,在成功1失败。 这包括怪诞滥用如问它来验证一个shell脚本。

你会很安全的假设零成功,非零失败,并没有其他信息。



文章来源: ld-linux --verify exit codes
标签: linux