aboutsummaryrefslogtreecommitdiff
path: root/scripts/disas-objdump.pl
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2013-08-16 23:29:47 -0700
committerEdgar E. Iglesias <edgar.iglesias@gmail.com>2013-08-24 07:26:45 +0200
commit42eed424e1ea6469ce73cb2fdddb0d31bebb686a (patch)
tree626fb5c23bb90a8da809ea4e346551e00d08a873 /scripts/disas-objdump.pl
parent8dc6d24091edc34be1f989a2d92703130760401f (diff)
downloadqemu-42eed424e1ea6469ce73cb2fdddb0d31bebb686a.zip
qemu-42eed424e1ea6469ce73cb2fdddb0d31bebb686a.tar.gz
qemu-42eed424e1ea6469ce73cb2fdddb0d31bebb686a.tar.bz2
disas-objdump: Pass --adjust-vma to objdump
This gives the dumped blob its correct address during disassembly, which makes pc-relative insns much easier to interpret. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Diffstat (limited to 'scripts/disas-objdump.pl')
-rwxr-xr-xscripts/disas-objdump.pl18
1 files changed, 15 insertions, 3 deletions
diff --git a/scripts/disas-objdump.pl b/scripts/disas-objdump.pl
index c66a629..8f7e818 100755
--- a/scripts/disas-objdump.pl
+++ b/scripts/disas-objdump.pl
@@ -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;
}