Просмотр исходного кода

Dpkg::Shlibs::Objdump::get_format() fallback to host objdump if cross one failed

In many cases the cross objdump is not able to analyze the binaries from
the build host and yet dpkg-shlibdeps need to be able to verify that
the various binaries use the same ELF format. To achieve this get_format()
is enhanced to fallback on the objdump command when the cross one failed.
Raphaël Hertzog лет назад: 16
Родитель
Сommit
d9af569039
2 измененных файлов с 21 добавлено и 6 удалено
  1. 2 0
      debian/changelog
  2. 19 6
      scripts/Dpkg/Shlibs/Objdump.pm

+ 2 - 0
debian/changelog

@@ -7,6 +7,8 @@ dpkg (1.15.8.4) UNRELEASED; urgency=low
   [ Raphaël Hertzog ]
   * Fix make -C man install so that it actually finds the manual pages
     to install. Closes: #591588
+  * When analyzing the ELF format of a binary in dpkg-shlibdeps, fallback on
+    usual objdump when the cross objdump failed. Closes: #591522
 
  -- Guillem Jover <guillem@debian.org>  Thu, 05 Aug 2010 17:42:51 +0200
 

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

@@ -22,6 +22,7 @@ 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);
+use Dpkg::IPC;
 
 our $VERSION = "0.01";
 
@@ -89,17 +90,29 @@ sub has_object {
 	if (exists $format{$file}) {
 	    return $format{$file};
 	} else {
-	    local $ENV{LC_ALL} = "C";
-	    open(P, "-|", $OBJDUMP, "-a", "--", $file)
-		|| syserr(_g("cannot fork for %s"), $OBJDUMP);
-	    while (<P>) {
+	    my ($output, %opts, $pid, $res);
+	    if ($OBJDUMP ne "objdump") {
+		$opts{"error_to_file"} = "/dev/null";
+	    }
+	    $pid = spawn(exec => [ $OBJDUMP, "-a", "--", $file ],
+			 env => { "LC_ALL" => "C" },
+			 to_pipe => \$output, %opts);
+	    while (<$output>) {
 		chomp;
 		if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) {
 		    $format{$file} = $1;
-		    return $format{$file};
+		    $res = $format{$file};
+		    last;
 		}
 	    }
-	    close(P) or subprocerr($OBJDUMP);
+	    close($output);
+	    wait_child($pid, nocheck => 1);
+	    if ($?) {
+		subprocerr("objdump") if $OBJDUMP eq "objdump";
+		local $OBJDUMP = "objdump";
+		$res = get_format($file);
+	    }
+	    return $res;
 	}
     }
 }