summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRod Vagg <rod@vagg.org>2023-12-14 17:29:01 +1100
committerGitHub <noreply@github.com>2023-12-13 22:29:01 -0800
commit4e043bb16b6466702bc03898116d27748047e9b5 (patch)
treebf9a1f79c51d7bbec7d14bc9dec3dcf45f67e3eb
parente97a1cbe920b96174c59ee347969eaf42d4116f0 (diff)
downloadwabt-4e043bb16b6466702bc03898116d27748047e9b5.tar.gz
wabt-4e043bb16b6466702bc03898116d27748047e9b5.tar.bz2
wabt-4e043bb16b6466702bc03898116d27748047e9b5.zip
[wasm-objdump] set function types for correct params+locals indexing (#2353)
-rw-r--r--src/binary-reader-objdump.cc8
-rw-r--r--test/dump/noncanon-leb128-opcode.txt2
2 files changed, 9 insertions, 1 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index a96d4947..b1335f68 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -519,6 +519,8 @@ class BinaryReaderObjdumpDisassemble : public BinaryReaderObjdumpBase {
std::string BlockSigToString(Type type) const;
+ Result OnFunction(Index index, Index sig_index) override;
+
Result BeginFunctionBody(Index index, Offset size) override;
Result EndFunctionBody(Index index) override;
@@ -940,6 +942,12 @@ Result BinaryReaderObjdumpDisassemble::OnEndExpr() {
return Result::Ok;
}
+Result BinaryReaderObjdumpDisassemble::OnFunction(Index index,
+ Index sig_index) {
+ objdump_state_->function_types[index] = sig_index;
+ return Result::Ok;
+}
+
Result BinaryReaderObjdumpDisassemble::BeginFunctionBody(Index index,
Offset size) {
printf("%06" PRIzx " func[%" PRIindex "]", GetPrintOffset(state->offset),
diff --git a/test/dump/noncanon-leb128-opcode.txt b/test/dump/noncanon-leb128-opcode.txt
index 785dc9dd..c9e52267 100644
--- a/test/dump/noncanon-leb128-opcode.txt
+++ b/test/dump/noncanon-leb128-opcode.txt
@@ -19,7 +19,7 @@ noncanon-leb128-opcode.0.wasm: file format wasm 0x1
Code Disassembly:
00002d func[0] <main>:
- 00002e: 03 7e | local[0..2] type=i64
+ 00002e: 03 7e | local[1..3] type=i64
000030: 20 00 | local.get 0
000032: 41 d6 49 | i32.const 4294960342
000035: 02 7f | block i32