@@ -210,8 +210,7 @@ entry_resolution: FunctionImport.Resolution = .unresolved,
210
210
211
211
/// Empty when outputting an object.
212
212
function_exports : std .AutoArrayHashMapUnmanaged (String , FunctionIndex ) = .empty ,
213
- /// Tracks the value at the end of prelink.
214
- function_exports_len : u32 = 0 ,
213
+ hidden_function_exports : std .AutoArrayHashMapUnmanaged (String , FunctionIndex ) = .empty ,
215
214
global_exports : std .ArrayListUnmanaged (GlobalExport ) = .empty ,
216
215
/// Tracks the value at the end of prelink.
217
216
global_exports_len : u32 = 0 ,
@@ -360,9 +359,8 @@ pub const FunctionIndex = enum(u32) {
360
359
if (wasm .object_function_imports .getPtr (name )) | import | {
361
360
return fromResolution (wasm , import .resolution );
362
361
}
363
- if (wasm .function_exports .get (name )) | index | {
364
- return index ;
365
- }
362
+ if (wasm .function_exports .get (name )) | index | return index ;
363
+ if (wasm .hidden_function_exports .get (name )) | index | return index ;
366
364
return null ;
367
365
}
368
366
@@ -1919,8 +1917,11 @@ pub const DataSegmentId = enum(u32) {
1919
1917
const zcu = wasm .base .comp .zcu .? ;
1920
1918
const ip = & zcu .intern_pool ;
1921
1919
const nav = ip .getNav (i .key (wasm ).* );
1922
- return nav .getLinkSection ().toSlice (ip ) orelse
1923
- if (nav .isThreadlocal (ip )) ".tdata" else ".data" ;
1920
+ return nav .getLinkSection ().toSlice (ip ) orelse switch (category (id , wasm )) {
1921
+ .tls = > ".tdata" ,
1922
+ .data = > ".data" ,
1923
+ .zero = > ".bss" ,
1924
+ };
1924
1925
},
1925
1926
};
1926
1927
}
@@ -3110,6 +3111,7 @@ pub fn deinit(wasm: *Wasm) void {
3110
3111
3111
3112
wasm .func_types .deinit (gpa );
3112
3113
wasm .function_exports .deinit (gpa );
3114
+ wasm .hidden_function_exports .deinit (gpa );
3113
3115
wasm .function_imports .deinit (gpa );
3114
3116
wasm .functions .deinit (gpa );
3115
3117
wasm .globals .deinit (gpa );
@@ -3417,7 +3419,6 @@ pub fn prelink(wasm: *Wasm, prog_node: std.Progress.Node) link.File.FlushError!v
3417
3419
}
3418
3420
}
3419
3421
wasm .functions_end_prelink = @intCast (wasm .functions .entries .len );
3420
- wasm .function_exports_len = @intCast (wasm .function_exports .entries .len );
3421
3422
3422
3423
for (wasm .object_global_imports .keys (), wasm .object_global_imports .values (), 0.. ) | name , * import , i | {
3423
3424
if (import .flags .isIncluded (rdynamic )) {
@@ -3491,8 +3492,14 @@ fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex) link.File.FlushError!void {
3491
3492
const function = i .ptr (wasm );
3492
3493
markObject (wasm , function .object_index );
3493
3494
3494
- if (! is_obj and function .flags .isExported (rdynamic ))
3495
- try wasm .function_exports .put (gpa , function .name .unwrap ().? , @enumFromInt (gop .index ));
3495
+ if (! is_obj and function .flags .isExported (rdynamic )) {
3496
+ const symbol_name = function .name .unwrap ().? ;
3497
+ if (function .flags .visibility_hidden ) {
3498
+ try wasm .hidden_function_exports .put (gpa , symbol_name , @enumFromInt (gop .index ));
3499
+ } else {
3500
+ try wasm .function_exports .put (gpa , symbol_name , @enumFromInt (gop .index ));
3501
+ }
3502
+ }
3496
3503
3497
3504
try wasm .markRelocations (function .relocations (wasm ));
3498
3505
}
@@ -3778,6 +3785,9 @@ pub fn flushModule(
3778
3785
const function_exports_end_zcu : u32 = @intCast (wasm .function_exports .entries .len );
3779
3786
defer wasm .function_exports .shrinkRetainingCapacity (function_exports_end_zcu );
3780
3787
3788
+ const hidden_function_exports_end_zcu : u32 = @intCast (wasm .hidden_function_exports .entries .len );
3789
+ defer wasm .hidden_function_exports .shrinkRetainingCapacity (hidden_function_exports_end_zcu );
3790
+
3781
3791
wasm .flush_buffer .clear ();
3782
3792
try wasm .flush_buffer .missing_exports .reinit (gpa , wasm .missing_exports .keys (), &.{});
3783
3793
try wasm .flush_buffer .function_imports .reinit (gpa , wasm .function_imports .keys (), wasm .function_imports .values ());
0 commit comments