authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-07-13 10:00:38+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-07-18 09:13:08+02:00
log84189f9d56f207e92d0a9d1f5145079cc46f8db0
treec52d002b877432631c7a1f90ce5ec3b4cc3cf56f
parent129fe8668c8b4835c11c50360ee4ed36972ae773

macho: skip resizing incremental Zig sections in r mode


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

src/link/MachO/relocatable.zig+6-4
...@@ -637,11 +637,13 @@ fn writeSections(macho_file: *MachO) !void {...@@ -637,11 +637,13 @@ fn writeSections(macho_file: *MachO) !void {
637 const gpa = macho_file.base.comp.gpa;637 const gpa = macho_file.base.comp.gpa;
638 const cpu_arch = macho_file.getTarget().cpu.arch;638 const cpu_arch = macho_file.getTarget().cpu.arch;
639 const slice = macho_file.sections.slice();639 const slice = macho_file.sections.slice();
640 for (slice.items(.header), slice.items(.out), slice.items(.relocs)) |header, *out, *relocs| {640 for (slice.items(.header), slice.items(.out), slice.items(.relocs), 0..) |header, *out, *relocs, n_sect| {
641 if (header.isZerofill()) continue;641 if (header.isZerofill()) continue;
642 try out.resize(gpa, header.size);642 if (!macho_file.isZigSection(@intCast(n_sect))) { // TODO this is wrong; what about debug sections?
643 const padding_byte: u8 = if (header.isCode() and cpu_arch == .x86_64) 0xcc else 0;643 try out.resize(gpa, header.size);
644 @memset(out.items, padding_byte);644 const padding_byte: u8 = if (header.isCode() and cpu_arch == .x86_64) 0xcc else 0;
645 @memset(out.items, padding_byte);
646 }
645 try relocs.resize(gpa, header.nreloc);647 try relocs.resize(gpa, header.nreloc);
646 }648 }
647649