Closed
Description
In binary, the section payload size is inefficiently encoded.
It is generated by the binary/encode.ml
, the output is still correctly loaded
by binary/decode.ml
but defy the purpose of using a compact representation for
the Section
payload size.
A payload size is a varuint7
, the upper byte set indicate a next block to read
in stream. For the problem at hand, it would be decoded so
[0x84 0x80 0x80 0x80 0x00] fold ((a,b) => a | ((b & 0x7F) << 7))
which equals 4.
The correct (or smallest) varuint7
encoding would be directly 0x04
.
Example text format
(module
(type (func))
)
Hex stream
0061736D 01000000 01 8480808000 01 60 00 00 implementation
0061736d 01000000 01 04 01 60 00 00 specification
Header
hex stream | name: type |
value |
---|---|---|
00 61 73 6D |
magic: uint8 |
\0asm |
01 00 00 00 |
version: uint8 |
1 |
Sections
hex stream | name: type |
value |
---|---|---|
01 |
id: varuint7 |
Type |
84 80 80 80 00 / 04 |
payload_size: varuint7 |
6 |
Type
hex stream | name: type |
value |
---|---|---|
01 |
count: varuint32 |
1 |
Func Type
hex stream | name: type |
value |
---|---|---|
60 |
form: varint7 |
func type constructor |
00 |
param_count: varuint |
0 |
00 |
return_count: varuint |
0 |
Metadata
Metadata
Assignees
Labels
No labels