| ... | @@ -185,13 +185,16 @@ uavs: std.array_hash_map.Auto(InternPool.Index, struct { | ... | @@ -185,13 +185,16 @@ uavs: std.array_hash_map.Auto(InternPool.Index, struct { |
| 185 | first_symbol_reloc: SymbolReloc.Index, | 185 | first_symbol_reloc: SymbolReloc.Index, |
| 186 | // No `first_got_reloc` field because a UAV never contains GOT relocations. | 186 | // No `first_got_reloc` field because a UAV never contains GOT relocations. |
| 187 | }), | 187 | }), |
| 188 | lazy: std.EnumArray(link.File.LazySymbol.Kind, std.array_hash_map.Auto(link.ConstPool.Index, struct { | 188 | lazy: std.EnumArray(link.File.LazySymbol.Kind, struct { |
| 189 | lsi: Symbol.LocalIndex, | 189 | map: std.array_hash_map.Auto(InternPool.Index, struct { |
| 190 | /// The start index of the contiguous sequence of symbol relocations in this lazy code/data. | 190 | lsi: Symbol.LocalIndex, |
| 191 | first_symbol_reloc: SymbolReloc.Index, | 191 | /// The start index of the contiguous sequence of symbol relocations in this lazy code/data. |
| 192 | /// The start index of the contiguous sequence of GOT relocations in this lazy code/data. | 192 | first_symbol_reloc: SymbolReloc.Index, |
| 193 | first_got_reloc: GotReloc.Index, | 193 | /// The start index of the contiguous sequence of GOT relocations in this lazy code/data. |
| 194 | })), | 194 | first_got_reloc: GotReloc.Index, |
| | 195 | }), |
| | 196 | pending_index: u32, |
| | 197 | }), |
| 195 | pending_uavs: std.ArrayList(Node.UavMapIndex), | 198 | pending_uavs: std.ArrayList(Node.UavMapIndex), |
| 196 | symbol_relocs: std.ArrayList(SymbolReloc), | 199 | symbol_relocs: std.ArrayList(SymbolReloc), |
| 197 | node_relocs: std.ArrayList(NodeReloc), | 200 | node_relocs: std.ArrayList(NodeReloc), |
| ... | @@ -391,23 +394,20 @@ const Node = union(enum) { | ... | @@ -391,23 +394,20 @@ const Node = union(enum) { |
| 391 | } | 394 | } |
| 392 | | 395 | |
| 393 | fn firstSymbolReloc(lmi: @This(), elf: *const Elf) SymbolReloc.Index { | 396 | fn firstSymbolReloc(lmi: @This(), elf: *const Elf) SymbolReloc.Index { |
| 394 | return elf.lazy.getPtrConst(kind).values()[@backingInt(lmi)].first_symbol_reloc; | 397 | return elf.lazy.getPtrConst(kind).map.values()[@backingInt(lmi)].first_symbol_reloc; |
| 395 | } | 398 | } |
| 396 | fn firstGotReloc(lmi: @This(), elf: *const Elf) GotReloc.Index { | 399 | fn firstGotReloc(lmi: @This(), elf: *const Elf) GotReloc.Index { |
| 397 | return elf.lazy.getPtrConst(kind).values()[@backingInt(lmi)].first_got_reloc; | 400 | return elf.lazy.getPtrConst(kind).map.values()[@backingInt(lmi)].first_got_reloc; |
| 398 | } | 401 | } |
| 399 | }; | 402 | }; |
| 400 | } | 403 | } |
| 401 | | 404 | |
| 402 | pub fn lazySymbol(lmr: LazyMapRef, elf: *const Elf) link.File.LazySymbol { | 405 | pub fn lazySymbol(lmr: LazyMapRef, elf: *const Elf) link.File.LazySymbol { |
| 403 | return .{ | 406 | return .{ .kind = lmr.kind, .ty = elf.lazy.getPtrConst(lmr.kind).map.keys()[lmr.index] }; |
| 404 | .kind = lmr.kind, | | |
| 405 | .ty = elf.lazy.getPtrConst(lmr.kind).keys()[lmr.index].val(&elf.dwarf.const_pool), | | |
| 406 | }; | | |
| 407 | } | 407 | } |
| 408 | | 408 | |
| 409 | pub fn symbol(lmr: LazyMapRef, elf: *const Elf) Symbol.LocalIndex { | 409 | pub fn symbol(lmr: LazyMapRef, elf: *const Elf) Symbol.LocalIndex { |
| 410 | return elf.lazy.getPtrConst(lmr.kind).values()[lmr.index].lsi; | 410 | return elf.lazy.getPtrConst(lmr.kind).map.values()[lmr.index].lsi; |
| 411 | } | 411 | } |
| 412 | }; | 412 | }; |
| 413 | | 413 | |
| ... | @@ -3340,26 +3340,20 @@ pub fn symbolForAtom(elf: *Elf, atom: link.File.AtomId) link.File.SymbolId { | ... | @@ -3340,26 +3340,20 @@ pub fn symbolForAtom(elf: *Elf, atom: link.File.AtomId) link.File.SymbolId { |
| 3340 | const s: Symbol.Id = .local(lsi); | 3340 | const s: Symbol.Id = .local(lsi); |
| 3341 | return s.toTypeErased(); | 3341 | return s.toTypeErased(); |
| 3342 | } | 3342 | } |
| 3343 | pub fn lazySymbol( | 3343 | pub fn lazySymbol(elf: *Elf, lazy: link.File.LazySymbol) link.Error!link.File.SymbolId { |
| 3344 | elf: *Elf, | 3344 | return elf.lazySymbolInner(lazy) catch |err| switch (err) { |
| 3345 | pt: Zcu.PerThread, | | |
| 3346 | lazy: link.File.LazySymbol, | | |
| 3347 | ) link.Error!link.File.SymbolId { | | |
| 3348 | const diags = &elf.base.comp.link_diags; | | |
| 3349 | return elf.lazySymbolInner(pt, lazy) catch |err| switch (err) { | | |
| 3350 | else => |e| return e, | 3345 | else => |e| return e, |
| 3351 | error.MappedFileIo => return diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}), | 3346 | error.MappedFileIo => return elf.base.comp.link_diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}), |
| 3352 | }; | 3347 | }; |
| 3353 | } | 3348 | } |
| 3354 | fn lazySymbolInner(elf: *Elf, pt: Zcu.PerThread, lazy: link.File.LazySymbol) Error!link.File.SymbolId { | 3349 | fn lazySymbolInner(elf: *Elf, lazy: link.File.LazySymbol) Error!link.File.SymbolId { |
| 3355 | const gpa = elf.base.comp.gpa; | 3350 | const gpa = elf.base.comp.gpa; |
| 3356 | | 3351 | |
| 3357 | try elf.ensureUnusedSymbolCapacity(1, .all_local); | 3352 | try elf.ensureUnusedSymbolCapacity(1, .all_local); |
| 3358 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 3353 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 3359 | try elf.lazy.getPtr(lazy.kind).ensureUnusedCapacity(gpa, 1); | 3354 | try elf.lazy.getPtr(lazy.kind).map.ensureUnusedCapacity(gpa, 1); |
| 3360 | | 3355 | |
| 3361 | const cpi = try elf.dwarf.const_pool.get(pt, .{ .elf2 = elf }, lazy.ty); | 3356 | const gop = elf.lazy.getPtr(lazy.kind).map.getOrPutAssumeCapacity(lazy.ty); |
| 3362 | const gop = elf.lazy.getPtr(lazy.kind).getOrPutAssumeCapacity(cpi); | | |
| 3363 | if (!gop.found_existing) { | 3357 | if (!gop.found_existing) { |
| 3364 | const shndx: Section.Index, const sym_type: std.elf.STT = switch (lazy.kind) { | 3358 | const shndx: Section.Index, const sym_type: std.elf.STT = switch (lazy.kind) { |
| 3365 | .code => .{ .text, .FUNC }, | 3359 | .code => .{ .text, .FUNC }, |
| ... | @@ -3819,7 +3813,10 @@ fn create( | ... | @@ -3819,7 +3813,10 @@ fn create( |
| 3819 | .one_shot_fixups = .empty, | 3813 | .one_shot_fixups = .empty, |
| 3820 | .navs = .empty, | 3814 | .navs = .empty, |
| 3821 | .uavs = .empty, | 3815 | .uavs = .empty, |
| 3822 | .lazy = comptime .initFill(.empty), | 3816 | .lazy = comptime .initFill(.{ |
| | 3817 | .map = .empty, |
| | 3818 | .pending_index = 0, |
| | 3819 | }), |
| 3823 | .pending_uavs = .empty, | 3820 | .pending_uavs = .empty, |
| 3824 | .symbol_relocs = .empty, | 3821 | .symbol_relocs = .empty, |
| 3825 | .node_relocs = .empty, | 3822 | .node_relocs = .empty, |
| ... | @@ -3881,7 +3878,7 @@ pub fn deinit(elf: *Elf) void { | ... | @@ -3881,7 +3878,7 @@ pub fn deinit(elf: *Elf) void { |
| 3881 | elf.one_shot_fixups.deinit(gpa); | 3878 | elf.one_shot_fixups.deinit(gpa); |
| 3882 | elf.navs.deinit(gpa); | 3879 | elf.navs.deinit(gpa); |
| 3883 | elf.uavs.deinit(gpa); | 3880 | elf.uavs.deinit(gpa); |
| 3884 | for (&elf.lazy.values) |*lazy| lazy.deinit(gpa); | 3881 | for (&elf.lazy.values) |*lazy| lazy.map.deinit(gpa); |
| 3885 | elf.pending_uavs.deinit(gpa); | 3882 | elf.pending_uavs.deinit(gpa); |
| 3886 | elf.symbol_relocs.deinit(gpa); | 3883 | elf.symbol_relocs.deinit(gpa); |
| 3887 | elf.node_relocs.deinit(gpa); | 3884 | elf.node_relocs.deinit(gpa); |
| ... | @@ -5361,8 +5358,8 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { | ... | @@ -5361,8 +5358,8 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { |
| 5361 | .first_symbol_reloc = &elf.uavs.values()[@backingInt(umi)].first_symbol_reloc, | 5358 | .first_symbol_reloc = &elf.uavs.values()[@backingInt(umi)].first_symbol_reloc, |
| 5362 | }, | 5359 | }, |
| 5363 | inline .lazy_code, .lazy_const_data => |lmi| .{ | 5360 | inline .lazy_code, .lazy_const_data => |lmi| .{ |
| 5364 | .first_symbol_reloc = &elf.lazy.getPtr(lmi.ref().kind).values()[lmi.ref().index].first_symbol_reloc, | 5361 | .first_symbol_reloc = &elf.lazy.getPtr(lmi.ref().kind).map.values()[lmi.ref().index].first_symbol_reloc, |
| 5365 | .first_got_reloc = &elf.lazy.getPtr(lmi.ref().kind).values()[lmi.ref().index].first_got_reloc, | 5362 | .first_got_reloc = &elf.lazy.getPtr(lmi.ref().kind).map.values()[lmi.ref().index].first_got_reloc, |
| 5366 | }, | 5363 | }, |
| 5367 | .unit_debug_info_header => |ui| .{ | 5364 | .unit_debug_info_header => |ui| .{ |
| 5368 | .first_node_reloc = &elf.dwarf_units[@backingInt(ui)].debug_info_header_first_node_reloc, | 5365 | .first_node_reloc = &elf.dwarf_units[@backingInt(ui)].debug_info_header_first_node_reloc, |
| ... | @@ -7137,24 +7134,38 @@ fn prelinkInner(elf: *Elf) Error!void { | ... | @@ -7137,24 +7134,38 @@ fn prelinkInner(elf: *Elf) Error!void { |
| 7137 | }; | 7134 | }; |
| 7138 | elf.input_pending_index += 1; | 7135 | elf.input_pending_index += 1; |
| 7139 | | 7136 | |
| 7140 | try elf.nodes.ensureUnusedCapacity(gpa, 4 + 5); | 7137 | try elf.nodes.ensureUnusedCapacity(gpa, 5 + 4); |
| 7141 | | 7138 | |
| 7142 | elf.dwarf.debug_abbrev.ni = .wrap(elf.addNodeAssumeCapacity( | 7139 | switch (elf.shndx.debug_abbrev) { |
| 7143 | try elf.shndx.debug_abbrev.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}), | 7140 | .UNDEF => {}, |
| 7144 | .{ .debug_shared = .debug_abbrev }, | 7141 | else => |debug_abbrev_shndx| elf.dwarf.debug_abbrev.ni = .wrap(elf.addNodeAssumeCapacity( |
| 7145 | )); | 7142 | try debug_abbrev_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}), |
| 7146 | elf.dwarf.debug_line_str.ni = .wrap(elf.addNodeAssumeCapacity( | 7143 | .{ .debug_shared = .debug_abbrev }, |
| 7147 | try elf.shndx.debug_line_str.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}), | 7144 | )), |
| 7148 | .{ .debug_shared = .debug_line_str }, | 7145 | } |
| 7149 | )); | 7146 | switch (elf.shndx.debug_line_str) { |
| 7150 | elf.dwarf.debug_str.ni = .wrap(elf.addNodeAssumeCapacity( | 7147 | .UNDEF => {}, |
| 7151 | try elf.shndx.debug_str.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}), | 7148 | else => |debug_line_str_shndx| elf.dwarf.debug_line_str.ni = |
| 7152 | .{ .debug_shared = .debug_str }, | 7149 | .wrap(elf.addNodeAssumeCapacity( |
| 7153 | )); | 7150 | try debug_line_str_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}), |
| 7154 | elf.dwarf.debug_str_offsets.ni = .wrap(elf.addNodeAssumeCapacity( | 7151 | .{ .debug_shared = .debug_line_str }, |
| 7155 | try elf.shndx.debug_str_offsets.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}), | 7152 | )), |
| 7156 | .{ .debug_shared = .debug_str_offsets }, | 7153 | } |
| 7157 | )); | 7154 | switch (elf.shndx.debug_str) { |
| | 7155 | .UNDEF => {}, |
| | 7156 | else => |debug_str_shndx| elf.dwarf.debug_str.ni = .wrap(elf.addNodeAssumeCapacity( |
| | 7157 | try debug_str_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}), |
| | 7158 | .{ .debug_shared = .debug_str }, |
| | 7159 | )), |
| | 7160 | } |
| | 7161 | switch (elf.shndx.debug_str_offsets) { |
| | 7162 | .UNDEF => {}, |
| | 7163 | else => |debug_str_offsets_shndx| elf.dwarf.debug_str_offsets.ni = |
| | 7164 | .wrap(elf.addNodeAssumeCapacity( |
| | 7165 | try debug_str_offsets_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}), |
| | 7166 | .{ .debug_shared = .debug_str_offsets }, |
| | 7167 | )), |
| | 7168 | } |
| 7158 | | 7169 | |
| 7159 | for ([5]Section.Index{ | 7170 | for ([5]Section.Index{ |
| 7160 | elf.shndx.eh_frame, | 7171 | elf.shndx.eh_frame, |
| ... | @@ -8541,8 +8552,11 @@ fn updateNavInner(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) | ... | @@ -8541,8 +8552,11 @@ fn updateNavInner(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) |
| 8541 | | 8552 | |
| 8542 | const nav = ip.getNav(nav_index); | 8553 | const nav = ip.getNav(nav_index); |
| 8543 | if (ip.indexToKey(nav.resolved.?.value) == .@"extern") return; | 8554 | if (ip.indexToKey(nav.resolved.?.value) == .@"extern") return; |
| 8544 | if (!Type.fromInterned(nav.resolved.?.type).hasRuntimeBits(zcu)) | 8555 | if (!Type.fromInterned(nav.resolved.?.type).hasRuntimeBits(zcu)) { |
| 8545 | return elf.dwarf.updateComptimeNav(pt, nav_index); | 8556 | if (elf.ehdrMachine() != .X86_64) return; |
| | 8557 | const mod = zcu.fileByIndex(nav.srcInst(ip).resolveFile(ip)).mod.?; |
| | 8558 | return if (!mod.strip) elf.dwarf.updateComptimeNav(pt, nav_index); |
| | 8559 | } |
| 8546 | | 8560 | |
| 8547 | const nmi = try elf.navMapIndex(zcu, nav_index); | 8561 | const nmi = try elf.navMapIndex(zcu, nav_index); |
| 8548 | const ni = nmi.symbol(elf).index().ptr(elf).node.unwrap().?; | 8562 | const ni = nmi.symbol(elf).index().ptr(elf).node.unwrap().?; |
| ... | @@ -8581,7 +8595,32 @@ pub fn updateContainerType( | ... | @@ -8581,7 +8595,32 @@ pub fn updateContainerType( |
| 8581 | ty: InternPool.Index, | 8595 | ty: InternPool.Index, |
| 8582 | success: bool, | 8596 | success: bool, |
| 8583 | ) link.Error!void { | 8597 | ) link.Error!void { |
| 8584 | try elf.dwarf.const_pool.updateContainerType(pt, .{ .elf2 = elf }, ty, success); | 8598 | elf.updateContainerTypeInner(pt, ty, success) catch |err| switch (err) { |
| | 8599 | else => |e| return e, |
| | 8600 | error.MappedFileIo => return elf.base.comp.link_diags.fail( |
| | 8601 | "failed to write output file: {t}", |
| | 8602 | .{elf.mf.io_err.?}, |
| | 8603 | ), |
| | 8604 | }; |
| | 8605 | } |
| | 8606 | pub fn updateContainerTypeInner( |
| | 8607 | elf: *Elf, |
| | 8608 | pt: Zcu.PerThread, |
| | 8609 | ty: InternPool.Index, |
| | 8610 | success: bool, |
| | 8611 | ) Error!void { |
| | 8612 | switch (elf.base.comp.config.debug_format) { |
| | 8613 | .strip => {}, |
| | 8614 | .dwarf => try elf.dwarf.const_pool.updateContainerType(pt, .{ .elf2 = elf }, ty, success), |
| | 8615 | .code_view => unreachable, |
| | 8616 | } |
| | 8617 | if (!success) return; |
| | 8618 | var lazy_it = elf.lazy.iterator(); |
| | 8619 | while (lazy_it.next()) |lazy| if (lazy.value.map.getIndex(ty)) |lmi| { |
| | 8620 | if (lazy.value.pending_index <= lmi) continue; |
| | 8621 | // This type has changed on this incremental update, so update the lazy code/data. |
| | 8622 | try elf.genLazy(pt, .{ .kind = lazy.key, .index = @intCast(lmi) }); |
| | 8623 | }; |
| 8585 | } | 8624 | } |
| 8586 | | 8625 | |
| 8587 | pub fn addConst( | 8626 | pub fn addConst( |
| ... | @@ -8590,47 +8629,24 @@ pub fn addConst( | ... | @@ -8590,47 +8629,24 @@ pub fn addConst( |
| 8590 | index: link.ConstPool.Index, | 8629 | index: link.ConstPool.Index, |
| 8591 | val: InternPool.Index, | 8630 | val: InternPool.Index, |
| 8592 | ) link.Error!void { | 8631 | ) link.Error!void { |
| 8593 | try elf.dwarf.addConst(index, val); | 8632 | switch (elf.base.comp.config.debug_format) { |
| | 8633 | .strip => {}, |
| | 8634 | .dwarf => try elf.dwarf.addConst(index, val), |
| | 8635 | .code_view => unreachable, |
| | 8636 | } |
| 8594 | } | 8637 | } |
| 8595 | | 8638 | |
| 8596 | pub fn updateConst( | 8639 | pub fn updateConst( |
| 8597 | elf: *Elf, | 8640 | elf: *Elf, |
| 8598 | pt: Zcu.PerThread, | 8641 | _: Zcu.PerThread, |
| 8599 | cpi: link.ConstPool.Index, | | |
| 8600 | val: InternPool.Index, | | |
| 8601 | ) link.Error!void { | | |
| 8602 | if (val == .anyerror_type) return; | | |
| 8603 | try elf.updateConstInner(pt, cpi, val); | | |
| 8604 | } | | |
| 8605 | fn updateConstInner( | | |
| 8606 | elf: *Elf, | | |
| 8607 | pt: Zcu.PerThread, | | |
| 8608 | cpi: link.ConstPool.Index, | 8642 | cpi: link.ConstPool.Index, |
| 8609 | val: InternPool.Index, | 8643 | val: InternPool.Index, |
| 8610 | ) link.Error!void { | 8644 | ) link.Error!void { |
| 8611 | var lazy_it = elf.lazy.iterator(); | 8645 | switch (elf.base.comp.config.debug_format) { |
| 8612 | while (lazy_it.next()) |lazy| if (lazy.value.getIndex(cpi)) |li| { | 8646 | .strip => {}, |
| 8613 | const lazy_ty: Type = .fromInterned(val); | 8647 | .dwarf => elf.dwarf.updateConst(cpi, val), |
| 8614 | var prog_name_buf: [std.Progress.Node.max_name_len]u8 = undefined; | 8648 | .code_view => unreachable, |
| 8615 | const prog_name: []const u8 = switch (lazy_ty.zigTypeTag(pt.zcu)) { | 8649 | } |
| 8616 | .@"enum" => std.mem.print(&prog_name_buf, "@tagName({f})", .{lazy_ty.fmt(pt)}) catch &prog_name_buf, | | |
| 8617 | .error_set => switch (lazy.key) { | | |
| 8618 | .code => std.mem.print(&prog_name_buf, "@errorCast({f})", .{lazy_ty.fmt(pt)}) catch &prog_name_buf, | | |
| 8619 | .const_data => "@errorName(anyerror)", | | |
| 8620 | }, | | |
| 8621 | else => unreachable, | | |
| 8622 | }; | | |
| 8623 | const prog_node = elf.base.comp.link_prog_node.start(prog_name, 0); | | |
| 8624 | defer prog_node.end(); | | |
| 8625 | elf.genLazy(pt, .{ .kind = lazy.key, .index = @intCast(li) }) catch |err| switch (err) { | | |
| 8626 | else => |e| return e, | | |
| 8627 | error.MappedFileIo => return elf.base.comp.link_diags.fail( | | |
| 8628 | "failed to write output file: {t}", | | |
| 8629 | .{elf.mf.io_err.?}, | | |
| 8630 | ), | | |
| 8631 | }; | | |
| 8632 | }; | | |
| 8633 | elf.dwarf.updateConst(cpi, val); | | |
| 8634 | } | 8650 | } |
| 8635 | | 8651 | |
| 8636 | pub fn updateConstIncomplete( | 8652 | pub fn updateConstIncomplete( |
| ... | @@ -8639,11 +8655,17 @@ pub fn updateConstIncomplete( | ... | @@ -8639,11 +8655,17 @@ pub fn updateConstIncomplete( |
| 8639 | cpi: link.ConstPool.Index, | 8655 | cpi: link.ConstPool.Index, |
| 8640 | val: InternPool.Index, | 8656 | val: InternPool.Index, |
| 8641 | ) link.Error!void { | 8657 | ) link.Error!void { |
| 8642 | const debug_info_ni = Dwarf.Const.get(cpi, &elf.dwarf).debug_info_ni.unwrap().?; | 8658 | switch (elf.base.comp.config.debug_format) { |
| 8643 | var di_nw: MappedFile.Node.Writer = undefined; | 8659 | .strip => {}, |
| 8644 | debug_info_ni.writer(elf.base.comp.gpa, &elf.mf, &di_nw); | 8660 | .dwarf => { |
| 8645 | defer di_nw.deinit(); | 8661 | const debug_info_ni = Dwarf.Const.get(cpi, &elf.dwarf).debug_info_ni.unwrap().?; |
| 8646 | try elf.dwarf.updateConstIncomplete(pt, &di_nw, val); | 8662 | var di_nw: MappedFile.Node.Writer = undefined; |
| | 8663 | debug_info_ni.writer(elf.base.comp.gpa, &elf.mf, &di_nw); |
| | 8664 | defer di_nw.deinit(); |
| | 8665 | try elf.dwarf.updateConstIncomplete(pt, &di_nw, val); |
| | 8666 | }, |
| | 8667 | .code_view => unreachable, |
| | 8668 | } |
| 8647 | } | 8669 | } |
| 8648 | | 8670 | |
| 8649 | pub fn updateFunc( | 8671 | pub fn updateFunc( |
| ... | @@ -8930,11 +8952,16 @@ pub fn lostTracking( | ... | @@ -8930,11 +8952,16 @@ pub fn lostTracking( |
| 8930 | } | 8952 | } |
| 8931 | | 8953 | |
| 8932 | pub fn updateErrorData(elf: *Elf, pt: Zcu.PerThread) link.Error!void { | 8954 | pub fn updateErrorData(elf: *Elf, pt: Zcu.PerThread) link.Error!void { |
| 8933 | try elf.updateConstInner( | 8955 | elf.genLazyInner(pt, .{ |
| 8934 | pt, | 8956 | .kind = .const_data, |
| 8935 | elf.dwarf.const_pool.getIfExists(.anyerror_type) orelse return, | 8957 | .index = @intCast(elf.lazy.getPtr(.const_data).map.getIndex(.anyerror_type) orelse return), |
| 8936 | .anyerror_type, | 8958 | }) catch |err| switch (err) { |
| 8937 | ); | 8959 | else => |e| return e, |
| | 8960 | error.MappedFileIo => return elf.base.comp.link_diags.fail( |
| | 8961 | "failed to write output file: {t}", |
| | 8962 | .{elf.mf.io_err.?}, |
| | 8963 | ), |
| | 8964 | }; |
| 8938 | } | 8965 | } |
| 8939 | | 8966 | |
| 8940 | pub fn flush( | 8967 | pub fn flush( |
| ... | @@ -9266,7 +9293,16 @@ fn genPending(elf: *Elf, pt: Zcu.PerThread) Error!void { | ... | @@ -9266,7 +9293,16 @@ fn genPending(elf: *Elf, pt: Zcu.PerThread) Error!void { |
| 9266 | defer prog_node.end(); | 9293 | defer prog_node.end(); |
| 9267 | try elf.genUav(pt, umi); | 9294 | try elf.genUav(pt, umi); |
| 9268 | } | 9295 | } |
| 9269 | try elf.dwarf.const_pool.flushPending(pt, .{ .elf2 = elf }); | 9296 | var lazy_it = elf.lazy.iterator(); |
| | 9297 | while (lazy_it.next()) |lazy| while (lazy.value.pending_index < lazy.value.map.count()) { |
| | 9298 | try elf.genLazy(pt, .{ .kind = lazy.key, .index = lazy.value.pending_index }); |
| | 9299 | lazy.value.pending_index += 1; |
| | 9300 | }; |
| | 9301 | switch (elf.base.comp.config.debug_format) { |
| | 9302 | .strip => {}, |
| | 9303 | .dwarf => try elf.dwarf.const_pool.flushPending(pt, .{ .elf2 = elf }), |
| | 9304 | .code_view => unreachable, |
| | 9305 | } |
| 9270 | } | 9306 | } |
| 9271 | | 9307 | |
| 9272 | fn genUav( | 9308 | fn genUav( |
| ... | @@ -9302,6 +9338,23 @@ fn genUav( | ... | @@ -9302,6 +9338,23 @@ fn genUav( |
| 9302 | } | 9338 | } |
| 9303 | | 9339 | |
| 9304 | fn genLazy(elf: *Elf, pt: Zcu.PerThread, lmr: Node.LazyMapRef) Error!void { | 9340 | fn genLazy(elf: *Elf, pt: Zcu.PerThread, lmr: Node.LazyMapRef) Error!void { |
| | 9341 | const lazy = lmr.lazySymbol(elf); |
| | 9342 | if (lazy.ty == .anyerror_type) return; |
| | 9343 | const lazy_ty: Type = .fromInterned(lazy.ty); |
| | 9344 | var prog_name_buf: [std.Progress.Node.max_name_len]u8 = undefined; |
| | 9345 | const prog_name: []const u8 = switch (lazy_ty.zigTypeTag(pt.zcu)) { |
| | 9346 | .@"enum" => std.mem.print(&prog_name_buf, "@tagName({f})", .{lazy_ty.fmt(pt)}) catch &prog_name_buf, |
| | 9347 | .error_set => switch (lmr.kind) { |
| | 9348 | .code => std.mem.print(&prog_name_buf, "@errorCast({f})", .{lazy_ty.fmt(pt)}) catch &prog_name_buf, |
| | 9349 | .const_data => "@errorName(anyerror)", |
| | 9350 | }, |
| | 9351 | else => unreachable, |
| | 9352 | }; |
| | 9353 | const prog_node = elf.base.comp.link_prog_node.start(prog_name, 0); |
| | 9354 | defer prog_node.end(); |
| | 9355 | try elf.genLazyInner(pt, lmr); |
| | 9356 | } |
| | 9357 | fn genLazyInner(elf: *Elf, pt: Zcu.PerThread, lmr: Node.LazyMapRef) Error!void { |
| 9305 | const zcu = pt.zcu; | 9358 | const zcu = pt.zcu; |
| 9306 | const gpa = zcu.gpa; | 9359 | const gpa = zcu.gpa; |
| 9307 | | 9360 | |