authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-09-07 16:09:31-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-09-07 19:53:07-04:00
log5637ede041a9b8b0a050343be5392f97994f6777
treed6118812b7ba7207513ddbc2b6b86eaa843e5cdc
parent804b044235954830e66a27b2365e1b26db51478a

Dwarf2: use indexed strings

This saves ~75MB on a `zig build -Dnew-linker` compiler binary.

2 files changed, 492 insertions(+), 329 deletions(-)

src/link/Dwarf2.zig+292-230
...@@ -199,8 +199,8 @@ pub const Line = struct {...@@ -199,8 +199,8 @@ pub const Line = struct {
199199
200pub const Str = struct {200pub const Str = struct {
201 ni: link.MappedFile.Node.Index.Optional,201 ni: link.MappedFile.Node.Index.Optional,
202 offset: usize,202 end: usize,
203 map: std.HashMapUnmanaged(usize, void, Context, std.hash_map.default_max_load_percentage),203 map: std.array_hash_map.Custom(usize, void, Context, true),
204204
205 fn get(205 fn get(
206 s: *Str,206 s: *Str,
...@@ -217,21 +217,21 @@ pub const Str = struct {...@@ -217,21 +217,21 @@ pub const Str = struct {
217 .{ .slice = slice },217 .{ .slice = slice },
218 );218 );
219 if (!gop.found_existing) {219 if (!gop.found_existing) {
220 gop.key_ptr.* = s.offset;220 gop.key_ptr.* = s.end;
221 try ni.ensureMinimumSize(gpa, mf, s.offset + str.len + 1);221 try ni.ensureMinimumSize(gpa, mf, s.end + str.len + 1);
222 const slice_mut = ni.slice(mf);222 const slice_mut = ni.slice(mf);
223 @memcpy(slice_mut[s.offset..][0..str.len], str);223 @memcpy(slice_mut[s.end..][0..str.len], str);
224 s.offset += str.len;224 s.end += str.len;
225 slice_mut[s.offset] = 0;225 slice_mut[s.end] = 0;
226 s.offset += 1;226 s.end += 1;
227 }227 }
228 return gop.key_ptr.*;228 return gop.key_ptr.*;
229 }229 }
230230
231 const Context = struct {231 const Context = struct {
232 slice: []const u8,232 slice: []const u8,
233 pub fn hash(context: Context, offset: usize) u64 {233 pub fn hash(context: Context, offset: usize) u32 {
234 return std.hash.Wyhash.hash(0, std.mem.sliceTo(context.slice[offset..], 0));234 return @truncate(std.hash.Wyhash.hash(0, std.mem.sliceTo(context.slice[offset..], 0)));
235 }235 }
236 pub fn eql(_: Context, lhs_offset: usize, rhs_offset: usize) bool {236 pub fn eql(_: Context, lhs_offset: usize, rhs_offset: usize) bool {
237 return lhs_offset == rhs_offset;237 return lhs_offset == rhs_offset;
...@@ -240,10 +240,10 @@ pub const Str = struct {...@@ -240,10 +240,10 @@ pub const Str = struct {
240240
241 const Adapter = struct {241 const Adapter = struct {
242 slice: []const u8,242 slice: []const u8,
243 pub fn hash(_: Adapter, key: []const u8) u64 {243 pub fn hash(_: Adapter, key: []const u8) u32 {
244 return std.hash.Wyhash.hash(0, key);244 return @truncate(std.hash.Wyhash.hash(0, key));
245 }245 }
246 pub fn eql(adapter: Adapter, key: []const u8, rhs_offset: usize) bool {246 pub fn eql(adapter: Adapter, key: []const u8, rhs_offset: usize, _: usize) bool {
247 return std.mem.startsWith(u8, adapter.slice[rhs_offset..], key) and247 return std.mem.startsWith(u8, adapter.slice[rhs_offset..], key) and
248 adapter.slice[rhs_offset + key.len] == 0;248 adapter.slice[rhs_offset + key.len] == 0;
249 }249 }
...@@ -251,17 +251,47 @@ pub const Str = struct {...@@ -251,17 +251,47 @@ pub const Str = struct {
251};251};
252252
253pub const Rnglists = struct {253pub const Rnglists = struct {
254 fn offsetsTableOffset(dwarf: *Dwarf) usize {254 fn tableOffset(dwarf: *Dwarf) usize {
255 return dwarf.unitLengthSize() + 2 + 1 + 1 + 4;255 return dwarf.unitLengthSize() + 2 + 1 + 1 + 4;
256 }256 }
257
258 pub fn size(dwarf: *Dwarf, ui: Unit.Index) usize {
259 return ui.get(dwarf).debug_rnglists_end + 1;
260 }
257};261};
258262
259pub const StrOffsets = struct {263pub const StrOffsets = struct {
260 ni: link.MappedFile.Node.Index.Optional,264 ni: link.MappedFile.Node.Index.Optional,
261 offset: usize,265 pending_index: usize,
266 map: std.array_hash_map.Auto(usize, void),
267
268 fn get(
269 so: *StrOffsets,
270 dwarf: *Dwarf,
271 s: *Str,
272 mf: *link.MappedFile,
273 str: []const u8,
274 ) link.Error!usize {
275 const comp = dwarf.lf.comp;
276 try so.map.ensureUnusedCapacity(comp.gpa, 1);
277 return so.map.getOrPutAssumeCapacity(s.get(comp.gpa, mf, str) catch |err| switch (err) {
278 else => |e| return e,
279 error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{
280 mf.io_err.?,
281 }),
282 }).index;
283 }
284
285 fn tableOffset(dwarf: *Dwarf) usize {
286 return dwarf.unitLengthSize() + 2 + 2;
287 }
288
289 pub fn size(so: *StrOffsets, dwarf: *Dwarf) usize {
290 return tableOffset(dwarf) + dwarf.secOffsetSize() * so.pending_index;
291 }
262};292};
263293
264pub const SharedSection = enum { debug_abbrev, debug_line_str, debug_str, debug_str_offsets };294pub const SharedSection = enum { debug_abbrev, debug_line_str, debug_str };
265295
266pub const Loc = union(enum) {296pub const Loc = union(enum) {
267 empty,297 empty,
...@@ -695,8 +725,8 @@ pub const WipFunc = struct {...@@ -695,8 +725,8 @@ pub const WipFunc = struct {
695 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);725 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
696 try di_w.writeUleb128(decl.src_column + 1);726 try di_w.writeUleb128(decl.src_column + 1);
697 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);727 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
698 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));728 try dwarf.strx(di_nw, nav.name.toSlice(ip));
699 try dwarf.strp(&dwarf.debug_str, di_nw, switch (decl.linkage) {729 try dwarf.strx(di_nw, switch (decl.linkage) {
700 .normal => nav.fqn,730 .normal => nav.fqn,
701 .@"extern", .@"export" => nav.name,731 .@"extern", .@"export" => nav.name,
702 }.toSlice(ip));732 }.toSlice(ip));
...@@ -813,7 +843,7 @@ pub const WipFunc = struct {...@@ -813,7 +843,7 @@ pub const WipFunc = struct {
813 .arg => if (opt_name) |_| .arg else .unnamed_arg,843 .arg => if (opt_name) |_| .arg else .unnamed_arg,
814 .local_var => if (opt_name) |_| .local_var else unreachable,844 .local_var => if (opt_name) |_| .local_var else unreachable,
815 });845 });
816 if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name);846 if (opt_name) |name| try dwarf.strx(di_nw, name);
817 try dwarf.refType(debug.pt, di_nw, ty);847 try dwarf.refType(debug.pt, di_nw, ty);
818 try dwarf.exprLoc(di_nw, loc);848 try dwarf.exprLoc(di_nw, loc);
819 debug.empty = false;849 debug.empty = false;
...@@ -865,7 +895,7 @@ pub const WipFunc = struct {...@@ -865,7 +895,7 @@ pub const WipFunc = struct {
865 .fully_comptime => .local_const_fully_comptime,895 .fully_comptime => .local_const_fully_comptime,
866 } else unreachable,896 } else unreachable,
867 });897 });
868 if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name);898 if (opt_name) |name| try dwarf.strx(di_nw, name);
869 try dwarf.refType(pt, di_nw, ty);899 try dwarf.refType(pt, di_nw, ty);
870 if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val);900 if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val);
871 if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val);901 if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val);
...@@ -1297,18 +1327,19 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf {...@@ -1297,18 +1327,19 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf {
1297 },1327 },
1298 .debug_line_str = .{1328 .debug_line_str = .{
1299 .ni = .none,1329 .ni = .none,
1300 .offset = 0,1330 .end = 0,
1301 .map = .empty,1331 .map = .empty,
1302 },1332 },
1303 .debug_rnglists = .{},1333 .debug_rnglists = .{},
1304 .debug_str = .{1334 .debug_str = .{
1305 .ni = .none,1335 .ni = .none,
1306 .offset = 0,1336 .end = 0,
1307 .map = .empty,1337 .map = .empty,
1308 },1338 },
1309 .debug_str_offsets = .{1339 .debug_str_offsets = .{
1310 .ni = .none,1340 .ni = .none,
1311 .offset = 0,1341 .pending_index = 0,
1342 .map = .empty,
1312 },1343 },
1313 };1344 };
1314}1345}
...@@ -1324,6 +1355,7 @@ pub fn deinit(dwarf: *Dwarf) void {...@@ -1324,6 +1355,7 @@ pub fn deinit(dwarf: *Dwarf) void {
1324 dwarf.decls.deinit(gpa);1355 dwarf.decls.deinit(gpa);
1325 dwarf.debug_line_str.map.deinit(gpa);1356 dwarf.debug_line_str.map.deinit(gpa);
1326 dwarf.debug_str.map.deinit(gpa);1357 dwarf.debug_str.map.deinit(gpa);
1358 dwarf.debug_str_offsets.map.deinit(gpa);
1327 dwarf.* = undefined;1359 dwarf.* = undefined;
1328}1360}
13291361
...@@ -1499,7 +1531,7 @@ fn getConstDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedIns...@@ -1499,7 +1531,7 @@ fn getConstDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedIns
1499 }).srcInst(ip),1531 }).srcInst(ip),
1500 }1532 }
1501}1533}
1502fn getConstDecl(1534pub fn getConstDecl(
1503 dwarf: *Dwarf,1535 dwarf: *Dwarf,
1504 pt: Zcu.PerThread,1536 pt: Zcu.PerThread,
1505 instance_const: InternPool.Index,1537 instance_const: InternPool.Index,
...@@ -1509,7 +1541,7 @@ fn getConstDecl(...@@ -1509,7 +1541,7 @@ fn getConstDecl(
1509 return Const.get(cpi, dwarf).debug_info_ni.unwrap().?;1541 return Const.get(cpi, dwarf).debug_info_ni.unwrap().?;
1510 }, .{ .@"const" = instance_const });1542 }, .{ .@"const" = instance_const });
1511}1543}
1512fn getGlobalDecl(1544pub fn getGlobalDecl(
1513 dwarf: *Dwarf,1545 dwarf: *Dwarf,
1514 pt: Zcu.PerThread,1546 pt: Zcu.PerThread,
1515 instance_global: InternPool.Nav.Index,1547 instance_global: InternPool.Nav.Index,
...@@ -1567,7 +1599,7 @@ pub fn unitLengthSize(dwarf: *Dwarf) usize {...@@ -1567,7 +1599,7 @@ pub fn unitLengthSize(dwarf: *Dwarf) usize {
1567 .@"64" => 4 + 8,1599 .@"64" => 4 + 8,
1568 };1600 };
1569}1601}
1570pub fn genUnitLength(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void {1602fn genUnitLength(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void {
1571 switch (dwarf.format) {1603 switch (dwarf.format) {
1572 .@"32" => try w.writeInt(u32, undefined, dwarf.endian),1604 .@"32" => try w.writeInt(u32, undefined, dwarf.endian),
1573 .@"64" => {1605 .@"64" => {
...@@ -1700,22 +1732,23 @@ pub fn genDebugInfoHeader(...@@ -1700,22 +1732,23 @@ pub fn genDebugInfoHeader(
1700 const compile_unit_offset = dih_w.end;1732 const compile_unit_offset = dih_w.end;
1701 try dwarf.abbrevCode(dih_nw, .compile_unit);1733 try dwarf.abbrevCode(dih_nw, .compile_unit);
1702 try dih_w.writeByte(DW.LANG.Zig);1734 try dih_w.writeByte(DW.LANG.Zig);
1703 try dwarf.strp(&dwarf.debug_str, dih_nw, "zig " ++ @import("build_options").version);
1704 const root_dir_path = try mod.root.toAbsolute(&comp.dirs, comp.gpa);
1705 defer comp.gpa.free(root_dir_path);
1706 try dwarf.strp(&dwarf.debug_line_str, dih_nw, root_dir_path);
1707 try dwarf.strp(&dwarf.debug_line_str, dih_nw, mod.root_src_path);
1708 try dwarf.secOffset(1735 try dwarf.secOffset(
1709 dih_nw,1736 dih_nw,
1710 dwarf.getUnit(zcu.root_mod).get(dwarf).debug_info_header_ni.unwrap().?,1737 dwarf.getUnit(zcu.root_mod).get(dwarf).debug_info_header_ni.unwrap().?,
1711 compile_unit_offset,1738 compile_unit_offset,
1712 );1739 );
1713 try dwarf.secOffset(dih_nw, unit.debug_line_header_ni.unwrap().?, 0);1740 try dwarf.secOffset(dih_nw, unit.debug_line_header_ni.unwrap().?, 0);
1714 try dwarf.secOffset(dih_nw, unit.debug_rnglists_ni.unwrap().?, Rnglists.offsetsTableOffset(dwarf));1741 try dwarf.secOffset(dih_nw, unit.debug_rnglists_ni.unwrap().?, Rnglists.tableOffset(dwarf));
1742 try dwarf.secOffset(dih_nw, dwarf.debug_str_offsets.ni.unwrap().?, StrOffsets.tableOffset(dwarf));
1743 try dwarf.strx1(dih_nw, "zig " ++ @import("build_options").version);
1744 const root_dir_path = try mod.root.toAbsolute(&comp.dirs, comp.gpa);
1745 defer comp.gpa.free(root_dir_path);
1746 try dwarf.strp(&dwarf.debug_line_str, dih_nw, root_dir_path);
1747 try dwarf.strp(&dwarf.debug_line_str, dih_nw, mod.root_src_path);
1715 try dih_w.writeUleb128(0);1748 try dih_w.writeUleb128(0);
1716 const module_offset = dih_w.end;1749 const module_offset = dih_w.end;
1717 try dwarf.abbrevCode(dih_nw, .module);1750 try dwarf.abbrevCode(dih_nw, .module);
1718 try dwarf.strp(&dwarf.debug_str, dih_nw, mod.fully_qualified_name);1751 try dwarf.strx(dih_nw, mod.fully_qualified_name);
1719 try dih_w.writeUleb128(0);1752 try dih_w.writeUleb128(0);
1720 try dwarf.genModuleDependency(1753 try dwarf.genModuleDependency(
1721 dih_nw,1754 dih_nw,
...@@ -1741,7 +1774,7 @@ fn genModuleDependency(...@@ -1741,7 +1774,7 @@ fn genModuleDependency(
1741 const dep_unit = dwarf.getUnit(dep).get(dwarf);1774 const dep_unit = dwarf.getUnit(dep).get(dwarf);
1742 if (!dep_unit.alive) return;1775 if (!dep_unit.alive) return;
1743 try dwarf.abbrevCode(di_nw, .module_dependency);1776 try dwarf.abbrevCode(di_nw, .module_dependency);
1744 try dwarf.strp(&dwarf.debug_str, di_nw, name);1777 try dwarf.strx(di_nw, name);
1745 try dwarf.secOffset(di_nw, dep_unit.debug_info_header_ni.unwrap().?, module_offset);1778 try dwarf.secOffset(di_nw, dep_unit.debug_info_header_ni.unwrap().?, module_offset);
1746}1779}
17471780
...@@ -1858,11 +1891,7 @@ pub fn genDebugLineHeader(...@@ -1858,11 +1891,7 @@ pub fn genDebugLineHeader(
1858 }1891 }
1859 try dlh_w.writeInt(i64, @truncate(zf.stat.mtime.nanoseconds), dwarf.endian);1892 try dlh_w.writeInt(i64, @truncate(zf.stat.mtime.nanoseconds), dwarf.endian);
1860 try dlh_w.writeInt(u64, zf.stat.size, dwarf.endian);1893 try dlh_w.writeInt(u64, zf.stat.size, dwarf.endian);
1861 try dwarf.strp(1894 try dwarf.strp(&dwarf.debug_line_str, dlh_nw, if (zf.is_builtin) zf.source.? else "");
1862 &dwarf.debug_line_str,
1863 dlh_nw,
1864 if (zf.is_builtin) zf.source.? else "",
1865 );
1866 }1895 }
1867 switch (dwarf.format) {1896 switch (dwarf.format) {
1868 .@"32" => std.mem.writeInt(1897 .@"32" => std.mem.writeInt(
...@@ -1924,7 +1953,7 @@ pub fn genDebugRnglistsHeader(...@@ -1924,7 +1953,7 @@ pub fn genDebugRnglistsHeader(
1924 try drh_w.writeByte(@backingInt(dwarf.address_size));1953 try drh_w.writeByte(@backingInt(dwarf.address_size));
1925 try drh_w.writeByte(0);1954 try drh_w.writeByte(0);
1926 try drh_w.writeInt(u32, 1, dwarf.endian);1955 try drh_w.writeInt(u32, 1, dwarf.endian);
1927 assert(drh_w.end == Rnglists.offsetsTableOffset(dwarf));1956 assert(drh_w.end == Rnglists.tableOffset(dwarf));
1928 switch (dwarf.format) {1957 switch (dwarf.format) {
1929 .@"32" => try drh_w.writeInt(u32, 4, dwarf.endian),1958 .@"32" => try drh_w.writeInt(u32, 4, dwarf.endian),
1930 .@"64" => try drh_w.writeInt(u64, 8, dwarf.endian),1959 .@"64" => try drh_w.writeInt(u64, 8, dwarf.endian),
...@@ -1933,7 +1962,7 @@ pub fn genDebugRnglistsHeader(...@@ -1933,7 +1962,7 @@ pub fn genDebugRnglistsHeader(
1933 try drh_w.writeByte(DW.RLE.end_of_list);1962 try drh_w.writeByte(DW.RLE.end_of_list);
1934}1963}
19351964
1936pub fn genDebugRnglists(1965pub fn genDebugRnglistsRange(
1937 dwarf: *Dwarf,1966 dwarf: *Dwarf,
1938 unit: *Unit,1967 unit: *Unit,
1939 dr_nw: *link.MappedFile.Node.Writer,1968 dr_nw: *link.MappedFile.Node.Writer,
...@@ -1949,6 +1978,24 @@ pub fn genDebugRnglists(...@@ -1949,6 +1978,24 @@ pub fn genDebugRnglists(
1949 try dr_w.writeByte(DW.RLE.end_of_list);1978 try dr_w.writeByte(DW.RLE.end_of_list);
1950}1979}
19511980
1981pub fn genDebugStrOffsetsHeader(dwarf: *Dwarf, dsoh_w: *std.Io.Writer) std.Io.Writer.Error!void {
1982 try dwarf.genUnitLength(dsoh_w);
1983 try dsoh_w.writeInt(u16, 5, dwarf.endian);
1984 try dsoh_w.writeInt(u16, 0, dwarf.endian);
1985 assert(dsoh_w.end == StrOffsets.tableOffset(dwarf));
1986}
1987
1988pub fn genPendingDebugStrOffsets(dwarf: *Dwarf, dso_nw: *link.MappedFile.Node.Writer) link.Error!void {
1989 dso_nw.interface.end = dwarf.debug_str_offsets.size(dwarf);
1990 for (dwarf.debug_str_offsets.map.keys()[dwarf.debug_str_offsets.pending_index..]) |offset| {
1991 dwarf.secOffset(dso_nw, dwarf.debug_str.ni.unwrap().?, offset) catch |err| switch (err) {
1992 else => |e| return e,
1993 error.WriteFailed => return dwarf.reportWriteError(dso_nw),
1994 };
1995 dwarf.debug_str_offsets.pending_index += 1;
1996 }
1997}
1998
1952pub fn updateExtern(1999pub fn updateExtern(
1953 dwarf: *Dwarf,2000 dwarf: *Dwarf,
1954 pt: Zcu.PerThread,2001 pt: Zcu.PerThread,
...@@ -2012,17 +2059,17 @@ fn updateExternInner(...@@ -2012,17 +2059,17 @@ fn updateExternInner(
2012 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);2059 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2013 try di_w.writeUleb128(decl.src_column + 1);2060 try di_w.writeUleb128(decl.src_column + 1);
2014 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);2061 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2015 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));2062 try dwarf.strx(di_nw, nav.name.toSlice(ip));
2016 } else {2063 } else {
2017 try dwarf.abbrevCode(di_nw, .decl_var);2064 try dwarf.abbrevCode(di_nw, .decl_var);
2018 try dwarf.refType(pt, di_nw, .fromInterned(zcu.fileRootType(inst_info.file)));2065 try dwarf.refType(pt, di_nw, .fromInterned(zcu.fileRootType(inst_info.file)));
2019 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);2066 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2020 try di_w.writeUleb128(decl.src_column + 1);2067 try di_w.writeUleb128(decl.src_column + 1);
2021 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);2068 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2022 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));2069 try dwarf.strx(di_nw, nav.name.toSlice(ip));
2023 },2070 },
2024 }2071 }
2025 try dwarf.strp(&dwarf.debug_str, di_nw, nav_extern.name.toSlice(ip));2072 try dwarf.strx(di_nw, nav_extern.name.toSlice(ip));
2026 if (maybe_func_type) |func_type| {2073 if (maybe_func_type) |func_type| {
2027 try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type));2074 try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type));
2028 try dwarf.addrSym(di_nw, si, 0);2075 try dwarf.addrSym(di_nw, si, 0);
...@@ -2115,9 +2162,9 @@ fn updateGlobalInner(...@@ -2115,9 +2162,9 @@ fn updateGlobalInner(
2115 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);2162 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2116 try di_w.writeUleb128(decl.src_column + 1);2163 try di_w.writeUleb128(decl.src_column + 1);
2117 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);2164 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2118 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));2165 try dwarf.strx(di_nw, nav.name.toSlice(ip));
2119 }2166 }
2120 try dwarf.strp(&dwarf.debug_str, di_nw, switch (decl.linkage) {2167 try dwarf.strx(di_nw, switch (decl.linkage) {
2121 .normal => nav.fqn,2168 .normal => nav.fqn,
2122 .@"extern" => unreachable,2169 .@"extern" => unreachable,
2123 .@"export" => nav.name,2170 .@"export" => nav.name,
...@@ -2286,12 +2333,12 @@ fn genComptimeGlobalInner(...@@ -2286,12 +2333,12 @@ fn genComptimeGlobalInner(
2286 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);2333 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2287 try di_w.writeUleb128(decl.src_column + 1);2334 try di_w.writeUleb128(decl.src_column + 1);
2288 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);2335 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2289 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));2336 try dwarf.strx(di_nw, nav.name.toSlice(ip));
2290 }2337 }
2291 switch (nav_ty.toIntern()) {2338 switch (nav_ty.toIntern()) {
2292 .type_type => try dwarf.refConst(pt, di_nw, nav_val),2339 .type_type => try dwarf.refConst(pt, di_nw, nav_val),
2293 else => {2340 else => {
2294 try dwarf.strp(&dwarf.debug_str, di_nw, switch (decl.linkage) {2341 try dwarf.strx(di_nw, switch (decl.linkage) {
2295 .normal => nav.fqn,2342 .normal => nav.fqn,
2296 .@"extern", .@"export" => nav.name,2343 .@"extern", .@"export" => nav.name,
2297 }.toSlice(ip));2344 }.toSlice(ip));
...@@ -2389,7 +2436,7 @@ fn updateConstInner(...@@ -2389,7 +2436,7 @@ fn updateConstInner(
2389 const ty: Type = .fromInterned(val);2436 const ty: Type = .fromInterned(val);
2390 try dwarf.abbrevCode(di_nw, .numeric_type);2437 try dwarf.abbrevCode(di_nw, .numeric_type);
2391 var name_buf: [std.fmt.count("i{d}", .{std.math.maxInt(u16)})]u8 = undefined;2438 var name_buf: [std.fmt.count("i{d}", .{std.math.maxInt(u16)})]u8 = undefined;
2392 try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&name_buf, "{f}", .{2439 try dwarf.strx(di_nw, std.mem.print(&name_buf, "{f}", .{
2393 ty.fmt(pt),2440 ty.fmt(pt),
2394 }) catch unreachable);2441 }) catch unreachable);
2395 try di_w.writeByte(switch (int_type.signedness) {2442 try di_w.writeByte(switch (int_type.signedness) {
...@@ -2408,7 +2455,7 @@ fn updateConstInner(...@@ -2408,7 +2455,7 @@ fn updateConstInner(
2408 .none => .ptr_type,2455 .none => .ptr_type,
2409 else => .ptr_sentinel_type,2456 else => .ptr_sentinel_type,
2410 });2457 });
2411 try dwarf.strp(&dwarf.debug_str, di_nw, name);2458 try dwarf.strx(di_nw, name);
2412 switch (ptr_type.sentinel) {2459 switch (ptr_type.sentinel) {
2413 .none => {},2460 .none => {},
2414 else => |sentinel| try dwarf.blockConst(pt, di_nw, .fromInterned(sentinel)),2461 else => |sentinel| try dwarf.blockConst(pt, di_nw, .fromInterned(sentinel)),
...@@ -2440,16 +2487,16 @@ fn updateConstInner(...@@ -2440,16 +2487,16 @@ fn updateConstInner(
2440 const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)});2487 const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)});
2441 defer zcu.gpa.free(name);2488 defer zcu.gpa.free(name);
2442 try dwarf.abbrevCode(di_nw, .generated_struct_type);2489 try dwarf.abbrevCode(di_nw, .generated_struct_type);
2443 try dwarf.strp(&dwarf.debug_str, di_nw, name);2490 try dwarf.strx(di_nw, name);
2444 try di_w.writeUleb128(ty.abiSize(zcu));2491 try di_w.writeUleb128(ty.abiSize(zcu));
2445 try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?);2492 try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?);
2446 try dwarf.abbrevCode(di_nw, .generated_field);2493 try dwarf.abbrevCode(di_nw, .generated_field);
2447 try dwarf.strp(&dwarf.debug_str, di_nw, "ptr");2494 try dwarf.strx(di_nw, "ptr");
2448 const ptr_field_ty = ty.slicePtrFieldType(zcu);2495 const ptr_field_ty = ty.slicePtrFieldType(zcu);
2449 try dwarf.refType(pt, di_nw, ptr_field_ty);2496 try dwarf.refType(pt, di_nw, ptr_field_ty);
2450 try di_w.writeUleb128(0);2497 try di_w.writeUleb128(0);
2451 try dwarf.abbrevCode(di_nw, .generated_field);2498 try dwarf.abbrevCode(di_nw, .generated_field);
2452 try dwarf.strp(&dwarf.debug_str, di_nw, "len");2499 try dwarf.strx(di_nw, "len");
2453 const len_field_ty: Type = .usize;2500 const len_field_ty: Type = .usize;
2454 try dwarf.refType(pt, di_nw, len_field_ty);2501 try dwarf.refType(pt, di_nw, len_field_ty);
2455 try di_w.writeUleb128(len_field_ty.abiAlignment(zcu).forward(ptr_field_ty.abiSize(zcu)));2502 try di_w.writeUleb128(len_field_ty.abiAlignment(zcu).forward(ptr_field_ty.abiSize(zcu)));
...@@ -2463,7 +2510,7 @@ fn updateConstInner(...@@ -2463,7 +2510,7 @@ fn updateConstInner(
2463 di_nw,2510 di_nw,
2464 if (array_type.sentinel == .none) .array_type else .array_sentinel_type,2511 if (array_type.sentinel == .none) .array_type else .array_sentinel_type,
2465 );2512 );
2466 try dwarf.strp(&dwarf.debug_str, di_nw, name);2513 try dwarf.strx(di_nw, name);
2467 if (array_type.sentinel != .none)2514 if (array_type.sentinel != .none)
2468 try dwarf.blockConst(pt, di_nw, .fromInterned(array_type.sentinel));2515 try dwarf.blockConst(pt, di_nw, .fromInterned(array_type.sentinel));
2469 try dwarf.refType(pt, di_nw, .fromInterned(array_type.child));2516 try dwarf.refType(pt, di_nw, .fromInterned(array_type.child));
...@@ -2476,7 +2523,7 @@ fn updateConstInner(...@@ -2476,7 +2523,7 @@ fn updateConstInner(
2476 const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)});2523 const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)});
2477 defer zcu.gpa.free(name);2524 defer zcu.gpa.free(name);
2478 try dwarf.abbrevCode(di_nw, .vector_type);2525 try dwarf.abbrevCode(di_nw, .vector_type);
2479 try dwarf.strp(&dwarf.debug_str, di_nw, name);2526 try dwarf.strx(di_nw, name);
2480 try dwarf.refType(pt, di_nw, .fromInterned(vector_type.child));2527 try dwarf.refType(pt, di_nw, .fromInterned(vector_type.child));
2481 try dwarf.abbrevCode(di_nw, .array_len);2528 try dwarf.abbrevCode(di_nw, .array_len);
2482 try dwarf.refType(pt, di_nw, .usize);2529 try dwarf.refType(pt, di_nw, .usize);
...@@ -2490,13 +2537,13 @@ fn updateConstInner(...@@ -2490,13 +2537,13 @@ fn updateConstInner(
2490 const name = try zcu.gpa.print("{f}", .{opt_ty.fmt(pt)});2537 const name = try zcu.gpa.print("{f}", .{opt_ty.fmt(pt)});
2491 defer zcu.gpa.free(name);2538 defer zcu.gpa.free(name);
2492 try dwarf.abbrevCode(di_nw, .generated_union_type);2539 try dwarf.abbrevCode(di_nw, .generated_union_type);
2493 try dwarf.strp(&dwarf.debug_str, di_nw, name);2540 try dwarf.strx(di_nw, name);
2494 try di_w.writeUleb128(opt_ty.abiSize(zcu));2541 try di_w.writeUleb128(opt_ty.abiSize(zcu));
2495 try di_w.writeUleb128(opt_ty.abiAlignment(zcu).toByteUnits().?);2542 try di_w.writeUleb128(opt_ty.abiAlignment(zcu).toByteUnits().?);
2496 switch (opt_repr) {2543 switch (opt_repr) {
2497 .opv_null => {2544 .opv_null => {
2498 try dwarf.abbrevCode(di_nw, .generated_field);2545 try dwarf.abbrevCode(di_nw, .generated_field);
2499 try dwarf.strp(&dwarf.debug_str, di_nw, "null");2546 try dwarf.strx(di_nw, "null");
2500 try dwarf.refType(pt, di_nw, .null);2547 try dwarf.refType(pt, di_nw, .null);
2501 try di_w.writeUleb128(0);2548 try di_w.writeUleb128(0);
2502 },2549 },
...@@ -2507,7 +2554,7 @@ fn updateConstInner(...@@ -2507,7 +2554,7 @@ fn updateConstInner(
2507 {2554 {
2508 try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end);2555 try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end);
2509 try dwarf.abbrevCode(di_nw, .generated_field);2556 try dwarf.abbrevCode(di_nw, .generated_field);
2510 try dwarf.strp(&dwarf.debug_str, di_nw, "has_value");2557 try dwarf.strx(di_nw, "has_value");
2511 switch (opt_repr) {2558 switch (opt_repr) {
2512 .opv_null => unreachable,2559 .opv_null => unreachable,
2513 .unpacked => {2560 .unpacked => {
...@@ -2535,7 +2582,7 @@ fn updateConstInner(...@@ -2535,7 +2582,7 @@ fn updateConstInner(
2535 try di_w.writeByte(0);2582 try di_w.writeByte(0);
2536 {2583 {
2537 try dwarf.abbrevCode(di_nw, .generated_field);2584 try dwarf.abbrevCode(di_nw, .generated_field);
2538 try dwarf.strp(&dwarf.debug_str, di_nw, "null");2585 try dwarf.strx(di_nw, "null");
2539 try dwarf.refType(pt, di_nw, .null);2586 try dwarf.refType(pt, di_nw, .null);
2540 try di_w.writeUleb128(0);2587 try di_w.writeUleb128(0);
2541 }2588 }
...@@ -2544,7 +2591,7 @@ fn updateConstInner(...@@ -2544,7 +2591,7 @@ fn updateConstInner(
2544 try dwarf.abbrevCode(di_nw, .tagged_union_default_field);2591 try dwarf.abbrevCode(di_nw, .tagged_union_default_field);
2545 {2592 {
2546 try dwarf.abbrevCode(di_nw, .generated_field);2593 try dwarf.abbrevCode(di_nw, .generated_field);
2547 try dwarf.strp(&dwarf.debug_str, di_nw, "?");2594 try dwarf.strx(di_nw, "?");
2548 try dwarf.refType(pt, di_nw, opt_child_ty);2595 try dwarf.refType(pt, di_nw, opt_child_ty);
2549 try di_w.writeUleb128(0);2596 try di_w.writeUleb128(0);
2550 }2597 }
...@@ -2571,7 +2618,7 @@ fn updateConstInner(...@@ -2571,7 +2618,7 @@ fn updateConstInner(
2571 defer zcu.gpa.free(name);2618 defer zcu.gpa.free(name);
25722619
2573 try dwarf.abbrevCode(di_nw, .generated_union_type);2620 try dwarf.abbrevCode(di_nw, .generated_union_type);
2574 try dwarf.strp(&dwarf.debug_str, di_nw, name);2621 try dwarf.strx(di_nw, name);
2575 if (error_union_type.error_set_type != .generic_poison_type and2622 if (error_union_type.error_set_type != .generic_poison_type and
2576 error_union_type.payload_type != .generic_poison_type)2623 error_union_type.payload_type != .generic_poison_type)
2577 {2624 {
...@@ -2588,7 +2635,7 @@ fn updateConstInner(...@@ -2588,7 +2635,7 @@ fn updateConstInner(
2588 {2635 {
2589 try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end);2636 try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end);
2590 try dwarf.abbrevCode(di_nw, .generated_field);2637 try dwarf.abbrevCode(di_nw, .generated_field);
2591 try dwarf.strp(&dwarf.debug_str, di_nw, "is_error");2638 try dwarf.strx(di_nw, "is_error");
2592 try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits()));2639 try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits()));
2593 try di_w.writeUleb128(eu_error_set_offset);2640 try di_w.writeUleb128(eu_error_set_offset);
25942641
...@@ -2597,7 +2644,7 @@ fn updateConstInner(...@@ -2597,7 +2644,7 @@ fn updateConstInner(
2597 try di_w.writeUleb128(0);2644 try di_w.writeUleb128(0);
2598 {2645 {
2599 try dwarf.abbrevCode(di_nw, .generated_field);2646 try dwarf.abbrevCode(di_nw, .generated_field);
2600 try dwarf.strp(&dwarf.debug_str, di_nw, "value");2647 try dwarf.strx(di_nw, "value");
2601 try dwarf.refType(pt, di_nw, eu_payload_ty);2648 try dwarf.refType(pt, di_nw, eu_payload_ty);
2602 try di_w.writeUleb128(eu_payload_offset);2649 try di_w.writeUleb128(eu_payload_offset);
2603 }2650 }
...@@ -2606,7 +2653,7 @@ fn updateConstInner(...@@ -2606,7 +2653,7 @@ fn updateConstInner(
2606 try dwarf.abbrevCode(di_nw, .tagged_union_default_field);2653 try dwarf.abbrevCode(di_nw, .tagged_union_default_field);
2607 {2654 {
2608 try dwarf.abbrevCode(di_nw, .generated_field);2655 try dwarf.abbrevCode(di_nw, .generated_field);
2609 try dwarf.strp(&dwarf.debug_str, di_nw, "error");2656 try dwarf.strx(di_nw, "error");
2610 try dwarf.refType(pt, di_nw, eu_error_set_ty);2657 try dwarf.refType(pt, di_nw, eu_error_set_ty);
2611 try di_w.writeUleb128(eu_error_set_offset);2658 try di_w.writeUleb128(eu_error_set_offset);
2612 }2659 }
...@@ -2638,7 +2685,7 @@ fn updateConstInner(...@@ -2638,7 +2685,7 @@ fn updateConstInner(
2638 => {2685 => {
2639 const ty: Type = .fromInterned(val);2686 const ty: Type = .fromInterned(val);
2640 try dwarf.abbrevCode(di_nw, .numeric_type);2687 try dwarf.abbrevCode(di_nw, .numeric_type);
2641 try dwarf.strp(&dwarf.debug_str, di_nw, @tagName(simple_type));2688 try dwarf.strx(di_nw, @tagName(simple_type));
2642 try di_w.writeByte(if (val == .bool_type)2689 try di_w.writeByte(if (val == .bool_type)
2643 DW.ATE.boolean2690 DW.ATE.boolean
2644 else if (ty.isRuntimeFloat())2691 else if (ty.isRuntimeFloat())
...@@ -2655,7 +2702,7 @@ fn updateConstInner(...@@ -2655,7 +2702,7 @@ fn updateConstInner(
2655 },2702 },
2656 .generic_poison => {2703 .generic_poison => {
2657 try dwarf.abbrevCode(di_nw, .void_type);2704 try dwarf.abbrevCode(di_nw, .void_type);
2658 try dwarf.strp(&dwarf.debug_str, di_nw, "anytype");2705 try dwarf.strx(di_nw, "anytype");
2659 },2706 },
2660 .anyopaque,2707 .anyopaque,
2661 .void,2708 .void,
...@@ -2670,7 +2717,7 @@ fn updateConstInner(...@@ -2670,7 +2717,7 @@ fn updateConstInner(
2670 const ty: Type = .fromInterned(val);2717 const ty: Type = .fromInterned(val);
2671 try dwarf.abbrevCode(di_nw, .void_type);2718 try dwarf.abbrevCode(di_nw, .void_type);
2672 var name_buf: ["@TypeOf(undefined)".len]u8 = undefined;2719 var name_buf: ["@TypeOf(undefined)".len]u8 = undefined;
2673 try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&name_buf, "{f}", .{2720 try dwarf.strx(di_nw, std.mem.print(&name_buf, "{f}", .{
2674 ty.fmt(pt),2721 ty.fmt(pt),
2675 }) catch unreachable);2722 }) catch unreachable);
2676 },2723 },
...@@ -2680,13 +2727,13 @@ fn updateConstInner(...@@ -2680,13 +2727,13 @@ fn updateConstInner(
2680 .generated_enum_type2727 .generated_enum_type
2681 else2728 else
2682 .generated_empty_enum_type);2729 .generated_empty_enum_type);
2683 try dwarf.strp(&dwarf.debug_str, di_nw, "anyerror");2730 try dwarf.strx(di_nw, "anyerror");
2684 try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits()));2731 try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits()));
2685 for (global_error_set_names, 1..) |name, value| {2732 for (global_error_set_names, 1..) |name, value| {
2686 try dwarf.abbrevCode(di_nw, .enum_field);2733 try dwarf.abbrevCode(di_nw, .enum_field);
2687 try di_w.writeUleb128(DW.FORM.udata);2734 try di_w.writeUleb128(DW.FORM.udata);
2688 try di_w.writeUleb128(value);2735 try di_w.writeUleb128(value);
2689 try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip));2736 try dwarf.strx(di_nw, name.toSlice(ip));
2690 }2737 }
2691 if (global_error_set_names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null));2738 if (global_error_set_names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null));
2692 },2739 },
...@@ -2698,11 +2745,11 @@ fn updateConstInner(...@@ -2698,11 +2745,11 @@ fn updateConstInner(
2698 defer zcu.gpa.free(name);2745 defer zcu.gpa.free(name);
2699 if (tuple_type.types.len == 0) {2746 if (tuple_type.types.len == 0) {
2700 try dwarf.abbrevCode(di_nw, .generated_empty_struct_type);2747 try dwarf.abbrevCode(di_nw, .generated_empty_struct_type);
2701 try dwarf.strp(&dwarf.debug_str, di_nw, name);2748 try dwarf.strx(di_nw, name);
2702 try di_w.writeByte(@intFromBool(false));2749 try di_w.writeByte(@intFromBool(false));
2703 } else {2750 } else {
2704 try dwarf.abbrevCode(di_nw, .generated_struct_type);2751 try dwarf.abbrevCode(di_nw, .generated_struct_type);
2705 try dwarf.strp(&dwarf.debug_str, di_nw, name);2752 try dwarf.strx(di_nw, name);
2706 try di_w.writeUleb128(ty.abiSize(zcu));2753 try di_w.writeUleb128(ty.abiSize(zcu));
2707 try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?);2754 try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?);
2708 var field_byte_offset: u64 = 0;2755 var field_byte_offset: u64 = 0;
...@@ -2723,7 +2770,7 @@ fn updateConstInner(...@@ -2723,7 +2770,7 @@ fn updateConstInner(
2723 },2770 },
2724 });2771 });
2725 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;2772 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;
2726 try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&field_name_buf, "{d}", .{2773 try dwarf.strx(di_nw, std.mem.print(&field_name_buf, "{d}", .{
2727 field_index,2774 field_index,
2728 }) catch unreachable);2775 }) catch unreachable);
2729 try dwarf.refType(pt, di_nw, field_ty);2776 try dwarf.refType(pt, di_nw, field_ty);
...@@ -2755,7 +2802,7 @@ fn updateConstInner(...@@ -2755,7 +2802,7 @@ fn updateConstInner(
2755 .@"extern", .@"packed" => unreachable,2802 .@"extern", .@"packed" => unreachable,
2756 });2803 });
2757 try di_w.writeUleb128(@backingInt(fi));2804 try di_w.writeUleb128(@backingInt(fi));
2758 try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip));2805 try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip));
2759 } else if (loaded_struct.captures.len > 0 or loaded_struct.is_reified) {2806 } else if (loaded_struct.captures.len > 0 or loaded_struct.is_reified) {
2760 try dwarf.abbrevCode(di_nw, if (loaded_struct.captures.len > 0 or2807 try dwarf.abbrevCode(di_nw, if (loaded_struct.captures.len > 0 or
2761 loaded_struct.field_types.len > 0) switch (loaded_struct.layout) {2808 loaded_struct.field_types.len > 0) switch (loaded_struct.layout) {
...@@ -2788,7 +2835,7 @@ fn updateConstInner(...@@ -2788,7 +2835,7 @@ fn updateConstInner(
2788 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);2835 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2789 try di_w.writeUleb128(decl.src_column + 1);2836 try di_w.writeUleb128(decl.src_column + 1);
2790 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);2837 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2791 try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip));2838 try dwarf.strx(di_nw, name_nav.name.toSlice(ip));
2792 } else {2839 } else {
2793 const decl = zf.zir.?.getStructDecl(src_inst.inst);2840 const decl = zf.zir.?.getStructDecl(src_inst.inst);
2794 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(2841 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
...@@ -2806,7 +2853,7 @@ fn updateConstInner(...@@ -2806,7 +2853,7 @@ fn updateConstInner(
2806 try dwarf.secOffset(di_nw, parent_ni, 0);2853 try dwarf.secOffset(di_nw, parent_ni, 0);
2807 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);2854 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2808 try di_w.writeUleb128(decl.src_column + 1);2855 try di_w.writeUleb128(decl.src_column + 1);
2809 try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip));2856 try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip));
2810 }2857 }
2811 switch (loaded_struct.layout) {2858 switch (loaded_struct.layout) {
2812 .auto, .@"extern" => {2859 .auto, .@"extern" => {
...@@ -2846,8 +2893,7 @@ fn updateConstInner(...@@ -2846,8 +2893,7 @@ fn updateConstInner(
2846 .partially_comptime => .field_default_partially_comptime,2893 .partially_comptime => .field_default_partially_comptime,
2847 .fully_comptime => .field_default_fully_comptime,2894 .fully_comptime => .field_default_fully_comptime,
2848 });2895 });
2849 try dwarf.strp(2896 try dwarf.strx(
2850 &dwarf.debug_str,
2851 di_nw,2897 di_nw,
2852 loaded_struct.field_names.get(ip)[field_index].toSlice(ip),2898 loaded_struct.field_names.get(ip)[field_index].toSlice(ip),
2853 );2899 );
...@@ -2871,8 +2917,7 @@ fn updateConstInner(...@@ -2871,8 +2917,7 @@ fn updateConstInner(
2871 var field_bit_offset: u16 = 0;2917 var field_bit_offset: u16 = 0;
2872 for (0..loaded_struct.field_types.len) |field_index| {2918 for (0..loaded_struct.field_types.len) |field_index| {
2873 try dwarf.abbrevCode(di_nw, .packed_field);2919 try dwarf.abbrevCode(di_nw, .packed_field);
2874 try dwarf.strp(2920 try dwarf.strx(
2875 &dwarf.debug_str,
2876 di_nw,2921 di_nw,
2877 loaded_struct.field_names.get(ip)[field_index].toSlice(ip),2922 loaded_struct.field_names.get(ip)[field_index].toSlice(ip),
2878 );2923 );
...@@ -2924,7 +2969,7 @@ fn updateConstInner(...@@ -2924,7 +2969,7 @@ fn updateConstInner(
2924 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);2969 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2925 try di_w.writeUleb128(decl.src_column + 1);2970 try di_w.writeUleb128(decl.src_column + 1);
2926 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);2971 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2927 try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip));2972 try dwarf.strx(di_nw, name_nav.name.toSlice(ip));
2928 } else {2973 } else {
2929 const decl = zf.zir.?.getUnionDecl(loaded_union.zir_index.resolve(ip).?);2974 const decl = zf.zir.?.getUnionDecl(loaded_union.zir_index.resolve(ip).?);
2930 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(2975 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
...@@ -2942,7 +2987,7 @@ fn updateConstInner(...@@ -2942,7 +2987,7 @@ fn updateConstInner(
2942 try dwarf.secOffset(di_nw, parent_ni, 0);2987 try dwarf.secOffset(di_nw, parent_ni, 0);
2943 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);2988 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
2944 try di_w.writeUleb128(decl.src_column + 1);2989 try di_w.writeUleb128(decl.src_column + 1);
2945 try dwarf.strp(&dwarf.debug_str, di_nw, loaded_union.name.toSlice(ip));2990 try dwarf.strx(di_nw, loaded_union.name.toSlice(ip));
2946 }2991 }
2947 switch (loaded_union.layout) {2992 switch (loaded_union.layout) {
2948 .auto, .@"extern" => {2993 .auto, .@"extern" => {
...@@ -2957,7 +3002,7 @@ fn updateConstInner(...@@ -2957,7 +3002,7 @@ fn updateConstInner(
2957 {3002 {
2958 try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end);3003 try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end);
2959 try dwarf.abbrevCode(di_nw, .generated_field);3004 try dwarf.abbrevCode(di_nw, .generated_field);
2960 try dwarf.strp(&dwarf.debug_str, di_nw, "tag");3005 try dwarf.strx(di_nw, "tag");
2961 try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.enum_tag_type));3006 try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.enum_tag_type));
2962 try di_w.writeUleb128(union_layout.tagOffset());3007 try di_w.writeUleb128(union_layout.tagOffset());
29633008
...@@ -2966,8 +3011,7 @@ fn updateConstInner(...@@ -2966,8 +3011,7 @@ fn updateConstInner(
2966 try dwarf.enumConstValue(di_w, loaded_tag, field_index);3011 try dwarf.enumConstValue(di_w, loaded_tag, field_index);
2967 {3012 {
2968 try dwarf.abbrevCode(di_nw, .field);3013 try dwarf.abbrevCode(di_nw, .field);
2969 try dwarf.strp(3014 try dwarf.strx(
2970 &dwarf.debug_str,
2971 di_nw,3015 di_nw,
2972 loaded_tag.field_names.get(ip)[field_index].toSlice(ip),3016 loaded_tag.field_names.get(ip)[field_index].toSlice(ip),
2973 );3017 );
...@@ -2989,8 +3033,7 @@ fn updateConstInner(...@@ -2989,8 +3033,7 @@ fn updateConstInner(
2989 try di_w.writeUleb128(@backingInt(AbbrevCode.null));3033 try di_w.writeUleb128(@backingInt(AbbrevCode.null));
2990 } else for (0..loaded_union.field_types.len) |field_index| {3034 } else for (0..loaded_union.field_types.len) |field_index| {
2991 try dwarf.abbrevCode(di_nw, .field);3035 try dwarf.abbrevCode(di_nw, .field);
2992 try dwarf.strp(3036 try dwarf.strx(
2993 &dwarf.debug_str,
2994 di_nw,3037 di_nw,
2995 loaded_tag.field_names.get(ip)[field_index].toSlice(ip),3038 loaded_tag.field_names.get(ip)[field_index].toSlice(ip),
2996 );3039 );
...@@ -3011,8 +3054,7 @@ fn updateConstInner(...@@ -3011,8 +3054,7 @@ fn updateConstInner(
3011 try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.packed_backing_int_type));3054 try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.packed_backing_int_type));
3012 for (0..loaded_union.field_types.len) |field_index| {3055 for (0..loaded_union.field_types.len) |field_index| {
3013 try dwarf.abbrevCode(di_nw, .packed_field);3056 try dwarf.abbrevCode(di_nw, .packed_field);
3014 try dwarf.strp(3057 try dwarf.strx(
3015 &dwarf.debug_str,
3016 di_nw,3058 di_nw,
3017 loaded_tag.field_names.get(ip)[field_index].toSlice(ip),3059 loaded_tag.field_names.get(ip)[field_index].toSlice(ip),
3018 );3060 );
...@@ -3057,7 +3099,7 @@ fn updateConstInner(...@@ -3057,7 +3099,7 @@ fn updateConstInner(
3057 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);3099 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
3058 try di_w.writeUleb128(decl.src_column + 1);3100 try di_w.writeUleb128(decl.src_column + 1);
3059 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);3101 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
3060 try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip));3102 try dwarf.strx(di_nw, name_nav.name.toSlice(ip));
3061 } else {3103 } else {
3062 const decl = zir.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?);3104 const decl = zir.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?);
3063 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(3105 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
...@@ -3070,7 +3112,7 @@ fn updateConstInner(...@@ -3070,7 +3112,7 @@ fn updateConstInner(
3070 try dwarf.secOffset(di_nw, parent_ni, 0);3112 try dwarf.secOffset(di_nw, parent_ni, 0);
3071 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);3113 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
3072 try di_w.writeUleb128(decl.src_column + 1);3114 try di_w.writeUleb128(decl.src_column + 1);
3073 try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip));3115 try dwarf.strx(di_nw, loaded_enum.name.toSlice(ip));
3074 }3116 }
3075 },3117 },
3076 else => {3118 else => {
...@@ -3078,7 +3120,7 @@ fn updateConstInner(...@@ -3078,7 +3120,7 @@ fn updateConstInner(
3078 .generated_enum_type3120 .generated_enum_type
3079 else3121 else
3080 .generated_empty_enum_type);3122 .generated_empty_enum_type);
3081 try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.fqn.toSlice(ip));3123 try dwarf.strx(di_nw, loaded_enum.fqn.toSlice(ip));
3082 },3124 },
3083 }3125 }
3084 try dwarf.refType(pt, di_nw, .fromInterned(loaded_enum.int_tag_type));3126 try dwarf.refType(pt, di_nw, .fromInterned(loaded_enum.int_tag_type));
...@@ -3086,11 +3128,7 @@ fn updateConstInner(...@@ -3086,11 +3128,7 @@ fn updateConstInner(
3086 for (0..loaded_enum.field_names.len) |field_index| {3128 for (0..loaded_enum.field_names.len) |field_index| {
3087 try dwarf.abbrevCode(di_nw, .enum_field);3129 try dwarf.abbrevCode(di_nw, .enum_field);
3088 try dwarf.enumConstValue(di_w, loaded_enum, field_index);3130 try dwarf.enumConstValue(di_w, loaded_enum, field_index);
3089 try dwarf.strp(3131 try dwarf.strx(di_nw, loaded_enum.field_names.get(ip)[field_index].toSlice(ip));
3090 &dwarf.debug_str,
3091 di_nw,
3092 loaded_enum.field_names.get(ip)[field_index].toSlice(ip),
3093 );
3094 }3132 }
3095 if (loaded_enum.captures.len > 0 or loaded_enum.field_names.len > 0)3133 if (loaded_enum.captures.len > 0 or loaded_enum.field_names.len > 0)
3096 try di_w.writeUleb128(@backingInt(AbbrevCode.null));3134 try di_w.writeUleb128(@backingInt(AbbrevCode.null));
...@@ -3103,7 +3141,7 @@ fn updateConstInner(...@@ -3103,7 +3141,7 @@ fn updateConstInner(
3103 const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)});3141 const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)});
3104 defer zcu.gpa.free(name);3142 defer zcu.gpa.free(name);
3105 try dwarf.abbrevCode(di_nw, if (is_empty) .empty_func_type else .func_type);3143 try dwarf.abbrevCode(di_nw, if (is_empty) .empty_func_type else .func_type);
3106 try dwarf.strp(&dwarf.debug_str, di_nw, name);3144 try dwarf.strx(di_nw, name);
3107 const cc: DW.CC = cc: {3145 const cc: DW.CC = cc: {
3108 if (zcu.getTarget().cCallingConvention()) |cc| {3146 if (zcu.getTarget().cCallingConvention()) |cc| {
3109 if (@as(std.lang.CallingConvention.Tag, cc) == func_type.cc) {3147 if (@as(std.lang.CallingConvention.Tag, cc) == func_type.cc) {
...@@ -3191,14 +3229,14 @@ fn updateConstInner(...@@ -3191,14 +3229,14 @@ fn updateConstInner(
3191 di_nw,3229 di_nw,
3192 if (error_set_type.names.len > 0) .generated_enum_type else .generated_empty_enum_type,3230 if (error_set_type.names.len > 0) .generated_enum_type else .generated_empty_enum_type,
3193 );3231 );
3194 try dwarf.strp(&dwarf.debug_str, di_nw, name);3232 try dwarf.strx(di_nw, name);
3195 try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits()));3233 try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits()));
3196 for (0..error_set_type.names.len) |field_index| {3234 for (0..error_set_type.names.len) |field_index| {
3197 const field_name = error_set_type.names.get(ip)[field_index];3235 const field_name = error_set_type.names.get(ip)[field_index];
3198 try dwarf.abbrevCode(di_nw, .enum_field);3236 try dwarf.abbrevCode(di_nw, .enum_field);
3199 try di_w.writeUleb128(DW.FORM.udata);3237 try di_w.writeUleb128(DW.FORM.udata);
3200 try di_w.writeUleb128(ip.getErrorValueIfExists(field_name).?);3238 try di_w.writeUleb128(ip.getErrorValueIfExists(field_name).?);
3201 try dwarf.strp(&dwarf.debug_str, di_nw, field_name.toSlice(ip));3239 try dwarf.strx(di_nw, field_name.toSlice(ip));
3202 }3240 }
3203 if (error_set_type.names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null));3241 if (error_set_type.names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null));
3204 },3242 },
...@@ -3206,7 +3244,7 @@ fn updateConstInner(...@@ -3206,7 +3244,7 @@ fn updateConstInner(
3206 const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)});3244 const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)});
3207 defer zcu.gpa.free(name);3245 defer zcu.gpa.free(name);
3208 try dwarf.abbrevCode(di_nw, .inferred_error_set_type);3246 try dwarf.abbrevCode(di_nw, .inferred_error_set_type);
3209 try dwarf.strp(&dwarf.debug_str, di_nw, name);3247 try dwarf.strx(di_nw, name);
3210 try dwarf.refType(pt, di_nw, switch (ies: {3248 try dwarf.refType(pt, di_nw, switch (ies: {
3211 const fi = dwarf.getFuncIfExists(ip.indexToKey(func).func.owner_nav) orelse3249 const fi = dwarf.getFuncIfExists(ip.indexToKey(func).func.owner_nav) orelse
3212 break :ies .none;3250 break :ies .none;
...@@ -3248,7 +3286,7 @@ fn updateConstInner(...@@ -3248,7 +3286,7 @@ fn updateConstInner(
3248 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);3286 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
3249 try di_w.writeUleb128(decl.src_column + 1);3287 try di_w.writeUleb128(decl.src_column + 1);
3250 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);3288 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
3251 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));3289 try dwarf.strx(di_nw, nav.name.toSlice(ip));
3252 try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type));3290 try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type));
3253 for (3291 for (
3254 zir.getParamBody(func.zir_body_inst.resolve(ip).?)[0..func_type.param_types.len],3292 zir.getParamBody(func.zir_body_inst.resolve(ip).?)[0..func_type.param_types.len],
...@@ -3258,7 +3296,7 @@ fn updateConstInner(...@@ -3258,7 +3296,7 @@ fn updateConstInner(
3258 .empty => try dwarf.abbrevCode(di_nw, .unnamed_param),3296 .empty => try dwarf.abbrevCode(di_nw, .unnamed_param),
3259 else => |param_name| {3297 else => |param_name| {
3260 try dwarf.abbrevCode(di_nw, .param);3298 try dwarf.abbrevCode(di_nw, .param);
3261 try dwarf.strp(&dwarf.debug_str, di_nw, zir.nullTerminatedString(param_name));3299 try dwarf.strx(di_nw, zir.nullTerminatedString(param_name));
3262 },3300 },
3263 }3301 }
3264 try dwarf.refType(pt, di_nw, .fromInterned(param_ty));3302 try dwarf.refType(pt, di_nw, .fromInterned(param_ty));
...@@ -3313,7 +3351,7 @@ fn updateConstInner(...@@ -3313,7 +3351,7 @@ fn updateConstInner(
3313 }3351 }
3314 {3352 {
3315 try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime);3353 try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime);
3316 try dwarf.strp(&dwarf.debug_str, di_nw, "is_error");3354 try dwarf.strx(di_nw, "is_error");
3317 try di_w.writeUleb128(err_bytes.len);3355 try di_w.writeUleb128(err_bytes.len);
3318 try di_w.writeAll(err_bytes);3356 try di_w.writeAll(err_bytes);
3319 }3357 }
...@@ -3328,7 +3366,7 @@ fn updateConstInner(...@@ -3328,7 +3366,7 @@ fn updateConstInner(
3328 .comptime_value_field_runtime3366 .comptime_value_field_runtime
3329 else3367 else
3330 break :payload_field);3368 break :payload_field);
3331 try dwarf.strp(&dwarf.debug_str, di_nw, "value");3369 try dwarf.strx(di_nw, "value");
3332 if (payload_class.comptimeOnly())3370 if (payload_class.comptimeOnly())
3333 try dwarf.refConst(pt, di_nw, .fromInterned(payload_val))3371 try dwarf.refConst(pt, di_nw, .fromInterned(payload_val))
3334 else if (payload_class.hasRuntimeBits())3372 else if (payload_class.hasRuntimeBits())
...@@ -3339,7 +3377,7 @@ fn updateConstInner(...@@ -3339,7 +3377,7 @@ fn updateConstInner(
3339 }3377 }
3340 {3378 {
3341 try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime);3379 try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime);
3342 try dwarf.strp(&dwarf.debug_str, di_nw, "error");3380 try dwarf.strx(di_nw, "error");
3343 try di_w.writeUleb128(err_bytes.len);3381 try di_w.writeUleb128(err_bytes.len);
3344 try di_w.writeAll(err_bytes);3382 try di_w.writeAll(err_bytes);
3345 }3383 }
...@@ -3348,8 +3386,8 @@ fn updateConstInner(...@@ -3348,8 +3386,8 @@ fn updateConstInner(
3348 .enum_literal => |enum_literal| {3386 .enum_literal => |enum_literal| {
3349 try dwarf.abbrevCode(di_nw, .comptime_value);3387 try dwarf.abbrevCode(di_nw, .comptime_value);
3350 try dwarf.refType(pt, di_nw, .enum_literal);3388 try dwarf.refType(pt, di_nw, .enum_literal);
3351 try di_w.writeUleb128(DW.FORM.strp);3389 try di_w.writeUleb128(DW.FORM.strx);
3352 try dwarf.strp(&dwarf.debug_str, di_nw, enum_literal.toSlice(ip));3390 try dwarf.strx(di_nw, enum_literal.toSlice(ip));
3353 },3391 },
3354 .enum_tag => |enum_tag| {3392 .enum_tag => |enum_tag| {
3355 var big_int_space: Value.BigIntSpace = undefined;3393 var big_int_space: Value.BigIntSpace = undefined;
...@@ -3493,11 +3531,11 @@ fn updateConstInner(...@@ -3493,11 +3531,11 @@ fn updateConstInner(
3493 },3531 },
3494 .field => |field| {3532 .field => |field| {
3495 try dwarf.abbrevCode(di_nw, .access);3533 try dwarf.abbrevCode(di_nw, .access);
3496 try dwarf.strp(&dwarf.debug_str, di_nw, field.toSlice(ip));3534 try dwarf.strx(di_nw, field.toSlice(ip));
3497 },3535 },
3498 .synthetic_field => |field| {3536 .synthetic_field => |field| {
3499 try dwarf.abbrevCode(di_nw, .access);3537 try dwarf.abbrevCode(di_nw, .access);
3500 try dwarf.strp(&dwarf.debug_str, di_nw, field);3538 try dwarf.strx(di_nw, field);
3501 },3539 },
3502 .tuple_index => |index| {3540 .tuple_index => |index| {
3503 try dwarf.abbrevCode(di_nw, .access);3541 try dwarf.abbrevCode(di_nw, .access);
...@@ -3505,7 +3543,7 @@ fn updateConstInner(...@@ -3505,7 +3543,7 @@ fn updateConstInner(
3505 undefined;3543 undefined;
3506 const field_name = std.mem.print(&field_name_buf, "{d}", .{index}) catch3544 const field_name = std.mem.print(&field_name_buf, "{d}", .{index}) catch
3507 unreachable;3545 unreachable;
3508 try dwarf.strp(&dwarf.debug_str, di_nw, field_name);3546 try dwarf.strx(di_nw, field_name);
3509 },3547 },
3510 };3548 };
3511 try di_w.writeUleb128(@backingInt(AbbrevCode.null));3549 try di_w.writeUleb128(@backingInt(AbbrevCode.null));
...@@ -3516,12 +3554,12 @@ fn updateConstInner(...@@ -3516,12 +3554,12 @@ fn updateConstInner(
3516 try dwarf.refType(pt, di_nw, .fromInterned(slice.ty));3554 try dwarf.refType(pt, di_nw, .fromInterned(slice.ty));
3517 {3555 {
3518 try dwarf.abbrevCode(di_nw, .comptime_value_field_comptime);3556 try dwarf.abbrevCode(di_nw, .comptime_value_field_comptime);
3519 try dwarf.strp(&dwarf.debug_str, di_nw, "ptr");3557 try dwarf.strx(di_nw, "ptr");
3520 try dwarf.refConst(pt, di_nw, .fromInterned(slice.ptr));3558 try dwarf.refConst(pt, di_nw, .fromInterned(slice.ptr));
3521 }3559 }
3522 {3560 {
3523 try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime);3561 try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime);
3524 try dwarf.strp(&dwarf.debug_str, di_nw, "len");3562 try dwarf.strx(di_nw, "len");
3525 try dwarf.blockConst(pt, di_nw, .fromInterned(slice.len));3563 try dwarf.blockConst(pt, di_nw, .fromInterned(slice.len));
3526 }3564 }
3527 try di_w.writeUleb128(@backingInt(AbbrevCode.null));3565 try di_w.writeUleb128(@backingInt(AbbrevCode.null));
...@@ -3532,7 +3570,7 @@ fn updateConstInner(...@@ -3532,7 +3570,7 @@ fn updateConstInner(
3532 try dwarf.refType(pt, di_nw, .fromInterned(opt.ty));3570 try dwarf.refType(pt, di_nw, .fromInterned(opt.ty));
3533 {3571 {
3534 try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime);3572 try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime);
3535 try dwarf.strp(&dwarf.debug_str, di_nw, "has_value");3573 try dwarf.strx(di_nw, "has_value");
3536 switch (optRepr(opt_child_ty, zcu)) {3574 switch (optRepr(opt_child_ty, zcu)) {
3537 .opv_null => try di_w.writeUleb128(0),3575 .opv_null => try di_w.writeUleb128(0),
3538 .unpacked => try dwarf.blockConst(pt, di_nw, .makeBool(opt.val != .none)),3576 .unpacked => try dwarf.blockConst(pt, di_nw, .makeBool(opt.val != .none)),
...@@ -3547,7 +3585,7 @@ fn updateConstInner(...@@ -3547,7 +3585,7 @@ fn updateConstInner(
3547 .comptime_value_field_runtime3585 .comptime_value_field_runtime
3548 else3586 else
3549 break :child_field);3587 break :child_field);
3550 try dwarf.strp(&dwarf.debug_str, di_nw, "?");3588 try dwarf.strx(di_nw, "?");
3551 if (opt_child_class.comptimeOnly())3589 if (opt_child_class.comptimeOnly())
3552 try dwarf.refConst(pt, di_nw, .fromInterned(opt.val))3590 try dwarf.refConst(pt, di_nw, .fromInterned(opt.val))
3553 else if (opt_child_class.hasRuntimeBits())3591 else if (opt_child_class.hasRuntimeBits())
...@@ -3575,8 +3613,7 @@ fn updateConstInner(...@@ -3575,8 +3613,7 @@ fn updateConstInner(
3575 .comptime_value_field_runtime3613 .comptime_value_field_runtime
3576 else3614 else
3577 continue);3615 continue);
3578 try dwarf.strp(3616 try dwarf.strx(
3579 &dwarf.debug_str,
3580 di_nw,3617 di_nw,
3581 loaded_struct.field_names.get(ip)[field_index].toSlice(ip),3618 loaded_struct.field_names.get(ip)[field_index].toSlice(ip),
3582 );3619 );
...@@ -3608,7 +3645,7 @@ fn updateConstInner(...@@ -3608,7 +3645,7 @@ fn updateConstInner(
3608 undefined;3645 undefined;
3609 const field_name = std.mem.print(&field_name_buf, "{d}", .{field_index}) catch3646 const field_name = std.mem.print(&field_name_buf, "{d}", .{field_index}) catch
3610 unreachable;3647 unreachable;
3611 try dwarf.strp(&dwarf.debug_str, di_nw, field_name);3648 try dwarf.strx(di_nw, field_name);
3612 }3649 }
3613 const field_value: Value = .fromInterned(switch (aggregate.storage) {3650 const field_value: Value = .fromInterned(switch (aggregate.storage) {
3614 .bytes => unreachable,3651 .bytes => unreachable,
...@@ -3665,7 +3702,7 @@ fn updateConstInner(...@@ -3665,7 +3702,7 @@ fn updateConstInner(
3665 .comptime_value_field_runtime3702 .comptime_value_field_runtime
3666 else3703 else
3667 .access);3704 .access);
3668 try dwarf.strp(&dwarf.debug_str, di_nw, field_name.toSlice(ip));3705 try dwarf.strx(di_nw, field_name.toSlice(ip));
3669 if (field_class.comptimeOnly())3706 if (field_class.comptimeOnly())
3670 try dwarf.refConst(pt, di_nw, .fromInterned(un.val))3707 try dwarf.refConst(pt, di_nw, .fromInterned(un.val))
3671 else if (field_class.hasRuntimeBits())3708 else if (field_class.hasRuntimeBits())
...@@ -3727,7 +3764,7 @@ fn updateConstIncompleteInner(...@@ -3727,7 +3764,7 @@ fn updateConstIncompleteInner(
3727 _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file);3764 _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file);
3728 try dwarf.abbrevCode(di_nw, .empty_file);3765 try dwarf.abbrevCode(di_nw, .empty_file);
3729 try di_w.writeUleb128(@backingInt(fi));3766 try di_w.writeUleb128(@backingInt(fi));
3730 try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip));3767 try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip));
3731 try di_w.writeByte(@intFromBool(true));3768 try di_w.writeByte(@intFromBool(true));
3732 break :done;3769 break :done;
3733 },3770 },
...@@ -3798,7 +3835,7 @@ fn updateConstIncompleteInner(...@@ -3798,7 +3835,7 @@ fn updateConstIncompleteInner(
3798 const loaded_enum = ip.loadEnumType(val);3835 const loaded_enum = ip.loadEnumType(val);
3799 const zir_index = loaded_enum.zir_index.unwrap() orelse {3836 const zir_index = loaded_enum.zir_index.unwrap() orelse {
3800 try dwarf.abbrevCode(di_nw, .generated_empty_struct_type);3837 try dwarf.abbrevCode(di_nw, .generated_empty_struct_type);
3801 try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip));3838 try dwarf.strx(di_nw, loaded_enum.name.toSlice(ip));
3802 try di_w.writeByte(@intFromBool(true));3839 try di_w.writeByte(@intFromBool(true));
3803 break :done;3840 break :done;
3804 };3841 };
...@@ -3858,7 +3895,7 @@ fn updateConstIncompleteInner(...@@ -3858,7 +3895,7 @@ fn updateConstIncompleteInner(
3858 const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)});3895 const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)});
3859 defer zcu.gpa.free(name);3896 defer zcu.gpa.free(name);
3860 try dwarf.abbrevCode(di_nw, .generated_empty_struct_type);3897 try dwarf.abbrevCode(di_nw, .generated_empty_struct_type);
3861 try dwarf.strp(&dwarf.debug_str, di_nw, name);3898 try dwarf.strx(di_nw, name);
3862 try di_w.writeByte(@intFromBool(true));3899 try di_w.writeByte(@intFromBool(true));
3863 },3900 },
3864 else => |ty| {3901 else => |ty| {
...@@ -3899,7 +3936,7 @@ fn updateConstIncompleteInner(...@@ -3899,7 +3936,7 @@ fn updateConstIncompleteInner(
3899 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);3936 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
3900 try di_w.writeUleb128(decl.src_column + 1);3937 try di_w.writeUleb128(decl.src_column + 1);
3901 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);3938 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
3902 try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip));3939 try dwarf.strx(di_nw, name_nav.name.toSlice(ip));
3903 } else {3940 } else {
3904 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(3941 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
3905 ip.namespacePtr(namespace).parent.unwrap().?,3942 ip.namespacePtr(namespace).parent.unwrap().?,
...@@ -3916,7 +3953,7 @@ fn updateConstIncompleteInner(...@@ -3916,7 +3953,7 @@ fn updateConstIncompleteInner(
3916 try dwarf.secOffset(di_nw, parent_ni, 0);3953 try dwarf.secOffset(di_nw, parent_ni, 0);
3917 try di_w.writeInt(u32, src_line + 1, dwarf.endian);3954 try di_w.writeInt(u32, src_line + 1, dwarf.endian);
3918 try di_w.writeUleb128(src_column + 1);3955 try di_w.writeUleb128(src_column + 1);
3919 try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip));3956 try dwarf.strx(di_nw, name.toSlice(ip));
3920 }3957 }
3921 try dwarf.genCaptures(pt, di_nw, captures);3958 try dwarf.genCaptures(pt, di_nw, captures);
3922 if (captures.len > 0) try di_w.writeByte(@backingInt(AbbrevCode.null));3959 if (captures.len > 0) try di_w.writeByte(@backingInt(AbbrevCode.null));
...@@ -4169,7 +4206,7 @@ fn genDeclInner(...@@ -4169,7 +4206,7 @@ fn genDeclInner(
4169 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);4206 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
4170 try di_w.writeUleb128(decl.src_column + 1);4207 try di_w.writeUleb128(decl.src_column + 1);
4171 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);4208 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
4172 try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip));4209 try dwarf.strx(di_nw, name.toSlice(ip));
4173 } else {4210 } else {
4174 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(4211 const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr(
4175 ip.namespacePtr(namespace).parent.unwrap().?,4212 ip.namespacePtr(namespace).parent.unwrap().?,
...@@ -4186,21 +4223,20 @@ fn genDeclInner(...@@ -4186,21 +4223,20 @@ fn genDeclInner(
4186 try dwarf.secOffset(di_nw, parent_ni, 0);4223 try dwarf.secOffset(di_nw, parent_ni, 0);
4187 try di_w.writeInt(u32, src_line + 1, dwarf.endian);4224 try di_w.writeInt(u32, src_line + 1, dwarf.endian);
4188 try di_w.writeUleb128(src_column + 1);4225 try di_w.writeUleb128(src_column + 1);
4189 try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip));4226 try dwarf.strx(di_nw, name.toSlice(ip));
4190 }4227 }
4191 for (capture_names, captures.get(ip)) |capture_name, capture| {4228 for (capture_names, captures.get(ip)) |capture_name, capture| {
4192 try dwarf.abbrevCode(di_nw, .capture_specification);4229 try dwarf.abbrevCode(di_nw, .capture_specification);
4193 switch (capture.unwrap()) {4230 switch (capture.unwrap()) {
4194 .@"comptime", .runtime, .nav_val => try dwarf.strp(4231 .@"comptime",
4195 &dwarf.debug_str,4232 .runtime,
4196 di_nw,4233 .nav_val,
4197 zir.nullTerminatedString(capture_name),4234 => try dwarf.strx(di_nw, zir.nullTerminatedString(capture_name)),
4198 ),
4199 .nav_ref => {4235 .nav_ref => {
4200 const capture_name_slice =4236 const capture_name_slice =
4201 try zcu.gpa.print("&{s}", .{zir.nullTerminatedString(capture_name)});4237 try zcu.gpa.print("&{s}", .{zir.nullTerminatedString(capture_name)});
4202 defer zcu.gpa.free(capture_name_slice);4238 defer zcu.gpa.free(capture_name_slice);
4203 try dwarf.strp(&dwarf.debug_str, di_nw, capture_name_slice);4239 try dwarf.strx(di_nw, capture_name_slice);
4204 },4240 },
4205 }4241 }
4206 }4242 }
...@@ -4225,7 +4261,7 @@ fn genDeclInner(...@@ -4225,7 +4261,7 @@ fn genDeclInner(
4225 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);4261 try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian);
4226 try di_w.writeUleb128(decl.src_column + 1);4262 try di_w.writeUleb128(decl.src_column + 1);
4227 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);4263 try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
4228 try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip));4264 try dwarf.strx(di_nw, nav.name.toSlice(ip));
4229 },4265 },
4230 }4266 }
4231 try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen());4267 try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen());
...@@ -4310,7 +4346,7 @@ fn genDebugAbbrev(...@@ -4310,7 +4346,7 @@ fn genDebugAbbrev(
4310 dwarf.debug_abbrev.end = da_w.end;4346 dwarf.debug_abbrev.end = da_w.end;
4311}4347}
43124348
4313pub fn secOffsetSize(dwarf: *Dwarf) usize {4349fn secOffsetSize(dwarf: *Dwarf) usize {
4314 return switch (dwarf.format) {4350 return switch (dwarf.format) {
4315 .@"32" => 4,4351 .@"32" => 4,
4316 .@"64" => 8,4352 .@"64" => 8,
...@@ -4487,6 +4523,30 @@ fn strp(dwarf: *Dwarf, s: *Str, nw: *link.MappedFile.Node.Writer, str: []const u...@@ -4487,6 +4523,30 @@ fn strp(dwarf: *Dwarf, s: *Str, nw: *link.MappedFile.Node.Writer, str: []const u
4487 });4523 });
4488}4524}
44894525
4526fn strx(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void {
4527 try nw.interface.writeUleb128(try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str));
4528}
4529fn strx1(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void {
4530 try nw.interface.writeByte(@intCast(
4531 try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str),
4532 ));
4533}
4534fn strx2(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void {
4535 try nw.interface.writeInt(u16, @intCast(
4536 try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str),
4537 ), dwarf.endian);
4538}
4539fn strx3(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void {
4540 try nw.interface.writeInt(u24, @intCast(
4541 try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str),
4542 ), dwarf.endian);
4543}
4544fn strx4(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void {
4545 try nw.interface.writeInt(u32, @intCast(
4546 try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str),
4547 ), dwarf.endian);
4548}
4549
4490fn reportWriteError(dwarf: *Dwarf, nw: *const link.MappedFile.Node.Writer) link.Error {4550fn reportWriteError(dwarf: *Dwarf, nw: *const link.MappedFile.Node.Writer) link.Error {
4491 switch (nw.err.?) {4551 switch (nw.err.?) {
4492 else => |e| return e,4552 else => |e| return e,
...@@ -4621,9 +4681,6 @@ pub const AbbrevCode = enum {...@@ -4621,9 +4681,6 @@ pub const AbbrevCode = enum {
4621 decl_instance_func_generic,4681 decl_instance_func_generic,
4622 // the rest are unrestricted other than empty variants must not be longer4682 // the rest are unrestricted other than empty variants must not be longer
4623 // than the non-empty variant, and so should appear first4683 // than the non-empty variant, and so should appear first
4624 compile_unit,
4625 module,
4626 module_dependency,
4627 empty_file,4684 empty_file,
4628 file,4685 file,
4629 access,4686 access,
...@@ -4704,6 +4761,10 @@ pub const AbbrevCode = enum {...@@ -4704,6 +4761,10 @@ pub const AbbrevCode = enum {
4704 comptime_value_field_comptime,4761 comptime_value_field_comptime,
4705 comptime_value_elem_runtime,4762 comptime_value_elem_runtime,
4706 comptime_value_elem_comptime,4763 comptime_value_elem_comptime,
4764 // low-frequency should appear last
4765 compile_unit,
4766 module,
4767 module_dependency,
47074768
4708 const decl_size = uleb128Size(@backingInt(AbbrevCode.decl_func_generic));4769 const decl_size = uleb128Size(@backingInt(AbbrevCode.decl_func_generic));
4709 comptime {4770 comptime {
...@@ -4721,13 +4782,13 @@ pub const AbbrevCode = enum {...@@ -4721,13 +4782,13 @@ pub const AbbrevCode = enum {
4721 .{ .decl_line, .data4 },4782 .{ .decl_line, .data4 },
4722 .{ .decl_column, .udata },4783 .{ .decl_column, .udata },
4723 .{ .accessibility, .data1 },4784 .{ .accessibility, .data1 },
4724 .{ .name, .strp },4785 .{ .name, .strx },
4725 };4786 };
4726 const type_decl_attrs = &[_]Attr{4787 const type_decl_attrs = &[_]Attr{
4727 .{ .ZIG_parent, .ref_addr },4788 .{ .ZIG_parent, .ref_addr },
4728 .{ .decl_line, .data4 },4789 .{ .decl_line, .data4 },
4729 .{ .decl_column, .udata },4790 .{ .decl_column, .udata },
4730 .{ .name, .strp },4791 .{ .name, .strx },
4731 };4792 };
4732 const decl_specification_attrs = decl_attrs ++ &[_]Attr{4793 const decl_specification_attrs = decl_attrs ++ &[_]Attr{
4733 .{ .declaration, .flag_present },4794 .{ .declaration, .flag_present },
...@@ -4959,7 +5020,7 @@ pub const AbbrevCode = enum {...@@ -4959,7 +5020,7 @@ pub const AbbrevCode = enum {
4959 .decl_const = .{5020 .decl_const = .{
4960 .tag = .constant,5021 .tag = .constant,
4961 .attrs = decl_attrs ++ .{5022 .attrs = decl_attrs ++ .{
4962 .{ .linkage_name, .strp },5023 .{ .linkage_name, .strx },
4963 .{ .type, .ref_addr },5024 .{ .type, .ref_addr },
4964 .{ .alignment, .udata },5025 .{ .alignment, .udata },
4965 .{ .external, .flag },5026 .{ .external, .flag },
...@@ -4968,7 +5029,7 @@ pub const AbbrevCode = enum {...@@ -4968,7 +5029,7 @@ pub const AbbrevCode = enum {
4968 .decl_const_fully_runtime = .{5029 .decl_const_fully_runtime = .{
4969 .tag = .constant,5030 .tag = .constant,
4970 .attrs = decl_attrs ++ .{5031 .attrs = decl_attrs ++ .{
4971 .{ .linkage_name, .strp },5032 .{ .linkage_name, .strx },
4972 .{ .type, .ref_addr },5033 .{ .type, .ref_addr },
4973 .{ .alignment, .udata },5034 .{ .alignment, .udata },
4974 .{ .external, .flag },5035 .{ .external, .flag },
...@@ -4978,7 +5039,7 @@ pub const AbbrevCode = enum {...@@ -4978,7 +5039,7 @@ pub const AbbrevCode = enum {
4978 .decl_const_partially_comptime = .{5039 .decl_const_partially_comptime = .{
4979 .tag = .constant,5040 .tag = .constant,
4980 .attrs = decl_attrs ++ .{5041 .attrs = decl_attrs ++ .{
4981 .{ .linkage_name, .strp },5042 .{ .linkage_name, .strx },
4982 .{ .type, .ref_addr },5043 .{ .type, .ref_addr },
4983 .{ .alignment, .udata },5044 .{ .alignment, .udata },
4984 .{ .external, .flag },5045 .{ .external, .flag },
...@@ -4989,7 +5050,7 @@ pub const AbbrevCode = enum {...@@ -4989,7 +5050,7 @@ pub const AbbrevCode = enum {
4989 .decl_const_fully_comptime = .{5050 .decl_const_fully_comptime = .{
4990 .tag = .constant,5051 .tag = .constant,
4991 .attrs = decl_attrs ++ .{5052 .attrs = decl_attrs ++ .{
4992 .{ .linkage_name, .strp },5053 .{ .linkage_name, .strx },
4993 .{ .type, .ref_addr },5054 .{ .type, .ref_addr },
4994 .{ .alignment, .udata },5055 .{ .alignment, .udata },
4995 .{ .external, .flag },5056 .{ .external, .flag },
...@@ -4999,7 +5060,7 @@ pub const AbbrevCode = enum {...@@ -4999,7 +5060,7 @@ pub const AbbrevCode = enum {
4999 .decl_var = .{5060 .decl_var = .{
5000 .tag = .variable,5061 .tag = .variable,
5001 .attrs = decl_attrs ++ .{5062 .attrs = decl_attrs ++ .{
5002 .{ .linkage_name, .strp },5063 .{ .linkage_name, .strx },
5003 .{ .type, .ref_addr },5064 .{ .type, .ref_addr },
5004 .{ .location, .exprloc },5065 .{ .location, .exprloc },
5005 .{ .alignment, .udata },5066 .{ .alignment, .udata },
...@@ -5009,7 +5070,7 @@ pub const AbbrevCode = enum {...@@ -5009,7 +5070,7 @@ pub const AbbrevCode = enum {
5009 .decl_empty_func = .{5070 .decl_empty_func = .{
5010 .tag = .subprogram,5071 .tag = .subprogram,
5011 .attrs = decl_attrs ++ .{5072 .attrs = decl_attrs ++ .{
5012 .{ .linkage_name, .strp },5073 .{ .linkage_name, .strx },
5013 .{ .type, .ref_addr },5074 .{ .type, .ref_addr },
5014 .{ .low_pc, .addr },5075 .{ .low_pc, .addr },
5015 .{ .high_pc, .data4 },5076 .{ .high_pc, .data4 },
...@@ -5022,7 +5083,7 @@ pub const AbbrevCode = enum {...@@ -5022,7 +5083,7 @@ pub const AbbrevCode = enum {
5022 .tag = .subprogram,5083 .tag = .subprogram,
5023 .children = true,5084 .children = true,
5024 .attrs = decl_attrs ++ .{5085 .attrs = decl_attrs ++ .{
5025 .{ .linkage_name, .strp },5086 .{ .linkage_name, .strx },
5026 .{ .type, .ref_addr },5087 .{ .type, .ref_addr },
5027 .{ .low_pc, .addr },5088 .{ .low_pc, .addr },
5028 .{ .high_pc, .data4 },5089 .{ .high_pc, .data4 },
...@@ -5047,7 +5108,7 @@ pub const AbbrevCode = enum {...@@ -5047,7 +5108,7 @@ pub const AbbrevCode = enum {
5047 .decl_extern_empty_func = .{5108 .decl_extern_empty_func = .{
5048 .tag = .subprogram,5109 .tag = .subprogram,
5049 .attrs = decl_attrs ++ .{5110 .attrs = decl_attrs ++ .{
5050 .{ .linkage_name, .strp },5111 .{ .linkage_name, .strx },
5051 .{ .type, .ref_addr },5112 .{ .type, .ref_addr },
5052 .{ .low_pc, .addr },5113 .{ .low_pc, .addr },
5053 .{ .external, .flag_present },5114 .{ .external, .flag_present },
...@@ -5058,7 +5119,7 @@ pub const AbbrevCode = enum {...@@ -5058,7 +5119,7 @@ pub const AbbrevCode = enum {
5058 .tag = .subprogram,5119 .tag = .subprogram,
5059 .children = true,5120 .children = true,
5060 .attrs = decl_attrs ++ .{5121 .attrs = decl_attrs ++ .{
5061 .{ .linkage_name, .strp },5122 .{ .linkage_name, .strx },
5062 .{ .type, .ref_addr },5123 .{ .type, .ref_addr },
5063 .{ .low_pc, .addr },5124 .{ .low_pc, .addr },
5064 .{ .external, .flag_present },5125 .{ .external, .flag_present },
...@@ -5240,7 +5301,7 @@ pub const AbbrevCode = enum {...@@ -5240,7 +5301,7 @@ pub const AbbrevCode = enum {
5240 .decl_instance_const = .{5301 .decl_instance_const = .{
5241 .tag = .constant,5302 .tag = .constant,
5242 .attrs = decl_instance_attrs ++ .{5303 .attrs = decl_instance_attrs ++ .{
5243 .{ .linkage_name, .strp },5304 .{ .linkage_name, .strx },
5244 .{ .type, .ref_addr },5305 .{ .type, .ref_addr },
5245 .{ .alignment, .udata },5306 .{ .alignment, .udata },
5246 .{ .external, .flag },5307 .{ .external, .flag },
...@@ -5249,7 +5310,7 @@ pub const AbbrevCode = enum {...@@ -5249,7 +5310,7 @@ pub const AbbrevCode = enum {
5249 .decl_instance_const_fully_runtime = .{5310 .decl_instance_const_fully_runtime = .{
5250 .tag = .constant,5311 .tag = .constant,
5251 .attrs = decl_instance_attrs ++ .{5312 .attrs = decl_instance_attrs ++ .{
5252 .{ .linkage_name, .strp },5313 .{ .linkage_name, .strx },
5253 .{ .type, .ref_addr },5314 .{ .type, .ref_addr },
5254 .{ .alignment, .udata },5315 .{ .alignment, .udata },
5255 .{ .external, .flag },5316 .{ .external, .flag },
...@@ -5259,7 +5320,7 @@ pub const AbbrevCode = enum {...@@ -5259,7 +5320,7 @@ pub const AbbrevCode = enum {
5259 .decl_instance_const_partially_comptime = .{5320 .decl_instance_const_partially_comptime = .{
5260 .tag = .constant,5321 .tag = .constant,
5261 .attrs = decl_instance_attrs ++ .{5322 .attrs = decl_instance_attrs ++ .{
5262 .{ .linkage_name, .strp },5323 .{ .linkage_name, .strx },
5263 .{ .type, .ref_addr },5324 .{ .type, .ref_addr },
5264 .{ .alignment, .udata },5325 .{ .alignment, .udata },
5265 .{ .external, .flag },5326 .{ .external, .flag },
...@@ -5270,7 +5331,7 @@ pub const AbbrevCode = enum {...@@ -5270,7 +5331,7 @@ pub const AbbrevCode = enum {
5270 .decl_instance_const_fully_comptime = .{5331 .decl_instance_const_fully_comptime = .{
5271 .tag = .constant,5332 .tag = .constant,
5272 .attrs = decl_instance_attrs ++ .{5333 .attrs = decl_instance_attrs ++ .{
5273 .{ .linkage_name, .strp },5334 .{ .linkage_name, .strx },
5274 .{ .type, .ref_addr },5335 .{ .type, .ref_addr },
5275 .{ .alignment, .udata },5336 .{ .alignment, .udata },
5276 .{ .external, .flag },5337 .{ .external, .flag },
...@@ -5280,7 +5341,7 @@ pub const AbbrevCode = enum {...@@ -5280,7 +5341,7 @@ pub const AbbrevCode = enum {
5280 .decl_instance_var = .{5341 .decl_instance_var = .{
5281 .tag = .variable,5342 .tag = .variable,
5282 .attrs = decl_instance_attrs ++ .{5343 .attrs = decl_instance_attrs ++ .{
5283 .{ .linkage_name, .strp },5344 .{ .linkage_name, .strx },
5284 .{ .type, .ref_addr },5345 .{ .type, .ref_addr },
5285 .{ .location, .exprloc },5346 .{ .location, .exprloc },
5286 .{ .alignment, .udata },5347 .{ .alignment, .udata },
...@@ -5290,7 +5351,7 @@ pub const AbbrevCode = enum {...@@ -5290,7 +5351,7 @@ pub const AbbrevCode = enum {
5290 .decl_instance_empty_func = .{5351 .decl_instance_empty_func = .{
5291 .tag = .subprogram,5352 .tag = .subprogram,
5292 .attrs = decl_instance_attrs ++ .{5353 .attrs = decl_instance_attrs ++ .{
5293 .{ .linkage_name, .strp },5354 .{ .linkage_name, .strx },
5294 .{ .type, .ref_addr },5355 .{ .type, .ref_addr },
5295 .{ .low_pc, .addr },5356 .{ .low_pc, .addr },
5296 .{ .high_pc, .data4 },5357 .{ .high_pc, .data4 },
...@@ -5303,7 +5364,7 @@ pub const AbbrevCode = enum {...@@ -5303,7 +5364,7 @@ pub const AbbrevCode = enum {
5303 .tag = .subprogram,5364 .tag = .subprogram,
5304 .children = true,5365 .children = true,
5305 .attrs = decl_instance_attrs ++ .{5366 .attrs = decl_instance_attrs ++ .{
5306 .{ .linkage_name, .strp },5367 .{ .linkage_name, .strx },
5307 .{ .type, .ref_addr },5368 .{ .type, .ref_addr },
5308 .{ .low_pc, .addr },5369 .{ .low_pc, .addr },
5309 .{ .high_pc, .data4 },5370 .{ .high_pc, .data4 },
...@@ -5325,41 +5386,11 @@ pub const AbbrevCode = enum {...@@ -5325,41 +5386,11 @@ pub const AbbrevCode = enum {
5325 .{ .type, .ref_addr },5386 .{ .type, .ref_addr },
5326 },5387 },
5327 },5388 },
5328 .compile_unit = .{
5329 .tag = .compile_unit,
5330 .children = true,
5331 .attrs = &.{
5332 .{ .language, .data1 },
5333 .{ .producer, .strp },
5334 .{ .comp_dir, .line_strp },
5335 .{ .name, .line_strp },
5336 .{ .base_types, .ref_addr },
5337 .{ .stmt_list, .sec_offset },
5338 .{ .rnglists_base, .sec_offset },
5339 .{ .ranges, .rnglistx },
5340 .{ .use_UTF8, .flag_present },
5341 },
5342 },
5343 .module = .{
5344 .tag = .module,
5345 .children = true,
5346 .attrs = &.{
5347 .{ .name, .strp },
5348 .{ .ranges, .rnglistx },
5349 },
5350 },
5351 .module_dependency = .{
5352 .tag = .imported_module,
5353 .attrs = &.{
5354 .{ .name, .strp },
5355 .{ .import, .ref_addr },
5356 },
5357 },
5358 .empty_file = .{5389 .empty_file = .{
5359 .tag = .structure_type,5390 .tag = .structure_type,
5360 .attrs = &.{5391 .attrs = &.{
5361 .{ .decl_file, .udata },5392 .{ .decl_file, .udata },
5362 .{ .name, .strp },5393 .{ .name, .strx },
5363 .{ .declaration, .flag },5394 .{ .declaration, .flag },
5364 },5395 },
5365 },5396 },
...@@ -5368,7 +5399,7 @@ pub const AbbrevCode = enum {...@@ -5368,7 +5399,7 @@ pub const AbbrevCode = enum {
5368 .children = true,5399 .children = true,
5369 .attrs = &.{5400 .attrs = &.{
5370 .{ .decl_file, .udata },5401 .{ .decl_file, .udata },
5371 .{ .name, .strp },5402 .{ .name, .strx },
5372 .{ .byte_size, .udata },5403 .{ .byte_size, .udata },
5373 .{ .alignment, .udata },5404 .{ .alignment, .udata },
5374 },5405 },
...@@ -5376,20 +5407,20 @@ pub const AbbrevCode = enum {...@@ -5376,20 +5407,20 @@ pub const AbbrevCode = enum {
5376 .access = .{5407 .access = .{
5377 .tag = .member,5408 .tag = .member,
5378 .attrs = &.{5409 .attrs = &.{
5379 .{ .name, .strp },5410 .{ .name, .strx },
5380 },5411 },
5381 },5412 },
5382 .enum_field = .{5413 .enum_field = .{
5383 .tag = .enumerator,5414 .tag = .enumerator,
5384 .attrs = &.{5415 .attrs = &.{
5385 .{ .const_value, .indirect },5416 .{ .const_value, .indirect },
5386 .{ .name, .strp },5417 .{ .name, .strx },
5387 },5418 },
5388 },5419 },
5389 .generated_field = .{5420 .generated_field = .{
5390 .tag = .member,5421 .tag = .member,
5391 .attrs = &.{5422 .attrs = &.{
5392 .{ .name, .strp },5423 .{ .name, .strx },
5393 .{ .type, .ref_addr },5424 .{ .type, .ref_addr },
5394 .{ .data_member_location, .udata },5425 .{ .data_member_location, .udata },
5395 .{ .artificial, .flag_present },5426 .{ .artificial, .flag_present },
...@@ -5398,7 +5429,7 @@ pub const AbbrevCode = enum {...@@ -5398,7 +5429,7 @@ pub const AbbrevCode = enum {
5398 .field = .{5429 .field = .{
5399 .tag = .member,5430 .tag = .member,
5400 .attrs = &.{5431 .attrs = &.{
5401 .{ .name, .strp },5432 .{ .name, .strx },
5402 .{ .type, .ref_addr },5433 .{ .type, .ref_addr },
5403 .{ .data_member_location, .udata },5434 .{ .data_member_location, .udata },
5404 .{ .alignment, .udata },5435 .{ .alignment, .udata },
...@@ -5407,7 +5438,7 @@ pub const AbbrevCode = enum {...@@ -5407,7 +5438,7 @@ pub const AbbrevCode = enum {
5407 .field_default_fully_runtime = .{5438 .field_default_fully_runtime = .{
5408 .tag = .member,5439 .tag = .member,
5409 .attrs = &.{5440 .attrs = &.{
5410 .{ .name, .strp },5441 .{ .name, .strx },
5411 .{ .type, .ref_addr },5442 .{ .type, .ref_addr },
5412 .{ .data_member_location, .udata },5443 .{ .data_member_location, .udata },
5413 .{ .alignment, .udata },5444 .{ .alignment, .udata },
...@@ -5417,7 +5448,7 @@ pub const AbbrevCode = enum {...@@ -5417,7 +5448,7 @@ pub const AbbrevCode = enum {
5417 .field_default_partially_comptime = .{5448 .field_default_partially_comptime = .{
5418 .tag = .member,5449 .tag = .member,
5419 .attrs = &.{5450 .attrs = &.{
5420 .{ .name, .strp },5451 .{ .name, .strx },
5421 .{ .type, .ref_addr },5452 .{ .type, .ref_addr },
5422 .{ .data_member_location, .udata },5453 .{ .data_member_location, .udata },
5423 .{ .alignment, .udata },5454 .{ .alignment, .udata },
...@@ -5428,7 +5459,7 @@ pub const AbbrevCode = enum {...@@ -5428,7 +5459,7 @@ pub const AbbrevCode = enum {
5428 .field_default_fully_comptime = .{5459 .field_default_fully_comptime = .{
5429 .tag = .member,5460 .tag = .member,
5430 .attrs = &.{5461 .attrs = &.{
5431 .{ .name, .strp },5462 .{ .name, .strx },
5432 .{ .type, .ref_addr },5463 .{ .type, .ref_addr },
5433 .{ .data_member_location, .udata },5464 .{ .data_member_location, .udata },
5434 .{ .alignment, .udata },5465 .{ .alignment, .udata },
...@@ -5439,7 +5470,7 @@ pub const AbbrevCode = enum {...@@ -5439,7 +5470,7 @@ pub const AbbrevCode = enum {
5439 .tag = .member,5470 .tag = .member,
5440 .attrs = &.{5471 .attrs = &.{
5441 .{ .const_expr, .flag_present },5472 .{ .const_expr, .flag_present },
5442 .{ .name, .strp },5473 .{ .name, .strx },
5443 .{ .type, .ref_addr },5474 .{ .type, .ref_addr },
5444 },5475 },
5445 },5476 },
...@@ -5447,7 +5478,7 @@ pub const AbbrevCode = enum {...@@ -5447,7 +5478,7 @@ pub const AbbrevCode = enum {
5447 .tag = .member,5478 .tag = .member,
5448 .attrs = &.{5479 .attrs = &.{
5449 .{ .const_expr, .flag_present },5480 .{ .const_expr, .flag_present },
5450 .{ .name, .strp },5481 .{ .name, .strx },
5451 .{ .type, .ref_addr },5482 .{ .type, .ref_addr },
5452 .{ .const_value, .block },5483 .{ .const_value, .block },
5453 },5484 },
...@@ -5456,7 +5487,7 @@ pub const AbbrevCode = enum {...@@ -5456,7 +5487,7 @@ pub const AbbrevCode = enum {
5456 .tag = .member,5487 .tag = .member,
5457 .attrs = &.{5488 .attrs = &.{
5458 .{ .const_expr, .flag_present },5489 .{ .const_expr, .flag_present },
5459 .{ .name, .strp },5490 .{ .name, .strx },
5460 .{ .type, .ref_addr },5491 .{ .type, .ref_addr },
5461 .{ .const_value, .block },5492 .{ .const_value, .block },
5462 .{ .ZIG_comptime_value, .ref_addr },5493 .{ .ZIG_comptime_value, .ref_addr },
...@@ -5466,7 +5497,7 @@ pub const AbbrevCode = enum {...@@ -5466,7 +5497,7 @@ pub const AbbrevCode = enum {
5466 .tag = .member,5497 .tag = .member,
5467 .attrs = &.{5498 .attrs = &.{
5468 .{ .const_expr, .flag_present },5499 .{ .const_expr, .flag_present },
5469 .{ .name, .strp },5500 .{ .name, .strx },
5470 .{ .type, .ref_addr },5501 .{ .type, .ref_addr },
5471 .{ .ZIG_comptime_value, .ref_addr },5502 .{ .ZIG_comptime_value, .ref_addr },
5472 },5503 },
...@@ -5474,7 +5505,7 @@ pub const AbbrevCode = enum {...@@ -5474,7 +5505,7 @@ pub const AbbrevCode = enum {
5474 .packed_field = .{5505 .packed_field = .{
5475 .tag = .member,5506 .tag = .member,
5476 .attrs = &.{5507 .attrs = &.{
5477 .{ .name, .strp },5508 .{ .name, .strx },
5478 .{ .type, .ref_addr },5509 .{ .type, .ref_addr },
5479 .{ .data_bit_offset, .udata },5510 .{ .data_bit_offset, .udata },
5480 },5511 },
...@@ -5500,13 +5531,13 @@ pub const AbbrevCode = enum {...@@ -5500,13 +5531,13 @@ pub const AbbrevCode = enum {
5500 .void_type = .{5531 .void_type = .{
5501 .tag = .unspecified_type,5532 .tag = .unspecified_type,
5502 .attrs = &.{5533 .attrs = &.{
5503 .{ .name, .strp },5534 .{ .name, .strx },
5504 },5535 },
5505 },5536 },
5506 .numeric_type = .{5537 .numeric_type = .{
5507 .tag = .base_type,5538 .tag = .base_type,
5508 .attrs = &.{5539 .attrs = &.{
5509 .{ .name, .strp },5540 .{ .name, .strx },
5510 .{ .encoding, .data1 },5541 .{ .encoding, .data1 },
5511 .{ .bit_size, .udata },5542 .{ .bit_size, .udata },
5512 .{ .byte_size, .udata },5543 .{ .byte_size, .udata },
...@@ -5516,14 +5547,14 @@ pub const AbbrevCode = enum {...@@ -5516,14 +5547,14 @@ pub const AbbrevCode = enum {
5516 .inferred_error_set_type = .{5547 .inferred_error_set_type = .{
5517 .tag = .typedef,5548 .tag = .typedef,
5518 .attrs = &.{5549 .attrs = &.{
5519 .{ .name, .strp },5550 .{ .name, .strx },
5520 .{ .type, .ref_addr },5551 .{ .type, .ref_addr },
5521 },5552 },
5522 },5553 },
5523 .ptr_type = .{5554 .ptr_type = .{
5524 .tag = .pointer_type,5555 .tag = .pointer_type,
5525 .attrs = &.{5556 .attrs = &.{
5526 .{ .name, .strp },5557 .{ .name, .strx },
5527 .{ .address_class, .data1 },5558 .{ .address_class, .data1 },
5528 .{ .type, .ref_addr },5559 .{ .type, .ref_addr },
5529 },5560 },
...@@ -5531,7 +5562,7 @@ pub const AbbrevCode = enum {...@@ -5531,7 +5562,7 @@ pub const AbbrevCode = enum {
5531 .ptr_sentinel_type = .{5562 .ptr_sentinel_type = .{
5532 .tag = .pointer_type,5563 .tag = .pointer_type,
5533 .attrs = &.{5564 .attrs = &.{
5534 .{ .name, .strp },5565 .{ .name, .strx },
5535 .{ .ZIG_sentinel, .block },5566 .{ .ZIG_sentinel, .block },
5536 .{ .address_class, .data1 },5567 .{ .address_class, .data1 },
5537 .{ .type, .ref_addr },5568 .{ .type, .ref_addr },
...@@ -5560,7 +5591,7 @@ pub const AbbrevCode = enum {...@@ -5560,7 +5591,7 @@ pub const AbbrevCode = enum {
5560 .tag = .array_type,5591 .tag = .array_type,
5561 .children = true,5592 .children = true,
5562 .attrs = &.{5593 .attrs = &.{
5563 .{ .name, .strp },5594 .{ .name, .strx },
5564 .{ .type, .ref_addr },5595 .{ .type, .ref_addr },
5565 },5596 },
5566 },5597 },
...@@ -5568,7 +5599,7 @@ pub const AbbrevCode = enum {...@@ -5568,7 +5599,7 @@ pub const AbbrevCode = enum {
5568 .tag = .array_type,5599 .tag = .array_type,
5569 .children = true,5600 .children = true,
5570 .attrs = &.{5601 .attrs = &.{
5571 .{ .name, .strp },5602 .{ .name, .strx },
5572 .{ .ZIG_sentinel, .block },5603 .{ .ZIG_sentinel, .block },
5573 .{ .type, .ref_addr },5604 .{ .type, .ref_addr },
5574 },5605 },
...@@ -5577,7 +5608,7 @@ pub const AbbrevCode = enum {...@@ -5577,7 +5608,7 @@ pub const AbbrevCode = enum {
5577 .tag = .array_type,5608 .tag = .array_type,
5578 .children = true,5609 .children = true,
5579 .attrs = &.{5610 .attrs = &.{
5580 .{ .name, .strp },5611 .{ .name, .strx },
5581 .{ .type, .ref_addr },5612 .{ .type, .ref_addr },
5582 .{ .GNU_vector, .flag_present },5613 .{ .GNU_vector, .flag_present },
5583 },5614 },
...@@ -5598,7 +5629,7 @@ pub const AbbrevCode = enum {...@@ -5598,7 +5629,7 @@ pub const AbbrevCode = enum {
5598 .empty_func_type = .{5629 .empty_func_type = .{
5599 .tag = .subroutine_type,5630 .tag = .subroutine_type,
5600 .attrs = &.{5631 .attrs = &.{
5601 .{ .name, .strp },5632 .{ .name, .strx },
5602 .{ .calling_convention, .data1 },5633 .{ .calling_convention, .data1 },
5603 .{ .type, .ref_addr },5634 .{ .type, .ref_addr },
5604 },5635 },
...@@ -5607,7 +5638,7 @@ pub const AbbrevCode = enum {...@@ -5607,7 +5638,7 @@ pub const AbbrevCode = enum {
5607 .tag = .subroutine_type,5638 .tag = .subroutine_type,
5608 .children = true,5639 .children = true,
5609 .attrs = &.{5640 .attrs = &.{
5610 .{ .name, .strp },5641 .{ .name, .strx },
5611 .{ .calling_convention, .data1 },5642 .{ .calling_convention, .data1 },
5612 .{ .type, .ref_addr },5643 .{ .type, .ref_addr },
5613 },5644 },
...@@ -5615,7 +5646,7 @@ pub const AbbrevCode = enum {...@@ -5615,7 +5646,7 @@ pub const AbbrevCode = enum {
5615 .param = .{5646 .param = .{
5616 .tag = .formal_parameter,5647 .tag = .formal_parameter,
5617 .attrs = &.{5648 .attrs = &.{
5618 .{ .name, .strp },5649 .{ .name, .strx },
5619 .{ .type, .ref_addr },5650 .{ .type, .ref_addr },
5620 },5651 },
5621 },5652 },
...@@ -5631,7 +5662,7 @@ pub const AbbrevCode = enum {...@@ -5631,7 +5662,7 @@ pub const AbbrevCode = enum {
5631 .generated_empty_enum_type = .{5662 .generated_empty_enum_type = .{
5632 .tag = .enumeration_type,5663 .tag = .enumeration_type,
5633 .attrs = &.{5664 .attrs = &.{
5634 .{ .name, .strp },5665 .{ .name, .strx },
5635 .{ .type, .ref_addr },5666 .{ .type, .ref_addr },
5636 },5667 },
5637 },5668 },
...@@ -5639,14 +5670,14 @@ pub const AbbrevCode = enum {...@@ -5639,14 +5670,14 @@ pub const AbbrevCode = enum {
5639 .tag = .enumeration_type,5670 .tag = .enumeration_type,
5640 .children = true,5671 .children = true,
5641 .attrs = &.{5672 .attrs = &.{
5642 .{ .name, .strp },5673 .{ .name, .strx },
5643 .{ .type, .ref_addr },5674 .{ .type, .ref_addr },
5644 },5675 },
5645 },5676 },
5646 .generated_empty_struct_type = .{5677 .generated_empty_struct_type = .{
5647 .tag = .structure_type,5678 .tag = .structure_type,
5648 .attrs = &.{5679 .attrs = &.{
5649 .{ .name, .strp },5680 .{ .name, .strx },
5650 .{ .declaration, .flag },5681 .{ .declaration, .flag },
5651 },5682 },
5652 },5683 },
...@@ -5654,7 +5685,7 @@ pub const AbbrevCode = enum {...@@ -5654,7 +5685,7 @@ pub const AbbrevCode = enum {
5654 .tag = .structure_type,5685 .tag = .structure_type,
5655 .children = true,5686 .children = true,
5656 .attrs = &.{5687 .attrs = &.{
5657 .{ .name, .strp },5688 .{ .name, .strx },
5658 .{ .byte_size, .udata },5689 .{ .byte_size, .udata },
5659 .{ .alignment, .udata },5690 .{ .alignment, .udata },
5660 },5691 },
...@@ -5663,7 +5694,7 @@ pub const AbbrevCode = enum {...@@ -5663,7 +5694,7 @@ pub const AbbrevCode = enum {
5663 .tag = .union_type,5694 .tag = .union_type,
5664 .children = true,5695 .children = true,
5665 .attrs = &.{5696 .attrs = &.{
5666 .{ .name, .strp },5697 .{ .name, .strx },
5667 .{ .byte_size, .udata },5698 .{ .byte_size, .udata },
5668 .{ .alignment, .udata },5699 .{ .alignment, .udata },
5669 },5700 },
...@@ -5671,7 +5702,7 @@ pub const AbbrevCode = enum {...@@ -5671,7 +5702,7 @@ pub const AbbrevCode = enum {
5671 .capture_specification = .{5702 .capture_specification = .{
5672 .tag = .template_value_parameter,5703 .tag = .template_value_parameter,
5673 .attrs = &.{5704 .attrs = &.{
5674 .{ .name, .strp },5705 .{ .name, .strx },
5675 },5706 },
5676 },5707 },
5677 .comptime_capture = .{5708 .comptime_capture = .{
...@@ -5718,7 +5749,7 @@ pub const AbbrevCode = enum {...@@ -5718,7 +5749,7 @@ pub const AbbrevCode = enum {
5718 .tag = .subprogram,5749 .tag = .subprogram,
5719 .attrs = &.{5750 .attrs = &.{
5720 .{ .ZIG_parent, .ref_addr },5751 .{ .ZIG_parent, .ref_addr },
5721 .{ .linkage_name, .strp },5752 .{ .linkage_name, .strx },
5722 .{ .type, .ref_addr },5753 .{ .type, .ref_addr },
5723 .{ .low_pc, .addr },5754 .{ .low_pc, .addr },
5724 .{ .external, .flag_present },5755 .{ .external, .flag_present },
...@@ -5730,7 +5761,7 @@ pub const AbbrevCode = enum {...@@ -5730,7 +5761,7 @@ pub const AbbrevCode = enum {
5730 .children = true,5761 .children = true,
5731 .attrs = &.{5762 .attrs = &.{
5732 .{ .ZIG_parent, .ref_addr },5763 .{ .ZIG_parent, .ref_addr },
5733 .{ .linkage_name, .strp },5764 .{ .linkage_name, .strx },
5734 .{ .type, .ref_addr },5765 .{ .type, .ref_addr },
5735 .{ .low_pc, .addr },5766 .{ .low_pc, .addr },
5736 .{ .external, .flag_present },5767 .{ .external, .flag_present },
...@@ -5741,7 +5772,7 @@ pub const AbbrevCode = enum {...@@ -5741,7 +5772,7 @@ pub const AbbrevCode = enum {
5741 .tag = .variable,5772 .tag = .variable,
5742 .attrs = &.{5773 .attrs = &.{
5743 .{ .ZIG_parent, .ref_addr },5774 .{ .ZIG_parent, .ref_addr },
5744 .{ .linkage_name, .strp },5775 .{ .linkage_name, .strx },
5745 .{ .type, .ref_addr },5776 .{ .type, .ref_addr },
5746 .{ .location, .exprloc },5777 .{ .location, .exprloc },
5747 .{ .alignment, .udata },5778 .{ .alignment, .udata },
...@@ -5787,7 +5818,7 @@ pub const AbbrevCode = enum {...@@ -5787,7 +5818,7 @@ pub const AbbrevCode = enum {
5787 .arg = .{5818 .arg = .{
5788 .tag = .formal_parameter,5819 .tag = .formal_parameter,
5789 .attrs = &.{5820 .attrs = &.{
5790 .{ .name, .strp },5821 .{ .name, .strx },
5791 .{ .type, .ref_addr },5822 .{ .type, .ref_addr },
5792 .{ .location, .exprloc },5823 .{ .location, .exprloc },
5793 },5824 },
...@@ -5803,7 +5834,7 @@ pub const AbbrevCode = enum {...@@ -5803,7 +5834,7 @@ pub const AbbrevCode = enum {
5803 .tag = .formal_parameter,5834 .tag = .formal_parameter,
5804 .attrs = &.{5835 .attrs = &.{
5805 .{ .const_expr, .flag_present },5836 .{ .const_expr, .flag_present },
5806 .{ .name, .strp },5837 .{ .name, .strx },
5807 .{ .type, .ref_addr },5838 .{ .type, .ref_addr },
5808 },5839 },
5809 },5840 },
...@@ -5811,7 +5842,7 @@ pub const AbbrevCode = enum {...@@ -5811,7 +5842,7 @@ pub const AbbrevCode = enum {
5811 .tag = .formal_parameter,5842 .tag = .formal_parameter,
5812 .attrs = &.{5843 .attrs = &.{
5813 .{ .const_expr, .flag_present },5844 .{ .const_expr, .flag_present },
5814 .{ .name, .strp },5845 .{ .name, .strx },
5815 .{ .type, .ref_addr },5846 .{ .type, .ref_addr },
5816 .{ .const_value, .block },5847 .{ .const_value, .block },
5817 },5848 },
...@@ -5820,7 +5851,7 @@ pub const AbbrevCode = enum {...@@ -5820,7 +5851,7 @@ pub const AbbrevCode = enum {
5820 .tag = .formal_parameter,5851 .tag = .formal_parameter,
5821 .attrs = &.{5852 .attrs = &.{
5822 .{ .const_expr, .flag_present },5853 .{ .const_expr, .flag_present },
5823 .{ .name, .strp },5854 .{ .name, .strx },
5824 .{ .type, .ref_addr },5855 .{ .type, .ref_addr },
5825 .{ .const_value, .block },5856 .{ .const_value, .block },
5826 .{ .ZIG_comptime_value, .ref_addr },5857 .{ .ZIG_comptime_value, .ref_addr },
...@@ -5830,7 +5861,7 @@ pub const AbbrevCode = enum {...@@ -5830,7 +5861,7 @@ pub const AbbrevCode = enum {
5830 .tag = .formal_parameter,5861 .tag = .formal_parameter,
5831 .attrs = &.{5862 .attrs = &.{
5832 .{ .const_expr, .flag_present },5863 .{ .const_expr, .flag_present },
5833 .{ .name, .strp },5864 .{ .name, .strx },
5834 .{ .type, .ref_addr },5865 .{ .type, .ref_addr },
5835 .{ .ZIG_comptime_value, .ref_addr },5866 .{ .ZIG_comptime_value, .ref_addr },
5836 },5867 },
...@@ -5876,7 +5907,7 @@ pub const AbbrevCode = enum {...@@ -5876,7 +5907,7 @@ pub const AbbrevCode = enum {
5876 .local_var = .{5907 .local_var = .{
5877 .tag = .variable,5908 .tag = .variable,
5878 .attrs = &.{5909 .attrs = &.{
5879 .{ .name, .strp },5910 .{ .name, .strx },
5880 .{ .type, .ref_addr },5911 .{ .type, .ref_addr },
5881 .{ .location, .exprloc },5912 .{ .location, .exprloc },
5882 },5913 },
...@@ -5884,14 +5915,14 @@ pub const AbbrevCode = enum {...@@ -5884,14 +5915,14 @@ pub const AbbrevCode = enum {
5884 .local_const = .{5915 .local_const = .{
5885 .tag = .constant,5916 .tag = .constant,
5886 .attrs = &.{5917 .attrs = &.{
5887 .{ .name, .strp },5918 .{ .name, .strx },
5888 .{ .type, .ref_addr },5919 .{ .type, .ref_addr },
5889 },5920 },
5890 },5921 },
5891 .local_const_fully_runtime = .{5922 .local_const_fully_runtime = .{
5892 .tag = .constant,5923 .tag = .constant,
5893 .attrs = &.{5924 .attrs = &.{
5894 .{ .name, .strp },5925 .{ .name, .strx },
5895 .{ .type, .ref_addr },5926 .{ .type, .ref_addr },
5896 .{ .const_value, .block },5927 .{ .const_value, .block },
5897 },5928 },
...@@ -5899,7 +5930,7 @@ pub const AbbrevCode = enum {...@@ -5899,7 +5930,7 @@ pub const AbbrevCode = enum {
5899 .local_const_partially_comptime = .{5930 .local_const_partially_comptime = .{
5900 .tag = .constant,5931 .tag = .constant,
5901 .attrs = &.{5932 .attrs = &.{
5902 .{ .name, .strp },5933 .{ .name, .strx },
5903 .{ .type, .ref_addr },5934 .{ .type, .ref_addr },
5904 .{ .const_value, .block },5935 .{ .const_value, .block },
5905 .{ .ZIG_comptime_value, .ref_addr },5936 .{ .ZIG_comptime_value, .ref_addr },
...@@ -5908,7 +5939,7 @@ pub const AbbrevCode = enum {...@@ -5908,7 +5939,7 @@ pub const AbbrevCode = enum {
5908 .local_const_fully_comptime = .{5939 .local_const_fully_comptime = .{
5909 .tag = .constant,5940 .tag = .constant,
5910 .attrs = &.{5941 .attrs = &.{
5911 .{ .name, .strp },5942 .{ .name, .strx },
5912 .{ .type, .ref_addr },5943 .{ .type, .ref_addr },
5913 .{ .ZIG_comptime_value, .ref_addr },5944 .{ .ZIG_comptime_value, .ref_addr },
5914 },5945 },
...@@ -5959,14 +5990,14 @@ pub const AbbrevCode = enum {...@@ -5959,14 +5990,14 @@ pub const AbbrevCode = enum {
5959 .comptime_value_field_runtime = .{5990 .comptime_value_field_runtime = .{
5960 .tag = .member,5991 .tag = .member,
5961 .attrs = &.{5992 .attrs = &.{
5962 .{ .name, .strp },5993 .{ .name, .strx },
5963 .{ .const_value, .block },5994 .{ .const_value, .block },
5964 },5995 },
5965 },5996 },
5966 .comptime_value_field_comptime = .{5997 .comptime_value_field_comptime = .{
5967 .tag = .member,5998 .tag = .member,
5968 .attrs = &.{5999 .attrs = &.{
5969 .{ .name, .strp },6000 .{ .name, .strx },
5970 .{ .ZIG_comptime_value, .ref_addr },6001 .{ .ZIG_comptime_value, .ref_addr },
5971 },6002 },
5972 },6003 },
...@@ -5982,6 +6013,37 @@ pub const AbbrevCode = enum {...@@ -5982,6 +6013,37 @@ pub const AbbrevCode = enum {
5982 .{ .ZIG_comptime_value, .ref_addr },6013 .{ .ZIG_comptime_value, .ref_addr },
5983 },6014 },
5984 },6015 },
6016 .compile_unit = .{
6017 .tag = .compile_unit,
6018 .children = true,
6019 .attrs = &.{
6020 .{ .language, .data1 },
6021 .{ .base_types, .ref_addr },
6022 .{ .stmt_list, .sec_offset },
6023 .{ .rnglists_base, .sec_offset },
6024 .{ .str_offsets_base, .sec_offset },
6025 .{ .producer, .strx1 },
6026 .{ .comp_dir, .line_strp },
6027 .{ .name, .line_strp },
6028 .{ .ranges, .rnglistx },
6029 .{ .use_UTF8, .flag_present },
6030 },
6031 },
6032 .module = .{
6033 .tag = .module,
6034 .children = true,
6035 .attrs = &.{
6036 .{ .name, .strx },
6037 .{ .ranges, .rnglistx },
6038 },
6039 },
6040 .module_dependency = .{
6041 .tag = .imported_module,
6042 .attrs = &.{
6043 .{ .name, .strx },
6044 .{ .import, .ref_addr },
6045 },
6046 },
5985 });6047 });
5986};6048};
59876049
src/link/Elf2.zig+200-99
...@@ -215,6 +215,7 @@ textrel_count: u32,...@@ -215,6 +215,7 @@ textrel_count: u32,
215215
216dwarf: Dwarf,216dwarf: Dwarf,
217dwarf_shared: std.enums.EnumArray(Dwarf.SharedSection, dwarf_relocs.Shared),217dwarf_shared: std.enums.EnumArray(Dwarf.SharedSection, dwarf_relocs.Shared),
218dwarf_str_offsets: dwarf_relocs.StrOffsets,
218dwarf_units: []dwarf_relocs.Unit,219dwarf_units: []dwarf_relocs.Unit,
219dwarf_consts: std.array_hash_map.Auto(link.ConstPool.Index, dwarf_relocs.Const),220dwarf_consts: std.array_hash_map.Auto(link.ConstPool.Index, dwarf_relocs.Const),
220dwarf_globals: std.ArrayList(dwarf_relocs.Global),221dwarf_globals: std.ArrayList(dwarf_relocs.Global),
...@@ -287,6 +288,7 @@ const Node = union(enum) {...@@ -287,6 +288,7 @@ const Node = union(enum) {
287288
288 debug_shared: Dwarf.SharedSection,289 debug_shared: Dwarf.SharedSection,
289 eh_frame_footer,290 eh_frame_footer,
291 debug_str_offsets,
290 unit_padding,292 unit_padding,
291 unit_frame: Dwarf.Unit.Index,293 unit_frame: Dwarf.Unit.Index,
292 unit_frame_cie: Dwarf.Unit.Index,294 unit_frame_cie: Dwarf.Unit.Index,
...@@ -880,6 +882,10 @@ const dwarf_relocs = struct {...@@ -880,6 +882,10 @@ const dwarf_relocs = struct {
880 const Shared = struct {882 const Shared = struct {
881 first_target_reloc: NodeReloc.Index,883 first_target_reloc: NodeReloc.Index,
882 };884 };
885 const StrOffsets = struct {
886 first_target_reloc: NodeReloc.Index,
887 node_relocs: std.ArrayList(NodeReloc.Index),
888 };
883 const Unit = struct {889 const Unit = struct {
884 frame_cie_first_target_reloc: NodeReloc.Index,890 frame_cie_first_target_reloc: NodeReloc.Index,
885 debug_info_header_first_target_reloc: NodeReloc.Index,891 debug_info_header_first_target_reloc: NodeReloc.Index,
...@@ -887,7 +893,7 @@ const dwarf_relocs = struct {...@@ -887,7 +893,7 @@ const dwarf_relocs = struct {
887 debug_line_header_first_target_reloc: NodeReloc.Index,893 debug_line_header_first_target_reloc: NodeReloc.Index,
888 debug_line_header_first_node_reloc: NodeReloc.Index,894 debug_line_header_first_node_reloc: NodeReloc.Index,
889 debug_rnglists_first_target_reloc: NodeReloc.Index,895 debug_rnglists_first_target_reloc: NodeReloc.Index,
890 debug_rnglists_symbol_relocs: std.array_hash_map.Auto(SymbolReloc.Index, void),896 debug_rnglists_symbol_relocs: std.ArrayList(SymbolReloc.Index),
891 };897 };
892 const Const = struct {898 const Const = struct {
893 debug_info_first_target_reloc: NodeReloc.Index,899 debug_info_first_target_reloc: NodeReloc.Index,
...@@ -3347,6 +3353,7 @@ pub fn symbolForAtom(elf: *Elf, atom: link.File.AtomId) link.File.SymbolId {...@@ -3347,6 +3353,7 @@ pub fn symbolForAtom(elf: *Elf, atom: link.File.AtomId) link.File.SymbolId {
3347 .copied_global,3353 .copied_global,
3348 .debug_shared,3354 .debug_shared,
3349 .eh_frame_footer,3355 .eh_frame_footer,
3356 .debug_str_offsets,
3350 .unit_padding,3357 .unit_padding,
3351 .unit_frame,3358 .unit_frame,
3352 .unit_frame_cie,3359 .unit_frame_cie,
...@@ -3866,6 +3873,10 @@ fn create(...@@ -3866,6 +3873,10 @@ fn create(
3866 .dwarf_shared = comptime .initFill(.{3873 .dwarf_shared = comptime .initFill(.{
3867 .first_target_reloc = .none,3874 .first_target_reloc = .none,
3868 }),3875 }),
3876 .dwarf_str_offsets = .{
3877 .first_target_reloc = .none,
3878 .node_relocs = .empty,
3879 },
3869 .dwarf_units = &.{},3880 .dwarf_units = &.{},
3870 .dwarf_consts = .empty,3881 .dwarf_consts = .empty,
3871 .dwarf_globals = .empty,3882 .dwarf_globals = .empty,
...@@ -3921,6 +3932,7 @@ pub fn deinit(elf: *Elf) void {...@@ -3921,6 +3932,7 @@ pub fn deinit(elf: *Elf) void {
3921 elf.changed_symtab_index.deinit(gpa);3932 elf.changed_symtab_index.deinit(gpa);
39223933
3923 elf.dwarf.deinit();3934 elf.dwarf.deinit();
3935 elf.dwarf_str_offsets.node_relocs.deinit(gpa);
3924 for (elf.dwarf_units) |*dwarf_unit| dwarf_unit.debug_rnglists_symbol_relocs.deinit(gpa);3936 for (elf.dwarf_units) |*dwarf_unit| dwarf_unit.debug_rnglists_symbol_relocs.deinit(gpa);
3925 gpa.free(elf.dwarf_units);3937 gpa.free(elf.dwarf_units);
3926 elf.dwarf_consts.deinit(gpa);3938 elf.dwarf_consts.deinit(gpa);
...@@ -5132,6 +5144,8 @@ fn initHeaders(...@@ -5132,6 +5144,8 @@ fn initHeaders(
5132 });5144 });
5133 elf.shndx.debug_str_offsets = try elf.addSection(elf.ni.elf, .{5145 elf.shndx.debug_str_offsets = try elf.addSection(elf.ni.elf, .{
5134 .name = ".debug_str_offsets",5146 .name = ".debug_str_offsets",
5147 .addralign = addr_align,
5148 .node_align = elf.mf.flags.block_size,
5135 });5149 });
5136 },5150 },
5137 .code_view => unreachable,5151 .code_view => unreachable,
...@@ -5227,6 +5241,7 @@ fn getNodeShndx(elf: *const Elf, ni: MappedFile.Node.Index) Section.Index {...@@ -5227,6 +5241,7 @@ fn getNodeShndx(elf: *const Elf, ni: MappedFile.Node.Index) Section.Index {
5227 .lazy_const_data,5241 .lazy_const_data,
5228 .debug_shared,5242 .debug_shared,
5229 .eh_frame_footer,5243 .eh_frame_footer,
5244 .debug_str_offsets,
5230 .unit_padding,5245 .unit_padding,
5231 .unit_frame,5246 .unit_frame,
5232 .unit_debug_info,5247 .unit_debug_info,
...@@ -5274,6 +5289,7 @@ fn getNodeVAddr(elf: *Elf, ni: MappedFile.Node.Index) u64 {...@@ -5274,6 +5289,7 @@ fn getNodeVAddr(elf: *Elf, ni: MappedFile.Node.Index) u64 {
5274 => |i| Symbol.Id.local(i.symbol(elf)).value(elf),5289 => |i| Symbol.Id.local(i.symbol(elf)).value(elf),
5275 .debug_shared,5290 .debug_shared,
5276 .eh_frame_footer,5291 .eh_frame_footer,
5292 .debug_str_offsets,
5277 .unit_padding,5293 .unit_padding,
5278 .unit_frame,5294 .unit_frame,
5279 .unit_frame_cie,5295 .unit_frame_cie,
...@@ -5313,7 +5329,7 @@ fn computeNodeVAddr(elf: *Elf, ni: MappedFile.Node.Index) u64 {...@@ -5313,7 +5329,7 @@ fn computeNodeVAddr(elf: *Elf, ni: MappedFile.Node.Index) u64 {
5313 .lazy_code,5329 .lazy_code,
5314 .lazy_const_data,5330 .lazy_const_data,
5315 => |i| Symbol.Id.local(i.symbol(elf)).value(elf),5331 => |i| Symbol.Id.local(i.symbol(elf)).value(elf),
5316 .debug_shared, .eh_frame_footer, .unit_padding => unreachable,5332 .debug_shared, .eh_frame_footer, .debug_str_offsets, .unit_padding => unreachable,
5317 .unit_frame, .unit_debug_info, .unit_debug_line => {5333 .unit_frame, .unit_debug_info, .unit_debug_line => {
5318 const section_offset, _ = parent_ni.location(&elf.mf).resolve(&elf.mf);5334 const section_offset, _ = parent_ni.location(&elf.mf).resolve(&elf.mf);
5319 break :parent_vaddr elf.getNodeShndx(parent_ni).vaddr(elf) + section_offset;5335 break :parent_vaddr elf.getNodeShndx(parent_ni).vaddr(elf) + section_offset;
...@@ -5350,7 +5366,7 @@ fn computeNodeSectionOffset(elf: *Elf, ni: MappedFile.Node.Index) u64 {...@@ -5350,7 +5366,7 @@ fn computeNodeSectionOffset(elf: *Elf, ni: MappedFile.Node.Index) u64 {
5350 .section, .section_manual_size => 0,5366 .section, .section_manual_size => 0,
5351 .input_section, .copied_global => unreachable,5367 .input_section, .copied_global => unreachable,
5352 .nav, .uav, .lazy_code, .lazy_const_data => unreachable,5368 .nav, .uav, .lazy_code, .lazy_const_data => unreachable,
5353 .debug_shared, .eh_frame_footer, .unit_padding => unreachable,5369 .debug_shared, .eh_frame_footer, .debug_str_offsets, .unit_padding => unreachable,
5354 .unit_frame, .unit_debug_info, .unit_debug_line => {5370 .unit_frame, .unit_debug_info, .unit_debug_line => {
5355 const parent_section_offset, _ = parent_ni.location(&elf.mf).resolve(&elf.mf);5371 const parent_section_offset, _ = parent_ni.location(&elf.mf).resolve(&elf.mf);
5356 break :parent_section_offset parent_section_offset;5372 break :parent_section_offset parent_section_offset;
...@@ -5400,6 +5416,7 @@ pub fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void {...@@ -5400,6 +5416,7 @@ pub fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void {
5400 .copied_global,5416 .copied_global,
5401 .debug_shared,5417 .debug_shared,
5402 .eh_frame_footer,5418 .eh_frame_footer,
5419 .debug_str_offsets,
5403 .unit_padding,5420 .unit_padding,
5404 .unit_frame,5421 .unit_frame,
5405 .unit_frame_cie,5422 .unit_frame_cie,
...@@ -7163,8 +7180,8 @@ fn updateInitFiniArraySectionSize(...@@ -7163,8 +7180,8 @@ fn updateInitFiniArraySectionSize(
7163}7180}
71647181
7165pub fn prelink(elf: *Elf, prog_node: std.Progress.Node) link.Error!void {7182pub fn prelink(elf: *Elf, prog_node: std.Progress.Node) link.Error!void {
7166 const sub_prog_node = prog_node.start("ELF Prelink", 0);7183 const prelink_prog_node = prog_node.start("ELF Prelink", 0);
7167 defer sub_prog_node.end();7184 defer prelink_prog_node.end();
71687185
7169 const diags = &elf.base.comp.link_diags;7186 const diags = &elf.base.comp.link_diags;
7170 elf.prelinkInner() catch |err| switch (err) {7187 elf.prelinkInner() catch |err| switch (err) {
...@@ -7198,45 +7215,14 @@ fn prelinkInner(elf: *Elf) Error!void {...@@ -7198,45 +7215,14 @@ fn prelinkInner(elf: *Elf) Error!void {
7198 };7215 };
7199 elf.input_pending_index += 1;7216 elf.input_pending_index += 1;
72007217
7201 try elf.nodes.ensureUnusedCapacity(gpa, 4 + 5);7218 try elf.nodes.ensureUnusedCapacity(gpa, 6 + 4);
72027219 for ([6]Section.Index{
7203 switch (elf.shndx.debug_abbrev) {
7204 .UNDEF => {},
7205 else => |debug_abbrev_shndx| elf.dwarf.debug_abbrev.ni = .wrap(elf.addNodeAssumeCapacity(
7206 try debug_abbrev_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
7207 .{ .debug_shared = .debug_abbrev },
7208 )),
7209 }
7210 switch (elf.shndx.debug_line_str) {
7211 .UNDEF => {},
7212 else => |debug_line_str_shndx| elf.dwarf.debug_line_str.ni =
7213 .wrap(elf.addNodeAssumeCapacity(
7214 try debug_line_str_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
7215 .{ .debug_shared = .debug_line_str },
7216 )),
7217 }
7218 switch (elf.shndx.debug_str) {
7219 .UNDEF => {},
7220 else => |debug_str_shndx| elf.dwarf.debug_str.ni = .wrap(elf.addNodeAssumeCapacity(
7221 try debug_str_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
7222 .{ .debug_shared = .debug_str },
7223 )),
7224 }
7225 switch (elf.shndx.debug_str_offsets) {
7226 .UNDEF => {},
7227 else => |debug_str_offsets_shndx| elf.dwarf.debug_str_offsets.ni =
7228 .wrap(elf.addNodeAssumeCapacity(
7229 try debug_str_offsets_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
7230 .{ .debug_shared = .debug_str_offsets },
7231 )),
7232 }
7233
7234 for ([5]Section.Index{
7235 elf.shndx.eh_frame,7220 elf.shndx.eh_frame,
7236 elf.shndx.debug_frame,7221 elf.shndx.debug_frame,
7237 elf.shndx.debug_info,7222 elf.shndx.debug_info,
7238 elf.shndx.debug_line,7223 elf.shndx.debug_line,
7239 elf.shndx.debug_rnglists,7224 elf.shndx.debug_rnglists,
7225 elf.shndx.debug_str_offsets,
7240 }) |debug_shndx| {7226 }) |debug_shndx| {
7241 if (debug_shndx == .UNDEF) continue;7227 if (debug_shndx == .UNDEF) continue;
7242 const debug_ni = debug_shndx.get(elf).ni;7228 const debug_ni = debug_shndx.get(elf).ni;
...@@ -7272,6 +7258,53 @@ fn prelinkInner(elf: *Elf) Error!void {...@@ -7272,6 +7258,53 @@ fn prelinkInner(elf: *Elf) Error!void {
7272 error.WriteFailed => return debug_nw.err.?,7258 error.WriteFailed => return debug_nw.err.?,
7273 };7259 };
7274 }7260 }
7261 switch (elf.shndx.debug_abbrev) {
7262 .UNDEF => {},
7263 else => |debug_abbrev_shndx| elf.dwarf.debug_abbrev.ni = .wrap(elf.addNodeAssumeCapacity(
7264 try debug_abbrev_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
7265 .{ .debug_shared = .debug_abbrev },
7266 )),
7267 }
7268 switch (elf.shndx.debug_line_str) {
7269 .UNDEF => {},
7270 else => |debug_line_str_shndx| elf.dwarf.debug_line_str.ni =
7271 .wrap(elf.addNodeAssumeCapacity(
7272 try debug_line_str_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
7273 .{ .debug_shared = .debug_line_str },
7274 )),
7275 }
7276 switch (elf.shndx.debug_str) {
7277 .UNDEF => {},
7278 else => |debug_str_shndx| elf.dwarf.debug_str.ni = .wrap(elf.addNodeAssumeCapacity(
7279 try debug_str_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
7280 .{ .debug_shared = .debug_str },
7281 )),
7282 }
7283 switch (elf.shndx.debug_str_offsets) {
7284 .UNDEF => {},
7285 else => |debug_str_offsets_shndx| {
7286 const debug_str_offsets_ni = elf.addNodeAssumeCapacity(
7287 try debug_str_offsets_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
7288 .alignment = switch (elf.dwarf.format) {
7289 .@"32" => .@"4",
7290 .@"64" => .@"8",
7291 },
7292 .next_moved = true,
7293 .enable_next_moved = true,
7294 }),
7295 .debug_str_offsets,
7296 );
7297 elf.dwarf.debug_str_offsets.ni = .wrap(debug_str_offsets_ni);
7298
7299 var dsoh_nw: link.MappedFile.Node.Writer = undefined;
7300 debug_str_offsets_ni.writer(gpa, &elf.mf, &dsoh_nw);
7301 defer dsoh_nw.deinit();
7302 elf.dwarf.genDebugStrOffsetsHeader(&dsoh_nw.interface) catch |err| switch (err) {
7303 else => |e| return e,
7304 error.WriteFailed => return dsoh_nw.err.?,
7305 };
7306 },
7307 }
7275 }7308 }
7276}7309}
72777310
...@@ -7397,6 +7430,7 @@ fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void {...@@ -7397,6 +7430,7 @@ fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void {
7397 error.WriteFailed => return dih_nw.err.?,7430 error.WriteFailed => return dih_nw.err.?,
7398 };7431 };
7399 }7432 }
7433 try elf.genPendingDebugStrings(gpa);
7400}7434}
74017435
7402fn flushFiles(elf: *Elf) Error!void {7436fn flushFiles(elf: *Elf) Error!void {
...@@ -8221,6 +8255,7 @@ fn addNodeRelocAssumeCapacity(...@@ -8221,6 +8255,7 @@ fn addNodeRelocAssumeCapacity(
8221 const first_target_reloc = switch (elf.getNode(target)) {8255 const first_target_reloc = switch (elf.getNode(target)) {
8222 else => unreachable,8256 else => unreachable,
8223 .debug_shared => |ss| &elf.dwarf_shared.getPtr(ss).first_target_reloc,8257 .debug_shared => |ss| &elf.dwarf_shared.getPtr(ss).first_target_reloc,
8258 .debug_str_offsets => &elf.dwarf_str_offsets.first_target_reloc,
8224 .unit_frame_cie => |ui| &elf.dwarf_units[@backingInt(ui)].frame_cie_first_target_reloc,8259 .unit_frame_cie => |ui| &elf.dwarf_units[@backingInt(ui)].frame_cie_first_target_reloc,
8225 .unit_debug_info_header => |ui| &elf.dwarf_units[@backingInt(ui)].debug_info_header_first_target_reloc,8260 .unit_debug_info_header => |ui| &elf.dwarf_units[@backingInt(ui)].debug_info_header_first_target_reloc,
8226 .unit_debug_line_header => |ui| &elf.dwarf_units[@backingInt(ui)].debug_line_header_first_target_reloc,8261 .unit_debug_line_header => |ui| &elf.dwarf_units[@backingInt(ui)].debug_line_header_first_target_reloc,
...@@ -8327,6 +8362,7 @@ fn addGotRelocAssumeCapacity(...@@ -8327,6 +8362,7 @@ fn addGotRelocAssumeCapacity(
8327 .copied_global,8362 .copied_global,
8328 .debug_shared,8363 .debug_shared,
8329 .eh_frame_footer,8364 .eh_frame_footer,
8365 .debug_str_offsets,
8330 .unit_padding,8366 .unit_padding,
8331 .unit_frame,8367 .unit_frame,
8332 .unit_frame_cie,8368 .unit_frame_cie,
...@@ -9049,10 +9085,12 @@ fn updateFuncInner(...@@ -9049,10 +9085,12 @@ fn updateFuncInner(
9049 const unit = debug.wip_func.unit.get(debug.wip_func.dwarf);9085 const unit = debug.wip_func.unit.get(debug.wip_func.dwarf);
9050 {9086 {
9051 var dr_nw: MappedFile.Node.Writer = undefined;9087 var dr_nw: MappedFile.Node.Writer = undefined;
9052 unit.debug_rnglists_ni.unwrap().?.writer(gpa, &elf.mf, &dr_nw);9088 const debug_rnglists_ni = unit.debug_rnglists_ni.unwrap().?;
9089 try debug_rnglists_ni.moved(gpa, &elf.mf);
9090 debug_rnglists_ni.writer(gpa, &elf.mf, &dr_nw);
9053 defer dr_nw.deinit();9091 defer dr_nw.deinit();
9054 const first_symbol_reloc = elf.symbol_relocs.items.len;9092 const first_symbol_ri = elf.symbol_relocs.items.len;
9055 debug.wip_func.dwarf.genDebugRnglists(9093 debug.wip_func.dwarf.genDebugRnglistsRange(
9056 unit,9094 unit,
9057 &dr_nw,9095 &dr_nw,
9058 debug.wip_func.func_si,9096 debug.wip_func.func_si,
...@@ -9064,12 +9102,9 @@ fn updateFuncInner(...@@ -9064,12 +9102,9 @@ fn updateFuncInner(
9064 const symbol_relocs = &elf.dwarf_units[@backingInt(debug.wip_func.unit)]9102 const symbol_relocs = &elf.dwarf_units[@backingInt(debug.wip_func.unit)]
9065 .debug_rnglists_symbol_relocs;9103 .debug_rnglists_symbol_relocs;
9066 try symbol_relocs.ensureUnusedCapacity(gpa, elf.symbol_relocs.items.len -9104 try symbol_relocs.ensureUnusedCapacity(gpa, elf.symbol_relocs.items.len -
9067 first_symbol_reloc);9105 first_symbol_ri);
9068 for (first_symbol_reloc..elf.symbol_relocs.items.len) |symbol_ri|9106 for (first_symbol_ri..elf.symbol_relocs.items.len) |symbol_ri|
9069 symbol_relocs.putAssumeCapacityNoClobber(9107 symbol_relocs.appendAssumeCapacity(@fromBackingInt(@intCast(symbol_ri)));
9070 @fromBackingInt(@intCast(symbol_ri)),
9071 {},
9072 );
9073 }9108 }
9074 debug.wip_func.finishDebugFrameFde(func_length);9109 debug.wip_func.finishDebugFrameFde(func_length);
9075 if (func.analysisUnordered(ip).inferred_error_set) {9110 if (func.analysisUnordered(ip).inferred_error_set) {
...@@ -9153,8 +9188,8 @@ fn flushInner(...@@ -9153,8 +9188,8 @@ fn flushInner(
9153 const diags = &comp.link_diags;9188 const diags = &comp.link_diags;
9154 _ = arena;9189 _ = arena;
91559190
9156 const sub_prog_node = prog_node.start("ELF Flush", 0);9191 const flush_prog_node = prog_node.start("ELF Flush", 0);
9157 defer sub_prog_node.end();9192 defer flush_prog_node.end();
91589193
9159 try elf.flushFiles();9194 try elf.flushFiles();
91609195
...@@ -9172,8 +9207,11 @@ fn flushInner(...@@ -9172,8 +9207,11 @@ fn flushInner(
91729207
9173 while (try elf.idle(tid)) {}9208 while (try elf.idle(tid)) {}
91749209
9210 assert(elf.input_pending_index == elf.inputs.items.len);
9211 assert(elf.input_section_pending_index == elf.input_sections.items.len);
9175 assert(elf.pending_uavs.items.len == 0);9212 assert(elf.pending_uavs.items.len == 0);
9176 assert(elf.dwarf.const_pool.pending.items.len == 0);9213 assert(elf.dwarf.const_pool.pending.items.len == 0);
9214 assert(elf.dwarf.debug_str_offsets.pending_index == elf.dwarf.debug_str_offsets.map.count());
91779215
9178 // We've done the final `idle` loop, so everything is at its final place in the file. We have a9216 // We've done the final `idle` loop, so everything is at its final place in the file. We have a
9179 // few more things to check and write now that addresses and offsets are finalized.9217 // few more things to check and write now that addresses and offsets are finalized.
...@@ -9237,22 +9275,24 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool {...@@ -9237,22 +9275,24 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool {
9237 assert(elf.dwarf.const_pool.pending.items.len == 0);9275 assert(elf.dwarf.const_pool.pending.items.len == 0);
92389276
9239 task: {9277 task: {
9240 if (elf.input_pending_index < elf.inputs.items.len) {9278 if (elf.inputs.items.len - elf.input_pending_index > 0) {
9241 const ii: Node.InputIndex = @fromBackingInt(elf.input_pending_index);9279 const ii: Node.InputIndex = @fromBackingInt(elf.input_pending_index);
9242 elf.input_pending_index += 1;9280 elf.input_pending_index += 1;
9243 const sub_prog_node = elf.idleProgNode(tid, elf.input_prog_node, elf.getNode(ii.node(elf)));9281 const idle_prog_node =
9244 defer sub_prog_node.end();9282 elf.startIdleProgress(tid, elf.input_prog_node, elf.getNode(ii.node(elf)));
9283 defer idle_prog_node.end();
9245 elf.flushInput(ii) catch |err| switch (err) {9284 elf.flushInput(ii) catch |err| switch (err) {
9246 else => |e| return e,9285 else => |e| return e,
9247 error.MappedFileIo => return diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}),9286 error.MappedFileIo => return diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}),
9248 };9287 };
9249 break :task;9288 break :task;
9250 }9289 }
9251 if (elf.input_section_pending_index < elf.input_sections.items.len) {9290 if (elf.input_sections.items.len - elf.input_section_pending_index > 0) {
9252 const isi: InputSection.Index = @fromBackingInt(elf.input_section_pending_index);9291 const isi: InputSection.Index = @fromBackingInt(elf.input_section_pending_index);
9253 elf.input_section_pending_index += 1;9292 elf.input_section_pending_index += 1;
9254 const sub_prog_node = elf.idleProgNode(tid, elf.input_prog_node, elf.getNode(isi.node(elf)));9293 const idle_prog_node =
9255 defer sub_prog_node.end();9294 elf.startIdleProgress(tid, elf.input_prog_node, elf.getNode(isi.node(elf)));
9295 defer idle_prog_node.end();
9256 elf.flushInputSection(isi) catch |err| switch (err) {9296 elf.flushInputSection(isi) catch |err| switch (err) {
9257 else => |e| return e,9297 else => |e| return e,
9258 error.MappedFileIo => return diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}),9298 error.MappedFileIo => return diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}),
...@@ -9279,8 +9319,8 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool {...@@ -9279,8 +9319,8 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool {
9279 break :task;9319 break :task;
9280 }9320 }
9281 if (elf.changed_symtab_index.pop()) |kv| {9321 if (elf.changed_symtab_index.pop()) |kv| {
9282 const sub_prog_node = elf.mf.update_prog_node.start(kv.key.slice(elf), 0);9322 const idle_prog_node = elf.mf.update_prog_node.start(kv.key.slice(elf), 0);
9283 defer sub_prog_node.end();9323 defer idle_prog_node.end();
92849324
9285 const global_name = kv.key;9325 const global_name = kv.key;
9286 const global = elf.globalByName(global_name).?;9326 const global = elf.globalByName(global_name).?;
...@@ -9359,22 +9399,23 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool {...@@ -9359,22 +9399,23 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool {
9359 const clean_resized = ni.cleanResized(&elf.mf);9399 const clean_resized = ni.cleanResized(&elf.mf);
9360 const clean_next_moved = ni.cleanNextMoved(&elf.mf);9400 const clean_next_moved = ni.cleanNextMoved(&elf.mf);
9361 if (!clean_moved and !clean_resized and !clean_next_moved) continue;9401 if (!clean_moved and !clean_resized and !clean_next_moved) continue;
9362 const sub_prog_node = elf.idleProgNode(tid, elf.mf.update_prog_node, elf.getNode(ni));9402 const idle_prog_node = elf.startIdleProgress(tid, elf.mf.update_prog_node, elf.getNode(ni));
9363 defer sub_prog_node.end();9403 defer idle_prog_node.end();
9364 if (clean_moved) try elf.flushMoved(ni);9404 if (clean_moved) try elf.flushMoved(ni);
9365 if (clean_resized) try elf.flushResized(ni);9405 if (clean_resized) try elf.flushResized(ni);
9366 if (clean_moved or clean_resized or clean_next_moved) try elf.flushPadding(ni);9406 if (clean_moved or clean_resized or clean_next_moved) try elf.flushPadding(ni);
9367 break :task;9407 break :task;
9368 }9408 }
9369 }9409 }
9370 if (elf.input_sections.items.len > elf.input_section_pending_index) return true;9410 if (elf.inputs.items.len - elf.input_pending_index > 0) return true;
9411 if (elf.input_sections.items.len - elf.input_section_pending_index > 0) return true;
9371 if (elf.one_shot_fixups.items.len > 0) return true;9412 if (elf.one_shot_fixups.items.len > 0) return true;
9372 if (elf.changed_symtab_index.count() > 0) return true;9413 if (elf.changed_symtab_index.count() > 0) return true;
9373 if (elf.mf.updates.items.len > 0) return true;9414 if (elf.mf.updates.items.len > 0) return true;
9374 return false;9415 return false;
9375}9416}
93769417
9377fn idleProgNode(9418fn startIdleProgress(
9378 elf: *Elf,9419 elf: *Elf,
9379 tid: Zcu.PerThread.Id,9420 tid: Zcu.PerThread.Id,
9380 prog_node: std.Progress.Node,9421 prog_node: std.Progress.Node,
...@@ -9405,7 +9446,7 @@ fn idleProgNode(...@@ -9405,7 +9446,7 @@ fn idleProgNode(
9405 }) catch &name,9446 }) catch &name,
9406 .debug_shared => |ss| switch (ss) {9447 .debug_shared => |ss| switch (ss) {
9407 .debug_abbrev => "debug info abbrevs",9448 .debug_abbrev => "debug info abbrevs",
9408 .debug_str, .debug_str_offsets => "debug info strings",9449 .debug_str => "debug info strings",
9409 .debug_line_str => "line info strings",9450 .debug_line_str => "line info strings",
9410 },9451 },
9411 .unit_frame,9452 .unit_frame,
...@@ -9474,29 +9515,43 @@ fn genPending(elf: *Elf, pt: Zcu.PerThread) link.Error!void {...@@ -9474,29 +9515,43 @@ fn genPending(elf: *Elf, pt: Zcu.PerThread) link.Error!void {
9474 try elf.genUav(pt, umi);9515 try elf.genUav(pt, umi);
9475 }9516 }
9476 var lazy_it = elf.lazy.iterator();9517 var lazy_it = elf.lazy.iterator();
9477 while (lazy_it.next()) |lazy| while (lazy.value.pending_index < lazy.value.map.count()) {9518 while (lazy_it.next()) |lazy| while (lazy.value.map.count() - lazy.value.pending_index > 0) {
9478 try elf.genLazy(pt, .{ .kind = lazy.key, .index = lazy.value.pending_index });9519 try elf.genLazy(pt, .{ .kind = lazy.key, .index = lazy.value.pending_index });
9479 lazy.value.pending_index += 1;9520 lazy.value.pending_index += 1;
9480 };9521 };
9522 const gpa = elf.base.comp.gpa;
9481 switch (elf.base.comp.config.debug_format) {9523 switch (elf.base.comp.config.debug_format) {
9482 .strip => {},9524 .strip => {},
9483 .dwarf => {9525 .dwarf => while (true) {
9484 const gpa = elf.base.comp.gpa;9526 const pending = elf.dwarf.pending_decl;
9485 while (true) {9527 if (pending.instance == .none) break;
9486 const pending = elf.dwarf.pending_decl;9528 elf.dwarf.pending_decl = .{ .di = undefined, .instance = .none };
9487 if (pending.instance == .none) break;9529 const debug_info_ni = pending.di.get(&elf.dwarf).debug_info_ni.unwrap().?;
9488 elf.dwarf.pending_decl = .{ .di = undefined, .instance = .none };9530 try debug_info_ni.moved(gpa, &elf.mf);
9489 const debug_info_ni = pending.di.get(&elf.dwarf).debug_info_ni.unwrap().?;9531 var di_nw: MappedFile.Node.Writer = undefined;
9490 try debug_info_ni.moved(gpa, &elf.mf);9532 debug_info_ni.writer(gpa, &elf.mf, &di_nw);
9491 var di_nw: MappedFile.Node.Writer = undefined;9533 defer di_nw.deinit();
9492 debug_info_ni.writer(gpa, &elf.mf, &di_nw);9534 elf.resetNodeRelocs(debug_info_ni);
9493 defer di_nw.deinit();9535 try elf.dwarf.genDecl(pt, &di_nw, pending.instance);
9494 elf.resetNodeRelocs(debug_info_ni);
9495 try elf.dwarf.genDecl(pt, &di_nw, pending.instance);
9496 }
9497 },9536 },
9498 .code_view => unreachable,9537 .code_view => unreachable,
9499 }9538 }
9539 try elf.genPendingDebugStrings(gpa);
9540}
9541fn genPendingDebugStrings(elf: *Elf, gpa: std.mem.Allocator) link.Error!void {
9542 while (elf.dwarf.debug_str_offsets.map.count() - elf.dwarf.debug_str_offsets.pending_index > 0) {
9543 const debug_str_offsets_ni = elf.dwarf.debug_str_offsets.ni.unwrap().?;
9544 try debug_str_offsets_ni.moved(gpa, &elf.mf);
9545 var dso_nw: link.MappedFile.Node.Writer = undefined;
9546 debug_str_offsets_ni.writer(gpa, &elf.mf, &dso_nw);
9547 defer dso_nw.deinit();
9548 const first_node_ri = elf.node_relocs.items.len;
9549 try elf.dwarf.genPendingDebugStrOffsets(&dso_nw);
9550 const node_relocs = &elf.dwarf_str_offsets.node_relocs;
9551 try node_relocs.ensureUnusedCapacity(gpa, elf.node_relocs.items.len - first_node_ri);
9552 for (first_node_ri..elf.node_relocs.items.len) |node_ri|
9553 node_relocs.appendAssumeCapacity(@fromBackingInt(@intCast(node_ri)));
9554 }
9500}9555}
95019556
9502fn genUav(9557fn genUav(
...@@ -9897,7 +9952,28 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void...@@ -9897,7 +9952,28 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void
9897 target_ri = target_reloc.next;9952 target_ri = target_reloc.next;
9898 }9953 }
9899 },9954 },
9900 .eh_frame_footer, .unit_padding, .unit_frame, .unit_debug_info, .unit_debug_line => {},9955 .eh_frame_footer,
9956 .unit_padding,
9957 .unit_frame,
9958 .unit_debug_info,
9959 .unit_debug_line,
9960 => {},
9961 .debug_str_offsets => {
9962 const target_section_offset = elf.computeNodeSectionOffset(ni);
9963 var target_ri = elf.dwarf_str_offsets.first_target_reloc;
9964 while (target_ri != .none) {
9965 const target_reloc = target_ri.get(elf);
9966 assert(target_reloc.target == ni);
9967 target_reloc.flushMovedTarget(elf, target_section_offset);
9968 target_ri = target_reloc.next;
9969 }
9970 const node_vaddr = elf.computeNodeVAddr(ni);
9971 for (elf.dwarf_str_offsets.node_relocs.items) |node_ri| {
9972 const node_reloc = node_ri.get(elf);
9973 assert(node_reloc.node.unwrap().? == ni);
9974 node_reloc.flushMovedNode(elf, node_vaddr);
9975 }
9976 },
9901 .unit_frame_cie => |ui| {9977 .unit_frame_cie => |ui| {
9902 const target_section_offset = elf.computeNodeSectionOffset(ni);9978 const target_section_offset = elf.computeNodeSectionOffset(ni);
9903 var target_ri = elf.dwarf_units[@backingInt(ui)].frame_cie_first_target_reloc;9979 var target_ri = elf.dwarf_units[@backingInt(ui)].frame_cie_first_target_reloc;
...@@ -9948,7 +10024,7 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void...@@ -9948,7 +10024,7 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void
9948 target_ri = target_reloc.next;10024 target_ri = target_reloc.next;
9949 }10025 }
9950 const node_vaddr = elf.computeNodeVAddr(ni);10026 const node_vaddr = elf.computeNodeVAddr(ni);
9951 for (dwarf_unit.debug_rnglists_symbol_relocs.keys()) |symbol_ri| {10027 for (dwarf_unit.debug_rnglists_symbol_relocs.items) |symbol_ri| {
9952 const symbol_reloc = symbol_ri.get(elf);10028 const symbol_reloc = symbol_ri.get(elf);
9953 assert(symbol_reloc.node.unwrap().? == ni);10029 assert(symbol_reloc.node.unwrap().? == ni);
9954 symbol_reloc.flushMovedNode(elf, node_vaddr);10030 symbol_reloc.flushMovedNode(elf, node_vaddr);
...@@ -10281,6 +10357,7 @@ fn flushResized(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10281,6 +10357,7 @@ fn flushResized(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10281 .lazy_const_data,10357 .lazy_const_data,
10282 .debug_shared,10358 .debug_shared,
10283 .eh_frame_footer,10359 .eh_frame_footer,
10360 .debug_str_offsets,
10284 .unit_padding,10361 .unit_padding,
10285 .unit_frame,10362 .unit_frame,
10286 .unit_frame_cie,10363 .unit_frame_cie,
...@@ -10304,7 +10381,8 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10304,7 +10381,8 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10304 const trace = tracy.trace(@src());10381 const trace = tracy.trace(@src());
10305 defer trace.end();10382 defer trace.end();
1030610383
10307 switch (elf.getNode(ni)) {10384 const node = elf.getNode(ni);
10385 switch (node) {
10308 .deleted => unreachable,10386 .deleted => unreachable,
10309 .archive,10387 .archive,
10310 .archive_input_member,10388 .archive_input_member,
...@@ -10352,6 +10430,7 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10352,6 +10430,7 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10352 error.NoSpaceLeft => archive.strtab_member_too_big = true,10430 error.NoSpaceLeft => archive.strtab_member_too_big = true,
10353 }10431 }
10354 },10432 },
10433 .debug_str_offsets,
10355 .unit_padding,10434 .unit_padding,
10356 .unit_frame_cie,10435 .unit_frame_cie,
10357 .unit_debug_info_header,10436 .unit_debug_info_header,
...@@ -10363,8 +10442,26 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10363,8 +10442,26 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10363 .func_debug_info,10442 .func_debug_info,
10364 .func_debug_line,10443 .func_debug_line,
10365 .decl_debug_info,10444 .decl_debug_info,
10366 => |_, tag| {10445 => {
10367 const offset, const size = ni.location(&elf.mf).resolve(&elf.mf);10446 const offset, const size = location: {
10447 const offset, const size = ni.location(&elf.mf).resolve(&elf.mf);
10448 break :location .{ offset, switch (node) {
10449 else => unreachable,
10450 .debug_str_offsets => elf.dwarf.debug_str_offsets.size(&elf.dwarf),
10451 .unit_padding,
10452 .unit_frame_cie,
10453 .unit_debug_info_header,
10454 .unit_debug_line_header,
10455 .const_debug_info,
10456 .global_debug_info,
10457 .func_frame_fde,
10458 .func_debug_info,
10459 .func_debug_line,
10460 .decl_debug_info,
10461 => size,
10462 .unit_debug_rnglists => |ui| Dwarf.Rnglists.size(&elf.dwarf, ui),
10463 } };
10464 };
10368 const parent_ni = ni.parent(&elf.mf).unwrap().?;10465 const parent_ni = ni.parent(&elf.mf).unwrap().?;
10369 const slice = slice: {10466 const slice = slice: {
10370 if (ni.next(&elf.mf).unwrap()) |next_ni| switch (next_ni.position(&elf.mf)) {10467 if (ni.next(&elf.mf).unwrap()) |next_ni| switch (next_ni.position(&elf.mf)) {
...@@ -10376,9 +10473,9 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10376,9 +10473,9 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10376 break :slice parent_slice[@intCast(offset)..@intCast(next_offset)];10473 break :slice parent_slice[@intCast(offset)..@intCast(next_offset)];
10377 },10474 },
10378 };10475 };
10379 switch (tag) {10476 switch (node) {
10380 else => unreachable,10477 else => unreachable,
10381 .unit_padding, .unit_debug_rnglists => {10478 .debug_str_offsets, .unit_padding, .unit_debug_rnglists => {
10382 const parent_slice = parent_ni.slicePadding(&elf.mf);10479 const parent_slice = parent_ni.slicePadding(&elf.mf);
10383 const frame_shndx = elf.getNodeShndx(parent_ni);10480 const frame_shndx = elf.getNodeShndx(parent_ni);
10384 const frame_format = frame_shndx.debugFrameFormat(elf) orelse10481 const frame_format = frame_shndx.debugFrameFormat(elf) orelse
...@@ -10453,7 +10550,7 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10453,7 +10550,7 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10453 break :buffer debug_slice[@intCast(parent_offset)..];10550 break :buffer debug_slice[@intCast(parent_offset)..];
10454 });10551 });
10455 fw.end = @intCast(offset + size);10552 fw.end = @intCast(offset + size);
10456 switch (tag) {10553 switch (node) {
10457 else => unreachable,10554 else => unreachable,
10458 .unit_debug_info_header,10555 .unit_debug_info_header,
10459 .const_debug_info,10556 .const_debug_info,
...@@ -10470,7 +10567,7 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10470,7 +10567,7 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10470 error.WriteFailed => {10567 error.WriteFailed => {
10471 fw.end = unit_padding_offset;10568 fw.end = unit_padding_offset;
10472 elf.dwarf.updateUnitLength(fw.buffer, fw.buffer.len);10569 elf.dwarf.updateUnitLength(fw.buffer, fw.buffer.len);
10473 switch (tag) {10570 switch (node) {
10474 else => unreachable,10571 else => unreachable,
10475 .unit_debug_info_header,10572 .unit_debug_info_header,
10476 .const_debug_info,10573 .const_debug_info,
...@@ -10501,8 +10598,23 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10501,8 +10598,23 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10501 }10598 }
10502 };10599 };
10503 var fw: Io.Writer = .fixed(slice[@intCast(size)..]);10600 var fw: Io.Writer = .fixed(slice[@intCast(size)..]);
10504 switch (tag) {10601 switch (node) {
10505 else => unreachable,10602 else => unreachable,
10603 .debug_str_offsets, .unit_debug_rnglists => {
10604 elf.dwarf.genUnitPadding(&fw) catch |err| switch (err) {
10605 error.WriteFailed => {
10606 elf.dwarf.updateUnitLength(slice, slice.len);
10607 @memset(fw.buffer, switch (node) {
10608 else => unreachable,
10609 .debug_str_offsets => std.math.maxInt(u8),
10610 .unit_debug_rnglists => std.dwarf.RLE.end_of_list,
10611 });
10612 return;
10613 },
10614 };
10615 elf.dwarf.updateUnitLength(slice, size);
10616 elf.dwarf.updateUnitLength(fw.buffer, fw.buffer.len);
10617 },
10506 .unit_padding => elf.dwarf.updateUnitLength(slice, slice.len),10618 .unit_padding => elf.dwarf.updateUnitLength(slice, slice.len),
10507 .unit_frame_cie, .func_frame_fde => {10619 .unit_frame_cie, .func_frame_fde => {
10508 elf.dwarf.updateUnitLength(slice, slice.len);10620 elf.dwarf.updateUnitLength(slice, slice.len);
...@@ -10517,17 +10629,6 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo...@@ -10517,17 +10629,6 @@ fn flushPadding(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo
10517 .unit_debug_line_header,10629 .unit_debug_line_header,
10518 .func_debug_line,10630 .func_debug_line,
10519 => Dwarf.genDebugLinePadding(&fw, fw.buffer.len) catch unreachable,10631 => Dwarf.genDebugLinePadding(&fw, fw.buffer.len) catch unreachable,
10520 .unit_debug_rnglists => {
10521 elf.dwarf.genUnitPadding(&fw) catch |err| switch (err) {
10522 error.WriteFailed => {
10523 elf.dwarf.updateUnitLength(slice, slice.len);
10524 @memset(fw.buffer, std.dwarf.RLE.end_of_list);
10525 return;
10526 },
10527 };
10528 elf.dwarf.updateUnitLength(slice, size);
10529 elf.dwarf.updateUnitLength(fw.buffer, fw.buffer.len);
10530 },
10531 }10632 }
10532 },10633 },
10533 .unit_frame, .unit_debug_info, .unit_debug_line => {10634 .unit_frame, .unit_debug_info, .unit_debug_line => {