mirror of
https://github.com/ziglang/zig.git
synced 2026-01-09 17:05:16 +00:00
macho: fix incorrect skip conditions for zig and dwarf sections
This commit is contained in:
parent
dcb7f5791a
commit
5da9d250ff
@ -402,8 +402,7 @@ fn calcSectionSizes(macho_file: *MachO) !void {
|
||||
const atom = macho_file.getAtom(atom_index) orelse continue;
|
||||
if (!atom.flags.alive) continue;
|
||||
const header = &macho_file.sections.items(.header)[atom.out_n_sect];
|
||||
if (!macho_file.isZigSection(atom.out_n_sect)) continue;
|
||||
if (!macho_file.isDebugSection(atom.out_n_sect)) continue;
|
||||
if (!macho_file.isZigSection(atom.out_n_sect) and !macho_file.isDebugSection(atom.out_n_sect)) continue;
|
||||
header.nreloc += atom.calcNumRelocs(macho_file);
|
||||
}
|
||||
}
|
||||
@ -542,8 +541,7 @@ fn writeAtoms(macho_file: *MachO) !void {
|
||||
for (slice.items(.header), slice.items(.atoms), 0..) |header, atoms, i| {
|
||||
if (atoms.items.len == 0) continue;
|
||||
if (header.isZerofill()) continue;
|
||||
if (macho_file.isZigSection(@intCast(i))) continue;
|
||||
if (macho_file.isDebugSection(@intCast(i))) continue;
|
||||
if (macho_file.isZigSection(@intCast(i)) or macho_file.isDebugSection(@intCast(i))) continue;
|
||||
|
||||
const size = math.cast(usize, header.size) orelse return error.Overflow;
|
||||
const code = try gpa.alloc(u8, size);
|
||||
@ -584,8 +582,7 @@ fn writeAtoms(macho_file: *MachO) !void {
|
||||
|
||||
for (macho_file.sections.items(.header), 0..) |header, n_sect| {
|
||||
if (header.isZerofill()) continue;
|
||||
if (!macho_file.isZigSection(@intCast(n_sect))) continue;
|
||||
if (!macho_file.isDebugSection(@intCast(n_sect))) continue;
|
||||
if (!macho_file.isZigSection(@intCast(n_sect)) and !macho_file.isDebugSection(@intCast(n_sect))) continue;
|
||||
const gop = try relocs.getOrPut(@intCast(n_sect));
|
||||
if (gop.found_existing) continue;
|
||||
gop.value_ptr.* = try std.ArrayList(macho.relocation_info).initCapacity(gpa, header.nreloc);
|
||||
@ -596,8 +593,7 @@ fn writeAtoms(macho_file: *MachO) !void {
|
||||
if (!atom.flags.alive) continue;
|
||||
const header = macho_file.sections.items(.header)[atom.out_n_sect];
|
||||
if (header.isZerofill()) continue;
|
||||
if (!macho_file.isZigSection(atom.out_n_sect)) continue;
|
||||
if (!macho_file.isDebugSection(atom.out_n_sect)) continue;
|
||||
if (!macho_file.isZigSection(atom.out_n_sect) and !macho_file.isDebugSection(atom.out_n_sect)) continue;
|
||||
if (atom.getRelocs(macho_file).len == 0) continue;
|
||||
const atom_size = math.cast(usize, atom.size) orelse return error.Overflow;
|
||||
const code = try gpa.alloc(u8, atom_size);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user