authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-08 23:50:31+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-08 23:51:30+01:00
log3bfda3d791c5315712f4c4c2fd0e83c8518d089a
treed686966f7cd90332e2226c5516df1b89f054c074
parent8c0e5435b32bfcd7e8a55cce9fc5b4ba70d1a148

macho: fix alignment of objects in archive


1 files changed, 6 insertions(+), 6 deletions(-)

src/link/MachO/relocatable.zig+6-6
......@@ -193,8 +193,8 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ?
193193 // Update file offsets of contributing objects
194194 const total_size: usize = blk: {
195195 var pos: usize = Archive.SARMAG;
196 pos += @sizeOf(Archive.ar_hdr) + Archive.SYMDEF.len + 1;
197 pos = mem.alignForward(usize, pos, ptr_width);
196 pos += @sizeOf(Archive.ar_hdr);
197 pos += mem.alignForward(usize, Archive.SYMDEF.len + 1, ptr_width);
198198 pos += ar_symtab.size(format);
199199
200200 for (files.items) |index| {
......@@ -209,10 +209,10 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ?
209209 .object => |x| x.path,
210210 else => unreachable,
211211 };
212 pos = mem.alignForward(usize, pos, ptr_width);
212 pos = mem.alignForward(usize, pos, 2);
213213 state.file_off = pos;
214 pos += @sizeOf(Archive.ar_hdr) + path.len + 1;
215 pos = mem.alignForward(usize, pos, ptr_width);
214 pos += @sizeOf(Archive.ar_hdr);
215 pos += mem.alignForward(usize, path.len + 1, ptr_width);
216216 pos += math.cast(usize, state.size) orelse return error.Overflow;
217217 }
218218
......@@ -236,7 +236,7 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ?
236236
237237 // Write object files
238238 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);
240240 const padding = aligned - buffer.items.len;
241241 if (padding > 0) {
242242 try writer.writeByteNTimes(0, padding);