From 4ab34b142ef53ecb5e469b0494e5ab8ff322769c Mon Sep 17 00:00:00 2001 From: SuperAuguste <19855629+SuperAuguste@users.noreply.github.com> Date: Tue, 8 Apr 2025 02:26:23 -0400 Subject: [PATCH] Fix mach-o naming for sancov sections --- src/codegen/llvm.zig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 4cf3f687f9d268c887452037f8a244e5180ab911..52cd4ed0a3745f758c8aad13022eb9d77adc304a 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1769,7 +1769,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, @@ -1831,7 +1836,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); } -- 2.54.0