| ... | ... | @@ -168,11 +168,17 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 168 | 168 | if (ip.isFunctionType(ip.getNav(nav_export.nav_index).typeOf(ip))) { |
| 169 | 169 | log.debug("flush export '{s}' nav={d}", .{ nav_export.name.slice(wasm), nav_export.nav_index }); |
| 170 | 170 | const function_index = Wasm.FunctionIndex.fromIpNav(wasm, nav_export.nav_index).?; |
| 171 | | switch (export_index.ptr(zcu).opts.visibility) { |
| 172 | | .default, .protected => try wasm.function_exports.put(gpa, nav_export.name, function_index), |
| 173 | | .hidden => try wasm.hidden_function_exports.put(gpa, nav_export.name, function_index), |
| 171 | const explicit = f.missing_exports.swapRemove(nav_export.name); |
| 172 | const is_hidden = !explicit and switch (export_index.ptr(zcu).opts.visibility) { |
| 173 | .protected => false, |
| 174 | .hidden => true, |
| 175 | .default => !comp.config.rdynamic, |
| 176 | }; |
| 177 | if (is_hidden) { |
| 178 | try wasm.hidden_function_exports.put(gpa, nav_export.name, function_index); |
| 179 | } else { |
| 180 | try wasm.function_exports.put(gpa, nav_export.name, function_index); |
| 174 | 181 | } |
| 175 | | _ = f.missing_exports.swapRemove(nav_export.name); |
| 176 | 182 | _ = f.function_imports.swapRemove(nav_export.name); |
| 177 | 183 | |
| 178 | 184 | if (nav_export.name.toOptional() == entry_name) |
| ... | ... | @@ -281,9 +287,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 281 | 287 | // We also initialize bss segments (using memory.fill) as part of this |
| 282 | 288 | // function. |
| 283 | 289 | if (wasm.any_passive_inits) { |
| 284 | | wasm.functions.putAssumeCapacity(.__wasm_init_memory, {}); |
| 285 | | const empty = try wasm.internValtypeList(&.{}); |
| 286 | | _ = try wasm.addFuncType(.{ .params = empty, .returns = empty }); |
| 290 | try wasm.addFunction(.__wasm_init_memory, &.{}, &.{}); |
| 287 | 291 | } |
| 288 | 292 | |
| 289 | 293 | // When we have TLS GOT entries and shared memory is enabled, |
| ... | ... | @@ -291,8 +295,8 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 291 | 295 | if (shared_memory) { |
| 292 | 296 | // This logic that checks `any_tls_relocs` is missing the part where it |
| 293 | 297 | // also notices threadlocal globals from Zcu code. |
| 294 | | if (wasm.any_tls_relocs) wasm.functions.putAssumeCapacity(.__wasm_apply_global_tls_relocs, {}); |
| 295 | | wasm.functions.putAssumeCapacity(.__wasm_init_tls, {}); |
| 298 | if (wasm.any_tls_relocs) try wasm.addFunction(.__wasm_apply_global_tls_relocs, &.{}, &.{}); |
| 299 | try wasm.addFunction(.__wasm_init_tls, &.{.i32}, &.{}); |
| 296 | 300 | } |
| 297 | 301 | |
| 298 | 302 | try wasm.tables.ensureUnusedCapacity(gpa, 1); |