authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-08 11:08:00+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-09 09:24:25+01:00
logfa44c73c1efe2dae62c80a7785b496d83ddac8d1
tree6c546e402c978c930ab9c1f773067f5bce16ae4a
parentb14e580ad87d70bb14a3bf942bfac41acf1b51b8

dwarf: move any remaining section growth to dsym


2 files changed, 6 insertions(+), 11 deletions(-)

src/link/Dwarf.zig+4-9
......@@ -2336,16 +2336,13 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void {
23362336 const delta = needed_with_padding - dbg_line_prg_off;
23372337
23382338 const d_sym = self.bin_file.cast(File.MachO).?.getDebugSymbols().?;
2339 const debug_line_sect = d_sym.getSectionPtr(d_sym.debug_line_section_index.?);
2340 const needed_size = debug_line_sect.size + delta;
2341
2342 if (needed_size > d_sym.allocatedSize(debug_line_sect.offset)) {
2343 @panic("TODO grow debug_line section");
2344 }
2339 const sect_index = d_sym.debug_line_section_index.?;
2340 const needed_size = @intCast(u32, d_sym.getSection(sect_index).size + delta);
2341 try d_sym.growSection(sect_index, needed_size);
23452342
23462343 var src_fn = self.dbg_line_fn_first.?;
23472344 const last_fn = self.dbg_line_fn_last.?;
2348 const file_pos = debug_line_sect.offset + src_fn.off;
2345 const file_pos = d_sym.getSection(sect_index).offset + src_fn.off;
23492346
23502347 var buffer = try gpa.alloc(u8, last_fn.off + last_fn.len - src_fn.off);
23512348 defer gpa.free(buffer);
......@@ -2354,8 +2351,6 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void {
23542351
23552352 try d_sym.file.pwriteAll(buffer, file_pos + delta);
23562353
2357 debug_line_sect.size = needed_size;
2358
23592354 while (true) {
23602355 src_fn.off += delta;
23612356
src/link/MachO/DebugSymbols.zig+2-2
......@@ -202,7 +202,7 @@ fn detectAllocCollision(self: *DebugSymbols, start: u64, size: u64) ?u64 {
202202 return null;
203203}
204204
205pub fn findFreeSpace(self: *DebugSymbols, object_size: u64, min_alignment: u64) u64 {
205fn findFreeSpace(self: *DebugSymbols, object_size: u64, min_alignment: u64) u64 {
206206 const segment = self.getDwarfSegmentPtr();
207207 var offset: u64 = segment.fileoff;
208208 while (self.detectAllocCollision(offset, object_size)) |item_end| {
......@@ -464,7 +464,7 @@ fn writeHeader(self: *DebugSymbols, macho_file: *MachO, ncmds: u32, sizeofcmds:
464464 try self.file.pwriteAll(mem.asBytes(&header), 0);
465465}
466466
467pub fn allocatedSize(self: *DebugSymbols, start: u64) u64 {
467fn allocatedSize(self: *DebugSymbols, start: u64) u64 {
468468 const seg = self.getDwarfSegmentPtr();
469469 assert(start >= seg.fileoff);
470470 var min_pos: u64 = std.math.maxInt(u64);