authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-08 22:08:51+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-02-08 22:08:51+01:00
log5da9d250ff1f8bcfb4a9e9a6be7393dfbe92f669
tree289eaba46ae827534d71618e8f8cab8fc7ffbcee
parentdcb7f5791a206d7713bea153a8d94f22dfb155a9

macho: fix incorrect skip conditions for zig and dwarf sections


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

src/link/MachO/relocatable.zig+4-8
......@@ -402,8 +402,7 @@ fn calcSectionSizes(macho_file: *MachO) !void {
402402 const atom = macho_file.getAtom(atom_index) orelse continue;
403403 if (!atom.flags.alive) continue;
404404 const header = &macho_file.sections.items(.header)[atom.out_n_sect];
405 if (!macho_file.isZigSection(atom.out_n_sect)) continue;
406 if (!macho_file.isDebugSection(atom.out_n_sect)) continue;
405 if (!macho_file.isZigSection(atom.out_n_sect) and !macho_file.isDebugSection(atom.out_n_sect)) continue;
407406 header.nreloc += atom.calcNumRelocs(macho_file);
408407 }
409408 }
......@@ -542,8 +541,7 @@ fn writeAtoms(macho_file: *MachO) !void {
542541 for (slice.items(.header), slice.items(.atoms), 0..) |header, atoms, i| {
543542 if (atoms.items.len == 0) continue;
544543 if (header.isZerofill()) continue;
545 if (macho_file.isZigSection(@intCast(i))) continue;
546 if (macho_file.isDebugSection(@intCast(i))) continue;
544 if (macho_file.isZigSection(@intCast(i)) or macho_file.isDebugSection(@intCast(i))) continue;
547545
548546 const size = math.cast(usize, header.size) orelse return error.Overflow;
549547 const code = try gpa.alloc(u8, size);
......@@ -584,8 +582,7 @@ fn writeAtoms(macho_file: *MachO) !void {
584582
585583 for (macho_file.sections.items(.header), 0..) |header, n_sect| {
586584 if (header.isZerofill()) continue;
587 if (!macho_file.isZigSection(@intCast(n_sect))) continue;
588 if (!macho_file.isDebugSection(@intCast(n_sect))) continue;
585 if (!macho_file.isZigSection(@intCast(n_sect)) and !macho_file.isDebugSection(@intCast(n_sect))) continue;
589586 const gop = try relocs.getOrPut(@intCast(n_sect));
590587 if (gop.found_existing) continue;
591588 gop.value_ptr.* = try std.ArrayList(macho.relocation_info).initCapacity(gpa, header.nreloc);
......@@ -596,8 +593,7 @@ fn writeAtoms(macho_file: *MachO) !void {
596593 if (!atom.flags.alive) continue;
597594 const header = macho_file.sections.items(.header)[atom.out_n_sect];
598595 if (header.isZerofill()) continue;
599 if (!macho_file.isZigSection(atom.out_n_sect)) continue;
600 if (!macho_file.isDebugSection(atom.out_n_sect)) continue;
596 if (!macho_file.isZigSection(atom.out_n_sect) and !macho_file.isDebugSection(atom.out_n_sect)) continue;
601597 if (atom.getRelocs(macho_file).len == 0) continue;
602598 const atom_size = math.cast(usize, atom.size) orelse return error.Overflow;
603599 const code = try gpa.alloc(u8, atom_size);