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