Re: Cross-objdump, -objcopy, -strip support in Debian tools
On Wed, Mar 24, 2010, Hector Oron wrote:
> Loïc, the patches you have, why don't you send them to BTS as wishlist bug?
Well I can attach a couple here, but I wanted to check whether they
might cause any drawback or whether they add any value on top of
binutils-multiarch.
(attached)
--
Loïc Minier
--- scripts/Dpkg/Shlibs/Objdump.pm 2010-03-16 11:29:49.000000000 +0100
+++ /usr/share/perl5/Dpkg/Shlibs/Objdump.pm 2010-03-24 13:43:05.601524516 +0100
@@ -78,8 +78,13 @@ sub has_object {
return $format{$file};
} else {
local $ENV{LC_ALL} = "C";
- open(P, "-|", "objdump", "-a", "--", $file)
- || syserr(_g("cannot fork for %s"), "objdump");
+ my $od = "objdump";
+ # cross-compiling?
+ if ($ENV{'DEB_BUILD_GNU_TYPE'} ne $ENV{'DEB_HOST_GNU_TYPE'}) {
+ $od = $ENV{'DEB_HOST_GNU_TYPE'} . "-objdump";
+ }
+ open(P, "-|", "$od", "-a", "--", $file)
+ || syserr(_g("cannot fork for %s"), "$od");
while (<P>) {
chomp;
if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) {
@@ -87,7 +92,7 @@ sub has_object {
return $format{$file};
}
}
- close(P) or subprocerr(_g("objdump on \`%s'"), $file);
+ close(P) or subprocerr(_g("$od on \`%s'"), $file);
}
}
}
@@ -152,8 +157,13 @@ sub _read {
$self->{file} = $file;
local $ENV{LC_ALL} = 'C';
- open(my $objdump, "-|", "objdump", "-w", "-f", "-p", "-T", "-R", $file)
- || syserr(_g("cannot fork for %s"), "objdump");
+ my $od = "objdump";
+ # cross-compiling?
+ if ($ENV{'DEB_BUILD_GNU_TYPE'} ne $ENV{'DEB_HOST_GNU_TYPE'}) {
+ $od = $ENV{'DEB_HOST_GNU_TYPE'} . "-objdump";
+ }
+ open(my $objdump, "-|", "$od", "-w", "-f", "-p", "-T", "-R", $file)
+ || syserr(_g("cannot fork for %s"), "$od");
my $ret = $self->_parse($objdump);
close($objdump);
return $ret;
--- /usr/bin/dh_strip.pkg-create-dbgsym 2010-03-24 13:27:41.931486006 +0100
+++ dh_strip 2009-12-04 20:56:12.000000000 +0100
@@ -86,15 +86,6 @@ if (defined $ENV{DEB_BUILD_OPTIONS} && $
exit;
}
- my $objcopy = "objcopy";
- my $strip = "strip";
- # cross-compiling?
- if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE")
- ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) {
- $objcopy=dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-objcopy";
- $strip=dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-strip";
- }
-
# I could just use `file $_[0]`, but this is safer
sub get_file_type {
my $file=shift;
@@ -172,7 +163,7 @@ sub make_debug {
if (! -d $debug_dir) {
doit("install", "-d", $debug_dir);
}
- doit("$objcopy", "--only-keep-debug", $file, $debug_path);
+ doit("objcopy", "--only-keep-debug", $file, $debug_path);
# No reason for this to be executable.
doit("chmod", 644, $debug_path);
return $debug_path;
@@ -181,7 +172,7 @@ sub make_debug {
sub attach_debug {
my $file=shift;
my $debug_path=shift;
- doit("$objcopy", "--add-gnu-debuglink", $debug_path, $file);
+ doit("objcopy", "--add-gnu-debuglink", $debug_path, $file);
}
foreach my $package (@{$dh{DOPACKAGES}}) {
@@ -216,20 +207,20 @@ foreach my $package (@{$dh{DOPACKAGES}})
my $debug_path = make_debug($_, $tmp, $debugtmp) if $keep_debug;
# Note that all calls to strip on shared libs
# *must* inclde the --strip-unneeded.
- doit("$strip","--remove-section=.comment",
+ doit("strip","--remove-section=.comment",
"--remove-section=.note","--strip-unneeded",$_);
attach_debug($_, $debug_path) if defined $debug_path;
}
foreach (@executables) {
my $debug_path = make_debug($_, $tmp, $debugtmp) if $keep_debug;
- doit("$strip","--remove-section=.comment",
+ doit("strip","--remove-section=.comment",
"--remove-section=.note",$_);
attach_debug($_, $debug_path) if defined $debug_path;
}
foreach (@static_libs) {
- doit("$strip","--strip-debug",$_);
+ doit("strip","--strip-debug",$_);
}
}
Reply to: