public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: cppjavaperl <cppjavaperl@yahoo.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Re: ldd fails when dll has no execute permissions
Date: Wed, 07 Mar 2012 17:26:00 -0000	[thread overview]
Message-ID: <1331141199.1263.YahooMailNeo@web36701.mail.mud.yahoo.com> (raw)

On Mar 6 20:51, Christopher Faylor wrote:

> On Tue, Mar 06, 2012 at 03:53:34PM -0800, cppjavaperl wrote:
> > > On Feb 24 12:56, Corinna Vinschen wrote:
> > >
> > > On Feb 23 15:03, 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.
> > > 
> > > DLL's must have execute permissions to be loaded into the process.
> > > And that is what ldd does, it starts a process and inspects the 
> > > process memory to see what DLLs are loaded via the Win32 debug API.
> > > 
> > > The problem is that the Win32 loader stops loading as soon as it
> > > encounters the non-executable DLL.  So there will simply be no further
> > > LOAD_DLL_DEBUG_EVENT.  The next event is an EXIT_PROCESS_DEBUG_EVENT
> > > which means to ldd that it collected all DLLs and so it just prints
> > > the list of so far collected DLLs.
> > > 
> > > I don't see how this could be changed to behave differently in this
> > > case.
> > > 
> > > 
> > > Corinna
> > > 
> >
> > Sorry I just got back to this topic.  After a little research, I found
> > this old link which discusses a similar type tool provided by Microsoft:
> > 
> > http://www.mail-archive.com/delphi@delphi.org.nz/msg11393.html
> > 
> > After reading that thread, I downloaded the code from Microsofts ftp site
> > here:
> > 
> > ftp://ftp.microsoft.com/softlib/mslfiles/MSJFEB97.EXE
> > 
> > The code looks reasonable, and doesn't appear to be difficult at all to 
> > follow.  Running the executable in testing like I did with ldd gives
> > better results (IMHO).  It finds the dependent DLLs even if the executable
> > bit is not set, and it continues looking for DLLs when it can't find one,
> > while noting each DLL that can't be found.
> > 
> > Perhaps it would be good to use this sample code to make modifications
> > to ldd, so that it could give more accurate information.  I do not know
> > if there are any situations where the Microsoft sample code would 
> > provide inaccurate information, and perhaps there are situations I'm not 
> > aware of where the existing ldd code would work and the Microsoft code
> > would not.  However, it seems to me that the Microsoft code is worth
> > looking at -- in order to consider improving ldd.  The Microsoft code
> > doesn't appear to me to be restricted in any way that would hinder its use 
> > in ldd.
> > 
> > It seems to me that the ideal solution would list all the DLLs, 
> > noting which could not be found, and also giving a warning if a DLL
> > is not executable.  Perhaps that kind of solution could be achieved by
> > modifiying ldd using Microsoft's sample code as an example.
> 
> ldd.exe is not going to change.  ldd on linux is also unable to display
> dependencies unless the thing being checked has executable permissions.

"ldd on linux is also unable to display dependencies unless the thing being
checked has executable permissions." -- Actually, that isn't true (at least,
not for all versions of ldd on Linux).  I tried running ldd against an
executable with a dependent DLL (both of which did not have executable
permissions), and on both CentOS 6.0 and Debian squeeze (6.0.4) I got this
warning:

  "ldd: warning: you do not have execution permission for [executable-name]" 

but they *did* print out the dependent DLLs (including the one with no 
executable permissions).

Then I tried it on an old machine running SuSE 9.0 (kernel 2.4.21, even).
In this case, ldd fails only if the *program's* executable has no execute 
permissions.  The dependent DLLs are not required to have executable 
permissions -- all the dependent DLLs were enumerated whether they had the
executable permissions or not.

--
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

             reply	other threads:[~2012-03-07 17:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 17:26 cppjavaperl [this message]
2012-03-07 17:57 ` Christopher Faylor
  -- strict thread matches above, loose matches on Subject: below --
2012-03-07 19:04 cppjavaperl
2012-03-07 19:16 ` Christopher Faylor
2012-03-07 17:33 cppjavaperl
2012-03-06 23:53 cppjavaperl
2012-03-07  1:52 ` Christopher Faylor
2012-02-23 23:03 cppjavaperl
2012-02-24 11:57 ` Corinna Vinschen
2012-02-24 20:42 ` Christopher Faylor
2012-02-24 20:52   ` Christopher Faylor
2012-02-24 20:54   ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331141199.1263.YahooMailNeo@web36701.mail.mud.yahoo.com \
    --to=cppjavaperl@yahoo.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).