From f8c3d6027dd64c7c3c962aa1d4bfc50e6ecc4a8c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 22 Mar 2017 12:59:19 -0700 Subject: wasmdump: Improve printing on relocation information (#364) Print the addend and make it more clear what the different offsets mean. --- src/binary-reader-objdump.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/binary-reader-objdump.cc') 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(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(user_data); uint32_t total_offset = ctx->section_starts[static_cast(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; -- cgit v1.2.3