authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-18 15:21:03-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:35-08:00
log3c70392210d3bd68943b3ebd09612fddfe52b082
tree509efea86b648f1e5dbb2281380cd3ab8f294b71
parent85b53730fe248cf02468a213903ddac4bffe8234

wasm linker: add __zig_error_name_table data when needed


1 files changed, 4 insertions(+), 1 deletions(-)

src/link/Wasm/Flush.zig+4-1
...@@ -134,7 +134,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {...@@ -134,7 +134,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
134134
135 // Merge and order the data segments. Depends on garbage collection so that135 // 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 }
146149
147 try wasm.functions.ensureUnusedCapacity(gpa, 3);150 try wasm.functions.ensureUnusedCapacity(gpa, 3);
148151