aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/link/Dwarf.zig13
-rw-r--r--src/link/MachO/DebugSymbols.zig4
2 files changed, 6 insertions, 11 deletions
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
index e5ee8569fb..15df5c84c3 100644
--- a/src/link/Dwarf.zig
+++ b/src/link/Dwarf.zig
@@ -2336,16 +2336,13 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void {
const delta = needed_with_padding - dbg_line_prg_off;
const d_sym = self.bin_file.cast(File.MachO).?.getDebugSymbols().?;
- const debug_line_sect = d_sym.getSectionPtr(d_sym.debug_line_section_index.?);
- const needed_size = debug_line_sect.size + delta;
-
- if (needed_size > d_sym.allocatedSize(debug_line_sect.offset)) {
- @panic("TODO grow debug_line section");
- }
+ const sect_index = d_sym.debug_line_section_index.?;
+ const needed_size = @intCast(u32, d_sym.getSection(sect_index).size + delta);
+ try d_sym.growSection(sect_index, needed_size);
var src_fn = self.dbg_line_fn_first.?;
const last_fn = self.dbg_line_fn_last.?;
- const file_pos = debug_line_sect.offset + src_fn.off;
+ const file_pos = d_sym.getSection(sect_index).offset + src_fn.off;
var buffer = try gpa.alloc(u8, last_fn.off + last_fn.len - src_fn.off);
defer gpa.free(buffer);
@@ -2354,8 +2351,6 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void {
try d_sym.file.pwriteAll(buffer, file_pos + delta);
- debug_line_sect.size = needed_size;
-
while (true) {
src_fn.off += delta;
diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig
index 1c759823cc..2191527dbb 100644
--- a/src/link/MachO/DebugSymbols.zig
+++ b/src/link/MachO/DebugSymbols.zig
@@ -202,7 +202,7 @@ fn detectAllocCollision(self: *DebugSymbols, start: u64, size: u64) ?u64 {
return null;
}
-pub fn findFreeSpace(self: *DebugSymbols, object_size: u64, min_alignment: u64) u64 {
+fn findFreeSpace(self: *DebugSymbols, object_size: u64, min_alignment: u64) u64 {
const segment = self.getDwarfSegmentPtr();
var offset: u64 = segment.fileoff;
while (self.detectAllocCollision(offset, object_size)) |item_end| {
@@ -464,7 +464,7 @@ fn writeHeader(self: *DebugSymbols, macho_file: *MachO, ncmds: u32, sizeofcmds:
try self.file.pwriteAll(mem.asBytes(&header), 0);
}
-pub fn allocatedSize(self: *DebugSymbols, start: u64) u64 {
+fn allocatedSize(self: *DebugSymbols, start: u64) u64 {
const seg = self.getDwarfSegmentPtr();
assert(start >= seg.fileoff);
var min_pos: u64 = std.math.maxInt(u64);