[wasm-objdump] set function types for correct params+locals indexing #2353
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
wasm-objdump --disassemble
has different treatment of locals than--details
because it doesn't collect function types so it can properly work out how many params the function has and therefore the index number of the local.test/dump/noncanon-leb128-opcode.txt
demonstrates this nicely as can be seen in here. The--details
of that test module looks like this:so
"main"
hassig=1
, i.e. it takes 1 parameter,(i32) -> i32
. But because--disassemble
mode doesn't collect function types, it defaults all functions to sig=0, so calculation oflocals[X]
always looks at the first type definition to figure out the number of parameters. In this case it's zero parameters but this is arbitrary and depends on what the first type is. I have other examples if that helps.Further details of how this happens:
local_index_
based on the signature look-up to find the number of params:wabt/src/binary-reader-objdump.cc
Lines 943 to 959 in e97a1cb
local[%d]
uses, and incrementslocal_index_
:wabt/src/binary-reader-objdump.cc
Lines 619 to 649 in e97a1cb