ldd fails when dll has no execute permissions

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Feb 24 20:54:00 GMT 2012


On Feb 24 15:42, Christopher Faylor wrote:
> On Thu, Feb 23, 2012 at 03:03:40PM -0800, cppjavaperl wrote:
> >This was discovered in cygwin-1.7.10-1.
> >
> >If you run 'ldd' against an executable, and the executable has
> >dependent DLLs which do *not* have execute permissions, ldd's output
> >stops when it reaches the offending dependent DLL, and reports no
> >further information.?  ldd does not give an error message, and the exit
> >code is zero.
> >
> >To test, pick an application with a dependent DLL, then chmod 666 on
> >that DLL (pick a DLL you can live without temporarily, of course), then
> >run 'ldd' against the executable.
> 
> Can't reproduce this (with the latest DLL from the snapshot):
> 
> bash$ chmod a-w /bin/*.dll

Try chmod -x instead of -w.  And do that only to a single DLL or
be prepared to suffer.

> bash$ ldd /bin/pwd
>         ntdll.dll => /cygdrive/c/Windows/SysWOW64/ntdll.dll (0x779a0000)
>         kernel32.dll => /cygdrive/c/Windows/syswow64/kernel32.dll (0x75310000)
>         KERNELBASE.dll => /cygdrive/c/Windows/syswow64/KERNELBASE.dll (0x75ae0000)
>         cygwin1.dll => /usr/bin/cygwin1.dll (0x61000000)
>         cygintl-8.dll => /usr/bin/cygintl-8.dll (0x61730000)
>         cygiconv-2.dll => /usr/bin/cygiconv-2.dll (0x63c10000)
> 
> Given how ldd works, it's hard to see why executable permissions should
> affect it.  ldd starts the executable for debugging and tracks .dlls as
> they are loaded.  The executable bit state should have no effect on
> that.

It has.  Windows only loads DLLs into executables if the execute bit
is set.  Here's what I did for testing:

  From tcsh, because I removed the execute bit from one of the DLLs
  used by bash:

   tcsh> ldd /bin/bash
        ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x77a30000)
        kernel32.dll => /cygdrive/c/Windows/system32/kernel32.dll (0x75ec0000)
        KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x75cd0000)
        cygwin1.dll => /usr/bin/cygwin1.dll (0x61000000)
        cygintl-8.dll => /usr/bin/cygintl-8.dll (0x68580000)
        cygiconv-2.dll => /usr/bin/cygiconv-2.dll (0x69460000)
        cygreadline7.dll => /usr/bin/cygreadline7.dll (0x67550000)
        cyggcc_s-1.dll => /usr/bin/cyggcc_s-1.dll (0x6bb40000)
        cygncursesw-10.dll => /usr/bin/cygncursesw-10.dll (0x66920000)
        USER32.dll => /cygdrive/c/Windows/system32/USER32.dll (0x776d0000)
        GDI32.dll => /cygdrive/c/Windows/system32/GDI32.dll (0x75fc0000)
        LPK.dll => /cygdrive/c/Windows/system32/LPK.dll (0x773c0000)
        USP10.dll => /cygdrive/c/Windows/system32/USP10.dll (0x777a0000)
        msvcrt.dll => /cygdrive/c/Windows/system32/msvcrt.dll (0x775c0000)
        IMM32.DLL => /cygdrive/c/Windows/system32/IMM32.DLL (0x77670000)
        MSCTF.dll => /cygdrive/c/Windows/system32/MSCTF.dll (0x77840000)
   tcsh> chmod -x /bin/cygreadline7.dll
   tcsh> ldd /bin/bash
        ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x77a30000)
        kernel32.dll => /cygdrive/c/Windows/system32/kernel32.dll (0x75ec0000)
        KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x75cd0000)
        cygwin1.dll => /usr/bin/cygwin1.dll (0x61000000)
        cygintl-8.dll => /usr/bin/cygintl-8.dll (0x68580000)
        cygiconv-2.dll => /usr/bin/cygiconv-2.dll (0x69460000)


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list