| ... | ... | @@ -212,37 +212,11 @@ changed_symtab_index: std.array_hash_map.Auto(String(.strtab), void), |
| 212 | 212 | textrel_count: u32, |
| 213 | 213 | |
| 214 | 214 | dwarf: Dwarf, |
| 215 | | dwarf_shared: std.enums.EnumArray(Dwarf.SharedSection, struct { |
| 216 | | first_target_reloc: NodeReloc.Index, |
| 217 | | }), |
| 218 | | dwarf_units: std.ArrayList(struct { |
| 219 | | frame_cie_first_target_reloc: NodeReloc.Index, |
| 220 | | debug_info_header_first_target_reloc: NodeReloc.Index, |
| 221 | | debug_info_header_first_node_reloc: NodeReloc.Index, |
| 222 | | debug_line_header_first_target_reloc: NodeReloc.Index, |
| 223 | | debug_line_header_first_node_reloc: NodeReloc.Index, |
| 224 | | debug_rnglists_first_target_reloc: NodeReloc.Index, |
| 225 | | debug_rnglists_symbol_relocs: std.array_hash_map.Auto(SymbolReloc.Index, void), |
| 226 | | }), |
| 227 | | dwarf_consts: std.array_hash_map.Auto(link.ConstPool.Index, struct { |
| 228 | | debug_info_first_target_reloc: NodeReloc.Index, |
| 229 | | debug_info_first_symbol_reloc: SymbolReloc.Index, |
| 230 | | debug_info_first_node_reloc: NodeReloc.Index, |
| 231 | | }), |
| 232 | | dwarf_globals: std.ArrayList(struct { |
| 233 | | debug_info_first_target_reloc: NodeReloc.Index, |
| 234 | | debug_info_first_symbol_reloc: SymbolReloc.Index, |
| 235 | | debug_info_first_node_reloc: NodeReloc.Index, |
| 236 | | }), |
| 237 | | dwarf_funcs: std.ArrayList(struct { |
| 238 | | frame_fde_first_symbol_reloc: SymbolReloc.Index, |
| 239 | | frame_fde_first_node_reloc: NodeReloc.Index, |
| 240 | | debug_info_first_target_reloc: NodeReloc.Index, |
| 241 | | debug_info_first_symbol_reloc: SymbolReloc.Index, |
| 242 | | debug_info_first_node_reloc: NodeReloc.Index, |
| 243 | | debug_line_first_symbol_reloc: SymbolReloc.Index, |
| 244 | | debug_line_first_node_reloc: NodeReloc.Index, |
| 245 | | }), |
| 215 | dwarf_shared: std.enums.EnumArray(Dwarf.SharedSection, dwarf_relocs.Shared), |
| 216 | dwarf_units: []dwarf_relocs.Unit, |
| 217 | dwarf_consts: std.array_hash_map.Auto(link.ConstPool.Index, dwarf_relocs.Const), |
| 218 | dwarf_globals: std.ArrayList(dwarf_relocs.Global), |
| 219 | dwarf_funcs: std.ArrayList(dwarf_relocs.Func), |
| 246 | 220 | |
| 247 | 221 | overflowed_reloc_count: u32, |
| 248 | 222 | misaligned_reloc_count: u32, |
| ... | ... | @@ -878,6 +852,40 @@ const Section = struct { |
| 878 | 852 | }; |
| 879 | 853 | }; |
| 880 | 854 | |
| 855 | const dwarf_relocs = struct { |
| 856 | const Shared = struct { |
| 857 | first_target_reloc: NodeReloc.Index, |
| 858 | }; |
| 859 | const Unit = struct { |
| 860 | frame_cie_first_target_reloc: NodeReloc.Index, |
| 861 | debug_info_header_first_target_reloc: NodeReloc.Index, |
| 862 | debug_info_header_first_node_reloc: NodeReloc.Index, |
| 863 | debug_line_header_first_target_reloc: NodeReloc.Index, |
| 864 | debug_line_header_first_node_reloc: NodeReloc.Index, |
| 865 | debug_rnglists_first_target_reloc: NodeReloc.Index, |
| 866 | debug_rnglists_symbol_relocs: std.array_hash_map.Auto(SymbolReloc.Index, void), |
| 867 | }; |
| 868 | const Const = struct { |
| 869 | debug_info_first_target_reloc: NodeReloc.Index, |
| 870 | debug_info_first_symbol_reloc: SymbolReloc.Index, |
| 871 | debug_info_first_node_reloc: NodeReloc.Index, |
| 872 | }; |
| 873 | const Global = struct { |
| 874 | debug_info_first_target_reloc: NodeReloc.Index, |
| 875 | debug_info_first_symbol_reloc: SymbolReloc.Index, |
| 876 | debug_info_first_node_reloc: NodeReloc.Index, |
| 877 | }; |
| 878 | const Func = struct { |
| 879 | frame_fde_first_symbol_reloc: SymbolReloc.Index, |
| 880 | frame_fde_first_node_reloc: NodeReloc.Index, |
| 881 | debug_info_first_target_reloc: NodeReloc.Index, |
| 882 | debug_info_first_symbol_reloc: SymbolReloc.Index, |
| 883 | debug_info_first_node_reloc: NodeReloc.Index, |
| 884 | debug_line_first_symbol_reloc: SymbolReloc.Index, |
| 885 | debug_line_first_node_reloc: NodeReloc.Index, |
| 886 | }; |
| 887 | }; |
| 888 | |
| 881 | 889 | pub const MachineRelocType = union { |
| 882 | 890 | AARCH64: std.elf.R_AARCH64, |
| 883 | 891 | LARCH: std.elf.R_LARCH, |
| ... | ... | @@ -1859,10 +1867,10 @@ const NodeReloc = struct { |
| 1859 | 1867 | const first_target_reloc = switch (elf.getNode(reloc.target)) { |
| 1860 | 1868 | else => unreachable, |
| 1861 | 1869 | .debug_shared => |ss| &elf.dwarf_shared.getPtr(ss).first_target_reloc, |
| 1862 | | .unit_frame_cie => |ui| &elf.dwarf_units.items[@backingInt(ui)].frame_cie_first_target_reloc, |
| 1863 | | .unit_debug_info_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_info_header_first_target_reloc, |
| 1864 | | .unit_debug_line_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_target_reloc, |
| 1865 | | .unit_debug_rnglists => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_rnglists_first_target_reloc, |
| 1870 | .unit_frame_cie => |ui| &elf.dwarf_units[@backingInt(ui)].frame_cie_first_target_reloc, |
| 1871 | .unit_debug_info_header => |ui| &elf.dwarf_units[@backingInt(ui)].debug_info_header_first_target_reloc, |
| 1872 | .unit_debug_line_header => |ui| &elf.dwarf_units[@backingInt(ui)].debug_line_header_first_target_reloc, |
| 1873 | .unit_debug_rnglists => |ui| &elf.dwarf_units[@backingInt(ui)].debug_rnglists_first_target_reloc, |
| 1866 | 1874 | .const_debug_info => |cpi| &elf.dwarf_consts.getPtr(cpi).?.debug_info_first_target_reloc, |
| 1867 | 1875 | .global_debug_info => |gi| &elf.dwarf_globals.items[@backingInt(gi)].debug_info_first_target_reloc, |
| 1868 | 1876 | .func_debug_info => |fi| &elf.dwarf_funcs.items[@backingInt(fi)].debug_info_first_target_reloc, |
| ... | ... | @@ -3829,7 +3837,7 @@ fn create( |
| 3829 | 3837 | .dwarf_shared = comptime .initFill(.{ |
| 3830 | 3838 | .first_target_reloc = .none, |
| 3831 | 3839 | }), |
| 3832 | | .dwarf_units = .empty, |
| 3840 | .dwarf_units = &.{}, |
| 3833 | 3841 | .dwarf_consts = .empty, |
| 3834 | 3842 | .dwarf_globals = .empty, |
| 3835 | 3843 | .dwarf_funcs = .empty, |
| ... | ... | @@ -3883,8 +3891,8 @@ pub fn deinit(elf: *Elf) void { |
| 3883 | 3891 | elf.changed_symtab_index.deinit(gpa); |
| 3884 | 3892 | |
| 3885 | 3893 | elf.dwarf.deinit(); |
| 3886 | | for (elf.dwarf_units.items) |*dwarf_unit| dwarf_unit.debug_rnglists_symbol_relocs.deinit(gpa); |
| 3887 | | elf.dwarf_units.deinit(gpa); |
| 3894 | for (elf.dwarf_units) |*dwarf_unit| dwarf_unit.debug_rnglists_symbol_relocs.deinit(gpa); |
| 3895 | gpa.free(elf.dwarf_units); |
| 3888 | 3896 | elf.dwarf_consts.deinit(gpa); |
| 3889 | 3897 | elf.dwarf_globals.deinit(gpa); |
| 3890 | 3898 | elf.dwarf_funcs.deinit(gpa); |
| ... | ... | @@ -4286,8 +4294,8 @@ fn initHeaders( |
| 4286 | 4294 | } |
| 4287 | 4295 | |
| 4288 | 4296 | elf.ni.shdr = elf.addNodeAssumeCapacity(try elf.ni.elf.addFloatingChild(gpa, &elf.mf, .{ |
| 4289 | | .size = node_block_align.forward(1 * entsize.sh), // as above, only the SHN_UNDEF initially |
| 4290 | | .alignment = addr_align.max(node_block_align), |
| 4297 | .size = 1 * entsize.sh, // as above, only the null shdr initially |
| 4298 | .alignment = addr_align, |
| 4291 | 4299 | .moved = true, |
| 4292 | 4300 | .resized = true, |
| 4293 | 4301 | }), .shdr); |
| ... | ... | @@ -5357,10 +5365,10 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { |
| 5357 | 5365 | .first_got_reloc = &elf.lazy.getPtr(lmi.ref().kind).values()[lmi.ref().index].first_got_reloc, |
| 5358 | 5366 | }, |
| 5359 | 5367 | .unit_debug_info_header => |ui| .{ |
| 5360 | | .first_node_reloc = &elf.dwarf_units.items[@backingInt(ui)].debug_info_header_first_node_reloc, |
| 5368 | .first_node_reloc = &elf.dwarf_units[@backingInt(ui)].debug_info_header_first_node_reloc, |
| 5361 | 5369 | }, |
| 5362 | 5370 | .unit_debug_line_header => |ui| .{ |
| 5363 | | .first_node_reloc = &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_node_reloc, |
| 5371 | .first_node_reloc = &elf.dwarf_units[@backingInt(ui)].debug_line_header_first_node_reloc, |
| 5364 | 5372 | }, |
| 5365 | 5373 | .unit_debug_rnglists => unreachable, // unsupported |
| 5366 | 5374 | .const_debug_info => |cpi| .{ |
| ... | ... | @@ -5744,13 +5752,12 @@ const ShdrPtr = union(std.elf.CLASS) { |
| 5744 | 5752 | @"64": *std.elf.Elf64.Shdr, |
| 5745 | 5753 | }; |
| 5746 | 5754 | fn shdrPtr(elf: *Elf, shndx: Section.Index) ShdrPtr { |
| 5747 | | const raw_slice = elf.ni.shdr.slice(&elf.mf); |
| 5755 | const slice = elf.ni.shdr.slice(&elf.mf); |
| 5748 | 5756 | switch (elf.identClass()) { |
| 5749 | 5757 | .NONE, _ => unreachable, |
| 5750 | 5758 | inline else => |class| { |
| 5751 | | const shdrs_len = elf.shdrs.items.len + 1; // +1 for SHN_UNDEF |
| 5752 | 5759 | const shdr_slice: []class.ElfN().Shdr = @ptrCast(@alignCast( |
| 5753 | | raw_slice[0 .. shdrs_len * @sizeOf(class.ElfN().Shdr)], |
| 5760 | slice[0 .. @sizeOf(class.ElfN().Shdr) * (1 + elf.shdrs.items.len)], |
| 5754 | 5761 | )); |
| 5755 | 5762 | const shdr_ptr = &shdr_slice[@backingInt(shndx)]; |
| 5756 | 5763 | return @unionInit(ShdrPtr, @tagName(class), shdr_ptr); |
| ... | ... | @@ -7196,104 +7203,110 @@ pub fn zcuFilesReady(elf: *Elf, zcu: *Zcu) link.Error!void { |
| 7196 | 7203 | } |
| 7197 | 7204 | fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void { |
| 7198 | 7205 | const gpa = zcu.gpa; |
| 7199 | | |
| 7200 | | try elf.dwarf.updateUnits(zcu); |
| 7201 | | const old_units_len = elf.dwarf_units.items.len; |
| 7202 | | const new_units_len = elf.dwarf.units.count(); |
| 7203 | | try elf.dwarf_units.appendNTimes(gpa, .{ |
| 7204 | | .frame_cie_first_target_reloc = .none, |
| 7205 | | .debug_info_header_first_target_reloc = .none, |
| 7206 | | .debug_info_header_first_node_reloc = .none, |
| 7207 | | .debug_line_header_first_target_reloc = .none, |
| 7208 | | .debug_line_header_first_node_reloc = .none, |
| 7209 | | .debug_rnglists_first_target_reloc = .none, |
| 7210 | | .debug_rnglists_symbol_relocs = .empty, |
| 7211 | | }, new_units_len - old_units_len); |
| 7212 | | try elf.nodes.ensureUnusedCapacity(gpa, 5 * (new_units_len - old_units_len)); |
| 7213 | | |
| 7214 | | for (old_units_len.., elf.dwarf.units.values()[old_units_len..]) |unit_index, *unit| { |
| 7206 | const units_len = zcu.module_roots.count(); |
| 7207 | if (elf.dwarf_units.len == 0) { |
| 7208 | @branchHint(.unlikely); |
| 7209 | try elf.dwarf.initUnits(gpa, units_len); |
| 7210 | elf.dwarf_units = try gpa.alloc(dwarf_relocs.Unit, zcu.module_roots.count()); |
| 7211 | @memset(elf.dwarf_units, .{ |
| 7212 | .frame_cie_first_target_reloc = .none, |
| 7213 | .debug_info_header_first_target_reloc = .none, |
| 7214 | .debug_info_header_first_node_reloc = .none, |
| 7215 | .debug_line_header_first_target_reloc = .none, |
| 7216 | .debug_line_header_first_node_reloc = .none, |
| 7217 | .debug_rnglists_first_target_reloc = .none, |
| 7218 | .debug_rnglists_symbol_relocs = .empty, |
| 7219 | }); |
| 7220 | } |
| 7221 | if (!try elf.dwarf.updateUnits(zcu)) return; |
| 7222 | try elf.nodes.ensureUnusedCapacity(gpa, 5 * units_len); |
| 7223 | for (0..units_len) |unit_index| { |
| 7215 | 7224 | const ui: Dwarf.Unit.Index = @fromBackingInt(@intCast(unit_index)); |
| 7225 | const unit = ui.get(&elf.dwarf); |
| 7226 | if (!unit.alive) continue; |
| 7216 | 7227 | switch (elf.shndx.debug_info) { |
| 7217 | 7228 | .UNDEF => {}, |
| 7218 | 7229 | else => |debug_info_shndx| { |
| 7219 | | const debug_info_ni = elf.addNodeAssumeCapacity( |
| 7220 | | try debug_info_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{ |
| 7221 | | .alignment = elf.mf.flags.block_size, |
| 7222 | | .enable_next_moved = true, |
| 7223 | | }), |
| 7224 | | .{ .unit_debug_info = ui }, |
| 7225 | | ); |
| 7226 | | unit.debug_info_ni = .wrap(debug_info_ni); |
| 7230 | const debug_info_ni = unit.debug_info_ni.unwrap() orelse debug_info_ni: { |
| 7231 | const debug_info_ni = elf.addNodeAssumeCapacity( |
| 7232 | try debug_info_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{ |
| 7233 | .alignment = elf.mf.flags.block_size, |
| 7234 | .enable_next_moved = true, |
| 7235 | }), |
| 7236 | .{ .unit_debug_info = ui }, |
| 7237 | ); |
| 7238 | unit.debug_info_ni = .wrap(debug_info_ni); |
| 7239 | break :debug_info_ni debug_info_ni; |
| 7240 | }; |
| 7227 | 7241 | |
| 7228 | | unit.debug_info_header_ni = .wrap(elf.addNodeAssumeCapacity( |
| 7229 | | try debug_info_ni.addOnlyHeaderChild(gpa, &elf.mf, .{ |
| 7242 | if (unit.debug_info_header_ni == .none) unit.debug_info_header_ni = .wrap( |
| 7243 | elf.addNodeAssumeCapacity(try debug_info_ni.addOnlyHeaderChild(gpa, &elf.mf, .{ |
| 7230 | 7244 | .next_moved = true, |
| 7231 | 7245 | .enable_next_moved = true, |
| 7232 | | }), |
| 7233 | | .{ .unit_debug_info_header = ui }, |
| 7234 | | )); |
| 7246 | }), .{ .unit_debug_info_header = ui }), |
| 7247 | ); |
| 7235 | 7248 | }, |
| 7236 | 7249 | } |
| 7237 | 7250 | switch (elf.shndx.debug_line) { |
| 7238 | 7251 | .UNDEF => {}, |
| 7239 | 7252 | else => |debug_line_shndx| { |
| 7240 | | const debug_line_ni = elf.addNodeAssumeCapacity( |
| 7241 | | try debug_line_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{ |
| 7242 | | .alignment = elf.mf.flags.block_size, |
| 7243 | | .enable_next_moved = true, |
| 7244 | | }), |
| 7245 | | .{ .unit_debug_line = ui }, |
| 7246 | | ); |
| 7247 | | unit.debug_line_ni = .wrap(debug_line_ni); |
| 7253 | const debug_line_ni = unit.debug_line_ni.unwrap() orelse debug_line_ni: { |
| 7254 | const debug_line_ni = elf.addNodeAssumeCapacity( |
| 7255 | try debug_line_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{ |
| 7256 | .alignment = elf.mf.flags.block_size, |
| 7257 | .enable_next_moved = true, |
| 7258 | }), |
| 7259 | .{ .unit_debug_line = ui }, |
| 7260 | ); |
| 7261 | unit.debug_line_ni = .wrap(debug_line_ni); |
| 7262 | break :debug_line_ni debug_line_ni; |
| 7263 | }; |
| 7248 | 7264 | |
| 7249 | | unit.debug_line_header_ni = .wrap(elf.addNodeAssumeCapacity( |
| 7250 | | try debug_line_ni.addOnlyHeaderChild(gpa, &elf.mf, .{ |
| 7265 | if (unit.debug_line_header_ni == .none) unit.debug_line_header_ni = .wrap( |
| 7266 | elf.addNodeAssumeCapacity(try debug_line_ni.addOnlyHeaderChild(gpa, &elf.mf, .{ |
| 7251 | 7267 | // Idle tasks are going to try to keep this up to date before we are able to |
| 7252 | 7268 | // write out the full header, so just reserve space for them to do so. |
| 7253 | 7269 | .size = elf.dwarf.unitLengthSize(), |
| 7254 | 7270 | .enable_next_moved = true, |
| 7255 | | }), |
| 7256 | | .{ .unit_debug_line_header = ui }, |
| 7257 | | )); |
| 7271 | }), .{ .unit_debug_line_header = ui }), |
| 7272 | ); |
| 7258 | 7273 | }, |
| 7259 | 7274 | } |
| 7260 | 7275 | switch (elf.shndx.debug_rnglists) { |
| 7261 | 7276 | .UNDEF => {}, |
| 7262 | | else => |debug_rnglists_shndx| unit.debug_rnglists_ni = .wrap(elf.addNodeAssumeCapacity( |
| 7263 | | try debug_rnglists_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{ |
| 7264 | | .next_moved = true, |
| 7265 | | .enable_next_moved = true, |
| 7266 | | }), |
| 7267 | | .{ .unit_debug_rnglists = ui }, |
| 7268 | | )), |
| 7277 | else => |debug_rnglists_shndx| { |
| 7278 | const debug_rnglists_ni = unit.debug_rnglists_ni.unwrap() orelse debug_rnglists_ni: { |
| 7279 | const debug_rnglists_ni = elf.addNodeAssumeCapacity( |
| 7280 | try debug_rnglists_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{ |
| 7281 | .next_moved = true, |
| 7282 | .enable_next_moved = true, |
| 7283 | }), |
| 7284 | .{ .unit_debug_rnglists = ui }, |
| 7285 | ); |
| 7286 | unit.debug_rnglists_ni = .wrap(debug_rnglists_ni); |
| 7287 | break :debug_rnglists_ni debug_rnglists_ni; |
| 7288 | }; |
| 7289 | |
| 7290 | var drh_nw: MappedFile.Node.Writer = undefined; |
| 7291 | debug_rnglists_ni.writer(gpa, &elf.mf, &drh_nw); |
| 7292 | defer drh_nw.deinit(); |
| 7293 | elf.dwarf.genDebugRnglistsHeader(unit, &drh_nw) catch |err| switch (err) { |
| 7294 | else => |e| return e, |
| 7295 | error.WriteFailed => return drh_nw.err.?, |
| 7296 | }; |
| 7297 | }, |
| 7269 | 7298 | } |
| 7270 | 7299 | } |
| 7271 | | |
| 7272 | | for ( |
| 7273 | | elf.dwarf.units.keys()[old_units_len..], |
| 7274 | | elf.dwarf.units.values()[old_units_len..], |
| 7275 | | ) |mod, *unit| { |
| 7276 | | var drh_nw: MappedFile.Node.Writer = undefined; |
| 7277 | | unit.debug_rnglists_ni.unwrap().?.writer(gpa, &elf.mf, &drh_nw); |
| 7278 | | defer drh_nw.deinit(); |
| 7279 | | const debug_rnglists_offsets_table_offset = |
| 7280 | | elf.dwarf.genDebugRnglistsHeader(unit, &drh_nw) catch |err| switch (err) { |
| 7281 | | else => |e| return e, |
| 7282 | | error.WriteFailed => return drh_nw.err.?, |
| 7283 | | }; |
| 7284 | | |
| 7300 | for (0..units_len) |unit_index| { |
| 7301 | const ui: Dwarf.Unit.Index = @fromBackingInt(@intCast(unit_index)); |
| 7302 | const unit = ui.get(&elf.dwarf); |
| 7303 | if (unit.debug_info_header_ni == .none) continue; |
| 7285 | 7304 | var dih_nw: MappedFile.Node.Writer = undefined; |
| 7286 | 7305 | const debug_info_header_ni = unit.debug_info_header_ni.unwrap().?; |
| 7287 | 7306 | debug_info_header_ni.writer(gpa, &elf.mf, &dih_nw); |
| 7288 | 7307 | defer dih_nw.deinit(); |
| 7289 | 7308 | elf.resetNodeRelocs(debug_info_header_ni); |
| 7290 | | elf.dwarf.genDebugInfoHeader( |
| 7291 | | zcu, |
| 7292 | | mod, |
| 7293 | | unit, |
| 7294 | | &dih_nw, |
| 7295 | | debug_rnglists_offsets_table_offset, |
| 7296 | | ) catch |err| switch (err) { |
| 7309 | elf.dwarf.genDebugInfoHeader(zcu, ui.mod(&elf.dwarf), unit, &dih_nw) catch |err| switch (err) { |
| 7297 | 7310 | else => |e| return e, |
| 7298 | 7311 | error.WriteFailed => return dih_nw.err.?, |
| 7299 | 7312 | }; |
| ... | ... | @@ -7302,8 +7315,9 @@ fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void { |
| 7302 | 7315 | |
| 7303 | 7316 | fn flushFiles(elf: *Elf) Error!void { |
| 7304 | 7317 | const gpa = elf.base.comp.gpa; |
| 7305 | | if (elf.shndx.debug_line != .UNDEF) for (elf.dwarf.units.values()) |*unit| { |
| 7318 | if (elf.shndx.debug_line != .UNDEF) for (elf.dwarf.units) |*unit| { |
| 7306 | 7319 | if (!unit.cleanDebugLineHeaderChanged()) continue; |
| 7320 | assert(unit.alive); |
| 7307 | 7321 | const debug_line_header_ni = unit.debug_line_header_ni.unwrap().?; |
| 7308 | 7322 | try debug_line_header_ni.parent(&elf.mf).unwrap().?.nextMoved(gpa, &elf.mf); |
| 7309 | 7323 | try debug_line_header_ni.moved(gpa, &elf.mf); |
| ... | ... | @@ -8122,10 +8136,10 @@ fn addNodeRelocAssumeCapacity( |
| 8122 | 8136 | const first_target_reloc = switch (elf.getNode(target)) { |
| 8123 | 8137 | else => unreachable, |
| 8124 | 8138 | .debug_shared => |ss| &elf.dwarf_shared.getPtr(ss).first_target_reloc, |
| 8125 | | .unit_frame_cie => |ui| &elf.dwarf_units.items[@backingInt(ui)].frame_cie_first_target_reloc, |
| 8126 | | .unit_debug_info_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_info_header_first_target_reloc, |
| 8127 | | .unit_debug_line_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_target_reloc, |
| 8128 | | .unit_debug_rnglists => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_rnglists_first_target_reloc, |
| 8139 | .unit_frame_cie => |ui| &elf.dwarf_units[@backingInt(ui)].frame_cie_first_target_reloc, |
| 8140 | .unit_debug_info_header => |ui| &elf.dwarf_units[@backingInt(ui)].debug_info_header_first_target_reloc, |
| 8141 | .unit_debug_line_header => |ui| &elf.dwarf_units[@backingInt(ui)].debug_line_header_first_target_reloc, |
| 8142 | .unit_debug_rnglists => |ui| &elf.dwarf_units[@backingInt(ui)].debug_rnglists_first_target_reloc, |
| 8129 | 8143 | .const_debug_info => |cpi| &elf.dwarf_consts.getPtr(cpi).?.debug_info_first_target_reloc, |
| 8130 | 8144 | .global_debug_info => |gi| &elf.dwarf_globals.items[@backingInt(gi)].debug_info_first_target_reloc, |
| 8131 | 8145 | .func_debug_info => |fi| &elf.dwarf_funcs.items[@backingInt(fi)].debug_info_first_target_reloc, |
| ... | ... | @@ -8621,7 +8635,7 @@ fn updateConstInner( |
| 8621 | 8635 | |
| 8622 | 8636 | pub fn updateConstIncomplete( |
| 8623 | 8637 | elf: *Elf, |
| 8624 | | _: Zcu.PerThread, |
| 8638 | pt: Zcu.PerThread, |
| 8625 | 8639 | cpi: link.ConstPool.Index, |
| 8626 | 8640 | val: InternPool.Index, |
| 8627 | 8641 | ) link.Error!void { |
| ... | ... | @@ -8629,7 +8643,7 @@ pub fn updateConstIncomplete( |
| 8629 | 8643 | var di_nw: MappedFile.Node.Writer = undefined; |
| 8630 | 8644 | debug_info_ni.writer(elf.base.comp.gpa, &elf.mf, &di_nw); |
| 8631 | 8645 | defer di_nw.deinit(); |
| 8632 | | try elf.dwarf.updateConstIncomplete(&di_nw, val); |
| 8646 | try elf.dwarf.updateConstIncomplete(pt, &di_nw, val); |
| 8633 | 8647 | } |
| 8634 | 8648 | |
| 8635 | 8649 | pub fn updateFunc( |
| ... | ... | @@ -8717,7 +8731,7 @@ fn updateFuncInner( |
| 8717 | 8731 | unit.frame_ni = .wrap(frame_ni); |
| 8718 | 8732 | break :frame_ni frame_ni; |
| 8719 | 8733 | }; |
| 8720 | | _ = unit.cie_ni.unwrap() orelse { |
| 8734 | if (unit.cie_ni == .none) { |
| 8721 | 8735 | const cie_ni = elf.addNodeAssumeCapacity( |
| 8722 | 8736 | try frame_ni.addOnlyHeaderChild(gpa, &elf.mf, .{ |
| 8723 | 8737 | .alignment = frame_align, |
| ... | ... | @@ -8736,19 +8750,19 @@ fn updateFuncInner( |
| 8736 | 8750 | }, wip_nav.frame_format) catch |err| switch (err) { |
| 8737 | 8751 | error.WriteFailed => return cie_nw.err.?, |
| 8738 | 8752 | }; |
| 8739 | | }; |
| 8753 | } |
| 8740 | 8754 | const dwarf_func = dwarf_fi.get(dwarf); |
| 8741 | 8755 | const fde_ni = if (dwarf_func.fde_ni.unwrap()) |fde_ni| fde_ni: { |
| 8742 | 8756 | try fde_ni.moved(gpa, &elf.mf); |
| 8743 | 8757 | try fde_ni.nextMoved(gpa, &elf.mf); |
| 8744 | 8758 | break :fde_ni fde_ni; |
| 8745 | 8759 | } else fde_ni: { |
| 8746 | | const fde_ni = try frame_ni.addFloatingChild(gpa, &elf.mf, .{ |
| 8760 | const fde_ni = elf.addNodeAssumeCapacity(try frame_ni.addFloatingChild(gpa, &elf.mf, .{ |
| 8747 | 8761 | .alignment = frame_align, |
| 8748 | 8762 | .moved = true, |
| 8749 | 8763 | .next_moved = true, |
| 8750 | 8764 | .enable_next_moved = true, |
| 8751 | | }); |
| 8765 | }), .{ .func_frame_fde = dwarf_fi }); |
| 8752 | 8766 | dwarf_func.fde_ni = .wrap(fde_ni); |
| 8753 | 8767 | break :fde_ni fde_ni; |
| 8754 | 8768 | }; |
| ... | ... | @@ -8868,7 +8882,7 @@ fn updateFuncInner( |
| 8868 | 8882 | else => |e| return e, |
| 8869 | 8883 | error.WriteFailed => return dr_nw.err.?, |
| 8870 | 8884 | }; |
| 8871 | | const symbol_relocs = &elf.dwarf_units.items[@backingInt(debug.wip_nav.unit)] |
| 8885 | const symbol_relocs = &elf.dwarf_units[@backingInt(debug.wip_nav.unit)] |
| 8872 | 8886 | .debug_rnglists_symbol_relocs; |
| 8873 | 8887 | try symbol_relocs.ensureUnusedCapacity(gpa, elf.symbol_relocs.items.len - |
| 8874 | 8888 | first_symbol_reloc); |
| ... | ... | @@ -9629,7 +9643,7 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void |
| 9629 | 9643 | .unit_padding, .unit_frame, .unit_debug_info, .unit_debug_line => {}, |
| 9630 | 9644 | .unit_frame_cie => |ui| { |
| 9631 | 9645 | const target_section_offset = elf.computeNodeSectionOffset(ni); |
| 9632 | | var target_ri = elf.dwarf_units.items[@backingInt(ui)].frame_cie_first_target_reloc; |
| 9646 | var target_ri = elf.dwarf_units[@backingInt(ui)].frame_cie_first_target_reloc; |
| 9633 | 9647 | while (target_ri != .none) { |
| 9634 | 9648 | const target_reloc = target_ri.get(elf); |
| 9635 | 9649 | assert(target_reloc.target == ni); |
| ... | ... | @@ -9638,7 +9652,7 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void |
| 9638 | 9652 | } |
| 9639 | 9653 | }, |
| 9640 | 9654 | .unit_debug_info_header => |ui| { |
| 9641 | | const dwarf_unit = &elf.dwarf_units.items[@backingInt(ui)]; |
| 9655 | const dwarf_unit = &elf.dwarf_units[@backingInt(ui)]; |
| 9642 | 9656 | const target_section_offset = elf.computeNodeSectionOffset(ni); |
| 9643 | 9657 | var target_ri = dwarf_unit.debug_info_header_first_target_reloc; |
| 9644 | 9658 | while (target_ri != .none) { |
| ... | ... | @@ -9652,7 +9666,7 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void |
| 9652 | 9666 | }); |
| 9653 | 9667 | }, |
| 9654 | 9668 | .unit_debug_line_header => |ui| { |
| 9655 | | const dwarf_unit = &elf.dwarf_units.items[@backingInt(ui)]; |
| 9669 | const dwarf_unit = &elf.dwarf_units[@backingInt(ui)]; |
| 9656 | 9670 | const target_section_offset = elf.computeNodeSectionOffset(ni); |
| 9657 | 9671 | var target_ri = dwarf_unit.debug_line_header_first_target_reloc; |
| 9658 | 9672 | while (target_ri != .none) { |
| ... | ... | @@ -9666,7 +9680,7 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void |
| 9666 | 9680 | }); |
| 9667 | 9681 | }, |
| 9668 | 9682 | .unit_debug_rnglists => |ui| { |
| 9669 | | const dwarf_unit = &elf.dwarf_units.items[@backingInt(ui)]; |
| 9683 | const dwarf_unit = &elf.dwarf_units[@backingInt(ui)]; |
| 9670 | 9684 | const target_section_offset = elf.computeNodeSectionOffset(ni); |
| 9671 | 9685 | var target_ri = dwarf_unit.debug_rnglists_first_target_reloc; |
| 9672 | 9686 | while (target_ri != .none) { |