commit 381abcfb7a24dcfda761390d6ef914047330f878 (tree)
parent 4bb66b63ba108a1c7e5c920348d72ed1e169fd99
Author: Jakub Konka <kubkon@jakubkonka.com>
Date: Thu, 8 Dec 2022 10:38:03 +0100
dwarf: move another sect growing routine to d_sym
Diffstat:
1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
@@ -1184,31 +1184,11 @@ pub fn commitDeclState(
},
.macho => {
- const macho_file = self.bin_file.cast(File.MachO).?;
- const d_sym = &macho_file.d_sym.?;
- const debug_line_sect = d_sym.getSectionPtr(d_sym.debug_line_section_index.?);
- if (needed_size != debug_line_sect.size) {
- if (needed_size > d_sym.allocatedSize(debug_line_sect.offset)) {
- const new_offset = d_sym.findFreeSpace(needed_size, 1);
- const existing_size = last_src_fn.off;
- std.log.scoped(.dsym).debug("moving __debug_line section: {} bytes from 0x{x} to 0x{x}", .{
- existing_size,
- debug_line_sect.offset,
- new_offset,
- });
- const amt = try d_sym.file.copyRangeAll(
- debug_line_sect.offset,
- d_sym.file,
- new_offset,
- existing_size,
- );
- if (amt != existing_size) return error.InputOutput;
- debug_line_sect.offset = @intCast(u32, new_offset);
- }
- debug_line_sect.size = needed_size;
- d_sym.debug_line_header_dirty = true;
- }
- const file_pos = debug_line_sect.offset + src_fn.off;
+ const d_sym = self.bin_file.cast(File.MachO).?.getDebugSymbols().?;
+ const sect_index = d_sym.debug_line_section_index.?;
+ try d_sym.growSection(sect_index, needed_size);
+ const sect = d_sym.getSection(sect_index);
+ const file_pos = sect.offset + src_fn.off;
try pwriteDbgLineNops(
d_sym.file,
file_pos,