Fix writing of load cmds headers *after* symtab update

This commit is contained in:
Jakub Konka 2020-10-11 00:38:23 +02:00
parent fc660af077
commit ecd480fe93

View File

@ -367,8 +367,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void {
.Lib => return error.TODOImplementWritingLibFiles,
}
if (self.cmd_table_dirty) try self.writeCmdHeaders();
{
// Update symbol table.
const nlocals = @intCast(u32, self.local_symbols.items.len);
@ -378,6 +376,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void {
symtab.nsyms = nlocals + nglobals + nundefs;
}
if (self.cmd_table_dirty) try self.writeCmdHeaders();
if (self.entry_addr == null and self.base.options.output_mode == .Exe) {
log.debug("flushing. no_entry_point_found = true\n", .{});
self.error_flags.no_entry_point_found = true;