| ... | ... | @@ -1778,14 +1778,16 @@ pub const ObjectDataImport = extern struct { |
| 1778 | 1778 | __zig_error_name_table, |
| 1779 | 1779 | __zig_tag_names, |
| 1780 | 1780 | __zig_tag_name_table, |
| 1781 | __global_base, |
| 1781 | 1782 | __heap_base, |
| 1782 | 1783 | __heap_end, |
| 1784 | __wasm_first_page_end, |
| 1783 | 1785 | /// Next, an `ObjectData.Index`. |
| 1784 | 1786 | /// Next, index into `uavs_obj` or `uavs_exe` depending on whether emitting an object. |
| 1785 | 1787 | /// Next, index into `navs_obj` or `navs_exe` depending on whether emitting an object. |
| 1786 | 1788 | _, |
| 1787 | 1789 | |
| 1788 | | const first_object = @backingInt(Resolution.__heap_end) + 1; |
| 1790 | const first_object = @backingInt(Resolution.__wasm_first_page_end) + 1; |
| 1789 | 1791 | |
| 1790 | 1792 | pub const Unpacked = union(enum) { |
| 1791 | 1793 | unresolved, |
| ... | ... | @@ -1793,8 +1795,10 @@ pub const ObjectDataImport = extern struct { |
| 1793 | 1795 | __zig_error_name_table, |
| 1794 | 1796 | __zig_tag_names, |
| 1795 | 1797 | __zig_tag_name_table, |
| 1798 | __global_base, |
| 1796 | 1799 | __heap_base, |
| 1797 | 1800 | __heap_end, |
| 1801 | __wasm_first_page_end, |
| 1798 | 1802 | object: ObjectData.Index, |
| 1799 | 1803 | uav_exe: UavsExeIndex, |
| 1800 | 1804 | uav_obj: UavsObjIndex, |
| ... | ... | @@ -1809,8 +1813,10 @@ pub const ObjectDataImport = extern struct { |
| 1809 | 1813 | .__zig_error_name_table => .__zig_error_name_table, |
| 1810 | 1814 | .__zig_tag_names => .__zig_tag_names, |
| 1811 | 1815 | .__zig_tag_name_table => .__zig_tag_name_table, |
| 1816 | .__global_base => .__global_base, |
| 1812 | 1817 | .__heap_base => .__heap_base, |
| 1813 | 1818 | .__heap_end => .__heap_end, |
| 1819 | .__wasm_first_page_end => .__wasm_first_page_end, |
| 1814 | 1820 | _ => { |
| 1815 | 1821 | const object_index = @backingInt(r) - first_object; |
| 1816 | 1822 | |
| ... | ... | @@ -1847,8 +1853,10 @@ pub const ObjectDataImport = extern struct { |
| 1847 | 1853 | .__zig_error_name_table => .__zig_error_name_table, |
| 1848 | 1854 | .__zig_tag_names => .__zig_tag_names, |
| 1849 | 1855 | .__zig_tag_name_table => .__zig_tag_name_table, |
| 1856 | .__global_base => .__global_base, |
| 1850 | 1857 | .__heap_base => .__heap_base, |
| 1851 | 1858 | .__heap_end => .__heap_end, |
| 1859 | .__wasm_first_page_end => .__wasm_first_page_end, |
| 1852 | 1860 | .object => |i| @fromBackingInt(@intCast(first_object + @backingInt(i))), |
| 1853 | 1861 | inline .uav_exe, .uav_obj => |i| @fromBackingInt(@intCast(first_object + wasm.object_datas.items.len + @backingInt(i))), |
| 1854 | 1862 | .nav_exe => |i| @fromBackingInt(@intCast(first_object + wasm.object_datas.items.len + wasm.uavs_exe.entries.len + @backingInt(i))), |
| ... | ... | @@ -1886,8 +1894,10 @@ pub const ObjectDataImport = extern struct { |
| 1886 | 1894 | .__zig_error_name_table, |
| 1887 | 1895 | .__zig_tag_names, |
| 1888 | 1896 | .__zig_tag_name_table, |
| 1897 | .__global_base, |
| 1889 | 1898 | .__heap_base, |
| 1890 | 1899 | .__heap_end, |
| 1900 | .__wasm_first_page_end, |
| 1891 | 1901 | .uav_exe, |
| 1892 | 1902 | .uav_obj, |
| 1893 | 1903 | .nav_exe, |
| ... | ... | @@ -1910,8 +1920,11 @@ pub const ObjectDataImport = extern struct { |
| 1910 | 1920 | .__zig_error_name_table => .{ .segment = .__zig_error_name_table, .offset = 0 }, |
| 1911 | 1921 | .__zig_tag_names => .{ .segment = .__zig_tag_names, .offset = 0 }, |
| 1912 | 1922 | .__zig_tag_name_table => .{ .segment = .__zig_tag_name_table, .offset = 0 }, |
| 1913 | | .__heap_base => .{ .segment = .__heap_base, .offset = 0 }, |
| 1914 | | .__heap_end => .{ .segment = .__heap_end, .offset = 0 }, |
| 1923 | .__global_base, |
| 1924 | .__heap_base, |
| 1925 | .__heap_end, |
| 1926 | .__wasm_first_page_end, |
| 1927 | => unreachable, |
| 1915 | 1928 | .uav_exe => |i| .{ .segment = .pack(wasm, .{ .uav_exe = i }), .offset = 0 }, |
| 1916 | 1929 | .uav_obj => |i| .{ .segment = .pack(wasm, .{ .uav_obj = i }), .offset = 0 }, |
| 1917 | 1930 | .nav_exe => |i| .{ .segment = .pack(wasm, .{ .nav_exe = i }), .offset = 0 }, |
| ... | ... | @@ -1927,8 +1940,10 @@ pub const ObjectDataImport = extern struct { |
| 1927 | 1940 | .__zig_tag_names, |
| 1928 | 1941 | .__zig_tag_name_table, |
| 1929 | 1942 | => .{ .binding = .local }, |
| 1943 | .__global_base, |
| 1930 | 1944 | .__heap_base, |
| 1931 | 1945 | .__heap_end, |
| 1946 | .__wasm_first_page_end, |
| 1932 | 1947 | => unreachable, |
| 1933 | 1948 | .object => |i| i.ptr(wasm).flags, |
| 1934 | 1949 | inline .nav_exe, .nav_obj => |i| { |
| ... | ... | @@ -1976,8 +1991,10 @@ pub const ObjectDataImport = extern struct { |
| 1976 | 1991 | .__zig_error_name_table => @tagName(.__zig_error_name_table), |
| 1977 | 1992 | .__zig_tag_names => @tagName(.__zig_tag_names), |
| 1978 | 1993 | .__zig_tag_name_table => @tagName(.__zig_tag_name_table), |
| 1994 | .__global_base => @tagName(.__global_base), |
| 1979 | 1995 | .__heap_base => @tagName(.__heap_base), |
| 1980 | 1996 | .__heap_end => @tagName(.__heap_end), |
| 1997 | .__wasm_first_page_end => @tagName(.__wasm_first_page_end), |
| 1981 | 1998 | inline .uav_exe, .uav_obj => |i| std.fmt.bufPrint( |
| 1982 | 1999 | buf, |
| 1983 | 2000 | "__anon_{d}", |
| ... | ... | @@ -2006,7 +2023,7 @@ pub const ObjectDataImport = extern struct { |
| 2006 | 2023 | const elem_size = Zcu.Type.slice_const_u8_sentinel_0.abiSize(zcu); |
| 2007 | 2024 | return @intCast(table_len * elem_size); |
| 2008 | 2025 | }, |
| 2009 | | .__heap_base, .__heap_end => wasm.pointerSize(), |
| 2026 | .__global_base, .__heap_base, .__heap_end, .__wasm_first_page_end => 0, |
| 2010 | 2027 | .object => |i| i.ptr(wasm).size, |
| 2011 | 2028 | inline .uav_exe, .uav_obj, .nav_exe, .nav_obj => |i| i.value(wasm).code.len, |
| 2012 | 2029 | }; |
| ... | ... | @@ -2056,17 +2073,12 @@ pub const DataSegmentId = enum(u32) { |
| 2056 | 2073 | __zig_tag_names, |
| 2057 | 2074 | /// All tag name slices for all `@tagName` implementations, concatenated together. |
| 2058 | 2075 | __zig_tag_name_table, |
| 2059 | | /// This and `__heap_end` are better retrieved via a global, but there is |
| 2060 | | /// some suboptimal code out there (wasi libc) that additionally needs them |
| 2061 | | /// as data symbols. |
| 2062 | | __heap_base, |
| 2063 | | __heap_end, |
| 2064 | 2076 | /// First, an `ObjectDataSegment.Index`. |
| 2065 | 2077 | /// Next, index into `uavs_obj` or `uavs_exe` depending on whether emitting an object. |
| 2066 | 2078 | /// Next, index into `navs_obj` or `navs_exe` depending on whether emitting an object. |
| 2067 | 2079 | _, |
| 2068 | 2080 | |
| 2069 | | const first_object = @backingInt(DataSegmentId.__heap_end) + 1; |
| 2081 | const first_object = @backingInt(DataSegmentId.__zig_tag_name_table) + 1; |
| 2070 | 2082 | |
| 2071 | 2083 | pub const Category = enum { |
| 2072 | 2084 | /// Thread-local variables. |
| ... | ... | @@ -2083,8 +2095,6 @@ pub const DataSegmentId = enum(u32) { |
| 2083 | 2095 | __zig_error_name_table, |
| 2084 | 2096 | __zig_tag_names, |
| 2085 | 2097 | __zig_tag_name_table, |
| 2086 | | __heap_base, |
| 2087 | | __heap_end, |
| 2088 | 2098 | object: ObjectDataSegment.Index, |
| 2089 | 2099 | uav_exe: UavsExeIndex, |
| 2090 | 2100 | uav_obj: UavsObjIndex, |
| ... | ... | @@ -2098,8 +2108,6 @@ pub const DataSegmentId = enum(u32) { |
| 2098 | 2108 | .__zig_error_name_table => .__zig_error_name_table, |
| 2099 | 2109 | .__zig_tag_names => .__zig_tag_names, |
| 2100 | 2110 | .__zig_tag_name_table => .__zig_tag_name_table, |
| 2101 | | .__heap_base => .__heap_base, |
| 2102 | | .__heap_end => .__heap_end, |
| 2103 | 2111 | .object => |i| @fromBackingInt(@intCast(first_object + @backingInt(i))), |
| 2104 | 2112 | inline .uav_exe, .uav_obj => |i| @fromBackingInt(@intCast(first_object + wasm.object_data_segments.items.len + @backingInt(i))), |
| 2105 | 2113 | .nav_exe => |i| @fromBackingInt(@intCast(first_object + wasm.object_data_segments.items.len + wasm.uavs_exe.entries.len + @backingInt(i))), |
| ... | ... | @@ -2113,8 +2121,6 @@ pub const DataSegmentId = enum(u32) { |
| 2113 | 2121 | .__zig_error_name_table => .__zig_error_name_table, |
| 2114 | 2122 | .__zig_tag_names => .__zig_tag_names, |
| 2115 | 2123 | .__zig_tag_name_table => .__zig_tag_name_table, |
| 2116 | | .__heap_base => .__heap_base, |
| 2117 | | .__heap_end => .__heap_end, |
| 2118 | 2124 | _ => { |
| 2119 | 2125 | const object_index = @backingInt(id) - first_object; |
| 2120 | 2126 | |
| ... | ... | @@ -2164,8 +2170,6 @@ pub const DataSegmentId = enum(u32) { |
| 2164 | 2170 | .__zig_error_name_table, |
| 2165 | 2171 | .__zig_tag_names, |
| 2166 | 2172 | .__zig_tag_name_table, |
| 2167 | | .__heap_base, |
| 2168 | | .__heap_end, |
| 2169 | 2173 | => .data, |
| 2170 | 2174 | |
| 2171 | 2175 | .object => |i| { |
| ... | ... | @@ -2192,8 +2196,6 @@ pub const DataSegmentId = enum(u32) { |
| 2192 | 2196 | .__zig_error_name_table, |
| 2193 | 2197 | .__zig_tag_names, |
| 2194 | 2198 | .__zig_tag_name_table, |
| 2195 | | .__heap_base, |
| 2196 | | .__heap_end, |
| 2197 | 2199 | => false, |
| 2198 | 2200 | |
| 2199 | 2201 | .object => |i| i.ptr(wasm).flags.tls, |
| ... | ... | @@ -2213,8 +2215,6 @@ pub const DataSegmentId = enum(u32) { |
| 2213 | 2215 | |
| 2214 | 2216 | .__zig_error_name_table, |
| 2215 | 2217 | .__zig_tag_name_table, |
| 2216 | | .__heap_base, |
| 2217 | | .__heap_end, |
| 2218 | 2218 | => false, |
| 2219 | 2219 | |
| 2220 | 2220 | .object => |i| i.ptr(wasm).flags.strings, |
| ... | ... | @@ -2229,8 +2229,6 @@ pub const DataSegmentId = enum(u32) { |
| 2229 | 2229 | .__zig_error_name_table, |
| 2230 | 2230 | .__zig_tag_names, |
| 2231 | 2231 | .__zig_tag_name_table, |
| 2232 | | .__heap_base, |
| 2233 | | .__heap_end, |
| 2234 | 2232 | => false, |
| 2235 | 2233 | |
| 2236 | 2234 | .object => |i| i.ptr(wasm).flags.retain, |
| ... | ... | @@ -2251,8 +2249,6 @@ pub const DataSegmentId = enum(u32) { |
| 2251 | 2249 | .__zig_tag_name_table, |
| 2252 | 2250 | .uav_exe, |
| 2253 | 2251 | .uav_obj, |
| 2254 | | .__heap_base, |
| 2255 | | .__heap_end, |
| 2256 | 2252 | => ".data", |
| 2257 | 2253 | |
| 2258 | 2254 | .object => |i| i.ptr(wasm).name.unwrap().?.slice(wasm), |
| ... | ... | @@ -2272,7 +2268,7 @@ pub const DataSegmentId = enum(u32) { |
| 2272 | 2268 | pub fn alignment(id: DataSegmentId, wasm: *const Wasm) Alignment { |
| 2273 | 2269 | return switch (unpack(id, wasm)) { |
| 2274 | 2270 | .__zig_error_names, .__zig_tag_names => .@"1", |
| 2275 | | .__zig_error_name_table, .__zig_tag_name_table, .__heap_base, .__heap_end => wasm.pointerAlignment(), |
| 2271 | .__zig_error_name_table, .__zig_tag_name_table => wasm.pointerAlignment(), |
| 2276 | 2272 | .object => |i| i.ptr(wasm).flags.alignment, |
| 2277 | 2273 | inline .uav_exe, .uav_obj => |i| { |
| 2278 | 2274 | const zcu = wasm.base.comp.zcu.?; |
| ... | ... | @@ -2304,7 +2300,7 @@ pub const DataSegmentId = enum(u32) { |
| 2304 | 2300 | .__zig_error_name_table => wasm.error_name_table_ref_count, |
| 2305 | 2301 | .__zig_tag_names => @intCast(wasm.tag_name_offs.items.len), |
| 2306 | 2302 | .__zig_tag_name_table => wasm.tag_name_table_ref_count, |
| 2307 | | .object, .uav_obj, .nav_obj, .__heap_base, .__heap_end => 0, |
| 2303 | .object, .uav_obj, .nav_obj => 0, |
| 2308 | 2304 | inline .uav_exe, .nav_exe => |i| i.value(wasm).count, |
| 2309 | 2305 | }; |
| 2310 | 2306 | } |
| ... | ... | @@ -2317,8 +2313,6 @@ pub const DataSegmentId = enum(u32) { |
| 2317 | 2313 | .__zig_error_name_table, |
| 2318 | 2314 | .__zig_tag_names, |
| 2319 | 2315 | .__zig_tag_name_table, |
| 2320 | | .__heap_base, |
| 2321 | | .__heap_end, |
| 2322 | 2316 | => false, |
| 2323 | 2317 | |
| 2324 | 2318 | .object => |i| i.ptr(wasm).flags.is_passive, |
| ... | ... | @@ -2332,8 +2326,6 @@ pub const DataSegmentId = enum(u32) { |
| 2332 | 2326 | .__zig_error_name_table, |
| 2333 | 2327 | .__zig_tag_names, |
| 2334 | 2328 | .__zig_tag_name_table, |
| 2335 | | .__heap_base, |
| 2336 | | .__heap_end, |
| 2337 | 2329 | => false, |
| 2338 | 2330 | |
| 2339 | 2331 | .object => |i| i.ptr(wasm).payload.off == .none, |
| ... | ... | @@ -2359,7 +2351,6 @@ pub const DataSegmentId = enum(u32) { |
| 2359 | 2351 | const elem_size = Zcu.Type.slice_const_u8_sentinel_0.abiSize(zcu); |
| 2360 | 2352 | return @intCast(table_len * elem_size); |
| 2361 | 2353 | }, |
| 2362 | | .__heap_base, .__heap_end => wasm.pointerSize(), |
| 2363 | 2354 | .object => |i| i.ptr(wasm).payload.len, |
| 2364 | 2355 | inline .uav_exe, .uav_obj, .nav_exe, .nav_obj => |i| i.value(wasm).code.len, |
| 2365 | 2356 | }; |
| ... | ... | @@ -2491,6 +2482,7 @@ pub const Func = extern struct { |
| 2491 | 2482 | /// Type reflection is used on the field names to autopopulate each field |
| 2492 | 2483 | /// during initialization. |
| 2493 | 2484 | const PreloadedStrings = struct { |
| 2485 | __global_base: String, |
| 2494 | 2486 | __heap_base: String, |
| 2495 | 2487 | __heap_end: String, |
| 2496 | 2488 | __indirect_function_table: String, |
| ... | ... | @@ -2504,6 +2496,7 @@ const PreloadedStrings = struct { |
| 2504 | 2496 | __wasm_init_memory: String, |
| 2505 | 2497 | __wasm_init_memory_flag: String, |
| 2506 | 2498 | __wasm_init_tls: String, |
| 2499 | __wasm_first_page_end: String, |
| 2507 | 2500 | __zig_error_names: String, |
| 2508 | 2501 | __zig_error_name_table: String, |
| 2509 | 2502 | __zig_errors_len: String, |
| ... | ... | @@ -3907,21 +3900,11 @@ pub fn prelink(wasm: *Wasm, prog_node: std.Progress.Node) link.Error!void { |
| 3907 | 3900 | try markFunctionImport(wasm, name, import, @fromBackingInt(@intCast(i))); |
| 3908 | 3901 | } |
| 3909 | 3902 | } |
| 3910 | | // Also treat init functions as roots. |
| 3911 | | for (wasm.object_init_funcs.items) |init_func| { |
| 3912 | | const func = init_func.function_index.ptr(wasm); |
| 3913 | | if (func.object_index.ptr(wasm).is_included) { |
| 3914 | | try markFunction(wasm, init_func.function_index, false); |
| 3915 | | } |
| 3916 | | } |
| 3917 | | wasm.functions_end_prelink = @intCast(wasm.functions.entries.len); |
| 3918 | | |
| 3919 | 3903 | for (wasm.object_global_imports.keys(), wasm.object_global_imports.values(), 0..) |name, *import, i| { |
| 3920 | 3904 | if (import.flags.isIncluded(rdynamic, is_obj)) { |
| 3921 | 3905 | try markGlobalImport(wasm, name, import, @fromBackingInt(@intCast(i))); |
| 3922 | 3906 | } |
| 3923 | 3907 | } |
| 3924 | | wasm.globals_end_prelink = @intCast(wasm.globals.entries.len); |
| 3925 | 3908 | wasm.global_exports_len = @intCast(wasm.global_exports.items.len); |
| 3926 | 3909 | |
| 3927 | 3910 | for (wasm.object_table_imports.keys(), wasm.object_table_imports.values(), 0..) |name, *import, i| { |
| ... | ... | @@ -3944,6 +3927,8 @@ pub fn prelink(wasm: *Wasm, prog_node: std.Progress.Node) link.Error!void { |
| 3944 | 3927 | wasm.memories.limits.flags.has_max = wasm.memories.limits.flags.has_max or memory_import.limits_has_max; |
| 3945 | 3928 | } |
| 3946 | 3929 | |
| 3930 | wasm.functions_end_prelink = @intCast(wasm.functions.entries.len); |
| 3931 | wasm.globals_end_prelink = @intCast(wasm.globals.entries.len); |
| 3947 | 3932 | wasm.function_imports_len_prelink = @intCast(wasm.function_imports.entries.len); |
| 3948 | 3933 | wasm.data_imports_len_prelink = @intCast(wasm.data_imports.entries.len); |
| 3949 | 3934 | } |
| ... | ... | @@ -3998,7 +3983,7 @@ fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex, override_export: bool) link |
| 3998 | 3983 | const rdynamic = comp.config.rdynamic; |
| 3999 | 3984 | const is_obj = comp.config.output_mode == .Obj; |
| 4000 | 3985 | const function = i.ptr(wasm); |
| 4001 | | markObject(wasm, function.object_index); |
| 3986 | try markObject(wasm, function.object_index); |
| 4002 | 3987 | |
| 4003 | 3988 | if (!is_obj and (override_export or function.flags.isExported(rdynamic))) { |
| 4004 | 3989 | const symbol_name = function.name.unwrap().?; |
| ... | ... | @@ -4012,8 +3997,15 @@ fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex, override_export: bool) link |
| 4012 | 3997 | try wasm.markRelocations(function.relocations(wasm)); |
| 4013 | 3998 | } |
| 4014 | 3999 | |
| 4015 | | fn markObject(wasm: *Wasm, i: ObjectIndex) void { |
| 4016 | | i.ptr(wasm).is_included = true; |
| 4000 | fn markObject(wasm: *Wasm, i: ObjectIndex) link.Error!void { |
| 4001 | const object = i.ptr(wasm); |
| 4002 | if (object.is_included) return; |
| 4003 | object.is_included = true; |
| 4004 | |
| 4005 | const init_funcs = wasm.object_init_funcs.items[object.init_funcs.off..][0..object.init_funcs.len]; |
| 4006 | for (init_funcs) |init_func| { |
| 4007 | try markFunction(wasm, init_func.function_index, false); |
| 4008 | } |
| 4017 | 4009 | } |
| 4018 | 4010 | |
| 4019 | 4011 | /// Recursively mark alive everything referenced by the global. |
| ... | ... | @@ -4076,6 +4068,7 @@ fn markGlobal(wasm: *Wasm, i: ObjectGlobalIndex, override_export: bool) link.Err |
| 4076 | 4068 | const rdynamic = comp.config.rdynamic; |
| 4077 | 4069 | const is_obj = comp.config.output_mode == .Obj; |
| 4078 | 4070 | const global = i.ptr(wasm); |
| 4071 | try markObject(wasm, global.object_index); |
| 4079 | 4072 | |
| 4080 | 4073 | if (!is_obj and (override_export or global.flags.isExported(rdynamic))) try wasm.global_exports.append(gpa, .{ |
| 4081 | 4074 | .name = global.name.unwrap().?, |
| ... | ... | @@ -4122,6 +4115,7 @@ fn markDataSegment(wasm: *Wasm, segment_index: ObjectDataSegment.Index) link.Err |
| 4122 | 4115 | const segment = segment_index.ptr(wasm); |
| 4123 | 4116 | if (segment.flags.alive) return; |
| 4124 | 4117 | segment.flags.alive = true; |
| 4118 | try markObject(wasm, segment.object_index); |
| 4125 | 4119 | |
| 4126 | 4120 | wasm.any_passive_inits = wasm.any_passive_inits or segment.flags.is_passive or |
| 4127 | 4121 | (comp.config.import_memory and !wasm.isBss(segment.name)); |
| ... | ... | @@ -4143,16 +4137,16 @@ pub fn markDataImport( |
| 4143 | 4137 | const gpa = comp.gpa; |
| 4144 | 4138 | const is_obj = comp.config.output_mode == .Obj; |
| 4145 | 4139 | |
| 4146 | | try wasm.data_segments.ensureUnusedCapacity(gpa, 1); |
| 4147 | | |
| 4148 | 4140 | if (import.resolution == .unresolved) { |
| 4149 | 4141 | if (!is_obj) { |
| 4150 | | if (name == wasm.preloaded_strings.__heap_base) { |
| 4142 | if (name == wasm.preloaded_strings.__global_base) { |
| 4143 | import.resolution = .__global_base; |
| 4144 | } else if (name == wasm.preloaded_strings.__heap_base) { |
| 4151 | 4145 | import.resolution = .__heap_base; |
| 4152 | | wasm.data_segments.putAssumeCapacity(.__heap_base, {}); |
| 4153 | 4146 | } else if (name == wasm.preloaded_strings.__heap_end) { |
| 4154 | 4147 | import.resolution = .__heap_end; |
| 4155 | | wasm.data_segments.putAssumeCapacity(.__heap_end, {}); |
| 4148 | } else if (name == wasm.preloaded_strings.__wasm_first_page_end) { |
| 4149 | import.resolution = .__wasm_first_page_end; |
| 4156 | 4150 | } else { |
| 4157 | 4151 | try wasm.data_imports.put(gpa, name, .fromObject(data_index, wasm)); |
| 4158 | 4152 | } |
| ... | ... | @@ -4857,6 +4851,17 @@ pub fn uavAddr(wasm: *const Wasm, ip_index: InternPool.Index) u32 { |
| 4857 | 4851 | return wasm.flush_buffer.data_segments.get(ds_id).?; |
| 4858 | 4852 | } |
| 4859 | 4853 | |
| 4854 | pub fn syntheticDataAddr(wasm: *const Wasm, resolution: ObjectDataImport.Resolution) ?u32 { |
| 4855 | const virtual_addrs = wasm.flush_buffer.virtual_addrs; |
| 4856 | return switch (resolution.unpack(wasm)) { |
| 4857 | .__global_base => virtual_addrs.global_base, |
| 4858 | .__heap_base => virtual_addrs.heap_base, |
| 4859 | .__heap_end => virtual_addrs.heap_end, |
| 4860 | .__wasm_first_page_end => virtual_addrs.wasm_first_page_end, |
| 4861 | else => null, |
| 4862 | }; |
| 4863 | } |
| 4864 | |
| 4860 | 4865 | /// Asserts it is called after `Flush.data_segments` is fully populated and sorted. |
| 4861 | 4866 | pub fn navAddr(wasm: *const Wasm, nav_index: InternPool.Nav.Index) u32 { |
| 4862 | 4867 | assert(wasm.flush_buffer.memory_layout_finished); |
| ... | ... | @@ -4881,8 +4886,11 @@ pub fn navAddr(wasm: *const Wasm, nav_index: InternPool.Nav.Index) u32 { |
| 4881 | 4886 | const segment_base_addr = wasm.flush_buffer.data_segments.get(ds_id).?; |
| 4882 | 4887 | return segment_base_addr + object_data.offset; |
| 4883 | 4888 | }, |
| 4889 | .__global_base, |
| 4884 | 4890 | .__heap_base, |
| 4885 | 4891 | .__heap_end, |
| 4892 | .__wasm_first_page_end, |
| 4893 | => return wasm.syntheticDataAddr(import.resolution).?, |
| 4886 | 4894 | .uav_exe, |
| 4887 | 4895 | .nav_exe, |
| 4888 | 4896 | => { |