authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-08 11:01:22+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-09 09:24:25+01:00
logb14e580ad87d70bb14a3bf942bfac41acf1b51b8
tree9376606b6068cc3f6ed9e2fdd9c4212d4416c05f
parent136a508027dc13306eaea5ad8e77d384112bb897

dwarf: move growing debug_aranges section to dsym


2 files changed, 6 insertions(+), 16 deletions(-)

src/link/Dwarf.zig+5-16
......@@ -2170,7 +2170,7 @@ pub fn writeDbgAranges(self: *Dwarf, addr: u64, size: u64) !void {
21702170 },
21712171 }
21722172
2173 const needed_size = di_buf.items.len;
2173 const needed_size = @intCast(u32, di_buf.items.len);
21742174 switch (self.bin_file.tag) {
21752175 .elf => {
21762176 const elf_file = self.bin_file.cast(File.Elf).?;
......@@ -2190,21 +2190,10 @@ pub fn writeDbgAranges(self: *Dwarf, addr: u64, size: u64) !void {
21902190 },
21912191 .macho => {
21922192 const d_sym = self.bin_file.cast(File.MachO).?.getDebugSymbols().?;
2193 const dwarf_seg = d_sym.segments.items[d_sym.dwarf_segment_cmd_index.?];
2194 const debug_aranges_sect = &d_sym.sections.items[d_sym.debug_aranges_section_index.?];
2195 const allocated_size = d_sym.allocatedSize(debug_aranges_sect.offset);
2196 if (needed_size > allocated_size) {
2197 debug_aranges_sect.size = 0; // free the space
2198 const new_offset = d_sym.findFreeSpace(needed_size, 16);
2199 debug_aranges_sect.addr = dwarf_seg.vmaddr + new_offset - dwarf_seg.fileoff;
2200 debug_aranges_sect.offset = @intCast(u32, new_offset);
2201 }
2202 debug_aranges_sect.size = needed_size;
2203 log.debug("__debug_aranges start=0x{x} end=0x{x}", .{
2204 debug_aranges_sect.offset,
2205 debug_aranges_sect.offset + needed_size,
2206 });
2207 const file_pos = debug_aranges_sect.offset;
2193 const sect_index = d_sym.debug_aranges_section_index.?;
2194 try d_sym.growSection(sect_index, needed_size);
2195 const sect = d_sym.getSection(sect_index);
2196 const file_pos = sect.offset;
22082197 try d_sym.file.pwriteAll(di_buf.items, file_pos);
22092198 },
22102199 .wasm => {
src/link/MachO/DebugSymbols.zig+1
......@@ -171,6 +171,7 @@ pub fn growSection(self: *DebugSymbols, sect_index: u8, needed_size: u32) !void
171171 if (amt != existing_size) return error.InputOutput;
172172 sect.offset = @intCast(u32, new_offset);
173173 }
174
174175 sect.size = needed_size;
175176 self.markDirty(sect_index);
176177}