commit 227788e6d5025933d6d70086fb939dcf487fee0a (tree)
parent 9bbac4288697f056f0cdb0c6ac597e9b1b18ea12
Author: SuperAuguste <19855629+SuperAuguste@users.noreply.github.com>
Date: Tue, 8 Apr 2025 02:26:23 -0400
Fix mach-o naming for sancov sections
Diffstat:
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
@@ -1471,7 +1471,12 @@ pub const Object = struct {
try o.used.append(gpa, counters_variable.toConst(&o.builder));
counters_variable.setLinkage(.private, &o.builder);
counters_variable.setAlignment(comptime Builder.Alignment.fromByteUnits(1), &o.builder);
- counters_variable.setSection(try o.builder.string("__sancov_cntrs"), &o.builder);
+
+ if (target.ofmt == .macho) {
+ counters_variable.setSection(try o.builder.string("__DATA,__sancov_cntrs"), &o.builder);
+ } else {
+ counters_variable.setSection(try o.builder.string("__sancov_cntrs"), &o.builder);
+ }
break :f .{
.counters_variable = counters_variable,
@@ -1533,7 +1538,11 @@ pub const Object = struct {
pcs_variable.setLinkage(.private, &o.builder);
pcs_variable.setMutability(.constant, &o.builder);
pcs_variable.setAlignment(Type.usize.abiAlignment(zcu).toLlvm(), &o.builder);
- pcs_variable.setSection(try o.builder.string("__sancov_pcs1"), &o.builder);
+ if (target.ofmt == .macho) {
+ pcs_variable.setSection(try o.builder.string("__DATA,__sancov_pcs1"), &o.builder);
+ } else {
+ pcs_variable.setSection(try o.builder.string("__sancov_pcs1"), &o.builder);
+ }
try pcs_variable.setInitializer(init_val, &o.builder);
}