Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ld-linux --verify exit codes

Tags:

Checking the source from /usr/bin/ldd, I see that it uses ld-linux to find the dependencies of an executable, although it first calls ld-linux with the --verify argument. Then the script acts differently according to the exit code of the ld-linux --verify call.

The man page for ld-linux does not provide any info on exit codes, and a Google search turns nothing of value. Is there some documentation anywhere (other than by looking at ld-linux's source code) that provides a list of exit codes for ld-linux --verfify and their respective meanings?

like image 515
Fred Avatar asked Aug 10 '09 17:08

Fred


1 Answers

I didn't find any documentation, but...

  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 means success, i.e. "program is dynamically linked and this dynamic linker can handle it"
  • 1 means ld-linux was "not able to load the binary" (I got this when I ran ld-linux with non-existent, non-binary or static binary file)
  • 2 means "no interpreter is specified". More specifically, there is no element with p_type equal PT_INTERP in program header table (I get this when I run ld-linux with shared library)

There are no other codes.

like image 180
Des Nerger Avatar answered Oct 11 '22 17:10

Des Nerger