| ... | @@ -3420,7 +3420,7 @@ pub fn prelink(wasm: *Wasm, prog_node: std.Progress.Node) link.File.FlushError!v | ... | @@ -3420,7 +3420,7 @@ pub fn prelink(wasm: *Wasm, prog_node: std.Progress.Node) link.File.FlushError!v |
| 3420 | for (wasm.object_init_funcs.items) |init_func| { | 3420 | for (wasm.object_init_funcs.items) |init_func| { |
| 3421 | const func = init_func.function_index.ptr(wasm); | 3421 | const func = init_func.function_index.ptr(wasm); |
| 3422 | if (func.object_index.ptr(wasm).is_included) { | 3422 | if (func.object_index.ptr(wasm).is_included) { |
| 3423 | try markFunction(wasm, init_func.function_index); | 3423 | try markFunction(wasm, init_func.function_index, false); |
| 3424 | } | 3424 | } |
| 3425 | } | 3425 | } |
| 3426 | wasm.functions_end_prelink = @intCast(wasm.functions.entries.len); | 3426 | wasm.functions_end_prelink = @intCast(wasm.functions.entries.len); |
| ... | @@ -3484,12 +3484,12 @@ pub fn markFunctionImport( | ... | @@ -3484,12 +3484,12 @@ pub fn markFunctionImport( |
| 3484 | try wasm.function_imports.put(gpa, name, .fromObject(func_index, wasm)); | 3484 | try wasm.function_imports.put(gpa, name, .fromObject(func_index, wasm)); |
| 3485 | } | 3485 | } |
| 3486 | } else { | 3486 | } else { |
| 3487 | try markFunction(wasm, import.resolution.unpack(wasm).object_function); | 3487 | try markFunction(wasm, import.resolution.unpack(wasm).object_function, import.flags.exported); |
| 3488 | } | 3488 | } |
| 3489 | } | 3489 | } |
| 3490 | | 3490 | |
| 3491 | /// Recursively mark alive everything referenced by the function. | 3491 | /// Recursively mark alive everything referenced by the function. |
| 3492 | fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex) link.File.FlushError!void { | 3492 | fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex, override_export: bool) link.File.FlushError!void { |
| 3493 | const comp = wasm.base.comp; | 3493 | const comp = wasm.base.comp; |
| 3494 | const gpa = comp.gpa; | 3494 | const gpa = comp.gpa; |
| 3495 | const gop = try wasm.functions.getOrPut(gpa, .fromObjectFunction(wasm, i)); | 3495 | const gop = try wasm.functions.getOrPut(gpa, .fromObjectFunction(wasm, i)); |
| ... | @@ -3500,7 +3500,7 @@ fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex) link.File.FlushError!void { | ... | @@ -3500,7 +3500,7 @@ fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex) link.File.FlushError!void { |
| 3500 | const function = i.ptr(wasm); | 3500 | const function = i.ptr(wasm); |
| 3501 | markObject(wasm, function.object_index); | 3501 | markObject(wasm, function.object_index); |
| 3502 | | 3502 | |
| 3503 | if (!is_obj and function.flags.isExported(rdynamic)) { | 3503 | if (!is_obj and (override_export or function.flags.isExported(rdynamic))) { |
| 3504 | const symbol_name = function.name.unwrap().?; | 3504 | const symbol_name = function.name.unwrap().?; |
| 3505 | if (function.flags.visibility_hidden) { | 3505 | if (function.flags.visibility_hidden) { |
| 3506 | try wasm.hidden_function_exports.put(gpa, symbol_name, @enumFromInt(gop.index)); | 3506 | try wasm.hidden_function_exports.put(gpa, symbol_name, @enumFromInt(gop.index)); |
| ... | @@ -3554,11 +3554,11 @@ fn markGlobalImport( | ... | @@ -3554,11 +3554,11 @@ fn markGlobalImport( |
| 3554 | try wasm.global_imports.put(gpa, name, .fromObject(global_index, wasm)); | 3554 | try wasm.global_imports.put(gpa, name, .fromObject(global_index, wasm)); |
| 3555 | } | 3555 | } |
| 3556 | } else { | 3556 | } else { |
| 3557 | try markGlobal(wasm, import.resolution.unpack(wasm).object_global); | 3557 | try markGlobal(wasm, import.resolution.unpack(wasm).object_global, import.flags.exported); |
| 3558 | } | 3558 | } |
| 3559 | } | 3559 | } |
| 3560 | | 3560 | |
| 3561 | fn markGlobal(wasm: *Wasm, i: ObjectGlobalIndex) link.File.FlushError!void { | 3561 | fn markGlobal(wasm: *Wasm, i: ObjectGlobalIndex, override_export: bool) link.File.FlushError!void { |
| 3562 | const comp = wasm.base.comp; | 3562 | const comp = wasm.base.comp; |
| 3563 | const gpa = comp.gpa; | 3563 | const gpa = comp.gpa; |
| 3564 | const gop = try wasm.globals.getOrPut(gpa, .fromObjectGlobal(wasm, i)); | 3564 | const gop = try wasm.globals.getOrPut(gpa, .fromObjectGlobal(wasm, i)); |
| ... | @@ -3568,7 +3568,7 @@ fn markGlobal(wasm: *Wasm, i: ObjectGlobalIndex) link.File.FlushError!void { | ... | @@ -3568,7 +3568,7 @@ fn markGlobal(wasm: *Wasm, i: ObjectGlobalIndex) link.File.FlushError!void { |
| 3568 | const is_obj = comp.config.output_mode == .Obj; | 3568 | const is_obj = comp.config.output_mode == .Obj; |
| 3569 | const global = i.ptr(wasm); | 3569 | const global = i.ptr(wasm); |
| 3570 | | 3570 | |
| 3571 | if (!is_obj and global.flags.isExported(rdynamic)) try wasm.global_exports.append(gpa, .{ | 3571 | if (!is_obj and (override_export or global.flags.isExported(rdynamic))) try wasm.global_exports.append(gpa, .{ |
| 3572 | .name = global.name.unwrap().?, | 3572 | .name = global.name.unwrap().?, |
| 3573 | .global_index = @enumFromInt(gop.index), | 3573 | .global_index = @enumFromInt(gop.index), |
| 3574 | }); | 3574 | }); |
| ... | @@ -3700,7 +3700,7 @@ fn markRelocations(wasm: *Wasm, relocs: ObjectRelocation.IterableSlice) link.Fil | ... | @@ -3700,7 +3700,7 @@ fn markRelocations(wasm: *Wasm, relocs: ObjectRelocation.IterableSlice) link.Fil |
| 3700 | .function_index_i32, | 3700 | .function_index_i32, |
| 3701 | .function_offset_i32, | 3701 | .function_offset_i32, |
| 3702 | .function_offset_i64, | 3702 | .function_offset_i64, |
| 3703 | => try markFunction(wasm, pointee.function.chaseWeak(wasm)), | 3703 | => try markFunction(wasm, pointee.function.chaseWeak(wasm), false), |
| 3704 | .table_index_sleb, | 3704 | .table_index_sleb, |
| 3705 | .table_index_i32, | 3705 | .table_index_i32, |
| 3706 | .table_index_sleb64, | 3706 | .table_index_sleb64, |
| ... | @@ -3710,11 +3710,11 @@ fn markRelocations(wasm: *Wasm, relocs: ObjectRelocation.IterableSlice) link.Fil | ... | @@ -3710,11 +3710,11 @@ fn markRelocations(wasm: *Wasm, relocs: ObjectRelocation.IterableSlice) link.Fil |
| 3710 | => { | 3710 | => { |
| 3711 | const function = pointee.function; | 3711 | const function = pointee.function; |
| 3712 | try wasm.object_indirect_function_set.put(gpa, function, {}); | 3712 | try wasm.object_indirect_function_set.put(gpa, function, {}); |
| 3713 | try markFunction(wasm, function.chaseWeak(wasm)); | 3713 | try markFunction(wasm, function.chaseWeak(wasm), false); |
| 3714 | }, | 3714 | }, |
| 3715 | .global_index_leb, | 3715 | .global_index_leb, |
| 3716 | .global_index_i32, | 3716 | .global_index_i32, |
| 3717 | => try markGlobal(wasm, pointee.global.chaseWeak(wasm)), | 3717 | => try markGlobal(wasm, pointee.global.chaseWeak(wasm), false), |
| 3718 | .table_number_leb, | 3718 | .table_number_leb, |
| 3719 | => try markTable(wasm, pointee.table.chaseWeak(wasm)), | 3719 | => try markTable(wasm, pointee.table.chaseWeak(wasm)), |
| 3720 | | 3720 | |