summaryrefslogtreecommitdiffstats
path: root/config-db/slxldd
diff options
context:
space:
mode:
authorOliver Tappe2007-01-12 23:48:25 +0100
committerOliver Tappe2007-01-12 23:48:25 +0100
commit599c8eedc31ad2b6a41c014b69893845c0f52b2d (patch)
tree54d8cb42ab13f2e7dba50bb680360bd7e4fc0554 /config-db/slxldd
parentQuiet output, if in debug=0 ... (diff)
downloadcore-599c8eedc31ad2b6a41c014b69893845c0f52b2d.tar.gz
core-599c8eedc31ad2b6a41c014b69893845c0f52b2d.tar.xz
core-599c8eedc31ad2b6a41c014b69893845c0f52b2d.zip
* 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
Diffstat (limited to 'config-db/slxldd')
-rwxr-xr-xconfig-db/slxldd36
1 files changed, 28 insertions, 8 deletions
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);
}
}
}