]> git.proxmox.com Git - mirror_qemu.git/blobdiff - scripts/disas-objdump.pl
rbd: Clean up qemu_rbd_create()'s detour through QemuOpts
[mirror_qemu.git] / scripts / disas-objdump.pl
index c66a62976346458a492528c3be2e775663b1c864..8f7e8182a1b3c83a9b1da85ae2221d6742b65c1a 100755 (executable)
@@ -29,7 +29,7 @@ sub mkobjcommand ($$) {
     my ($cmd, $mach) = @_;
     return 0 if !$mach;
     $cmd = $aobjdump if !$cmd;
-    return "$cmd -m $mach --disassemble-all -b binary $outname";
+    return "$cmd -m $mach --disassemble-all -b binary";
 }
 
 $objdump[1] = mkobjcommand($hobjdump, $hmachine);
@@ -38,6 +38,7 @@ $objdump[2] = mkobjcommand($tobjdump, $tmachine);
 # Zero-initialize current dumping state.
 my $mem = "";
 my $inobjd = 0;
+my $vma = 0;
 
 sub objcommand {
     my $ret = $objdump[$inobjd];
@@ -50,7 +51,7 @@ sub objcommand {
 }
 
 while (<>) {
-    # Collect the data from the relevant OBJD-* lines.
+    # Collect the data from the relevant OBJD-* lines ...
     if (/^OBJD-H: /) {
         die "Internal error" if $inobjd == 2;
         $mem = $mem . pack("H*", substr($_, 8, -1));
@@ -68,8 +69,12 @@ while (<>) {
         truncate $outh, 0;
         syswrite $outh, $mem;
 
+        my $cmd = objcommand();
+        $cmd = $cmd . " --adjust-vma=" . $vma if $vma;
+        $cmd = $cmd . " " . $outname;
+
         # Pipe from objdump...
-        open IN, "-|", objcommand();
+        open IN, "-|", $cmd;
 
         # ... copying all but the first 7 lines of boilerplate to our stdout.
        my $i = 0;
@@ -81,6 +86,13 @@ while (<>) {
 
         $mem = "";
         $inobjd = 0;
+        $vma = 0;
+    }
+    # The line before "OBJD-*" will be of the form "0x<hex>+: +\n".
+    # Extract the value for passing to --adjust-vma.
+    elsif (/^(0x[0-9a-fA-F]+):\s*$/) {
+        $vma = $1;
+        print;
     } else {
         print;
     }