Bladeren bron

Dpkg::Shlibs::Objdump: use the cross objdump when cross compiling

When <cross-prefix>-objdump is available and when we're cross-compiling
let's use the cross objdump in preference over the standard objdump.

Based-on-patch-by: Loïc Minier <lool@debian.org>
Raphaël Hertzog 16 jaren geleden
bovenliggende
commit
452eb2fba8
2 gewijzigde bestanden met toevoegingen van 21 en 9 verwijderingen
  1. 2 0
      debian/changelog
  2. 19 9
      scripts/Dpkg/Shlibs/Objdump.pm

+ 2 - 0
debian/changelog

@@ -17,6 +17,8 @@ dpkg (1.15.8) UNRELEASED; urgency=low
   * Fix the non-regression test lib/dpkg/test/t-ar.c by not overflowing the
     size of ar_name. Thanks to Colin Watson for the report, analysis and patch.
     Closes: #582401
+  * Modify Dpkg::Shlibs::Objdump to use the cross objdump binary when cross
+    compiling. Thanks to Loïc Minier for the initial patch. Closes: #578365
 
   [ Guillem Jover ]
   * Require gettext 0.18:

+ 19 - 9
scripts/Dpkg/Shlibs/Objdump.pm

@@ -1,4 +1,4 @@
-# Copyright © 2007 Raphaël Hertzog <hertzog@debian.org>
+# Copyright © 2007-2010 Raphaël Hertzog <hertzog@debian.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -13,15 +13,25 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+package Dpkg::Shlibs::Objdump;
+
 use strict;
 use warnings;
 
+use Dpkg::Gettext;
+use Dpkg::ErrorHandling;
+use Dpkg::Path qw(find_command);
+use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch);
+
 our $VERSION = "0.01";
 
-package Dpkg::Shlibs::Objdump;
+# Decide which objdump to call
+our $OBJDUMP = "objdump";
+if (get_build_arch() ne get_host_arch()) {
+    my $od = debarch_to_gnutriplet(get_host_arch()) . "-objdump";
+    $OBJDUMP = $od if find_command($od);
+}
 
-use Dpkg::Gettext;
-use Dpkg::ErrorHandling;
 
 sub new {
     my $this = shift;
@@ -80,8 +90,8 @@ sub has_object {
 	    return $format{$file};
 	} else {
 	    local $ENV{LC_ALL} = "C";
-	    open(P, "-|", "objdump", "-a", "--", $file)
-		|| syserr(_g("cannot fork for %s"), "objdump");
+	    open(P, "-|", $OBJDUMP, "-a", "--", $file)
+		|| syserr(_g("cannot fork for %s"), $OBJDUMP);
 	    while (<P>) {
 		chomp;
 		if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) {
@@ -89,7 +99,7 @@ sub has_object {
 		    return $format{$file};
 		}
 	    }
-	    close(P) or subprocerr(_g("objdump on \`%s'"), $file);
+	    close(P) or subprocerr($OBJDUMP);
 	}
     }
 }
@@ -154,8 +164,8 @@ sub analyze {
     $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");
+    open(my $objdump, "-|", $OBJDUMP, "-w", "-f", "-p", "-T", "-R", $file)
+	|| syserr(_g("cannot fork for %s"), $OBJDUMP);
     my $ret = $self->parse_objdump_output($objdump);
     close($objdump);
     return $ret;