| ... | @@ -59,6 +59,10 @@ const IndirectFunctionTableIndex = enum(u32) { | ... | @@ -59,6 +59,10 @@ const IndirectFunctionTableIndex = enum(u32) { |
| 59 | // These are the same since those are added to the table first. | 59 | // These are the same since those are added to the table first. |
| 60 | return @enumFromInt(@intFromEnum(i)); | 60 | return @enumFromInt(@intFromEnum(i)); |
| 61 | } | 61 | } |
| | 62 | |
| | 63 | fn toAbi(i: IndirectFunctionTableIndex) u32 { |
| | 64 | return @intFromEnum(i) + 1; |
| | 65 | } |
| 62 | }; | 66 | }; |
| 63 | | 67 | |
| 64 | const DataSegmentGroup = struct { | 68 | const DataSegmentGroup = struct { |
| ... | @@ -777,9 +781,9 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { | ... | @@ -777,9 +781,9 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 777 | for (wasm.func_table_fixups.items) |fixup| { | 781 | for (wasm.func_table_fixups.items) |fixup| { |
| 778 | const table_index: IndirectFunctionTableIndex = .fromZcuIndirectFunctionSetIndex(fixup.table_index); | 782 | const table_index: IndirectFunctionTableIndex = .fromZcuIndirectFunctionSetIndex(fixup.table_index); |
| 779 | if (!is64) { | 783 | if (!is64) { |
| 780 | mem.writeInt(u32, wasm.string_bytes.items[fixup.offset..][0..4], @intFromEnum(table_index), .little); | 784 | mem.writeInt(u32, wasm.string_bytes.items[fixup.offset..][0..4], table_index.toAbi(), .little); |
| 781 | } else { | 785 | } else { |
| 782 | mem.writeInt(u64, wasm.string_bytes.items[fixup.offset..][0..8], @intFromEnum(table_index), .little); | 786 | mem.writeInt(u64, wasm.string_bytes.items[fixup.offset..][0..8], table_index.toAbi(), .little); |
| 783 | } | 787 | } |
| 784 | } | 788 | } |
| 785 | } | 789 | } |
| ... | @@ -1582,19 +1586,19 @@ fn applyRelocs(code: []u8, code_offset: u32, relocs: Wasm.ObjectRelocation.Itera | ... | @@ -1582,19 +1586,19 @@ fn applyRelocs(code: []u8, code_offset: u32, relocs: Wasm.ObjectRelocation.Itera |
| 1582 | } | 1586 | } |
| 1583 | | 1587 | |
| 1584 | fn reloc_u32_table_index(code: []u8, i: IndirectFunctionTableIndex) void { | 1588 | fn reloc_u32_table_index(code: []u8, i: IndirectFunctionTableIndex) void { |
| 1585 | mem.writeInt(u32, code[0..4], @intFromEnum(i), .little); | 1589 | mem.writeInt(u32, code[0..4], i.toAbi(), .little); |
| 1586 | } | 1590 | } |
| 1587 | | 1591 | |
| 1588 | fn reloc_u64_table_index(code: []u8, i: IndirectFunctionTableIndex) void { | 1592 | fn reloc_u64_table_index(code: []u8, i: IndirectFunctionTableIndex) void { |
| 1589 | mem.writeInt(u64, code[0..8], @intFromEnum(i), .little); | 1593 | mem.writeInt(u64, code[0..8], i.toAbi(), .little); |
| 1590 | } | 1594 | } |
| 1591 | | 1595 | |
| 1592 | fn reloc_sleb_table_index(code: []u8, i: IndirectFunctionTableIndex) void { | 1596 | fn reloc_sleb_table_index(code: []u8, i: IndirectFunctionTableIndex) void { |
| 1593 | leb.writeSignedFixed(5, code[0..5], @intFromEnum(i)); | 1597 | leb.writeSignedFixed(5, code[0..5], i.toAbi()); |
| 1594 | } | 1598 | } |
| 1595 | | 1599 | |
| 1596 | fn reloc_sleb64_table_index(code: []u8, i: IndirectFunctionTableIndex) void { | 1600 | fn reloc_sleb64_table_index(code: []u8, i: IndirectFunctionTableIndex) void { |
| 1597 | leb.writeSignedFixed(11, code[0..11], @intFromEnum(i)); | 1601 | leb.writeSignedFixed(11, code[0..11], i.toAbi()); |
| 1598 | } | 1602 | } |
| 1599 | | 1603 | |
| 1600 | fn reloc_u32_function(code: []u8, function: Wasm.OutputFunctionIndex) void { | 1604 | fn reloc_u32_function(code: []u8, function: Wasm.OutputFunctionIndex) void { |