On 2/10/2014 04:16, Peter Rosin wrote:
On 2014-02-10 10:02, Warren Young wrote:
there *has* to be a better way than strings(1) to extract an EXE's list of DLL
imports.
objdump -x /bin/foo.exe
Thank you!
-x turns on 6 other flags, the only one of which that really matters
here is -p. The output is complex enough that I decided to write a
better parser than a grep call. Here's my new checkfile script:
#!/usr/bin/perl -w
my ($exe, $symbol) = @ARGV;
my $in_cygdll = 0;
die "usage: $0 exename symbol\n" unless length($symbol);
open my $dump, '-|', "objdump -p '$exe'" or die "Can't dump $exe: $!\n";
while (<$dump>) {
if (m/DLL Name: cygwin1.dll/) {
$in_cygdll = 1;
}
elsif (m/DLL Name: /) {
last; # Last cygwin1.dll symbol found; on to another DLL
}
elsif ($in_cygdll) {
my @parts = split;
if (@parts == 3 and $parts[2] eq $symbol) {
print "$exe\n";
last;
}
}
}
Run it like before, except that it takes the import name to search for
as a second parameter now:
$ find /bin -name \*.exe -exec ./checkfile {} getpwent \;
I don't have my "almost everything" Cygwin install here to run it
against, so unless someone beats me to it, I won't be posting results
for many hours at least.
--
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