#! /usr/bin/perl -CLADS
# -----------------------------------------------------------------------------
# Copyright (c) 2006, 2007 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# slxldd
# - OpenSLX-rewrite of ldd that works on multiple architectures.
# -----------------------------------------------------------------------------
use strict;
use warnings;
my $abstract = q[
slxldd
This script reimplements ldd in a way that should work for all
binary formats supported by the binutils installed on the host system.
An example: if you have a folder containing an x86_64 system, you can
invoke this script on a x86_32-host in order to determine all the libraries
required by a binary of the x86_64 target system.
];
# add the lib-folder to perl's search path for modules:
use FindBin;
use lib "$FindBin::RealBin/../lib";
use File::Glob ':globally';
use Getopt::Long;
use Pod::Usage;
use OpenSLX::Basics;
use OpenSLX::LibScanner;
my (
$helpReq,
$manReq,
$verbose,
$rootPath,
$versionReq,
);
$rootPath = '/';
GetOptions(
'help|?' => \$helpReq,
'man' => \$manReq,
'root-path=s' => \$rootPath,
'verbose' => \$verbose,
'version' => \$versionReq,
)
or pod2usage(2);
pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $helpReq;
pod2usage(-verbose => 2) if $manReq;
if ($versionReq) {
system('slxversion');
exit 1;
}
openslxInit();
if (!$rootPath) {
print STDERR _tr("You need to specify the root-path!\n");
pod2usage(2);
}
$rootPath =~ s[/+$][];
# remove trailing slashes
if (!@ARGV) {
print STDERR _tr("You need to specify at least one file!\n");
pod2usage(2);
}
my $libScanner = OpenSLX::LibScanner->new({
'root-path' => $rootPath,
'verbose' => $verbose,
});
my @libs = $libScanner->determineRequiredLibs(@ARGV);
print join("\n", @libs), "\n";
=head1 NAME
slxldd - OpenSLX-script to determine the libraries required by any given
binary file.
=head1 SYNOPSIS
slxldd [options] file [...more files]
Options:
--help brief help message
--man show full documentation
--root-path=<string> path to the root folder for library search
--verbose show what's going on during execution
--version show version
=head1 OPTIONS
=over 8
=item B<--help>
Prints a brief help message and exits.
=item B<--man>
Prints the manual page and exits.
=item B<--root-path=<string>>
Sets the root folder that is used when searching for libraries. In order to
collect the loader-settings, etc/ld.so.conf is read relative to this path and
all libraries are sought relative to this path, too (a.k.a. a virtual chroot).
Defaults to '/'.
=item B<--verbose>
Prints info about the files as they are being scanned.
=item B<--version>
Prints the version and exits.
=back
=cut