| ... | ... | @@ -887,32 +887,12 @@ fn resolveLazySymbols(wasm: *Wasm) !void { |
| 887 | 887 | const loc = try wasm.createSyntheticSymbol("__heap_base", .data); |
| 888 | 888 | try wasm.discarded.putNoClobber(wasm.base.allocator, kv.value, loc); |
| 889 | 889 | _ = wasm.resolved_symbols.swapRemove(loc); // we don't want to emit this symbol, only use it for relocations. |
| 890 | | |
| 891 | | // TODO: Can we use `createAtom` here while also re-using the symbol |
| 892 | | // from `createSyntheticSymbol`. |
| 893 | | const atom_index = @intCast(Atom.Index, wasm.managed_atoms.items.len); |
| 894 | | const atom = try wasm.managed_atoms.addOne(wasm.base.allocator); |
| 895 | | atom.* = Atom.empty; |
| 896 | | atom.sym_index = loc.index; |
| 897 | | atom.alignment = 1; |
| 898 | | |
| 899 | | try wasm.parseAtom(atom_index, .{ .data = .synthetic }); |
| 900 | | try wasm.symbol_atom.putNoClobber(wasm.base.allocator, loc, atom_index); |
| 901 | 890 | } |
| 902 | 891 | |
| 903 | 892 | if (wasm.undefs.fetchSwapRemove("__heap_end")) |kv| { |
| 904 | 893 | const loc = try wasm.createSyntheticSymbol("__heap_end", .data); |
| 905 | 894 | try wasm.discarded.putNoClobber(wasm.base.allocator, kv.value, loc); |
| 906 | 895 | _ = wasm.resolved_symbols.swapRemove(loc); |
| 907 | | |
| 908 | | const atom_index = @intCast(Atom.Index, wasm.managed_atoms.items.len); |
| 909 | | const atom = try wasm.managed_atoms.addOne(wasm.base.allocator); |
| 910 | | atom.* = Atom.empty; |
| 911 | | atom.sym_index = loc.index; |
| 912 | | atom.alignment = 1; |
| 913 | | |
| 914 | | try wasm.parseAtom(atom_index, .{ .data = .synthetic }); |
| 915 | | try wasm.symbol_atom.putNoClobber(wasm.base.allocator, loc, atom_index); |
| 916 | 896 | } |
| 917 | 897 | } |
| 918 | 898 | |
| ... | ... | @@ -1614,7 +1594,6 @@ const Kind = union(enum) { |
| 1614 | 1594 | read_only, |
| 1615 | 1595 | uninitialized, |
| 1616 | 1596 | initialized, |
| 1617 | | synthetic, |
| 1618 | 1597 | }, |
| 1619 | 1598 | function: void, |
| 1620 | 1599 | |
| ... | ... | @@ -1625,7 +1604,6 @@ const Kind = union(enum) { |
| 1625 | 1604 | .read_only => return ".rodata.", |
| 1626 | 1605 | .uninitialized => return ".bss.", |
| 1627 | 1606 | .initialized => return ".data.", |
| 1628 | | .synthetic => return ".synthetic", |
| 1629 | 1607 | } |
| 1630 | 1608 | } |
| 1631 | 1609 | }; |
| ... | ... | @@ -1833,7 +1811,6 @@ fn sortDataSegments(wasm: *Wasm) !void { |
| 1833 | 1811 | if (mem.startsWith(u8, name, ".rodata")) return 0; |
| 1834 | 1812 | if (mem.startsWith(u8, name, ".data")) return 1; |
| 1835 | 1813 | if (mem.startsWith(u8, name, ".text")) return 2; |
| 1836 | | if (mem.startsWith(u8, name, ".synthetic")) return 100; // always at end |
| 1837 | 1814 | return 3; |
| 1838 | 1815 | } |
| 1839 | 1816 | }; |
| ... | ... | @@ -2245,10 +2222,6 @@ fn setupMemory(wasm: *Wasm) !void { |
| 2245 | 2222 | var offset: u32 = @intCast(u32, memory_ptr); |
| 2246 | 2223 | var data_seg_it = wasm.data_segments.iterator(); |
| 2247 | 2224 | while (data_seg_it.next()) |entry| { |
| 2248 | | if (mem.eql(u8, entry.key_ptr.*, ".synthetic")) { |
| 2249 | | // do not update synthetic segments as they are not part of the output |
| 2250 | | continue; |
| 2251 | | } |
| 2252 | 2225 | const segment = &wasm.segments.items[entry.value_ptr.*]; |
| 2253 | 2226 | memory_ptr = std.mem.alignForwardGeneric(u64, memory_ptr, segment.alignment); |
| 2254 | 2227 | memory_ptr += segment.size; |
| ... | ... | @@ -3447,8 +3420,6 @@ fn emitNameSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), arena: std.mem |
| 3447 | 3420 | // bss section is not emitted when this condition holds true, so we also |
| 3448 | 3421 | // do not output a name for it. |
| 3449 | 3422 | if (!wasm.base.options.import_memory and std.mem.eql(u8, key, ".bss")) continue; |
| 3450 | | // Synthetic segments are not emitted |
| 3451 | | if (std.mem.eql(u8, key, ".synthetic")) continue; |
| 3452 | 3423 | segments.appendAssumeCapacity(.{ .index = data_segment_index, .name = key }); |
| 3453 | 3424 | data_segment_index += 1; |
| 3454 | 3425 | } |