| ... | ... | @@ -79,6 +79,7 @@ growable_table: bool, |
| 79 | 79 | name: []const u8, |
| 80 | 80 | /// List of relocatable files to be linked into the final binary. |
| 81 | 81 | objects: std.ArrayList(Object) = .empty, |
| 82 | archive_builder: Archive.Builder = .{}, |
| 82 | 83 | |
| 83 | 84 | func_types: std.array_hash_map.Auto(FunctionType, void) = .empty, |
| 84 | 85 | /// Provides a mapping of both imports and provided functions to symbol name. |
| ... | ... | @@ -467,8 +468,7 @@ pub const OutputDataIndex = enum(u32) { |
| 467 | 468 | } |
| 468 | 469 | |
| 469 | 470 | pub fn fromUav(wasm: *const Wasm, ip_index: InternPool.Index) OutputDataIndex { |
| 470 | | const comp = wasm.base.comp; |
| 471 | | const resolution: ObjectDataImport.Resolution = if (comp.config.output_mode == .Obj) |
| 471 | const resolution: ObjectDataImport.Resolution = if (wasm.base.isRelocatable()) |
| 472 | 472 | .pack(wasm, .{ .uav_obj = @fromBackingInt(@intCast(wasm.uavs_obj.getIndex(ip_index).?)) }) |
| 473 | 473 | else |
| 474 | 474 | .pack(wasm, .{ .uav_exe = @fromBackingInt(@intCast(wasm.uavs_exe.getIndex(ip_index).?)) }); |
| ... | ... | @@ -482,7 +482,7 @@ pub const OutputDataIndex = enum(u32) { |
| 482 | 482 | if (nav.getExtern(ip) != null) { |
| 483 | 483 | return fromSymbolName(wasm, wasm.imports.get(nav_index).?); |
| 484 | 484 | } |
| 485 | | const resolution: ObjectDataImport.Resolution = if (wasm.base.comp.config.output_mode == .Obj) |
| 485 | const resolution: ObjectDataImport.Resolution = if (wasm.base.isRelocatable()) |
| 486 | 486 | .pack(wasm, .{ .nav_obj = @fromBackingInt(@intCast(wasm.navs_obj.getIndex(nav_index).?)) }) |
| 487 | 487 | else |
| 488 | 488 | .pack(wasm, .{ .nav_exe = @fromBackingInt(@intCast(wasm.navs_exe.getIndex(nav_index).?)) }); |
| ... | ... | @@ -500,7 +500,7 @@ pub const GlobalIndex = enum(u32) { |
| 500 | 500 | /// Same as `stack_pointer` but with a safety assertion. |
| 501 | 501 | pub fn stackPointer(wasm: *const Wasm) ObjectGlobal.Index { |
| 502 | 502 | const comp = wasm.base.comp; |
| 503 | | assert(comp.config.output_mode != .Obj); |
| 503 | assert(!wasm.base.isRelocatable()); |
| 504 | 504 | assert(comp.zcu != null); |
| 505 | 505 | return .stack_pointer; |
| 506 | 506 | } |
| ... | ... | @@ -879,8 +879,7 @@ const ZcuDataStarts = struct { |
| 879 | 879 | uavs_i: u32, |
| 880 | 880 | |
| 881 | 881 | fn init(wasm: *const Wasm) ZcuDataStarts { |
| 882 | | const comp = wasm.base.comp; |
| 883 | | const is_obj = comp.config.output_mode == .Obj; |
| 882 | const is_obj = wasm.base.isRelocatable(); |
| 884 | 883 | return if (is_obj) initObj(wasm) else initExe(wasm); |
| 885 | 884 | } |
| 886 | 885 | |
| ... | ... | @@ -897,8 +896,7 @@ const ZcuDataStarts = struct { |
| 897 | 896 | } |
| 898 | 897 | |
| 899 | 898 | fn finish(zds: ZcuDataStarts, wasm: *Wasm, pt: Zcu.PerThread) !void { |
| 900 | | const comp = wasm.base.comp; |
| 901 | | const is_obj = comp.config.output_mode == .Obj; |
| 899 | const is_obj = wasm.base.isRelocatable(); |
| 902 | 900 | return if (is_obj) finishObj(zds, wasm, pt) else finishExe(zds, wasm, pt); |
| 903 | 901 | } |
| 904 | 902 | |
| ... | ... | @@ -1276,8 +1274,7 @@ pub const GlobalImport = extern struct { |
| 1276 | 1274 | const object_global_index = i - first_object_global; |
| 1277 | 1275 | if (object_global_index < wasm.object_globals.items.len) |
| 1278 | 1276 | return .{ .object_global = @fromBackingInt(@intCast(object_global_index)) }; |
| 1279 | | const comp = wasm.base.comp; |
| 1280 | | const is_obj = comp.config.output_mode == .Obj; |
| 1277 | const is_obj = wasm.base.isRelocatable(); |
| 1281 | 1278 | const uav_index = object_global_index - wasm.object_globals.items.len; |
| 1282 | 1279 | if (is_obj) { |
| 1283 | 1280 | if (uav_index < wasm.uavs_obj.entries.len) { |
| ... | ... | @@ -1323,7 +1320,7 @@ pub const GlobalImport = extern struct { |
| 1323 | 1320 | } |
| 1324 | 1321 | |
| 1325 | 1322 | pub fn fromIpIndex(wasm: *const Wasm, ip_index: InternPool.Index) Resolution { |
| 1326 | | const is_obj = wasm.base.comp.config.output_mode == .Obj; |
| 1323 | const is_obj = wasm.base.isRelocatable(); |
| 1327 | 1324 | return pack(wasm, if (is_obj) .{ |
| 1328 | 1325 | .uav_obj = @fromBackingInt(@intCast(wasm.uavs_obj.getIndex(ip_index).?)), |
| 1329 | 1326 | } else .{ |
| ... | ... | @@ -1332,8 +1329,7 @@ pub const GlobalImport = extern struct { |
| 1332 | 1329 | } |
| 1333 | 1330 | |
| 1334 | 1331 | pub fn fromIpNav(wasm: *const Wasm, ip_nav: InternPool.Nav.Index) Resolution { |
| 1335 | | const comp = wasm.base.comp; |
| 1336 | | const is_obj = comp.config.output_mode == .Obj; |
| 1332 | const is_obj = wasm.base.isRelocatable(); |
| 1337 | 1333 | return pack(wasm, if (is_obj) .{ |
| 1338 | 1334 | .nav_obj = @fromBackingInt(@intCast(wasm.navs_obj.getIndex(ip_nav).?)), |
| 1339 | 1335 | } else .{ |
| ... | ... | @@ -1819,8 +1815,7 @@ pub const ObjectDataImport = extern struct { |
| 1819 | 1815 | else |
| 1820 | 1816 | object_index - wasm.object_datas.items.len; |
| 1821 | 1817 | |
| 1822 | | const comp = wasm.base.comp; |
| 1823 | | const is_obj = comp.config.output_mode == .Obj; |
| 1818 | const is_obj = wasm.base.isRelocatable(); |
| 1824 | 1819 | if (is_obj) { |
| 1825 | 1820 | const nav_index = if (uav_index < wasm.uavs_obj.entries.len) |
| 1826 | 1821 | return .{ .uav_obj = @fromBackingInt(@intCast(uav_index)) } |
| ... | ... | @@ -1863,7 +1858,7 @@ pub const ObjectDataImport = extern struct { |
| 1863 | 1858 | } |
| 1864 | 1859 | |
| 1865 | 1860 | pub fn fromIpIndex(wasm: *const Wasm, ip_index: InternPool.Index) Resolution { |
| 1866 | | const is_obj = wasm.base.comp.config.output_mode == .Obj; |
| 1861 | const is_obj = wasm.base.isRelocatable(); |
| 1867 | 1862 | return pack(wasm, if (is_obj) .{ |
| 1868 | 1863 | .uav_obj = @fromBackingInt(@intCast(wasm.uavs_obj.getIndex(ip_index).?)), |
| 1869 | 1864 | } else .{ |
| ... | ... | @@ -1872,7 +1867,7 @@ pub const ObjectDataImport = extern struct { |
| 1872 | 1867 | } |
| 1873 | 1868 | |
| 1874 | 1869 | pub fn fromIpNav(wasm: *const Wasm, nav_index: InternPool.Nav.Index) Resolution { |
| 1875 | | const is_obj = wasm.base.comp.config.output_mode == .Obj; |
| 1870 | const is_obj = wasm.base.isRelocatable(); |
| 1876 | 1871 | return pack(wasm, if (is_obj) .{ |
| 1877 | 1872 | .nav_obj = @fromBackingInt(@intCast(wasm.navs_obj.getIndex(nav_index).?)), |
| 1878 | 1873 | } else .{ |
| ... | ... | @@ -2117,8 +2112,7 @@ pub const DataSegmentId = enum(u32) { |
| 2117 | 2112 | else |
| 2118 | 2113 | object_index - wasm.object_data_segments.items.len; |
| 2119 | 2114 | |
| 2120 | | const comp = wasm.base.comp; |
| 2121 | | const is_obj = comp.config.output_mode == .Obj; |
| 2115 | const is_obj = wasm.base.isRelocatable(); |
| 2122 | 2116 | if (is_obj) { |
| 2123 | 2117 | const nav_index = if (uav_index < wasm.uavs_obj.entries.len) |
| 2124 | 2118 | return .{ .uav_obj = @fromBackingInt(@intCast(uav_index)) } |
| ... | ... | @@ -2139,8 +2133,7 @@ pub const DataSegmentId = enum(u32) { |
| 2139 | 2133 | } |
| 2140 | 2134 | |
| 2141 | 2135 | pub fn fromNav(wasm: *const Wasm, nav_index: InternPool.Nav.Index) DataSegmentId { |
| 2142 | | const comp = wasm.base.comp; |
| 2143 | | const is_obj = comp.config.output_mode == .Obj; |
| 2136 | const is_obj = wasm.base.isRelocatable(); |
| 2144 | 2137 | return pack(wasm, if (is_obj) .{ |
| 2145 | 2138 | .nav_obj = @fromBackingInt(@intCast(wasm.navs_obj.getIndex(nav_index).?)), |
| 2146 | 2139 | } else .{ |
| ... | ... | @@ -2717,7 +2710,7 @@ pub const FunctionImportId = enum(u32) { |
| 2717 | 2710 | /// Asserts not emitting an object, and `Wasm.import_symbols` is false. |
| 2718 | 2711 | pub fn undefinedAllowed(id: FunctionImportId, wasm: *const Wasm) bool { |
| 2719 | 2712 | assert(!wasm.import_symbols); |
| 2720 | | assert(wasm.base.comp.config.output_mode != .Obj); |
| 2713 | assert(!wasm.base.isRelocatable()); |
| 2721 | 2714 | return switch (unpack(id, wasm)) { |
| 2722 | 2715 | .object_function_import => |i| { |
| 2723 | 2716 | const import = i.value(wasm); |
| ... | ... | @@ -3343,6 +3336,7 @@ pub fn createEmpty( |
| 3343 | 3336 | assert(target.ofmt == .wasm); |
| 3344 | 3337 | |
| 3345 | 3338 | const output_mode = comp.config.output_mode; |
| 3339 | const is_relocatable = output_mode == .Obj or (output_mode == .Lib and comp.config.link_mode == .static); |
| 3346 | 3340 | const wasi_exec_model = comp.config.wasi_exec_model; |
| 3347 | 3341 | |
| 3348 | 3342 | const wasm = try arena.create(Wasm); |
| ... | ... | @@ -3356,7 +3350,7 @@ pub fn createEmpty( |
| 3356 | 3350 | // majority of cases, and therefore express "no garbage collection" |
| 3357 | 3351 | // in terms of setting the no_strip and must_link flags on all |
| 3358 | 3352 | // symbols. |
| 3359 | | .gc_sections = options.gc_sections orelse (output_mode != .Obj), |
| 3353 | .gc_sections = options.gc_sections orelse !is_relocatable, |
| 3360 | 3354 | .print_gc_sections = options.print_gc_sections, |
| 3361 | 3355 | .stack_size = options.stack_size orelse switch (target.os.tag) { |
| 3362 | 3356 | .freestanding => 1 * 1024 * 1024, // 1 MiB |
| ... | ... | @@ -3436,6 +3430,11 @@ fn parseObject(wasm: *Wasm, obj: link.Input.Object) !void { |
| 3436 | 3430 | }; |
| 3437 | 3431 | if (n != file_contents.len) return error.UnexpectedEndOfFile; |
| 3438 | 3432 | |
| 3433 | if (wasm.base.isStaticLib()) { |
| 3434 | try wasm.archive_builder.append(gpa, std.fs.path.basename(obj.path.sub_path), file_contents); |
| 3435 | return; |
| 3436 | } |
| 3437 | |
| 3439 | 3438 | var ss: Object.ScratchSpace = .{}; |
| 3440 | 3439 | defer ss.deinit(gpa); |
| 3441 | 3440 | |
| ... | ... | @@ -3526,6 +3525,7 @@ pub fn deinit(wasm: *Wasm) void { |
| 3526 | 3525 | wasm.object_relocations_table.deinit(gpa); |
| 3527 | 3526 | wasm.object_comdat_symbols.deinit(gpa); |
| 3528 | 3527 | wasm.objects.deinit(gpa); |
| 3528 | wasm.archive_builder.deinit(gpa); |
| 3529 | 3529 | |
| 3530 | 3530 | wasm.func_types.deinit(gpa); |
| 3531 | 3531 | wasm.function_exports.deinit(gpa); |
| ... | ... | @@ -3575,7 +3575,7 @@ pub fn updateFunc( |
| 3575 | 3575 | const zcu = pt.zcu; |
| 3576 | 3576 | const gpa = zcu.gpa; |
| 3577 | 3577 | const ip = &zcu.intern_pool; |
| 3578 | | const is_obj = zcu.comp.config.output_mode == .Obj; |
| 3578 | const is_obj = wasm.base.isRelocatable(); |
| 3579 | 3579 | const target = &zcu.comp.root_mod.resolved_target.result; |
| 3580 | 3580 | const owner_nav = zcu.funcInfo(func_index).owner_nav; |
| 3581 | 3581 | log.debug("updateFunc {f}", .{ip.getNav(owner_nav).fqn.fmt(ip)}); |
| ... | ... | @@ -3656,7 +3656,7 @@ pub fn updateNav(wasm: *Wasm, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index |
| 3656 | 3656 | const nav = ip.getNav(nav_index); |
| 3657 | 3657 | const comp = wasm.base.comp; |
| 3658 | 3658 | const gpa = comp.gpa; |
| 3659 | | const is_obj = comp.config.output_mode == .Obj; |
| 3659 | const is_obj = wasm.base.isRelocatable(); |
| 3660 | 3660 | const target = &comp.root_mod.resolved_target.result; |
| 3661 | 3661 | |
| 3662 | 3662 | switch (ip.indexToKey(nav.resolved.?.value)) { |
| ... | ... | @@ -3740,7 +3740,7 @@ pub fn updateExports( |
| 3740 | 3740 | const zcu = pt.zcu; |
| 3741 | 3741 | const gpa = zcu.gpa; |
| 3742 | 3742 | const ip = &zcu.intern_pool; |
| 3743 | | const is_obj = wasm.base.comp.config.output_mode == .Obj; |
| 3743 | const is_obj = wasm.base.isRelocatable(); |
| 3744 | 3744 | |
| 3745 | 3745 | for (export_indices) |export_idx| { |
| 3746 | 3746 | const exp = export_idx.ptr(zcu); |
| ... | ... | @@ -3797,7 +3797,11 @@ pub fn loadInput(wasm: *Wasm, input: link.Input) !void { |
| 3797 | 3797 | .dso => unreachable, |
| 3798 | 3798 | .tbd => unreachable, |
| 3799 | 3799 | .object => |obj| try parseObject(wasm, obj), |
| 3800 | | .archive => |obj| try parseArchive(wasm, obj), |
| 3800 | .archive => |obj| if (wasm.base.isStaticLib()) { |
| 3801 | obj.file.close(io); // ignore archives like LLVM |
| 3802 | } else { |
| 3803 | try parseArchive(wasm, obj); |
| 3804 | }, |
| 3801 | 3805 | } |
| 3802 | 3806 | } |
| 3803 | 3807 | |
| ... | ... | @@ -3811,7 +3815,7 @@ pub fn prelink(wasm: *Wasm, prog_node: std.Progress.Node) link.Error!void { |
| 3811 | 3815 | const comp = wasm.base.comp; |
| 3812 | 3816 | const gpa = comp.gpa; |
| 3813 | 3817 | const rdynamic = comp.config.rdynamic; |
| 3814 | | const is_obj = comp.config.output_mode == .Obj; |
| 3818 | const is_obj = wasm.base.isRelocatable(); |
| 3815 | 3819 | |
| 3816 | 3820 | assert(wasm.missing_exports.entries.len == 0); |
| 3817 | 3821 | for (wasm.export_symbol_names) |exp_name| { |
| ... | ... | @@ -3915,7 +3919,7 @@ pub fn markFunctionImport( |
| 3915 | 3919 | |
| 3916 | 3920 | const comp = wasm.base.comp; |
| 3917 | 3921 | const gpa = comp.gpa; |
| 3918 | | const is_obj = comp.config.output_mode == .Obj; |
| 3922 | const is_obj = wasm.base.isRelocatable(); |
| 3919 | 3923 | |
| 3920 | 3924 | try wasm.functions.ensureUnusedCapacity(gpa, 1); |
| 3921 | 3925 | |
| ... | ... | @@ -3949,7 +3953,7 @@ fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex, override_export: bool) link |
| 3949 | 3953 | if (gop.found_existing) return; |
| 3950 | 3954 | |
| 3951 | 3955 | const rdynamic = comp.config.rdynamic; |
| 3952 | | const is_obj = comp.config.output_mode == .Obj; |
| 3956 | const is_obj = wasm.base.isRelocatable(); |
| 3953 | 3957 | const function = i.ptr(wasm); |
| 3954 | 3958 | try markObject(wasm, function.object_index); |
| 3955 | 3959 | |
| ... | ... | @@ -3991,7 +3995,7 @@ fn markGlobalImport( |
| 3991 | 3995 | |
| 3992 | 3996 | const comp = wasm.base.comp; |
| 3993 | 3997 | const gpa = comp.gpa; |
| 3994 | | const is_obj = comp.config.output_mode == .Obj; |
| 3998 | const is_obj = wasm.base.isRelocatable(); |
| 3995 | 3999 | |
| 3996 | 4000 | try wasm.globals.ensureUnusedCapacity(gpa, 1); |
| 3997 | 4001 | |
| ... | ... | @@ -4034,7 +4038,7 @@ fn markGlobal(wasm: *Wasm, i: ObjectGlobalIndex, override_export: bool) link.Err |
| 4034 | 4038 | if (gop.found_existing) return; |
| 4035 | 4039 | |
| 4036 | 4040 | const rdynamic = comp.config.rdynamic; |
| 4037 | | const is_obj = comp.config.output_mode == .Obj; |
| 4041 | const is_obj = wasm.base.isRelocatable(); |
| 4038 | 4042 | const global = i.ptr(wasm); |
| 4039 | 4043 | try markObject(wasm, global.object_index); |
| 4040 | 4044 | |
| ... | ... | @@ -4057,7 +4061,7 @@ pub fn markTableImport( |
| 4057 | 4061 | |
| 4058 | 4062 | const comp = wasm.base.comp; |
| 4059 | 4063 | const gpa = comp.gpa; |
| 4060 | | const is_obj = comp.config.output_mode == .Obj; |
| 4064 | const is_obj = wasm.base.isRelocatable(); |
| 4061 | 4065 | |
| 4062 | 4066 | try wasm.tables.ensureUnusedCapacity(gpa, 1); |
| 4063 | 4067 | |
| ... | ... | @@ -4103,7 +4107,7 @@ pub fn markDataImport( |
| 4103 | 4107 | |
| 4104 | 4108 | const comp = wasm.base.comp; |
| 4105 | 4109 | const gpa = comp.gpa; |
| 4106 | | const is_obj = comp.config.output_mode == .Obj; |
| 4110 | const is_obj = wasm.base.isRelocatable(); |
| 4107 | 4111 | |
| 4108 | 4112 | if (import.resolution == .unresolved) { |
| 4109 | 4113 | if (!is_obj) { |
| ... | ... | @@ -4682,7 +4686,7 @@ pub fn addNavReloc( |
| 4682 | 4686 | const ip = &zcu.intern_pool; |
| 4683 | 4687 | const gpa = comp.gpa; |
| 4684 | 4688 | |
| 4685 | | const is_obj = comp.config.output_mode == .Obj; |
| 4689 | const is_obj = wasm.base.isRelocatable(); |
| 4686 | 4690 | |
| 4687 | 4691 | if (nav_ty.zigTypeTag(zcu) == .@"fn") { |
| 4688 | 4692 | const gop = try wasm.zcu_indirect_function_set.getOrPut(gpa, nav_index); |
| ... | ... | @@ -4751,7 +4755,7 @@ pub fn addUavReloc( |
| 4751 | 4755 | gop.value_ptr.* = if (gop.found_existing) gop.value_ptr.maxStrict(this_align) else this_align; |
| 4752 | 4756 | } |
| 4753 | 4757 | |
| 4754 | | if (comp.config.output_mode == .Obj) { |
| 4758 | if (wasm.base.isRelocatable()) { |
| 4755 | 4759 | const gop = try wasm.uavs_obj.getOrPut(gpa, uav_val); |
| 4756 | 4760 | if (!gop.found_existing) gop.value_ptr.* = undefined; // to avoid recursion, `ZcuDataStarts` will lower the value later |
| 4757 | 4761 | try wasm.zcu_relocations.append(gpa, .{ |
| ... | ... | @@ -4782,7 +4786,7 @@ pub fn addUavReloc( |
| 4782 | 4786 | pub fn refNavObj(wasm: *Wasm, nav_index: InternPool.Nav.Index) !NavsObjIndex { |
| 4783 | 4787 | const comp = wasm.base.comp; |
| 4784 | 4788 | const gpa = comp.gpa; |
| 4785 | | assert(comp.config.output_mode == .Obj); |
| 4789 | assert(wasm.base.isRelocatable()); |
| 4786 | 4790 | const gop = try wasm.navs_obj.getOrPut(gpa, nav_index); |
| 4787 | 4791 | if (!gop.found_existing) gop.value_ptr.* = .{ |
| 4788 | 4792 | // Lowering the value is delayed to avoid recursion. |
| ... | ... | @@ -4795,7 +4799,7 @@ pub fn refNavObj(wasm: *Wasm, nav_index: InternPool.Nav.Index) !NavsObjIndex { |
| 4795 | 4799 | pub fn refNavExe(wasm: *Wasm, nav_index: InternPool.Nav.Index) !NavsExeIndex { |
| 4796 | 4800 | const comp = wasm.base.comp; |
| 4797 | 4801 | const gpa = comp.gpa; |
| 4798 | | assert(comp.config.output_mode != .Obj); |
| 4802 | assert(!wasm.base.isRelocatable()); |
| 4799 | 4803 | const gop = try wasm.navs_exe.getOrPut(gpa, nav_index); |
| 4800 | 4804 | if (gop.found_existing) { |
| 4801 | 4805 | gop.value_ptr.count += 1; |
| ... | ... | @@ -4812,8 +4816,7 @@ pub fn refNavExe(wasm: *Wasm, nav_index: InternPool.Nav.Index) !NavsExeIndex { |
| 4812 | 4816 | /// Asserts it is called after `Flush.data_segments` is fully populated and sorted. |
| 4813 | 4817 | pub fn uavAddr(wasm: *const Wasm, ip_index: InternPool.Index) u32 { |
| 4814 | 4818 | assert(wasm.flush_buffer.memory_layout_finished); |
| 4815 | | const comp = wasm.base.comp; |
| 4816 | | assert(comp.config.output_mode != .Obj); |
| 4819 | assert(!wasm.base.isRelocatable()); |
| 4817 | 4820 | const uav_index: UavsExeIndex = @fromBackingInt(@intCast(wasm.uavs_exe.getIndex(ip_index).?)); |
| 4818 | 4821 | const ds_id: DataSegmentId = .pack(wasm, .{ .uav_exe = uav_index }); |
| 4819 | 4822 | return wasm.flush_buffer.data_segments.get(ds_id).?; |
| ... | ... | @@ -4834,7 +4837,7 @@ pub fn syntheticDataAddr(wasm: *const Wasm, resolution: ObjectDataImport.Resolut |
| 4834 | 4837 | pub fn navAddr(wasm: *const Wasm, nav_index: InternPool.Nav.Index) u32 { |
| 4835 | 4838 | assert(wasm.flush_buffer.memory_layout_finished); |
| 4836 | 4839 | const comp = wasm.base.comp; |
| 4837 | | assert(comp.config.output_mode != .Obj); |
| 4840 | assert(!wasm.base.isRelocatable()); |
| 4838 | 4841 | if (wasm.navs_exe.getIndex(nav_index)) |i| { |
| 4839 | 4842 | const navs_exe_index: NavsExeIndex = @fromBackingInt(@intCast(i)); |
| 4840 | 4843 | log.debug("navAddr {s} {}", .{ navs_exe_index.name(wasm), nav_index }); |
| ... | ... | @@ -4888,15 +4891,13 @@ pub fn navAddr(wasm: *const Wasm, nav_index: InternPool.Nav.Index) u32 { |
| 4888 | 4891 | /// Asserts it is called after `Flush.data_segments` is fully populated and sorted. |
| 4889 | 4892 | pub fn errorNameTableAddr(wasm: *Wasm) u32 { |
| 4890 | 4893 | assert(wasm.flush_buffer.memory_layout_finished); |
| 4891 | | const comp = wasm.base.comp; |
| 4892 | | assert(comp.config.output_mode != .Obj); |
| 4894 | assert(!wasm.base.isRelocatable()); |
| 4893 | 4895 | return wasm.flush_buffer.data_segments.get(.__zig_error_name_table).?; |
| 4894 | 4896 | } |
| 4895 | 4897 | |
| 4896 | 4898 | pub fn tagIndexTableAddr(wasm: *Wasm, ip_index: InternPool.Index) u32 { |
| 4897 | 4899 | assert(wasm.flush_buffer.memory_layout_finished); |
| 4898 | | const comp = wasm.base.comp; |
| 4899 | | assert(comp.config.output_mode != .Obj); |
| 4900 | assert(!wasm.base.isRelocatable()); |
| 4900 | 4901 | const f = &wasm.flush_buffer; |
| 4901 | 4902 | const table_base_addr = f.data_segments.get(.__zig_tag_name_table).?; |
| 4902 | 4903 | return table_base_addr + wasm.tagIndexTableOffset(ip_index); |