From 599c8eedc31ad2b6a41c014b69893845c0f52b2d Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 12 Jan 2007 22:48:25 +0000 Subject: * added support for dual-bitwidth platforms (32-/64-bit) by explicitly checking the bitwidth of every binary and library. This fixes the incongruent results reported by Dirk. * changed order of processing from depth-first to breadth-first to more closely resemble the output of ldd. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@623 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/slxldd | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'config-db/slxldd') diff --git a/config-db/slxldd b/config-db/slxldd index 230959a5..289bf860 100755 --- a/config-db/slxldd +++ b/config-db/slxldd @@ -37,6 +37,8 @@ my ( $rootPath, $versionReq, + @filesToDo, + @libFolders, @libs, %libInfo, @@ -79,14 +81,13 @@ foreach my $file (@ARGV) { # relative paths are relative to $rootPath: $file = "$rootPath/$file"; } - if (!-e $file) { die _tr("slxldd: unable to find file '%s'\n", $file); } + push @filesToDo, $file; +} - next if `file $file` =~ m[shell\s+script]; - # silently ignore shell scripts - +foreach my $file (@filesToDo) { addLibsForBinary($file); } @@ -131,12 +132,20 @@ sub fetchLoaderConfig sub addLib { my $lib = shift; + my $bitwidth = shift; if (!exists $libInfo{$lib}) { push @libs, $lib; my $libPath; foreach my $folder (@libFolders) { if (-e "$folder/$lib") { + # have library matching name, now check if the platform is ok, too: + my $libFileInfo = `file --dereference $folder/$lib 2>/dev/null`; + if ($?) { + die _tr("unable to fetch file info for $folder/$lib, giving up!\n"); + } + my $libBitwidth = ($libFileInfo =~ m[64-bit]i) ? 64 : 32; + next unless $bitwidth == $libBitwidth; $libPath = "$folder/$lib"; last; } @@ -146,7 +155,7 @@ sub addLib } print "$libPath\n"; $libInfo{$lib} = $libPath; - addLibsForBinary($libPath); + push @filesToDo, $libPath; } } @@ -154,11 +163,22 @@ sub addLibsForBinary { my $binary = shift; - # we try objdump... + # first do some checks: + my $fileInfo = `file --dereference $binary 2>/dev/null`; + if ($?) { + die _tr("unable to fetch file info for $binary, giving up!\n"); + } + next if $fileInfo =~ m[shell\s+script]; + # silently ignore shell scripts + + my $bitwidth = ($fileInfo =~ m[64-bit]i) ? 64 : 32; + # determine whether binary is 32- or 64-bit platform + + # now find out about needed libs, we first try objdump... my $res = `objdump -p $binary 2>/dev/null`; if (!$?) { while($res =~ m[^\s*NEEDED\s*(.+?)\s*$]gm) { - addLib($1); + addLib($1, $bitwidth); } } else { # ...objdump failed, so we try readelf instead: @@ -167,7 +187,7 @@ sub addLibsForBinary die _tr("neither objdump nor readelf seems to be installed, giving up!\n"); } while($res =~ m{\(NEEDED\)[^\[]+\[(.+?)\]\s*$}gm) { - addLib($1); + addLib($1, $bitwidth); } } } -- cgit v1.2.3-55-g7522