| ... | ... | @@ -326,7 +326,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 326 | 326 | const tracy = trace(@src()); |
| 327 | 327 | defer tracy.end(); |
| 328 | 328 | |
| 329 | | |
| 330 | 329 | switch (self.base.options.output_mode) { |
| 331 | 330 | .Exe => { |
| 332 | 331 | if (self.entry_addr) |addr| { |
| ... | ... | @@ -361,7 +360,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 361 | 360 | try self.base.file.?.pwriteAll(mem.spanZ(LIB_SYSTEM_PATH), off); |
| 362 | 361 | self.libsystem_cmd_dirty = false; |
| 363 | 362 | } |
| 364 | | |
| 363 | |
| 365 | 364 | // Write export trie. |
| 366 | 365 | try self.writeExportTrie(); |
| 367 | 366 | const linkedit = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; |
| ... | ... | @@ -1166,8 +1165,8 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 1166 | 1165 | text_segment.cmdsize += @sizeOf(macho.section_64); |
| 1167 | 1166 | text_segment.nsects += 1; |
| 1168 | 1167 | |
| 1169 | | // const program_code_size_hint = self.base.options.program_code_size_hint; |
| 1170 | | const program_code_size_hint = 128; |
| 1168 | const program_code_size_hint = self.base.options.program_code_size_hint; |
| 1169 | // const program_code_size_hint = 128; |
| 1171 | 1170 | const file_size = mem.alignForwardGeneric(u64, program_code_size_hint, self.page_size); |
| 1172 | 1171 | const off = @intCast(u32, self.findFreeSpace(file_size, self.page_size)); // TODO maybe findFreeSpace should return u32 directly? |
| 1173 | 1172 | const flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS; |
| ... | ... | @@ -1180,7 +1179,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 1180 | 1179 | .addr = text_segment.vmaddr + off, |
| 1181 | 1180 | .size = file_size, |
| 1182 | 1181 | .offset = off, |
| 1183 | | .@"align" = 2, // 2^12 = 4096 |
| 1182 | .@"align" = if (self.base.options.target.cpu.arch == .aarch64) 2 else 1, // 2^2 for aarch64, 2^1 for x86_64 |
| 1184 | 1183 | .reloff = 0, |
| 1185 | 1184 | .nreloc = 0, |
| 1186 | 1185 | .flags = flags, |
| ... | ... | @@ -1650,7 +1649,7 @@ fn writeOffsetTableEntry(self: *MachO, index: usize) !void { |
| 1650 | 1649 | fn writeSymbolTable(self: *MachO) !void { |
| 1651 | 1650 | const symtab = &self.load_commands.items[self.symtab_cmd_index.?].Symtab; |
| 1652 | 1651 | const locals_off = symtab.symoff; |
| 1653 | | |
| 1652 | |
| 1654 | 1653 | var locals = try self.base.allocator.alloc(macho.nlist_64, self.local_symbols.items.len - 1); |
| 1655 | 1654 | defer self.base.allocator.free(locals); |
| 1656 | 1655 | |
| ... | ... | @@ -1752,7 +1751,7 @@ fn writeStringTable(self: *MachO) !void { |
| 1752 | 1751 | // symtab.stroff = @intCast(u32, self.findFreeSpace(needed_size, 1)); |
| 1753 | 1752 | // } |
| 1754 | 1753 | symtab.strsize = mem.alignForwardGeneric(u32, @intCast(u32, needed_size), @sizeOf(u64)); |
| 1755 | | try self.base.file.?.pwriteAll(&[_]u8{ 0 }, symtab.stroff + symtab.strsize - 1); |
| 1754 | try self.base.file.?.pwriteAll(&[_]u8{0}, symtab.stroff + symtab.strsize - 1); |
| 1756 | 1755 | log.debug("writing string table from 0x{x} to 0x{x}\n", .{ symtab.stroff, symtab.stroff + needed_size }); |
| 1757 | 1756 | try self.base.file.?.pwriteAll(self.string_table.items, symtab.stroff); |
| 1758 | 1757 | } |