| ... | @@ -224,7 +224,7 @@ dwarf_units: std.ArrayList(struct { | ... | @@ -224,7 +224,7 @@ dwarf_units: std.ArrayList(struct { |
| 224 | debug_rnglists_first_target_reloc: NodeReloc.Index, | 224 | debug_rnglists_first_target_reloc: NodeReloc.Index, |
| 225 | debug_rnglists_symbol_relocs: std.array_hash_map.Auto(SymbolReloc.Index, void), | 225 | debug_rnglists_symbol_relocs: std.array_hash_map.Auto(SymbolReloc.Index, void), |
| 226 | }), | 226 | }), |
| 227 | dwarf_values: std.ArrayList(struct { | 227 | dwarf_consts: std.array_hash_map.Auto(link.ConstPool.Index, struct { |
| 228 | debug_info_first_target_reloc: NodeReloc.Index, | 228 | debug_info_first_target_reloc: NodeReloc.Index, |
| 229 | debug_info_first_symbol_reloc: SymbolReloc.Index, | 229 | debug_info_first_symbol_reloc: SymbolReloc.Index, |
| 230 | debug_info_first_node_reloc: NodeReloc.Index, | 230 | debug_info_first_node_reloc: NodeReloc.Index, |
| ... | @@ -318,7 +318,7 @@ const Node = union(enum) { | ... | @@ -318,7 +318,7 @@ const Node = union(enum) { |
| 318 | unit_debug_line_header: Dwarf.Unit.Index, | 318 | unit_debug_line_header: Dwarf.Unit.Index, |
| 319 | unit_debug_rnglists: Dwarf.Unit.Index, | 319 | unit_debug_rnglists: Dwarf.Unit.Index, |
| 320 | | 320 | |
| 321 | value_debug_info: link.ConstPool.Index, | 321 | const_debug_info: link.ConstPool.Index, |
| 322 | global_debug_info: Dwarf.Global.Index, | 322 | global_debug_info: Dwarf.Global.Index, |
| 323 | func_frame_fde: Dwarf.Func.Index, | 323 | func_frame_fde: Dwarf.Func.Index, |
| 324 | func_debug_info: Dwarf.Func.Index, | 324 | func_debug_info: Dwarf.Func.Index, |
| ... | @@ -1142,7 +1142,8 @@ const SymbolReloc = struct { | ... | @@ -1142,7 +1142,8 @@ const SymbolReloc = struct { |
| 1142 | /// * An input section | 1142 | /// * An input section |
| 1143 | /// * A section | 1143 | /// * A section |
| 1144 | /// * A NAV, UAV, or lazy code/data | 1144 | /// * A NAV, UAV, or lazy code/data |
| 1145 | node: MappedFile.Node.Index, | 1145 | /// * `.none`, if this relocation was deleted (in which case it should be ignored) |
| | 1146 | node: MappedFile.Node.Index.Optional, |
| 1146 | /// The offset of the relocation inside of `node`. | 1147 | /// The offset of the relocation inside of `node`. |
| 1147 | offset: u64, | 1148 | offset: u64, |
| 1148 | /// A symbol used to compute the relocated value. Precise meaning depends on `@"type"`. | 1149 | /// A symbol used to compute the relocated value. Precise meaning depends on `@"type"`. |
| ... | @@ -1182,7 +1183,7 @@ const SymbolReloc = struct { | ... | @@ -1182,7 +1183,7 @@ const SymbolReloc = struct { |
| 1182 | /// because relocations in the GOTPLT are handled specially, without `SymbolReloc` entries. | 1183 | /// because relocations in the GOTPLT are handled specially, without `SymbolReloc` entries. |
| 1183 | fn relaSection(sr: *const SymbolReloc, elf: *Elf) Section.Index { | 1184 | fn relaSection(sr: *const SymbolReloc, elf: *Elf) Section.Index { |
| 1184 | const shndx = switch (elf.ehdrType()) { | 1185 | const shndx = switch (elf.ehdrType()) { |
| 1185 | .REL => elf.getNodeShndx(sr.node).get(elf).rela.shndx, | 1186 | .REL => elf.getNodeShndx(sr.node.unwrap().?).get(elf).rela.shndx, |
| 1186 | .EXEC, .DYN => elf.shndx.rela_dyn, | 1187 | .EXEC, .DYN => elf.shndx.rela_dyn, |
| 1187 | }; | 1188 | }; |
| 1188 | assert(shndx != .UNDEF); | 1189 | assert(shndx != .UNDEF); |
| ... | @@ -1619,7 +1620,8 @@ const SymbolReloc = struct { | ... | @@ -1619,7 +1620,8 @@ const SymbolReloc = struct { |
| 1619 | | 1620 | |
| 1620 | fn apply(reloc: *SymbolReloc, elf: *Elf) void { | 1621 | fn apply(reloc: *SymbolReloc, elf: *Elf) void { |
| 1621 | assert(elf.ehdrType() != .REL); | 1622 | assert(elf.ehdrType() != .REL); |
| 1622 | if (reloc.node.hasMoved(&elf.mf) or reloc.target.hasMoved(elf)) { | 1623 | const node = reloc.node.unwrap() orelse return; // deleted |
| | 1624 | if (node.hasMoved(&elf.mf) or reloc.target.hasMoved(elf)) { |
| 1623 | // There's no point applying the relocation now, because it will be re-applied by | 1625 | // There's no point applying the relocation now, because it will be re-applied by |
| 1624 | // `flushMoved` at some point anyway. | 1626 | // `flushMoved` at some point anyway. |
| 1625 | return; | 1627 | return; |
| ... | @@ -1644,8 +1646,9 @@ const SymbolReloc = struct { | ... | @@ -1644,8 +1646,9 @@ const SymbolReloc = struct { |
| 1644 | } | 1646 | } |
| 1645 | } | 1647 | } |
| 1646 | fn applyInner(reloc: *const SymbolReloc, elf: *Elf) error{ RelocationOverflow, RelocationMisaligned }!void { | 1648 | fn applyInner(reloc: *const SymbolReloc, elf: *Elf) error{ RelocationOverflow, RelocationMisaligned }!void { |
| 1647 | const dest_vaddr = elf.getNodeVAddr(reloc.node) + reloc.offset; | 1649 | const node = reloc.node.unwrap().?; |
| 1648 | const dest_slice = reloc.node.slice(&elf.mf)[@intCast(reloc.offset)..]; | 1650 | const dest_vaddr = elf.getNodeVAddr(node) + reloc.offset; |
| | 1651 | const dest_slice = node.slice(&elf.mf)[@intCast(reloc.offset)..]; |
| 1649 | | 1652 | |
| 1650 | const addend: u64 = @bitCast(reloc.addend); | 1653 | const addend: u64 = @bitCast(reloc.addend); |
| 1651 | const target_val: u64 = type: switch (reloc.type.target) { | 1654 | const target_val: u64 = type: switch (reloc.type.target) { |
| ... | @@ -1737,6 +1740,7 @@ const SymbolReloc = struct { | ... | @@ -1737,6 +1740,7 @@ const SymbolReloc = struct { |
| 1737 | } | 1740 | } |
| 1738 | | 1741 | |
| 1739 | reloc.* = undefined; | 1742 | reloc.* = undefined; |
| | 1743 | reloc.node = .none; |
| 1740 | } | 1744 | } |
| 1741 | | 1745 | |
| 1742 | /// If `reloc.rela_index` is populated, reset it to `.none` and delete the relocation, updating | 1746 | /// If `reloc.rela_index` is populated, reset it to `.none` and delete the relocation, updating |
| ... | @@ -1746,7 +1750,7 @@ const SymbolReloc = struct { | ... | @@ -1746,7 +1750,7 @@ const SymbolReloc = struct { |
| 1746 | reloc.relaSection(elf).relaDeleteOne(elf, rela_index); | 1750 | reloc.relaSection(elf).relaDeleteOne(elf, rela_index); |
| 1747 | switch (elf.ehdrType()) { | 1751 | switch (elf.ehdrType()) { |
| 1748 | .REL => {}, | 1752 | .REL => {}, |
| 1749 | .EXEC, .DYN => switch (elf.nodeWantsDsoRelocation(reloc.node)) { | 1753 | .EXEC, .DYN => switch (elf.nodeWantsDsoRelocation(reloc.node.unwrap().?)) { |
| 1750 | .no => unreachable, // there *was* a dynamic relocation! | 1754 | .no => unreachable, // there *was* a dynamic relocation! |
| 1751 | .yes => {}, | 1755 | .yes => {}, |
| 1752 | .yes_textrel => elf.textrel_count -= 1, | 1756 | .yes_textrel => elf.textrel_count -= 1, |
| ... | @@ -1760,7 +1764,7 @@ const SymbolReloc = struct { | ... | @@ -1760,7 +1764,7 @@ const SymbolReloc = struct { |
| 1760 | /// This represents a symbol reloc against the section symbol containing the node | 1764 | /// This represents a symbol reloc against the section symbol containing the node |
| 1761 | /// with a variable addend that changes when the target node moves. | 1765 | /// with a variable addend that changes when the target node moves. |
| 1762 | const NodeReloc = struct { | 1766 | const NodeReloc = struct { |
| 1763 | node: MappedFile.Node.Index, | 1767 | node: MappedFile.Node.Index.Optional, |
| 1764 | offset: u64, | 1768 | offset: u64, |
| 1765 | target: MappedFile.Node.Index, | 1769 | target: MappedFile.Node.Index, |
| 1766 | addend: i64, | 1770 | addend: i64, |
| ... | @@ -1786,7 +1790,7 @@ const NodeReloc = struct { | ... | @@ -1786,7 +1790,7 @@ const NodeReloc = struct { |
| 1786 | assert(elf.ehdrType() == .REL); | 1790 | assert(elf.ehdrType() == .REL); |
| 1787 | // The node has moved, so the offset of the relocation within the section might have | 1791 | // The node has moved, so the offset of the relocation within the section might have |
| 1788 | // changed, so update the `offset` field of the `ElfN.Rela` entry. | 1792 | // changed, so update the `offset` field of the `ElfN.Rela` entry. |
| 1789 | elf.getNodeShndx(reloc.node).get(elf).rela.shndx.relaSetOffset(elf, rela_index, node_vaddr + reloc.offset); | 1793 | elf.getNodeShndx(reloc.node.unwrap().?).get(elf).rela.shndx.relaSetOffset(elf, rela_index, node_vaddr + reloc.offset); |
| 1790 | } else { | 1794 | } else { |
| 1791 | assert(elf.ehdrType() != .REL); | 1795 | assert(elf.ehdrType() != .REL); |
| 1792 | reloc.apply(elf); | 1796 | reloc.apply(elf); |
| ... | @@ -1797,7 +1801,7 @@ const NodeReloc = struct { | ... | @@ -1797,7 +1801,7 @@ const NodeReloc = struct { |
| 1797 | if (reloc.rela_index.unwrap()) |rela_index| { | 1801 | if (reloc.rela_index.unwrap()) |rela_index| { |
| 1798 | assert(elf.ehdrType() == .REL); | 1802 | assert(elf.ehdrType() == .REL); |
| 1799 | // The target has moved, so the `addend` field of the `ElfN.Rela` entry needs to be updated. | 1803 | // The target has moved, so the `addend` field of the `ElfN.Rela` entry needs to be updated. |
| 1800 | elf.getNodeShndx(reloc.node).get(elf).rela.shndx.relaSetAddend(elf, rela_index, target_section_offset +% @as(u64, @bitCast(reloc.addend))); | 1804 | elf.getNodeShndx(reloc.node.unwrap().?).get(elf).rela.shndx.relaSetAddend(elf, rela_index, target_section_offset +% @as(u64, @bitCast(reloc.addend))); |
| 1801 | } else { | 1805 | } else { |
| 1802 | assert(elf.ehdrType() != .REL); | 1806 | assert(elf.ehdrType() != .REL); |
| 1803 | reloc.apply(elf); | 1807 | reloc.apply(elf); |
| ... | @@ -1805,12 +1809,13 @@ const NodeReloc = struct { | ... | @@ -1805,12 +1809,13 @@ const NodeReloc = struct { |
| 1805 | } | 1809 | } |
| 1806 | | 1810 | |
| 1807 | fn apply(reloc: *NodeReloc, elf: *Elf) void { | 1811 | fn apply(reloc: *NodeReloc, elf: *Elf) void { |
| | 1812 | const node = reloc.node.unwrap() orelse return; // deleted |
| 1808 | if (reloc.rela_index.unwrap()) |rela_index| { | 1813 | if (reloc.rela_index.unwrap()) |rela_index| { |
| 1809 | assert(elf.ehdrType() == .REL); | 1814 | assert(elf.ehdrType() == .REL); |
| 1810 | _ = rela_index; | 1815 | _ = rela_index; |
| 1811 | } else { | 1816 | } else { |
| 1812 | assert(elf.ehdrType() != .REL); | 1817 | assert(elf.ehdrType() != .REL); |
| 1813 | if (reloc.node.hasMoved(&elf.mf) or reloc.target.hasMoved(&elf.mf)) { | 1818 | if (node.hasMoved(&elf.mf) or reloc.target.hasMoved(&elf.mf)) { |
| 1814 | // There's no point applying the relocation now, because it will be re-applied by | 1819 | // There's no point applying the relocation now, because it will be re-applied by |
| 1815 | // `flushMoved` at some point anyway. | 1820 | // `flushMoved` at some point anyway. |
| 1816 | return; | 1821 | return; |
| ... | @@ -1842,7 +1847,7 @@ const NodeReloc = struct { | ... | @@ -1842,7 +1847,7 @@ const NodeReloc = struct { |
| 1842 | }, .cast = .unsigned, .shift = .@"0" }; | 1847 | }, .cast = .unsigned, .shift = .@"0" }; |
| 1843 | const addend: u64 = @bitCast(reloc.addend); | 1848 | const addend: u64 = @bitCast(reloc.addend); |
| 1844 | const target_val = elf.getNodeVAddr(reloc.target) +% addend; | 1849 | const target_val = elf.getNodeVAddr(reloc.target) +% addend; |
| 1845 | const dest_slice = reloc.node.slice(&elf.mf)[@intCast(reloc.offset)..]; | 1850 | const dest_slice = reloc.node.unwrap().?.slice(&elf.mf)[@intCast(reloc.offset)..]; |
| 1846 | try simple.write(target_val, dest_slice, elf.targetEndian()); | 1851 | try simple.write(target_val, dest_slice, elf.targetEndian()); |
| 1847 | } | 1852 | } |
| 1848 | | 1853 | |
| ... | @@ -1858,7 +1863,7 @@ const NodeReloc = struct { | ... | @@ -1858,7 +1863,7 @@ const NodeReloc = struct { |
| 1858 | .unit_debug_info_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_info_header_first_target_reloc, | 1863 | .unit_debug_info_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_info_header_first_target_reloc, |
| 1859 | .unit_debug_line_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_target_reloc, | 1864 | .unit_debug_line_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_target_reloc, |
| 1860 | .unit_debug_rnglists => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_rnglists_first_target_reloc, | 1865 | .unit_debug_rnglists => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_rnglists_first_target_reloc, |
| 1861 | .value_debug_info => |vi| &elf.dwarf_values.items[@backingInt(vi)].debug_info_first_target_reloc, | 1866 | .const_debug_info => |cpi| &elf.dwarf_consts.getPtr(cpi).?.debug_info_first_target_reloc, |
| 1862 | .global_debug_info => |gi| &elf.dwarf_globals.items[@backingInt(gi)].debug_info_first_target_reloc, | 1867 | .global_debug_info => |gi| &elf.dwarf_globals.items[@backingInt(gi)].debug_info_first_target_reloc, |
| 1863 | .func_debug_info => |fi| &elf.dwarf_funcs.items[@backingInt(fi)].debug_info_first_target_reloc, | 1868 | .func_debug_info => |fi| &elf.dwarf_funcs.items[@backingInt(fi)].debug_info_first_target_reloc, |
| 1864 | }; | 1869 | }; |
| ... | @@ -1877,13 +1882,14 @@ const NodeReloc = struct { | ... | @@ -1877,13 +1882,14 @@ const NodeReloc = struct { |
| 1877 | } | 1882 | } |
| 1878 | | 1883 | |
| 1879 | reloc.* = undefined; | 1884 | reloc.* = undefined; |
| | 1885 | reloc.node = .none; |
| 1880 | } | 1886 | } |
| 1881 | | 1887 | |
| 1882 | /// If `reloc.rela_index` is populated, reset it to `.none` and delete the relocation. | 1888 | /// If `reloc.rela_index` is populated, reset it to `.none` and delete the relocation. |
| 1883 | fn deleteOutputRel(reloc: *NodeReloc, elf: *Elf) void { | 1889 | fn deleteOutputRel(reloc: *NodeReloc, elf: *Elf) void { |
| 1884 | const rela_index = reloc.rela_index.unwrap() orelse return; | 1890 | const rela_index = reloc.rela_index.unwrap() orelse return; |
| 1885 | assert(elf.ehdrType() == .REL); | 1891 | assert(elf.ehdrType() == .REL); |
| 1886 | elf.getNodeShndx(reloc.node).get(elf).rela.shndx.relaDeleteOne(elf, rela_index); | 1892 | elf.getNodeShndx(reloc.node.unwrap().?).get(elf).rela.shndx.relaDeleteOne(elf, rela_index); |
| 1887 | reloc.rela_index = .none; | 1893 | reloc.rela_index = .none; |
| 1888 | } | 1894 | } |
| 1889 | }; | 1895 | }; |
| ... | @@ -3175,7 +3181,8 @@ const Symbol = struct { | ... | @@ -3175,7 +3181,8 @@ const Symbol = struct { |
| 3175 | .abs, .pltabs => {}, | 3181 | .abs, .pltabs => {}, |
| 3176 | } | 3182 | } |
| 3177 | if (!reloc.type.action.simple.dest.isAddr(elf)) continue; | 3183 | if (!reloc.type.action.simple.dest.isAddr(elf)) continue; |
| 3178 | switch (elf.nodeWantsDsoRelocation(reloc.node)) { | 3184 | const node = reloc.node.unwrap().?; |
| | 3185 | switch (elf.nodeWantsDsoRelocation(node)) { |
| 3179 | .no => continue, | 3186 | .no => continue, |
| 3180 | .yes_textrel => elf.textrel_count += 1, | 3187 | .yes_textrel => elf.textrel_count += 1, |
| 3181 | .yes => {}, | 3188 | .yes => {}, |
| ... | @@ -3183,7 +3190,7 @@ const Symbol = struct { | ... | @@ -3183,7 +3190,7 @@ const Symbol = struct { |
| 3183 | // There is capacity for a relocation because we just deleted one earlier. | 3190 | // There is capacity for a relocation because we just deleted one earlier. |
| 3184 | reloc.rela_index = elf.shndx.rela_dyn.relaAddOneAssumeCapacity(elf, .{ | 3191 | reloc.rela_index = elf.shndx.rela_dyn.relaAddOneAssumeCapacity(elf, .{ |
| 3185 | .type = .relative(elf), | 3192 | .type = .relative(elf), |
| 3186 | .offset = elf.getNodeVAddr(reloc.node) + reloc.offset, | 3193 | .offset = elf.getNodeVAddr(node) + reloc.offset, |
| 3187 | .raw_sym_index = 0, | 3194 | .raw_sym_index = 0, |
| 3188 | .addend = 0, | 3195 | .addend = 0, |
| 3189 | }).toOptional(); | 3196 | }).toOptional(); |
| ... | @@ -3310,7 +3317,7 @@ pub fn symbolForAtom(elf: *Elf, atom: link.File.AtomId) link.File.SymbolId { | ... | @@ -3310,7 +3317,7 @@ pub fn symbolForAtom(elf: *Elf, atom: link.File.AtomId) link.File.SymbolId { |
| 3310 | .unit_debug_line, | 3317 | .unit_debug_line, |
| 3311 | .unit_debug_line_header, | 3318 | .unit_debug_line_header, |
| 3312 | .unit_debug_rnglists, | 3319 | .unit_debug_rnglists, |
| 3313 | .value_debug_info, | 3320 | .const_debug_info, |
| 3314 | .global_debug_info, | 3321 | .global_debug_info, |
| 3315 | .func_frame_fde, | 3322 | .func_frame_fde, |
| 3316 | .func_debug_info, | 3323 | .func_debug_info, |
| ... | @@ -3823,7 +3830,7 @@ fn create( | ... | @@ -3823,7 +3830,7 @@ fn create( |
| 3823 | .first_target_reloc = .none, | 3830 | .first_target_reloc = .none, |
| 3824 | }), | 3831 | }), |
| 3825 | .dwarf_units = .empty, | 3832 | .dwarf_units = .empty, |
| 3826 | .dwarf_values = .empty, | 3833 | .dwarf_consts = .empty, |
| 3827 | .dwarf_globals = .empty, | 3834 | .dwarf_globals = .empty, |
| 3828 | .dwarf_funcs = .empty, | 3835 | .dwarf_funcs = .empty, |
| 3829 | | 3836 | |
| ... | @@ -3878,7 +3885,7 @@ pub fn deinit(elf: *Elf) void { | ... | @@ -3878,7 +3885,7 @@ pub fn deinit(elf: *Elf) void { |
| 3878 | elf.dwarf.deinit(); | 3885 | elf.dwarf.deinit(); |
| 3879 | for (elf.dwarf_units.items) |*dwarf_unit| dwarf_unit.debug_rnglists_symbol_relocs.deinit(gpa); | 3886 | for (elf.dwarf_units.items) |*dwarf_unit| dwarf_unit.debug_rnglists_symbol_relocs.deinit(gpa); |
| 3880 | elf.dwarf_units.deinit(gpa); | 3887 | elf.dwarf_units.deinit(gpa); |
| 3881 | elf.dwarf_values.deinit(gpa); | 3888 | elf.dwarf_consts.deinit(gpa); |
| 3882 | elf.dwarf_globals.deinit(gpa); | 3889 | elf.dwarf_globals.deinit(gpa); |
| 3883 | elf.dwarf_funcs.deinit(gpa); | 3890 | elf.dwarf_funcs.deinit(gpa); |
| 3884 | | 3891 | |
| ... | @@ -5176,7 +5183,7 @@ fn getNodeShndx(elf: *const Elf, ni: MappedFile.Node.Index) Section.Index { | ... | @@ -5176,7 +5183,7 @@ fn getNodeShndx(elf: *const Elf, ni: MappedFile.Node.Index) Section.Index { |
| 5176 | .unit_frame_cie, | 5183 | .unit_frame_cie, |
| 5177 | .unit_debug_info_header, | 5184 | .unit_debug_info_header, |
| 5178 | .unit_debug_line_header, | 5185 | .unit_debug_line_header, |
| 5179 | .value_debug_info, | 5186 | .const_debug_info, |
| 5180 | .global_debug_info, | 5187 | .global_debug_info, |
| 5181 | .func_frame_fde, | 5188 | .func_frame_fde, |
| 5182 | .func_debug_info, | 5189 | .func_debug_info, |
| ... | @@ -5213,7 +5220,7 @@ fn getNodeVAddr(elf: *Elf, ni: MappedFile.Node.Index) u64 { | ... | @@ -5213,7 +5220,7 @@ fn getNodeVAddr(elf: *Elf, ni: MappedFile.Node.Index) u64 { |
| 5213 | .unit_debug_line, | 5220 | .unit_debug_line, |
| 5214 | .unit_debug_line_header, | 5221 | .unit_debug_line_header, |
| 5215 | .unit_debug_rnglists, | 5222 | .unit_debug_rnglists, |
| 5216 | .value_debug_info, | 5223 | .const_debug_info, |
| 5217 | .global_debug_info, | 5224 | .global_debug_info, |
| 5218 | .func_frame_fde, | 5225 | .func_frame_fde, |
| 5219 | .func_debug_info, | 5226 | .func_debug_info, |
| ... | @@ -5252,7 +5259,7 @@ fn computeNodeVAddr(elf: *Elf, ni: MappedFile.Node.Index) u64 { | ... | @@ -5252,7 +5259,7 @@ fn computeNodeVAddr(elf: *Elf, ni: MappedFile.Node.Index) u64 { |
| 5252 | .unit_debug_info_header, | 5259 | .unit_debug_info_header, |
| 5253 | .unit_debug_line_header, | 5260 | .unit_debug_line_header, |
| 5254 | .unit_debug_rnglists, | 5261 | .unit_debug_rnglists, |
| 5255 | .value_debug_info, | 5262 | .const_debug_info, |
| 5256 | .global_debug_info, | 5263 | .global_debug_info, |
| 5257 | .func_frame_fde, | 5264 | .func_frame_fde, |
| 5258 | .func_debug_info, | 5265 | .func_debug_info, |
| ... | @@ -5287,7 +5294,7 @@ fn computeNodeSectionOffset(elf: *Elf, ni: MappedFile.Node.Index) u64 { | ... | @@ -5287,7 +5294,7 @@ fn computeNodeSectionOffset(elf: *Elf, ni: MappedFile.Node.Index) u64 { |
| 5287 | .unit_debug_info_header, | 5294 | .unit_debug_info_header, |
| 5288 | .unit_debug_line_header, | 5295 | .unit_debug_line_header, |
| 5289 | .unit_debug_rnglists, | 5296 | .unit_debug_rnglists, |
| 5290 | .value_debug_info, | 5297 | .const_debug_info, |
| 5291 | .global_debug_info, | 5298 | .global_debug_info, |
| 5292 | .func_frame_fde, | 5299 | .func_frame_fde, |
| 5293 | .func_debug_info, | 5300 | .func_debug_info, |
| ... | @@ -5356,9 +5363,9 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { | ... | @@ -5356,9 +5363,9 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { |
| 5356 | .first_node_reloc = &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_node_reloc, | 5363 | .first_node_reloc = &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_node_reloc, |
| 5357 | }, | 5364 | }, |
| 5358 | .unit_debug_rnglists => unreachable, // unsupported | 5365 | .unit_debug_rnglists => unreachable, // unsupported |
| 5359 | .value_debug_info => |vi| .{ | 5366 | .const_debug_info => |cpi| .{ |
| 5360 | .first_symbol_reloc = &elf.dwarf_values.items[@backingInt(vi)].debug_info_first_symbol_reloc, | 5367 | .first_symbol_reloc = &elf.dwarf_consts.getPtr(cpi).?.debug_info_first_symbol_reloc, |
| 5361 | .first_node_reloc = &elf.dwarf_values.items[@backingInt(vi)].debug_info_first_node_reloc, | 5368 | .first_node_reloc = &elf.dwarf_consts.getPtr(cpi).?.debug_info_first_node_reloc, |
| 5362 | }, | 5369 | }, |
| 5363 | .global_debug_info => |gi| .{ | 5370 | .global_debug_info => |gi| .{ |
| 5364 | .first_symbol_reloc = &elf.dwarf_globals.items[@backingInt(gi)].debug_info_first_symbol_reloc, | 5371 | .first_symbol_reloc = &elf.dwarf_globals.items[@backingInt(gi)].debug_info_first_symbol_reloc, |
| ... | @@ -5387,8 +5394,11 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { | ... | @@ -5387,8 +5394,11 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { |
| 5387 | if (opts.first_symbol_reloc) |ptr| { | 5394 | if (opts.first_symbol_reloc) |ptr| { |
| 5388 | if (ptr.* != .none) { | 5395 | if (ptr.* != .none) { |
| 5389 | for (elf.symbol_relocs.items[@backingInt(ptr.*)..], @backingInt(ptr.*)..) |*reloc, index| { | 5396 | for (elf.symbol_relocs.items[@backingInt(ptr.*)..], @backingInt(ptr.*)..) |*reloc, index| { |
| 5390 | if (reloc.node.toOptional() == opts.skip_symbol_relocs) continue; | 5397 | if (reloc.node != ni.toOptional()) { |
| 5391 | if (reloc.node != ni) break; | 5398 | if (reloc.node == .none) continue; |
| | 5399 | if (reloc.node == opts.skip_symbol_relocs) continue; |
| | 5400 | break; |
| | 5401 | } |
| 5392 | reloc.delete(elf, @fromBackingInt(@intCast(index))); | 5402 | reloc.delete(elf, @fromBackingInt(@intCast(index))); |
| 5393 | } | 5403 | } |
| 5394 | } | 5404 | } |
| ... | @@ -5398,8 +5408,11 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { | ... | @@ -5398,8 +5408,11 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { |
| 5398 | if (opts.first_node_reloc) |ptr| { | 5408 | if (opts.first_node_reloc) |ptr| { |
| 5399 | if (ptr.* != .none) { | 5409 | if (ptr.* != .none) { |
| 5400 | for (elf.node_relocs.items[@backingInt(ptr.*)..]) |*reloc| { | 5410 | for (elf.node_relocs.items[@backingInt(ptr.*)..]) |*reloc| { |
| 5401 | if (reloc.node.toOptional() == opts.skip_node_relocs) continue; | 5411 | if (reloc.node != ni.toOptional()) { |
| 5402 | if (reloc.node != ni) break; | 5412 | if (reloc.node == .none) continue; |
| | 5413 | if (reloc.node == opts.skip_node_relocs) continue; |
| | 5414 | break; |
| | 5415 | } |
| 5403 | reloc.delete(elf); | 5416 | reloc.delete(elf); |
| 5404 | } | 5417 | } |
| 5405 | } | 5418 | } |
| ... | @@ -5409,7 +5422,10 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { | ... | @@ -5409,7 +5422,10 @@ fn resetNodeRelocs(elf: *Elf, ni: MappedFile.Node.Index) void { |
| 5409 | if (opts.first_got_reloc) |ptr| { | 5422 | if (opts.first_got_reloc) |ptr| { |
| 5410 | if (ptr.* != .none) { | 5423 | if (ptr.* != .none) { |
| 5411 | for (elf.got_relocs.items[@backingInt(ptr.*)..]) |*reloc| { | 5424 | for (elf.got_relocs.items[@backingInt(ptr.*)..]) |*reloc| { |
| 5412 | if (reloc.node != ni.toOptional()) break; | 5425 | if (reloc.node != ni.toOptional()) { |
| | 5426 | if (reloc.node == .none) continue; |
| | 5427 | break; |
| | 5428 | } |
| 5413 | reloc.delete(elf); | 5429 | reloc.delete(elf); |
| 5414 | } | 5430 | } |
| 5415 | } | 5431 | } |
| ... | @@ -5433,23 +5449,32 @@ fn flushMovedNodeRelocs( | ... | @@ -5433,23 +5449,32 @@ fn flushMovedNodeRelocs( |
| 5433 | ) void { | 5449 | ) void { |
| 5434 | if (opts.first_symbol_reloc != .none) { | 5450 | if (opts.first_symbol_reloc != .none) { |
| 5435 | for (elf.symbol_relocs.items[@backingInt(opts.first_symbol_reloc)..]) |*reloc| { | 5451 | for (elf.symbol_relocs.items[@backingInt(opts.first_symbol_reloc)..]) |*reloc| { |
| 5436 | if (reloc.node.toOptional() == opts.skip_symbol_relocs) continue; | 5452 | if (reloc.node != node.toOptional()) { |
| 5437 | if (reloc.node != node) break; | 5453 | if (reloc.node == .none) continue; |
| | 5454 | if (reloc.node == opts.skip_symbol_relocs) continue; |
| | 5455 | break; |
| | 5456 | } |
| 5438 | reloc.flushMovedNode(elf, node_vaddr); | 5457 | reloc.flushMovedNode(elf, node_vaddr); |
| 5439 | } | 5458 | } |
| 5440 | } | 5459 | } |
| 5441 | | 5460 | |
| 5442 | if (opts.first_node_reloc != .none) { | 5461 | if (opts.first_node_reloc != .none) { |
| 5443 | for (elf.node_relocs.items[@backingInt(opts.first_node_reloc)..]) |*reloc| { | 5462 | for (elf.node_relocs.items[@backingInt(opts.first_node_reloc)..]) |*reloc| { |
| 5444 | if (reloc.node.toOptional() == opts.skip_node_relocs) continue; | 5463 | if (reloc.node != node.toOptional()) { |
| 5445 | if (reloc.node != node) break; | 5464 | if (reloc.node == .none) continue; |
| | 5465 | if (reloc.node == opts.skip_node_relocs) continue; |
| | 5466 | break; |
| | 5467 | } |
| 5446 | reloc.flushMovedNode(elf, node_vaddr); | 5468 | reloc.flushMovedNode(elf, node_vaddr); |
| 5447 | } | 5469 | } |
| 5448 | } | 5470 | } |
| 5449 | | 5471 | |
| 5450 | if (opts.first_got_reloc != .none) { | 5472 | if (opts.first_got_reloc != .none) { |
| 5451 | for (elf.got_relocs.items[@backingInt(opts.first_got_reloc)..]) |*reloc| { | 5473 | for (elf.got_relocs.items[@backingInt(opts.first_got_reloc)..]) |*reloc| { |
| 5452 | if (reloc.node != node.toOptional()) break; | 5474 | if (reloc.node != node.toOptional()) { |
| | 5475 | if (reloc.node == .none) continue; |
| | 5476 | break; |
| | 5477 | } |
| 5453 | reloc.apply(elf); | 5478 | reloc.apply(elf); |
| 5454 | } | 5479 | } |
| 5455 | } | 5480 | } |
| ... | @@ -7277,7 +7302,7 @@ fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void { | ... | @@ -7277,7 +7302,7 @@ fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void { |
| 7277 | | 7302 | |
| 7278 | fn flushFiles(elf: *Elf) Error!void { | 7303 | fn flushFiles(elf: *Elf) Error!void { |
| 7279 | const gpa = elf.base.comp.gpa; | 7304 | const gpa = elf.base.comp.gpa; |
| 7280 | if (elf.shndx.debug_line != .UNDEF) for (elf.dwarf.units.keys(), elf.dwarf.units.values()) |mod, *unit| { | 7305 | if (elf.shndx.debug_line != .UNDEF) for (elf.dwarf.units.values()) |*unit| { |
| 7281 | if (!unit.cleanDebugLineHeaderChanged()) continue; | 7306 | if (!unit.cleanDebugLineHeaderChanged()) continue; |
| 7282 | const debug_line_header_ni = unit.debug_line_header_ni.unwrap().?; | 7307 | const debug_line_header_ni = unit.debug_line_header_ni.unwrap().?; |
| 7283 | try debug_line_header_ni.parent(&elf.mf).unwrap().?.nextMoved(gpa, &elf.mf); | 7308 | try debug_line_header_ni.parent(&elf.mf).unwrap().?.nextMoved(gpa, &elf.mf); |
| ... | @@ -7287,7 +7312,7 @@ fn flushFiles(elf: *Elf) Error!void { | ... | @@ -7287,7 +7312,7 @@ fn flushFiles(elf: *Elf) Error!void { |
| 7287 | debug_line_header_ni.writer(gpa, &elf.mf, &dlh_nw); | 7312 | debug_line_header_ni.writer(gpa, &elf.mf, &dlh_nw); |
| 7288 | defer dlh_nw.deinit(); | 7313 | defer dlh_nw.deinit(); |
| 7289 | elf.resetNodeRelocs(debug_line_header_ni); | 7314 | elf.resetNodeRelocs(debug_line_header_ni); |
| 7290 | elf.dwarf.genDebugLineHeader(mod, unit, &dlh_nw, elf.base.comp.zcu.?) catch |err| switch (err) { | 7315 | elf.dwarf.genDebugLineHeader(unit, &dlh_nw, elf.base.comp.zcu.?) catch |err| switch (err) { |
| 7291 | else => |e| return e, | 7316 | else => |e| return e, |
| 7292 | error.WriteFailed => return dlh_nw.err.?, | 7317 | error.WriteFailed => return dlh_nw.err.?, |
| 7293 | }; | 7318 | }; |
| ... | @@ -7629,7 +7654,7 @@ fn addRelocAssumeCapacity( | ... | @@ -7629,7 +7654,7 @@ fn addRelocAssumeCapacity( |
| 7629 | first_target_reloc.* = ri; | 7654 | first_target_reloc.* = ri; |
| 7630 | if (next != .none) next.get(elf).prev = ri; | 7655 | if (next != .none) next.get(elf).prev = ri; |
| 7631 | elf.symbol_relocs.appendAssumeCapacity(.{ | 7656 | elf.symbol_relocs.appendAssumeCapacity(.{ |
| 7632 | .node = node, | 7657 | .node = node.toOptional(), |
| 7633 | .offset = offset, | 7658 | .offset = offset, |
| 7634 | .type = undefined, | 7659 | .type = undefined, |
| 7635 | .target = target, | 7660 | .target = target, |
| ... | @@ -8067,7 +8092,7 @@ fn addSymbolRelocAssumeCapacity( | ... | @@ -8067,7 +8092,7 @@ fn addSymbolRelocAssumeCapacity( |
| 8067 | first_target_reloc.* = ri; | 8092 | first_target_reloc.* = ri; |
| 8068 | if (next != .none) next.get(elf).prev = ri; | 8093 | if (next != .none) next.get(elf).prev = ri; |
| 8069 | elf.symbol_relocs.appendAssumeCapacity(.{ | 8094 | elf.symbol_relocs.appendAssumeCapacity(.{ |
| 8070 | .node = node, | 8095 | .node = node.toOptional(), |
| 8071 | .offset = offset, | 8096 | .offset = offset, |
| 8072 | .target = target, | 8097 | .target = target, |
| 8073 | .addend = addend, | 8098 | .addend = addend, |
| ... | @@ -8101,7 +8126,7 @@ fn addNodeRelocAssumeCapacity( | ... | @@ -8101,7 +8126,7 @@ fn addNodeRelocAssumeCapacity( |
| 8101 | .unit_debug_info_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_info_header_first_target_reloc, | 8126 | .unit_debug_info_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_info_header_first_target_reloc, |
| 8102 | .unit_debug_line_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_target_reloc, | 8127 | .unit_debug_line_header => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_line_header_first_target_reloc, |
| 8103 | .unit_debug_rnglists => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_rnglists_first_target_reloc, | 8128 | .unit_debug_rnglists => |ui| &elf.dwarf_units.items[@backingInt(ui)].debug_rnglists_first_target_reloc, |
| 8104 | .value_debug_info => |vi| &elf.dwarf_values.items[@backingInt(vi)].debug_info_first_target_reloc, | 8129 | .const_debug_info => |cpi| &elf.dwarf_consts.getPtr(cpi).?.debug_info_first_target_reloc, |
| 8105 | .global_debug_info => |gi| &elf.dwarf_globals.items[@backingInt(gi)].debug_info_first_target_reloc, | 8130 | .global_debug_info => |gi| &elf.dwarf_globals.items[@backingInt(gi)].debug_info_first_target_reloc, |
| 8106 | .func_debug_info => |fi| &elf.dwarf_funcs.items[@backingInt(fi)].debug_info_first_target_reloc, | 8131 | .func_debug_info => |fi| &elf.dwarf_funcs.items[@backingInt(fi)].debug_info_first_target_reloc, |
| 8107 | }; | 8132 | }; |
| ... | @@ -8151,7 +8176,7 @@ fn addNodeRelocAssumeCapacity( | ... | @@ -8151,7 +8176,7 @@ fn addNodeRelocAssumeCapacity( |
| 8151 | .addend = 0, | 8176 | .addend = 0, |
| 8152 | }); | 8177 | }); |
| 8153 | elf.node_relocs.appendAssumeCapacity(.{ | 8178 | elf.node_relocs.appendAssumeCapacity(.{ |
| 8154 | .node = node, | 8179 | .node = node.toOptional(), |
| 8155 | .offset = offset, | 8180 | .offset = offset, |
| 8156 | .type = undefined, | 8181 | .type = undefined, |
| 8157 | .target = target, | 8182 | .target = target, |
| ... | @@ -8164,7 +8189,7 @@ fn addNodeRelocAssumeCapacity( | ... | @@ -8164,7 +8189,7 @@ fn addNodeRelocAssumeCapacity( |
| 8164 | }, | 8189 | }, |
| 8165 | .DYN, .EXEC => { | 8190 | .DYN, .EXEC => { |
| 8166 | elf.node_relocs.appendAssumeCapacity(.{ | 8191 | elf.node_relocs.appendAssumeCapacity(.{ |
| 8167 | .node = node, | 8192 | .node = node.toOptional(), |
| 8168 | .offset = offset, | 8193 | .offset = offset, |
| 8169 | .target = target, | 8194 | .target = target, |
| 8170 | .addend = addend, | 8195 | .addend = addend, |
| ... | @@ -8209,7 +8234,7 @@ fn addGotRelocAssumeCapacity( | ... | @@ -8209,7 +8234,7 @@ fn addGotRelocAssumeCapacity( |
| 8209 | .unit_debug_line, | 8234 | .unit_debug_line, |
| 8210 | .unit_debug_line_header, | 8235 | .unit_debug_line_header, |
| 8211 | .unit_debug_rnglists, | 8236 | .unit_debug_rnglists, |
| 8212 | .value_debug_info, | 8237 | .const_debug_info, |
| 8213 | .global_debug_info, | 8238 | .global_debug_info, |
| 8214 | .func_frame_fde, | 8239 | .func_frame_fde, |
| 8215 | .func_debug_info, | 8240 | .func_debug_info, |
| ... | @@ -8502,7 +8527,8 @@ fn updateNavInner(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) | ... | @@ -8502,7 +8527,8 @@ fn updateNavInner(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) |
| 8502 | | 8527 | |
| 8503 | const nav = ip.getNav(nav_index); | 8528 | const nav = ip.getNav(nav_index); |
| 8504 | if (ip.indexToKey(nav.resolved.?.value) == .@"extern") return; | 8529 | if (ip.indexToKey(nav.resolved.?.value) == .@"extern") return; |
| 8505 | if (!Type.fromInterned(nav.resolved.?.type).hasRuntimeBits(zcu)) return; | 8530 | if (!Type.fromInterned(nav.resolved.?.type).hasRuntimeBits(zcu)) |
| | 8531 | return elf.dwarf.updateComptimeNav(pt, nav_index); |
| 8506 | | 8532 | |
| 8507 | const nmi = try elf.navMapIndex(zcu, nav_index); | 8533 | const nmi = try elf.navMapIndex(zcu, nav_index); |
| 8508 | const ni = nmi.symbol(elf).index().ptr(elf).node.unwrap().?; | 8534 | const ni = nmi.symbol(elf).index().ptr(elf).node.unwrap().?; |
| ... | @@ -8546,11 +8572,11 @@ pub fn updateContainerType( | ... | @@ -8546,11 +8572,11 @@ pub fn updateContainerType( |
| 8546 | | 8572 | |
| 8547 | pub fn addConst( | 8573 | pub fn addConst( |
| 8548 | elf: *Elf, | 8574 | elf: *Elf, |
| 8549 | pt: Zcu.PerThread, | 8575 | _: Zcu.PerThread, |
| 8550 | index: link.ConstPool.Index, | 8576 | index: link.ConstPool.Index, |
| 8551 | val: InternPool.Index, | 8577 | val: InternPool.Index, |
| 8552 | ) std.mem.Allocator.Error!void { | 8578 | ) link.Error!void { |
| 8553 | if (false) try elf.dwarf.addConst(pt, index, val); | 8579 | try elf.dwarf.addConst(index, val); |
| 8554 | } | 8580 | } |
| 8555 | | 8581 | |
| 8556 | pub fn updateConst( | 8582 | pub fn updateConst( |
| ... | @@ -8570,7 +8596,7 @@ fn updateConstInner( | ... | @@ -8570,7 +8596,7 @@ fn updateConstInner( |
| 8570 | ) link.Error!void { | 8596 | ) link.Error!void { |
| 8571 | var lazy_it = elf.lazy.iterator(); | 8597 | var lazy_it = elf.lazy.iterator(); |
| 8572 | while (lazy_it.next()) |lazy| if (lazy.value.getIndex(cpi)) |li| { | 8598 | while (lazy_it.next()) |lazy| if (lazy.value.getIndex(cpi)) |li| { |
| 8573 | const lazy_ty: Type = .fromInterned(cpi.val(&elf.dwarf.const_pool)); | 8599 | const lazy_ty: Type = .fromInterned(val); |
| 8574 | var prog_name_buf: [std.Progress.Node.max_name_len]u8 = undefined; | 8600 | var prog_name_buf: [std.Progress.Node.max_name_len]u8 = undefined; |
| 8575 | const prog_name: []const u8 = switch (lazy_ty.zigTypeTag(pt.zcu)) { | 8601 | const prog_name: []const u8 = switch (lazy_ty.zigTypeTag(pt.zcu)) { |
| 8576 | .@"enum" => std.mem.print(&prog_name_buf, "@tagName({f})", .{lazy_ty.fmt(pt)}) catch &prog_name_buf, | 8602 | .@"enum" => std.mem.print(&prog_name_buf, "@tagName({f})", .{lazy_ty.fmt(pt)}) catch &prog_name_buf, |
| ... | @@ -8590,16 +8616,20 @@ fn updateConstInner( | ... | @@ -8590,16 +8616,20 @@ fn updateConstInner( |
| 8590 | ), | 8616 | ), |
| 8591 | }; | 8617 | }; |
| 8592 | }; | 8618 | }; |
| 8593 | if (false) try elf.dwarf.updateConst(pt, cpi, val); | 8619 | elf.dwarf.updateConst(cpi, val); |
| 8594 | } | 8620 | } |
| 8595 | | 8621 | |
| 8596 | pub fn updateConstIncomplete( | 8622 | pub fn updateConstIncomplete( |
| 8597 | elf: *Elf, | 8623 | elf: *Elf, |
| 8598 | pt: Zcu.PerThread, | 8624 | _: Zcu.PerThread, |
| 8599 | cpi: link.ConstPool.Index, | 8625 | cpi: link.ConstPool.Index, |
| 8600 | val: InternPool.Index, | 8626 | val: InternPool.Index, |
| 8601 | ) link.Error!void { | 8627 | ) link.Error!void { |
| 8602 | if (false) try elf.dwarf.updateConstIncomplete(pt, cpi, val); | 8628 | const debug_info_ni = Dwarf.Const.get(cpi, &elf.dwarf).debug_info_ni.unwrap().?; |
| | 8629 | var di_nw: MappedFile.Node.Writer = undefined; |
| | 8630 | debug_info_ni.writer(elf.base.comp.gpa, &elf.mf, &di_nw); |
| | 8631 | defer di_nw.deinit(); |
| | 8632 | try elf.dwarf.updateConstIncomplete(&di_nw, val); |
| 8603 | } | 8633 | } |
| 8604 | | 8634 | |
| 8605 | pub fn updateFunc( | 8635 | pub fn updateFunc( |
| ... | @@ -8770,7 +8800,7 @@ fn updateFuncInner( | ... | @@ -8770,7 +8800,7 @@ fn updateFuncInner( |
| 8770 | elf.resetNodeRelocs(dwarf_func.debug_line_ni.unwrap().?); | 8800 | elf.resetNodeRelocs(dwarf_func.debug_line_ni.unwrap().?); |
| 8771 | try debug.startDebugLine(); | 8801 | try debug.startDebugLine(); |
| 8772 | elf.resetNodeRelocs(dwarf_func.debug_info_ni.unwrap().?); | 8802 | elf.resetNodeRelocs(dwarf_func.debug_info_ni.unwrap().?); |
| 8773 | try debug.startDebugInfo(); | 8803 | try debug.startFuncDebugInfo(); |
| 8774 | }, | 8804 | }, |
| 8775 | .none => {}, | 8805 | .none => {}, |
| 8776 | } | 8806 | } |
| ... | @@ -9187,7 +9217,7 @@ fn idleProgNode( | ... | @@ -9187,7 +9217,7 @@ fn idleProgNode( |
| 9187 | }, | 9217 | }, |
| 9188 | ui.mod(&elf.dwarf).fully_qualified_name, | 9218 | ui.mod(&elf.dwarf).fully_qualified_name, |
| 9189 | }) catch &name, | 9219 | }) catch &name, |
| 9190 | .value_debug_info => |cpi| std.mem.print(&name, "debug info for {f}", .{ | 9220 | .const_debug_info => |cpi| std.mem.print(&name, "debug info for {f}", .{ |
| 9191 | Value.fromInterned(cpi.val(&elf.dwarf.const_pool)) | 9221 | Value.fromInterned(cpi.val(&elf.dwarf.const_pool)) |
| 9192 | .fmtValue(.{ .zcu = elf.base.comp.zcu.?, .tid = tid }), | 9222 | .fmtValue(.{ .zcu = elf.base.comp.zcu.?, .tid = tid }), |
| 9193 | }) catch &name, | 9223 | }) catch &name, |
| ... | @@ -9648,14 +9678,14 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void | ... | @@ -9648,14 +9678,14 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void |
| 9648 | const node_vaddr = elf.computeNodeVAddr(ni); | 9678 | const node_vaddr = elf.computeNodeVAddr(ni); |
| 9649 | for (dwarf_unit.debug_rnglists_symbol_relocs.keys()) |symbol_ri| { | 9679 | for (dwarf_unit.debug_rnglists_symbol_relocs.keys()) |symbol_ri| { |
| 9650 | const symbol_reloc = symbol_ri.get(elf); | 9680 | const symbol_reloc = symbol_ri.get(elf); |
| 9651 | assert(symbol_reloc.node == ni); | 9681 | assert(symbol_reloc.node.unwrap().? == ni); |
| 9652 | symbol_reloc.flushMovedNode(elf, node_vaddr); | 9682 | symbol_reloc.flushMovedNode(elf, node_vaddr); |
| 9653 | } | 9683 | } |
| 9654 | }, | 9684 | }, |
| 9655 | .value_debug_info => |vi| { | 9685 | .const_debug_info => |cpi| { |
| 9656 | const dwarf_value = &elf.dwarf_values.items[@backingInt(vi)]; | 9686 | const dwarf_const = &elf.dwarf_consts.get(cpi).?; |
| 9657 | const target_section_offset = elf.computeNodeSectionOffset(ni); | 9687 | const target_section_offset = elf.computeNodeSectionOffset(ni); |
| 9658 | var target_ri = dwarf_value.debug_info_first_target_reloc; | 9688 | var target_ri = dwarf_const.debug_info_first_target_reloc; |
| 9659 | while (target_ri != .none) { | 9689 | while (target_ri != .none) { |
| 9660 | const target_reloc = target_ri.get(elf); | 9690 | const target_reloc = target_ri.get(elf); |
| 9661 | assert(target_reloc.target == ni); | 9691 | assert(target_reloc.target == ni); |
| ... | @@ -9663,12 +9693,12 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void | ... | @@ -9663,12 +9693,12 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void |
| 9663 | target_ri = target_reloc.next; | 9693 | target_ri = target_reloc.next; |
| 9664 | } | 9694 | } |
| 9665 | elf.flushMovedNodeRelocs(ni, elf.computeNodeVAddr(ni), .{ | 9695 | elf.flushMovedNodeRelocs(ni, elf.computeNodeVAddr(ni), .{ |
| 9666 | .first_symbol_reloc = dwarf_value.debug_info_first_symbol_reloc, | 9696 | .first_symbol_reloc = dwarf_const.debug_info_first_symbol_reloc, |
| 9667 | .first_node_reloc = dwarf_value.debug_info_first_node_reloc, | 9697 | .first_node_reloc = dwarf_const.debug_info_first_node_reloc, |
| 9668 | }); | 9698 | }); |
| 9669 | }, | 9699 | }, |
| 9670 | .global_debug_info => |vi| { | 9700 | .global_debug_info => |gi| { |
| 9671 | const dwarf_global = &elf.dwarf_globals.items[@backingInt(vi)]; | 9701 | const dwarf_global = &elf.dwarf_globals.items[@backingInt(gi)]; |
| 9672 | const target_section_offset = elf.computeNodeSectionOffset(ni); | 9702 | const target_section_offset = elf.computeNodeSectionOffset(ni); |
| 9673 | var target_ri = dwarf_global.debug_info_first_target_reloc; | 9703 | var target_ri = dwarf_global.debug_info_first_target_reloc; |
| 9674 | while (target_ri != .none) { | 9704 | while (target_ri != .none) { |
| ... | @@ -9972,7 +10002,7 @@ fn flushResized(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo | ... | @@ -9972,7 +10002,7 @@ fn flushResized(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!vo |
| 9972 | .unit_debug_line, | 10002 | .unit_debug_line, |
| 9973 | .unit_debug_line_header, | 10003 | .unit_debug_line_header, |
| 9974 | .unit_debug_rnglists, | 10004 | .unit_debug_rnglists, |
| 9975 | .value_debug_info, | 10005 | .const_debug_info, |
| 9976 | .global_debug_info, | 10006 | .global_debug_info, |
| 9977 | .func_frame_fde, | 10007 | .func_frame_fde, |
| 9978 | .func_debug_info, | 10008 | .func_debug_info, |
| ... | @@ -10036,7 +10066,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! | ... | @@ -10036,7 +10066,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! |
| 10036 | .unit_debug_info_header, | 10066 | .unit_debug_info_header, |
| 10037 | .unit_debug_line_header, | 10067 | .unit_debug_line_header, |
| 10038 | .unit_debug_rnglists, | 10068 | .unit_debug_rnglists, |
| 10039 | .value_debug_info, | 10069 | .const_debug_info, |
| 10040 | .global_debug_info, | 10070 | .global_debug_info, |
| 10041 | .func_frame_fde, | 10071 | .func_frame_fde, |
| 10042 | .func_debug_info, | 10072 | .func_debug_info, |
| ... | @@ -10089,7 +10119,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! | ... | @@ -10089,7 +10119,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! |
| 10089 | }, | 10119 | }, |
| 10090 | .unit_debug_info_header, | 10120 | .unit_debug_info_header, |
| 10091 | .unit_debug_line_header, | 10121 | .unit_debug_line_header, |
| 10092 | .value_debug_info, | 10122 | .const_debug_info, |
| 10093 | .global_debug_info, | 10123 | .global_debug_info, |
| 10094 | .func_debug_info, | 10124 | .func_debug_info, |
| 10095 | .func_debug_line, | 10125 | .func_debug_line, |
| ... | @@ -10105,7 +10135,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! | ... | @@ -10105,7 +10135,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! |
| 10105 | switch (tag) { | 10135 | switch (tag) { |
| 10106 | else => unreachable, | 10136 | else => unreachable, |
| 10107 | .unit_debug_info_header, | 10137 | .unit_debug_info_header, |
| 10108 | .value_debug_info, | 10138 | .const_debug_info, |
| 10109 | .global_debug_info, | 10139 | .global_debug_info, |
| 10110 | .func_debug_info, | 10140 | .func_debug_info, |
| 10111 | => for (0..2) |_| fw.writeUleb128(@backingInt(Dwarf.AbbrevCode.null)) catch unreachable, | 10141 | => for (0..2) |_| fw.writeUleb128(@backingInt(Dwarf.AbbrevCode.null)) catch unreachable, |
| ... | @@ -10119,7 +10149,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! | ... | @@ -10119,7 +10149,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! |
| 10119 | elf.dwarf.updateUnitLength(fw.buffer, fw.buffer.len); | 10149 | elf.dwarf.updateUnitLength(fw.buffer, fw.buffer.len); |
| 10120 | switch (tag) { | 10150 | switch (tag) { |
| 10121 | else => unreachable, | 10151 | else => unreachable, |
| 10122 | .unit_debug_info_header, .value_debug_info, .global_debug_info, .func_debug_info => { | 10152 | .unit_debug_info_header, .const_debug_info, .global_debug_info, .func_debug_info => { |
| 10123 | comptime assert(Dwarf.uleb128Size(@backingInt(Dwarf.AbbrevCode.null)) == 1); | 10153 | comptime assert(Dwarf.uleb128Size(@backingInt(Dwarf.AbbrevCode.null)) == 1); |
| 10124 | @memset(fw.unusedCapacitySlice(), @backingInt(Dwarf.AbbrevCode.null)); | 10154 | @memset(fw.unusedCapacitySlice(), @backingInt(Dwarf.AbbrevCode.null)); |
| 10125 | }, | 10155 | }, |
| ... | @@ -10143,7 +10173,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! | ... | @@ -10143,7 +10173,7 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error! |
| 10143 | @memset(fw.buffer, std.dwarf.CFA.nop); | 10173 | @memset(fw.buffer, std.dwarf.CFA.nop); |
| 10144 | }, | 10174 | }, |
| 10145 | .unit_debug_info_header, | 10175 | .unit_debug_info_header, |
| 10146 | .value_debug_info, | 10176 | .const_debug_info, |
| 10147 | .global_debug_info, | 10177 | .global_debug_info, |
| 10148 | .func_debug_info, | 10178 | .func_debug_info, |
| 10149 | => elf.dwarf.genDebugInfoPadding(&fw, fw.buffer.len) catch unreachable, | 10179 | => elf.dwarf.genDebugInfoPadding(&fw, fw.buffer.len) catch unreachable, |
| ... | @@ -10693,9 +10723,11 @@ pub fn printNode( | ... | @@ -10693,9 +10723,11 @@ pub fn printNode( |
| 10693 | .unit_debug_line_header, | 10723 | .unit_debug_line_header, |
| 10694 | .unit_debug_rnglists, | 10724 | .unit_debug_rnglists, |
| 10695 | => |ui| try w.print("({s})", .{ui.mod(&elf.dwarf).fully_qualified_name}), | 10725 | => |ui| try w.print("({s})", .{ui.mod(&elf.dwarf).fully_qualified_name}), |
| 10696 | .value_debug_info => |cpi| try w.print("({f})", .{ | 10726 | .const_debug_info => |cpi| try w.print("({f})", .{ |
| 10697 | Value.fromInterned(cpi.val(&elf.dwarf.const_pool)) | 10727 | Value.fromInterned(cpi.val(&elf.dwarf.const_pool)).fmtValue(.{ |
| 10698 | .fmtValue(.{ .zcu = elf.base.comp.zcu.?, .tid = tid }), | 10728 | .zcu = elf.base.comp.zcu.?, |
| | 10729 | .tid = tid, |
| | 10730 | }), |
| 10699 | }), | 10731 | }), |
| 10700 | .global_debug_info => |gi| { | 10732 | .global_debug_info => |gi| { |
| 10701 | const zcu = elf.base.comp.zcu.?; | 10733 | const zcu = elf.base.comp.zcu.?; |