aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2024-02-08 22:08:51 +0100
committerJakub Konka <kubkon@jakubkonka.com>2024-02-08 22:08:51 +0100
commit5da9d250ff1f8bcfb4a9e9a6be7393dfbe92f669 (patch)
tree289eaba46ae827534d71618e8f8cab8fc7ffbcee /src
parentdcb7f5791a206d7713bea153a8d94f22dfb155a9 (diff)
downloadzig-5da9d250ff1f8bcfb4a9e9a6be7393dfbe92f669.tar.gz
zig-5da9d250ff1f8bcfb4a9e9a6be7393dfbe92f669.zip
macho: fix incorrect skip conditions for zig and dwarf sections
Diffstat (limited to 'src')
-rw-r--r--src/link/MachO/relocatable.zig12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/link/MachO/relocatable.zig b/src/link/MachO/relocatable.zig
index f6dd2e99e2..c66593f283 100644
--- a/src/link/MachO/relocatable.zig
+++ b/src/link/MachO/relocatable.zig
@@ -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);