aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-12-08 11:01:22 +0100
committerJakub Konka <kubkon@jakubkonka.com>2022-12-09 09:24:25 +0100
commitb14e580ad87d70bb14a3bf942bfac41acf1b51b8 (patch)
tree9376606b6068cc3f6ed9e2fdd9c4212d4416c05f /src
parent136a508027dc13306eaea5ad8e77d384112bb897 (diff)
downloadzig-b14e580ad87d70bb14a3bf942bfac41acf1b51b8.tar.gz
zig-b14e580ad87d70bb14a3bf942bfac41acf1b51b8.zip
dwarf: move growing debug_aranges section to dsym
Diffstat (limited to 'src')
-rw-r--r--src/link/Dwarf.zig21
-rw-r--r--src/link/MachO/DebugSymbols.zig1
2 files changed, 6 insertions, 16 deletions
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
index bed8f23193..e5ee8569fb 100644
--- a/src/link/Dwarf.zig
+++ b/src/link/Dwarf.zig
@@ -2170,7 +2170,7 @@ pub fn writeDbgAranges(self: *Dwarf, addr: u64, size: u64) !void {
},
}
- const needed_size = di_buf.items.len;
+ const needed_size = @intCast(u32, di_buf.items.len);
switch (self.bin_file.tag) {
.elf => {
const elf_file = self.bin_file.cast(File.Elf).?;
@@ -2190,21 +2190,10 @@ pub fn writeDbgAranges(self: *Dwarf, addr: u64, size: u64) !void {
},
.macho => {
const d_sym = self.bin_file.cast(File.MachO).?.getDebugSymbols().?;
- 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.vmaddr + new_offset - dwarf_seg.fileoff;
- debug_aranges_sect.offset = @intCast(u32, new_offset);
- }
- debug_aranges_sect.size = needed_size;
- log.debug("__debug_aranges start=0x{x} end=0x{x}", .{
- debug_aranges_sect.offset,
- debug_aranges_sect.offset + needed_size,
- });
- const file_pos = debug_aranges_sect.offset;
+ const sect_index = d_sym.debug_aranges_section_index.?;
+ try d_sym.growSection(sect_index, needed_size);
+ const sect = d_sym.getSection(sect_index);
+ const file_pos = sect.offset;
try d_sym.file.pwriteAll(di_buf.items, file_pos);
},
.wasm => {
diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig
index 436804cbaa..1c759823cc 100644
--- a/src/link/MachO/DebugSymbols.zig
+++ b/src/link/MachO/DebugSymbols.zig
@@ -171,6 +171,7 @@ pub fn growSection(self: *DebugSymbols, sect_index: u8, needed_size: u32) !void
if (amt != existing_size) return error.InputOutput;
sect.offset = @intCast(u32, new_offset);
}
+
sect.size = needed_size;
self.markDirty(sect_index);
}