diff mbox

[2/2] disas: Add disas-objdump.pl

Message ID CAMo8Bf+6RwnsTd+gCp-wcqWS0+-YNCx5xUBD_YgJpzcAsm00Fg@mail.gmail.com
State New
Headers show

Commit Message

Max Filippov Aug. 10, 2013, 4:08 a.m. UTC
On Fri, Aug 9, 2013 at 11:19 PM, Richard Henderson <rth@twiddle.net> wrote:
> The script massages the output produced for architectures that are
> not supported internally by qemu though an external objdump program
> for disassembly.

I'd add something like the following to get disassembled hunks with correct
addresses:

Comments

Richard Henderson Aug. 10, 2013, 10:39 a.m. UTC | #1
On 08/09/2013 06:08 PM, Max Filippov wrote:
> +    return $ret . " --adjust-vma=" . $vma;

Interesting.  I didn't consider this, as that option
doesn't appear in objdump --help.

Thanks,


r~
diff mbox

Patch

diff --git a/scripts/disas-objdump.pl b/scripts/disas-objdump.pl
index c66a629..b6824b4 100755
--- a/scripts/disas-objdump.pl
+++ b/scripts/disas-objdump.pl
@@ -38,15 +38,17 @@  $objdump[2] = mkobjcommand($tobjdump, $tmachine);
 # Zero-initialize current dumping state.
 my $mem = "";
 my $inobjd = 0;
+my $vma = "";

-sub objcommand {
+sub objcommand ($) {
+    my ($vma) = @_;
     my $ret = $objdump[$inobjd];
     if (!$ret) {
         die "Host machine type not specified" if $inobjd == 1;
         die "Target machine type not specified" if $inobjd == 2;
         die "Internal error";
     }
-    return $ret;
+    return $ret . " --adjust-vma=" . $vma;
 }

 while (<>) {
@@ -69,7 +71,8 @@  while (<>) {
         syswrite $outh, $mem;

         # Pipe from objdump...
-        open IN, "-|", objcommand();
+        $vma =~ s/:.*//;
+        open IN, "-|", objcommand($vma);

         # ... copying all but the first 7 lines of boilerplate to our stdout.
        my $i = 0;
@@ -82,6 +85,7 @@  while (<>) {
         $mem = "";
         $inobjd = 0;
     } else {
+        $vma = $_;
         print;
     }
 }