| ... | @@ -193,8 +193,8 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ? | ... | @@ -193,8 +193,8 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ? |
| 193 | // Update file offsets of contributing objects | 193 | // Update file offsets of contributing objects |
| 194 | const total_size: usize = blk: { | 194 | const total_size: usize = blk: { |
| 195 | var pos: usize = Archive.SARMAG; | 195 | var pos: usize = Archive.SARMAG; |
| 196 | pos += @sizeOf(Archive.ar_hdr) + Archive.SYMDEF.len + 1; | 196 | pos += @sizeOf(Archive.ar_hdr); |
| 197 | pos = mem.alignForward(usize, pos, ptr_width); | 197 | pos += mem.alignForward(usize, Archive.SYMDEF.len + 1, ptr_width); |
| 198 | pos += ar_symtab.size(format); | 198 | pos += ar_symtab.size(format); |
| 199 | | 199 | |
| 200 | for (files.items) |index| { | 200 | for (files.items) |index| { |
| ... | @@ -209,10 +209,10 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ? | ... | @@ -209,10 +209,10 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ? |
| 209 | .object => |x| x.path, | 209 | .object => |x| x.path, |
| 210 | else => unreachable, | 210 | else => unreachable, |
| 211 | }; | 211 | }; |
| 212 | pos = mem.alignForward(usize, pos, ptr_width); | 212 | pos = mem.alignForward(usize, pos, 2); |
| 213 | state.file_off = pos; | 213 | state.file_off = pos; |
| 214 | pos += @sizeOf(Archive.ar_hdr) + path.len + 1; | 214 | pos += @sizeOf(Archive.ar_hdr); |
| 215 | pos = mem.alignForward(usize, pos, ptr_width); | 215 | pos += mem.alignForward(usize, path.len + 1, ptr_width); |
| 216 | pos += math.cast(usize, state.size) orelse return error.Overflow; | 216 | pos += math.cast(usize, state.size) orelse return error.Overflow; |
| 217 | } | 217 | } |
| 218 | | 218 | |
| ... | @@ -236,7 +236,7 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ? | ... | @@ -236,7 +236,7 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ? |
| 236 | | 236 | |
| 237 | // Write object files | 237 | // Write object files |
| 238 | for (files.items) |index| { | 238 | for (files.items) |index| { |
| 239 | const aligned = mem.alignForward(usize, buffer.items.len, ptr_width); | 239 | const aligned = mem.alignForward(usize, buffer.items.len, 2); |
| 240 | const padding = aligned - buffer.items.len; | 240 | const padding = aligned - buffer.items.len; |
| 241 | if (padding > 0) { | 241 | if (padding > 0) { |
| 242 | try writer.writeByteNTimes(0, padding); | 242 | try writer.writeByteNTimes(0, padding); |