From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH v2 3/3] disas-objdump: Pass --adjust-vma to objdump
Date: Fri, 16 Aug 2013 23:29:47 -0700 [thread overview]
Message-ID: <1376720987-2576-4-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1376720987-2576-1-git-send-email-rth@twiddle.net>
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>
---
scripts/disas-objdump.pl | 18 +++++++++++++++---
1 file 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;
}
--
1.8.1.4
next prev parent reply other threads:[~2013-08-17 6:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-17 6:29 [Qemu-devel] [PATCH v2 0/3] Disassembly with external objdump Richard Henderson
2013-08-17 6:29 ` [Qemu-devel] [PATCH v2 1/3] disas: Implement fallback to dump object code as hex Richard Henderson
2013-08-17 6:29 ` [Qemu-devel] [PATCH v2 2/3] disas: Add disas-objdump.pl Richard Henderson
2013-08-17 6:29 ` Richard Henderson [this message]
2013-08-24 5:32 ` [Qemu-devel] [PATCH v2 0/3] Disassembly with external objdump Edgar E. Iglesias
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1376720987-2576-4-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).