summaryrefslogtreecommitdiff
path: root/src/binary-reader-objdump.cc
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-03-22 12:59:19 -0700
committerGitHub <noreply@github.com>2017-03-22 12:59:19 -0700
commitf8c3d6027dd64c7c3c962aa1d4bfc50e6ecc4a8c (patch)
treeb09412fdab3820dc6936d6d576907c06703c6467 /src/binary-reader-objdump.cc
parent6602d3cc97caa5bec08e274b2250c545ff0d71d1 (diff)
downloadwabt-f8c3d6027dd64c7c3c962aa1d4bfc50e6ecc4a8c.tar.gz
wabt-f8c3d6027dd64c7c3c962aa1d4bfc50e6ecc4a8c.tar.bz2
wabt-f8c3d6027dd64c7c3c962aa1d4bfc50e6ecc4a8c.zip
wasmdump: Improve printing on relocation information (#364)
Print the addend and make it more clear what the different offsets mean.
Diffstat (limited to 'src/binary-reader-objdump.cc')
-rw-r--r--src/binary-reader-objdump.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index fa59b2b9..95130643 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -253,8 +253,18 @@ static void log_opcode(Context* ctx,
ctx->section_starts[static_cast<size_t>(BinarySection::Code)];
size_t abs_offset = code_start + reloc->offset;
if (ctx->last_opcode_end > abs_offset) {
- printf(" %06" PRIzx ": %s\t%d\n", abs_offset,
+ printf(" %06" PRIzx ": %-18s %d", abs_offset,
get_reloc_type_name(reloc->type), reloc->index);
+ switch (reloc->type) {
+ case RelocType::MemoryAddressLEB:
+ case RelocType::MemoryAddressSLEB:
+ case RelocType::MemoryAddressI32:
+ printf(" + %d", reloc->addend);
+ break;
+ default:
+ break;
+ }
+ printf("\n");
ctx->next_reloc++;
}
}
@@ -633,8 +643,8 @@ Result on_reloc(RelocType type,
Context* ctx = static_cast<Context*>(user_data);
uint32_t total_offset =
ctx->section_starts[static_cast<size_t>(ctx->reloc_section)] + offset;
- print_details(ctx, " - %-18s offset=%#x (%#x)\n", get_reloc_type_name(type),
- total_offset, offset);
+ print_details(ctx, " - %-18s idx=%#-4x addend=%#-4x offset=%#x(file=%#x)\n",
+ get_reloc_type_name(type), index, addend, offset, total_offset);
if (ctx->options->mode == ObjdumpMode::Prepass &&
ctx->reloc_section == BinarySection::Code) {
Reloc reloc;