| ... | ... | @@ -1106,7 +1106,7 @@ pub fn commitDeclState( |
| 1106 | 1106 | .macho => { |
| 1107 | 1107 | const macho_file = self.bin_file.cast(File.MachO).?; |
| 1108 | 1108 | const d_sym = &macho_file.d_sym.?; |
| 1109 | | const debug_line_sect = &d_sym.sections.items[d_sym.debug_line_section_index.?]; |
| 1109 | const debug_line_sect = d_sym.getSectionPtr(d_sym.debug_line_section_index.?); |
| 1110 | 1110 | const file_pos = debug_line_sect.offset + src_fn.off; |
| 1111 | 1111 | try pwriteDbgLineNops(d_sym.file, file_pos, 0, &[0]u8{}, src_fn.len); |
| 1112 | 1112 | }, |
| ... | ... | @@ -1187,7 +1187,7 @@ pub fn commitDeclState( |
| 1187 | 1187 | .macho => { |
| 1188 | 1188 | const macho_file = self.bin_file.cast(File.MachO).?; |
| 1189 | 1189 | const d_sym = &macho_file.d_sym.?; |
| 1190 | | const debug_line_sect = &d_sym.sections.items[d_sym.debug_line_section_index.?]; |
| 1190 | const debug_line_sect = d_sym.getSectionPtr(d_sym.debug_line_section_index.?); |
| 1191 | 1191 | if (needed_size != debug_line_sect.size) { |
| 1192 | 1192 | if (needed_size > d_sym.allocatedSize(debug_line_sect.offset)) { |
| 1193 | 1193 | const new_offset = d_sym.findFreeSpace(needed_size, 1); |
| ... | ... | @@ -1381,7 +1381,7 @@ fn updateDeclDebugInfoAllocation(self: *Dwarf, atom: *Atom, len: u32) !void { |
| 1381 | 1381 | .macho => { |
| 1382 | 1382 | const macho_file = self.bin_file.cast(File.MachO).?; |
| 1383 | 1383 | const d_sym = &macho_file.d_sym.?; |
| 1384 | | const debug_info_sect = &d_sym.sections.items[d_sym.debug_info_section_index.?]; |
| 1384 | const debug_info_sect = d_sym.getSectionPtr(d_sym.debug_info_section_index.?); |
| 1385 | 1385 | const file_pos = debug_info_sect.offset + atom.off; |
| 1386 | 1386 | try pwriteDbgInfoNops(d_sym.file, file_pos, 0, &[0]u8{}, atom.len, false); |
| 1387 | 1387 | }, |
| ... | ... | @@ -1477,29 +1477,10 @@ fn writeDeclDebugInfo(self: *Dwarf, atom: *Atom, dbg_info_buf: []const u8) !void |
| 1477 | 1477 | .macho => { |
| 1478 | 1478 | const macho_file = self.bin_file.cast(File.MachO).?; |
| 1479 | 1479 | const d_sym = &macho_file.d_sym.?; |
| 1480 | | const debug_info_sect = &d_sym.sections.items[d_sym.debug_info_section_index.?]; |
| 1481 | | if (needed_size != debug_info_sect.size) { |
| 1482 | | if (needed_size > d_sym.allocatedSize(debug_info_sect.offset)) { |
| 1483 | | const new_offset = d_sym.findFreeSpace(needed_size, 1); |
| 1484 | | const existing_size = last_decl.off; |
| 1485 | | std.log.scoped(.dsym).debug("moving __debug_info section: {} bytes from 0x{x} to 0x{x}", .{ |
| 1486 | | existing_size, |
| 1487 | | debug_info_sect.offset, |
| 1488 | | new_offset, |
| 1489 | | }); |
| 1490 | | const amt = try d_sym.file.copyRangeAll( |
| 1491 | | debug_info_sect.offset, |
| 1492 | | d_sym.file, |
| 1493 | | new_offset, |
| 1494 | | existing_size, |
| 1495 | | ); |
| 1496 | | if (amt != existing_size) return error.InputOutput; |
| 1497 | | debug_info_sect.offset = @intCast(u32, new_offset); |
| 1498 | | } |
| 1499 | | debug_info_sect.size = needed_size; |
| 1500 | | d_sym.debug_info_header_dirty = true; |
| 1501 | | } |
| 1502 | | const file_pos = debug_info_sect.offset + atom.off; |
| 1480 | const sect_index = d_sym.debug_info_section_index.?; |
| 1481 | try d_sym.growSection(sect_index, needed_size); |
| 1482 | const sect = d_sym.getSection(sect_index); |
| 1483 | const file_pos = sect.offset + atom.off; |
| 1503 | 1484 | try pwriteDbgInfoNops( |
| 1504 | 1485 | d_sym.file, |
| 1505 | 1486 | file_pos, |
| ... | ... | @@ -1916,7 +1897,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, module: *Module, low_pc: u64, high_pc: u |
| 1916 | 1897 | .macho => { |
| 1917 | 1898 | const macho_file = self.bin_file.cast(File.MachO).?; |
| 1918 | 1899 | const d_sym = &macho_file.d_sym.?; |
| 1919 | | const debug_info_sect = d_sym.sections.items[d_sym.debug_info_section_index.?]; |
| 1900 | const debug_info_sect = d_sym.getSection(d_sym.debug_info_section_index.?); |
| 1920 | 1901 | const file_pos = debug_info_sect.offset; |
| 1921 | 1902 | try pwriteDbgInfoNops(d_sym.file, file_pos, 0, di_buf.items, jmp_amt, false); |
| 1922 | 1903 | }, |
| ... | ... | @@ -2406,7 +2387,7 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void { |
| 2406 | 2387 | |
| 2407 | 2388 | const macho_file = self.bin_file.cast(File.MachO).?; |
| 2408 | 2389 | const d_sym = &macho_file.d_sym.?; |
| 2409 | | const debug_line_sect = &d_sym.sections.items[d_sym.debug_line_section_index.?]; |
| 2390 | const debug_line_sect = d_sym.getSectionPtr(d_sym.debug_line_section_index.?); |
| 2410 | 2391 | const needed_size = debug_line_sect.size + delta; |
| 2411 | 2392 | |
| 2412 | 2393 | if (needed_size > d_sym.allocatedSize(debug_line_sect.offset)) { |
| ... | ... | @@ -2463,7 +2444,7 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void { |
| 2463 | 2444 | .macho => { |
| 2464 | 2445 | const macho_file = self.bin_file.cast(File.MachO).?; |
| 2465 | 2446 | const d_sym = &macho_file.d_sym.?; |
| 2466 | | const debug_line_sect = d_sym.sections.items[d_sym.debug_line_section_index.?]; |
| 2447 | const debug_line_sect = d_sym.getSection(d_sym.debug_line_section_index.?); |
| 2467 | 2448 | const file_pos = debug_line_sect.offset; |
| 2468 | 2449 | try pwriteDbgLineNops(d_sym.file, file_pos, 0, di_buf.items, jmp_amt); |
| 2469 | 2450 | }, |
| ... | ... | @@ -2606,7 +2587,7 @@ pub fn flushModule(self: *Dwarf, module: *Module) !void { |
| 2606 | 2587 | .macho => { |
| 2607 | 2588 | const macho_file = self.bin_file.cast(File.MachO).?; |
| 2608 | 2589 | const d_sym = &macho_file.d_sym.?; |
| 2609 | | const debug_info_sect = &d_sym.sections.items[d_sym.debug_info_section_index.?]; |
| 2590 | const debug_info_sect = d_sym.getSectionPtr(d_sym.debug_info_section_index.?); |
| 2610 | 2591 | break :blk debug_info_sect.offset; |
| 2611 | 2592 | }, |
| 2612 | 2593 | // for wasm, the offset is always 0 as we write to memory first |