| ... | @@ -169,6 +169,7 @@ pub fn growSection(self: *DebugSymbols, sect_index: u8, needed_size: u32) !void | ... | @@ -169,6 +169,7 @@ pub fn growSection(self: *DebugSymbols, sect_index: u8, needed_size: u32) !void |
| 169 | existing_size, | 169 | existing_size, |
| 170 | ); | 170 | ); |
| 171 | if (amt != existing_size) return error.InputOutput; | 171 | if (amt != existing_size) return error.InputOutput; |
| | 172 | |
| 172 | sect.offset = @intCast(u32, new_offset); | 173 | sect.offset = @intCast(u32, new_offset); |
| 173 | } | 174 | } |
| 174 | | 175 | |
| ... | @@ -283,24 +284,11 @@ pub fn flushModule(self: *DebugSymbols, macho_file: *MachO) !void { | ... | @@ -283,24 +284,11 @@ pub fn flushModule(self: *DebugSymbols, macho_file: *MachO) !void { |
| 283 | } | 284 | } |
| 284 | | 285 | |
| 285 | { | 286 | { |
| 286 | const debug_strtab_sect = &self.sections.items[self.debug_str_section_index.?]; | 287 | const sect_index = self.debug_str_section_index.?; |
| 287 | if (self.debug_string_table_dirty or self.dwarf.strtab.items.len != debug_strtab_sect.size) { | 288 | if (self.debug_string_table_dirty or self.dwarf.strtab.items.len != self.getSection(sect_index).size) { |
| 288 | const allocated_size = self.allocatedSize(debug_strtab_sect.offset); | 289 | const needed_size = @intCast(u32, self.dwarf.strtab.items.len); |
| 289 | const needed_size = self.dwarf.strtab.items.len; | 290 | try self.growSection(sect_index, needed_size); |
| 290 | | 291 | try self.file.pwriteAll(self.dwarf.strtab.items, self.getSection(sect_index).offset); |
| 291 | if (needed_size > allocated_size) { | | |
| 292 | debug_strtab_sect.size = 0; // free the space | | |
| 293 | const new_offset = self.findFreeSpace(needed_size, 1); | | |
| 294 | debug_strtab_sect.offset = @intCast(u32, new_offset); | | |
| 295 | } | | |
| 296 | debug_strtab_sect.size = @intCast(u32, needed_size); | | |
| 297 | | | |
| 298 | log.debug("__debug_strtab start=0x{x} end=0x{x}", .{ | | |
| 299 | debug_strtab_sect.offset, | | |
| 300 | debug_strtab_sect.offset + needed_size, | | |
| 301 | }); | | |
| 302 | | | |
| 303 | try self.file.pwriteAll(self.dwarf.strtab.items, debug_strtab_sect.offset); | | |
| 304 | self.debug_string_table_dirty = false; | 292 | self.debug_string_table_dirty = false; |
| 305 | } | 293 | } |
| 306 | } | 294 | } |