summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binary-reader-linker.cc4
-rw-r--r--src/binary-reader-logging.cc5
-rw-r--r--src/binary-reader-logging.h2
-rw-r--r--src/binary-reader-nop.h2
-rw-r--r--src/binary-reader-objdump.cc25
-rw-r--r--src/binary-reader.cc2
-rw-r--r--src/binary-reader.h2
7 files changed, 27 insertions, 15 deletions
diff --git a/src/binary-reader-linker.cc b/src/binary-reader-linker.cc
index 0da7b9c2..52a19adb 100644
--- a/src/binary-reader-linker.cc
+++ b/src/binary-reader-linker.cc
@@ -81,7 +81,7 @@ class BinaryReaderLinker : public BinaryReaderNop {
virtual Result OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend);
+ uint32_t addend);
virtual Result OnInitExprI32ConstExpr(uint32_t index, uint32_t value);
@@ -117,7 +117,7 @@ Result BinaryReaderLinker::OnRelocCount(uint32_t count,
Result BinaryReaderLinker::OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend) {
+ uint32_t addend) {
if (offset + RELOC_SIZE > reloc_section->size) {
WABT_FATAL("invalid relocation offset: %#x\n", offset);
}
diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc
index 093c9c07..7209a474 100644
--- a/src/binary-reader-logging.cc
+++ b/src/binary-reader-logging.cc
@@ -403,9 +403,10 @@ Result BinaryReaderLogging::OnRelocCount(uint32_t count,
Result BinaryReaderLogging::OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend) {
+ uint32_t addend) {
+ int32_t signed_addend = static_cast<int32_t>(addend);
LOGF("OnReloc(type: %s, offset: %u, index: %u, addend: %d)\n",
- get_reloc_type_name(type), offset, index, addend);
+ get_reloc_type_name(type), offset, index, signed_addend);
return reader->OnReloc(type, offset, index, addend);
}
diff --git a/src/binary-reader-logging.h b/src/binary-reader-logging.h
index 374095f8..27d54152 100644
--- a/src/binary-reader-logging.h
+++ b/src/binary-reader-logging.h
@@ -217,7 +217,7 @@ class BinaryReaderLogging : public BinaryReader {
virtual Result OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend);
+ uint32_t addend);
virtual Result EndRelocSection();
virtual Result OnInitExprF32ConstExpr(uint32_t index, uint32_t value);
diff --git a/src/binary-reader-nop.h b/src/binary-reader-nop.h
index c00614cc..8503e487 100644
--- a/src/binary-reader-nop.h
+++ b/src/binary-reader-nop.h
@@ -299,7 +299,7 @@ class BinaryReaderNop : public BinaryReader {
virtual Result OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend) {
+ uint32_t addend) {
return Result::Ok;
}
virtual Result EndRelocSection() { return Result::Ok; }
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index a57ec1bb..b11ad42e 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -126,7 +126,7 @@ class BinaryReaderObjdumpPrepass : public BinaryReaderObjdumpBase {
virtual Result OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend);
+ uint32_t addend);
};
BinaryReaderObjdumpPrepass::BinaryReaderObjdumpPrepass(const uint8_t* data,
@@ -144,7 +144,7 @@ Result BinaryReaderObjdumpPrepass::OnFunctionName(uint32_t index,
Result BinaryReaderObjdumpPrepass::OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend) {
+ uint32_t addend) {
BinaryReaderObjdumpBase::OnReloc(type, offset, index, addend);
if (reloc_section == BinarySection::Code) {
options->code_relocations.emplace_back(type, offset, index, addend);
@@ -478,7 +478,7 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase {
virtual Result OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend);
+ uint32_t addend);
private:
bool ShouldPrintDetails();
@@ -807,7 +807,7 @@ Result BinaryReaderObjdump::OnDataSegmentData(uint32_t index,
const void* src_data,
uint32_t size) {
if (ShouldPrintDetails()) {
- out_stream->WriteMemoryDump(src_data, size, 0, " - ", nullptr,
+ out_stream->WriteMemoryDump(src_data, size, state->offset - size, " - ", nullptr,
PrintChars::Yes);
}
return Result::Ok;
@@ -824,11 +824,22 @@ Result BinaryReaderObjdump::OnRelocCount(uint32_t count,
Result BinaryReaderObjdump::OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend) {
+ uint32_t addend) {
uint32_t total_offset =
section_starts[static_cast<size_t>(reloc_section)] + offset;
- PrintDetails(" - %-18s idx=%#-4x addend=%#-4x offset=%#x(file=%#x)\n",
- get_reloc_type_name(type), index, addend, offset, total_offset);
+ PrintDetails(" - %-18s offset=%#08x(file=%#08x) index=%#08x",
+ get_reloc_type_name(type), offset, total_offset, index);
+ if (addend) {
+ int32_t signed_addend = static_cast<int32_t>(addend);
+ if (signed_addend < 0) {
+ PrintDetails("-");
+ signed_addend = -signed_addend;
+ } else {
+ PrintDetails("+");
+ }
+ PrintDetails("%#x", signed_addend);
+ }
+ PrintDetails("\n");
return Result::Ok;
}
diff --git a/src/binary-reader.cc b/src/binary-reader.cc
index c6e1f564..435d4d5d 100644
--- a/src/binary-reader.cc
+++ b/src/binary-reader.cc
@@ -1001,7 +1001,7 @@ static void read_reloc_section(Context* ctx, uint32_t section_size) {
case RelocType::MemoryAddressLEB:
case RelocType::MemoryAddressSLEB:
case RelocType::MemoryAddressI32:
- in_u32_leb128(ctx, &addend, "addend");
+ in_i32_leb128(ctx, &addend, "addend");
break;
default:
break;
diff --git a/src/binary-reader.h b/src/binary-reader.h
index 1c2f2780..e8e5c45f 100644
--- a/src/binary-reader.h
+++ b/src/binary-reader.h
@@ -255,7 +255,7 @@ class BinaryReader {
virtual Result OnReloc(RelocType type,
uint32_t offset,
uint32_t index,
- int32_t addend) = 0;
+ uint32_t addend) = 0;
virtual Result EndRelocSection() = 0;
/* InitExpr - used by elem, data and global sections; these functions are