Skip to content

Commit 227788e

Browse files
SuperAugustealexrp
authored andcommitted
Fix mach-o naming for sancov sections
1 parent 9bbac42 commit 227788e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/codegen/llvm.zig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,12 @@ pub const Object = struct {
14711471
try o.used.append(gpa, counters_variable.toConst(&o.builder));
14721472
counters_variable.setLinkage(.private, &o.builder);
14731473
counters_variable.setAlignment(comptime Builder.Alignment.fromByteUnits(1), &o.builder);
1474-
counters_variable.setSection(try o.builder.string("__sancov_cntrs"), &o.builder);
1474+
1475+
if (target.ofmt == .macho) {
1476+
counters_variable.setSection(try o.builder.string("__DATA,__sancov_cntrs"), &o.builder);
1477+
} else {
1478+
counters_variable.setSection(try o.builder.string("__sancov_cntrs"), &o.builder);
1479+
}
14751480

14761481
break :f .{
14771482
.counters_variable = counters_variable,
@@ -1533,7 +1538,11 @@ pub const Object = struct {
15331538
pcs_variable.setLinkage(.private, &o.builder);
15341539
pcs_variable.setMutability(.constant, &o.builder);
15351540
pcs_variable.setAlignment(Type.usize.abiAlignment(zcu).toLlvm(), &o.builder);
1536-
pcs_variable.setSection(try o.builder.string("__sancov_pcs1"), &o.builder);
1541+
if (target.ofmt == .macho) {
1542+
pcs_variable.setSection(try o.builder.string("__DATA,__sancov_pcs1"), &o.builder);
1543+
} else {
1544+
pcs_variable.setSection(try o.builder.string("__sancov_pcs1"), &o.builder);
1545+
}
15371546
try pcs_variable.setInitializer(init_val, &o.builder);
15381547
}
15391548

0 commit comments

Comments
 (0)