| ... | @@ -597,7 +597,6 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { | ... | @@ -597,7 +597,6 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 597 | .n_desc = 0, | 597 | .n_desc = 0, |
| 598 | .n_value = 0, | 598 | .n_value = 0, |
| 599 | }); | 599 | }); |
| 600 | try self.strtab.append(self.base.allocator, 0); | | |
| 601 | } | 600 | } |
| 602 | | 601 | |
| 603 | // Positional arguments to the linker such as object files and static archives. | 602 | // Positional arguments to the linker such as object files and static archives. |
| ... | @@ -2608,7 +2607,6 @@ fn addLoadDylibLCs(self: *MachO) !void { | ... | @@ -2608,7 +2607,6 @@ fn addLoadDylibLCs(self: *MachO) !void { |
| 2608 | } | 2607 | } |
| 2609 | | 2608 | |
| 2610 | fn flushZld(self: *MachO) !void { | 2609 | fn flushZld(self: *MachO) !void { |
| 2611 | self.load_commands_dirty = true; | | |
| 2612 | try self.writeTextBlocks(); | 2610 | try self.writeTextBlocks(); |
| 2613 | try self.writeStubHelperCommon(); | 2611 | try self.writeStubHelperCommon(); |
| 2614 | | 2612 | |
| ... | @@ -3012,7 +3010,7 @@ fn writeSymbolTable(self: *MachO) !void { | ... | @@ -3012,7 +3010,7 @@ fn writeSymbolTable(self: *MachO) !void { |
| 3012 | const nexports = self.globals.items.len; | 3010 | const nexports = self.globals.items.len; |
| 3013 | const nundefs = self.undefs.items.len; | 3011 | const nundefs = self.undefs.items.len; |
| 3014 | | 3012 | |
| 3015 | const locals_off = symtab.symoff + symtab.nsyms * @sizeOf(macho.nlist_64); | 3013 | const locals_off = symtab.symoff + @sizeOf(macho.nlist_64); |
| 3016 | const locals_size = nlocals * @sizeOf(macho.nlist_64); | 3014 | const locals_size = nlocals * @sizeOf(macho.nlist_64); |
| 3017 | log.debug("writing local symbols from 0x{x} to 0x{x}", .{ locals_off, locals_size + locals_off }); | 3015 | log.debug("writing local symbols from 0x{x} to 0x{x}", .{ locals_off, locals_size + locals_off }); |
| 3018 | try self.base.file.?.pwriteAll(mem.sliceAsBytes(locals.items), locals_off); | 3016 | try self.base.file.?.pwriteAll(mem.sliceAsBytes(locals.items), locals_off); |
| ... | @@ -3027,7 +3025,7 @@ fn writeSymbolTable(self: *MachO) !void { | ... | @@ -3027,7 +3025,7 @@ fn writeSymbolTable(self: *MachO) !void { |
| 3027 | log.debug("writing undefined symbols from 0x{x} to 0x{x}", .{ undefs_off, undefs_size + undefs_off }); | 3025 | log.debug("writing undefined symbols from 0x{x} to 0x{x}", .{ undefs_off, undefs_size + undefs_off }); |
| 3028 | try self.base.file.?.pwriteAll(mem.sliceAsBytes(self.undefs.items), undefs_off); | 3026 | try self.base.file.?.pwriteAll(mem.sliceAsBytes(self.undefs.items), undefs_off); |
| 3029 | | 3027 | |
| 3030 | symtab.nsyms += @intCast(u32, nlocals + nexports + nundefs); | 3028 | symtab.nsyms = @intCast(u32, nlocals + nexports + nundefs); |
| 3031 | seg.inner.filesize += locals_size + exports_size + undefs_size; | 3029 | seg.inner.filesize += locals_size + exports_size + undefs_size; |
| 3032 | | 3030 | |
| 3033 | // Update dynamic symbol table. | 3031 | // Update dynamic symbol table. |
| ... | @@ -3826,7 +3824,11 @@ pub fn populateMissingMetadata(self: *MachO) !void { | ... | @@ -3826,7 +3824,11 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 3826 | .aarch64 => 2, | 3824 | .aarch64 => 2, |
| 3827 | else => unreachable, // unhandled architecture type | 3825 | else => unreachable, // unhandled architecture type |
| 3828 | }; | 3826 | }; |
| 3829 | const needed_size = @sizeOf(u64) * self.base.options.symbol_count_hint; | 3827 | const needed_size: u6 = switch (self.base.options.target.cpu.arch) { |
| | 3828 | .x86_64 => 15, |
| | 3829 | .aarch64 => 6 * @sizeOf(u32), |
| | 3830 | else => unreachable, |
| | 3831 | }; |
| 3830 | const off = text_segment.findFreeSpace(needed_size, @alignOf(u64), self.header_pad); | 3832 | const off = text_segment.findFreeSpace(needed_size, @alignOf(u64), self.header_pad); |
| 3831 | assert(off + needed_size <= text_segment.inner.fileoff + text_segment.inner.filesize); // TODO Must expand __TEXT segment. | 3833 | assert(off + needed_size <= text_segment.inner.fileoff + text_segment.inner.filesize); // TODO Must expand __TEXT segment. |
| 3832 | | 3834 | |