aboutsummaryrefslogtreecommitdiff
path: root/src/link/Dwarf.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-07-31 18:19:17 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-08-03 21:19:41 +0200
commitf26d5ee7ea97c8fd6e5b2655f845be7e4293930e (patch)
treefab17016b079fcd7aaef84672feb469136dcc646 /src/link/Dwarf.zig
parent4c750016eb9b1c0831cbb0398a4d6ee9dbdc932e (diff)
downloadzig-f26d5ee7ea97c8fd6e5b2655f845be7e4293930e.tar.gz
zig-f26d5ee7ea97c8fd6e5b2655f845be7e4293930e.zip
macho: sync with zld
gitrev a2c32e972f8c5adfcda8ed2d99379ae868f59c24 https://github.com/kubkon/zld/commit/a2c32e972f8c5adfcda8ed2d99379ae868f59c24
Diffstat (limited to 'src/link/Dwarf.zig')
-rw-r--r--src/link/Dwarf.zig44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
index 03ba53801b..627f946e36 100644
--- a/src/link/Dwarf.zig
+++ b/src/link/Dwarf.zig
@@ -853,8 +853,7 @@ pub fn commitDeclState(
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_segment = &d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_line_sect = &dwarf_segment.sections.items[d_sym.debug_line_section_index.?];
+ const debug_line_sect = &d_sym.sections.items[d_sym.debug_line_section_index.?];
const file_pos = debug_line_sect.offset + src_fn.off;
try pwriteDbgLineNops(d_sym.file, file_pos, 0, &[0]u8{}, src_fn.len);
},
@@ -933,8 +932,8 @@ pub fn commitDeclState(
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_segment = &d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_line_sect = &dwarf_segment.sections.items[d_sym.debug_line_section_index.?];
+ const dwarf_segment = d_sym.segments.items[d_sym.dwarf_segment_cmd_index.?];
+ const debug_line_sect = &d_sym.sections.items[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);
@@ -955,10 +954,9 @@ pub fn commitDeclState(
);
debug_line_sect.offset = @intCast(u32, new_offset);
- debug_line_sect.addr = dwarf_segment.inner.vmaddr + new_offset - dwarf_segment.inner.fileoff;
+ debug_line_sect.addr = dwarf_segment.vmaddr + new_offset - dwarf_segment.fileoff;
}
debug_line_sect.size = needed_size;
- d_sym.load_commands_dirty = true; // TODO look into making only the one section dirty
d_sym.debug_line_header_dirty = true;
}
const file_pos = debug_line_sect.offset + src_fn.off;
@@ -1137,8 +1135,7 @@ fn updateDeclDebugInfoAllocation(self: *Dwarf, file: *File, atom: *Atom, len: u3
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_segment = &d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_info_sect = &dwarf_segment.sections.items[d_sym.debug_info_section_index.?];
+ const debug_info_sect = &d_sym.sections.items[d_sym.debug_info_section_index.?];
const file_pos = debug_info_sect.offset + atom.off;
try pwriteDbgInfoNops(d_sym.file, file_pos, 0, &[0]u8{}, atom.len, false);
},
@@ -1235,8 +1232,8 @@ fn writeDeclDebugInfo(self: *Dwarf, file: *File, atom: *Atom, dbg_info_buf: []co
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_segment = &d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_info_sect = &dwarf_segment.sections.items[d_sym.debug_info_section_index.?];
+ const dwarf_segment = d_sym.segments.items[d_sym.dwarf_segment_cmd_index.?];
+ const debug_info_sect = &d_sym.sections.items[d_sym.debug_info_section_index.?];
if (needed_size != debug_info_sect.size) {
if (needed_size > d_sym.allocatedSize(debug_info_sect.offset)) {
const new_offset = d_sym.findFreeSpace(needed_size, 1);
@@ -1257,10 +1254,9 @@ fn writeDeclDebugInfo(self: *Dwarf, file: *File, atom: *Atom, dbg_info_buf: []co
);
debug_info_sect.offset = @intCast(u32, new_offset);
- debug_info_sect.addr = dwarf_segment.inner.vmaddr + new_offset - dwarf_segment.inner.fileoff;
+ debug_info_sect.addr = dwarf_segment.vmaddr + new_offset - dwarf_segment.fileoff;
}
debug_info_sect.size = needed_size;
- d_sym.load_commands_dirty = true; // TODO look into making only the one section dirty
d_sym.debug_line_header_dirty = true;
}
const file_pos = debug_info_sect.offset + atom.off;
@@ -1330,8 +1326,7 @@ pub fn updateDeclLineNumber(self: *Dwarf, file: *File, decl: *const Module.Decl)
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = macho_file.d_sym.?;
- const dwarf_seg = d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const sect = dwarf_seg.sections.items[d_sym.debug_line_section_index.?];
+ const sect = d_sym.sections.items[d_sym.debug_line_section_index.?];
const file_pos = sect.offset + decl.fn_link.macho.off + self.getRelocDbgLineOff();
try d_sym.file.pwriteAll(&data, file_pos);
},
@@ -1557,14 +1552,14 @@ pub fn writeDbgAbbrev(self: *Dwarf, file: *File) !void {
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_segment = &d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_abbrev_sect = &dwarf_segment.sections.items[d_sym.debug_abbrev_section_index.?];
+ const dwarf_segment = d_sym.segments.items[d_sym.dwarf_segment_cmd_index.?];
+ const debug_abbrev_sect = &d_sym.sections.items[d_sym.debug_abbrev_section_index.?];
const allocated_size = d_sym.allocatedSize(debug_abbrev_sect.offset);
if (needed_size > allocated_size) {
debug_abbrev_sect.size = 0; // free the space
const offset = d_sym.findFreeSpace(needed_size, 1);
debug_abbrev_sect.offset = @intCast(u32, offset);
- debug_abbrev_sect.addr = dwarf_segment.inner.vmaddr + offset - dwarf_segment.inner.fileoff;
+ debug_abbrev_sect.addr = dwarf_segment.vmaddr + offset - dwarf_segment.fileoff;
}
debug_abbrev_sect.size = needed_size;
log.debug("__debug_abbrev start=0x{x} end=0x{x}", .{
@@ -1681,8 +1676,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, file: *File, module: *Module, low_pc: u6
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_seg = d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_info_sect = dwarf_seg.sections.items[d_sym.debug_info_section_index.?];
+ const debug_info_sect = d_sym.sections.items[d_sym.debug_info_section_index.?];
const file_pos = debug_info_sect.offset;
try pwriteDbgInfoNops(d_sym.file, file_pos, 0, di_buf.items, jmp_amt, false);
},
@@ -1998,13 +1992,13 @@ pub fn writeDbgAranges(self: *Dwarf, file: *File, addr: u64, size: u64) !void {
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_seg = &d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_aranges_sect = &dwarf_seg.sections.items[d_sym.debug_aranges_section_index.?];
+ const dwarf_seg = d_sym.segments.items[d_sym.dwarf_segment_cmd_index.?];
+ const debug_aranges_sect = &d_sym.sections.items[d_sym.debug_aranges_section_index.?];
const allocated_size = d_sym.allocatedSize(debug_aranges_sect.offset);
if (needed_size > allocated_size) {
debug_aranges_sect.size = 0; // free the space
const new_offset = d_sym.findFreeSpace(needed_size, 16);
- debug_aranges_sect.addr = dwarf_seg.inner.vmaddr + new_offset - dwarf_seg.inner.fileoff;
+ debug_aranges_sect.addr = dwarf_seg.vmaddr + new_offset - dwarf_seg.fileoff;
debug_aranges_sect.offset = @intCast(u32, new_offset);
}
debug_aranges_sect.size = needed_size;
@@ -2134,8 +2128,7 @@ pub fn writeDbgLineHeader(self: *Dwarf, file: *File, module: *Module) !void {
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_seg = d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_line_sect = dwarf_seg.sections.items[d_sym.debug_line_section_index.?];
+ const debug_line_sect = d_sym.sections.items[d_sym.debug_line_section_index.?];
const file_pos = debug_line_sect.offset;
try pwriteDbgLineNops(d_sym.file, file_pos, 0, di_buf.items, jmp_amt);
},
@@ -2264,8 +2257,7 @@ pub fn flushModule(self: *Dwarf, file: *File, module: *Module) !void {
.macho => {
const macho_file = file.cast(File.MachO).?;
const d_sym = &macho_file.d_sym.?;
- const dwarf_segment = &d_sym.load_commands.items[d_sym.dwarf_segment_cmd_index.?].segment;
- const debug_info_sect = &dwarf_segment.sections.items[d_sym.debug_info_section_index.?];
+ const debug_info_sect = &d_sym.sections.items[d_sym.debug_info_section_index.?];
break :blk debug_info_sect.offset;
},
// for wasm, the offset is always 0 as we write to memory first