| ... | @@ -134,7 +134,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { | ... | @@ -134,7 +134,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 134 | | 134 | |
| 135 | // Merge and order the data segments. Depends on garbage collection so that | 135 | // Merge and order the data segments. Depends on garbage collection so that |
| 136 | // unused segments can be omitted. | 136 | // unused segments can be omitted. |
| 137 | try wasm.data_segments.ensureUnusedCapacity(gpa, wasm.object_data_segments.items.len); | 137 | try wasm.data_segments.ensureUnusedCapacity(gpa, wasm.object_data_segments.items.len + 1); |
| 138 | for (wasm.object_data_segments.items, 0..) |*ds, i| { | 138 | for (wasm.object_data_segments.items, 0..) |*ds, i| { |
| 139 | if (!ds.flags.alive) continue; | 139 | if (!ds.flags.alive) continue; |
| 140 | const data_segment_index: Wasm.ObjectDataSegmentIndex = @enumFromInt(i); | 140 | const data_segment_index: Wasm.ObjectDataSegmentIndex = @enumFromInt(i); |
| ... | @@ -143,6 +143,9 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { | ... | @@ -143,6 +143,9 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 143 | .object = data_segment_index, | 143 | .object = data_segment_index, |
| 144 | }), @as(u32, undefined)); | 144 | }), @as(u32, undefined)); |
| 145 | } | 145 | } |
| | 146 | if (wasm.error_name_table_ref_count > 0) { |
| | 147 | wasm.data_segments.putAssumeCapacity(.__zig_error_name_table, @as(u32, undefined)); |
| | 148 | } |
| 146 | | 149 | |
| 147 | try wasm.functions.ensureUnusedCapacity(gpa, 3); | 150 | try wasm.functions.ensureUnusedCapacity(gpa, 3); |
| 148 | | 151 | |