@@ -468,27 +468,42 @@ export fn fuzzer_init(cache_dir_struct: Fuzzer.Slice) void {
468
468
// Linkers are expected to automatically add `__start_<section>` and
469
469
// `__stop_<section>` symbols when section names are valid C identifiers.
470
470
471
+ const ofmt = builtin .object_format ;
472
+
473
+ const start_symbol_prefix : []const u8 = if (ofmt == .macho )
474
+ "\x01 section$start$__DATA$__"
475
+ else
476
+ "__start___" ;
477
+ const end_symbol_prefix : []const u8 = if (ofmt == .macho )
478
+ "\x01 section$end$__DATA$__"
479
+ else
480
+ "__end___" ;
481
+
482
+ const pc_counters_start_name = start_symbol_prefix ++ "sancov_cntrs" ;
471
483
const pc_counters_start = @extern ([* ]u8 , .{
472
- .name = "__start___sancov_cntrs" ,
484
+ .name = pc_counters_start_name ,
473
485
.linkage = .weak ,
474
- }) orelse fatal ("missing __start___sancov_cntrs symbol" , .{});
486
+ }) orelse fatal ("missing {s} symbol" , .{pc_counters_start_name });
475
487
488
+ const pc_counters_end_name = end_symbol_prefix ++ "sancov_cntrs" ;
476
489
const pc_counters_end = @extern ([* ]u8 , .{
477
- .name = "__stop___sancov_cntrs" ,
490
+ .name = pc_counters_end_name ,
478
491
.linkage = .weak ,
479
- }) orelse fatal ("missing __stop___sancov_cntrs symbol" , .{});
492
+ }) orelse fatal ("missing {s} symbol" , .{pc_counters_end_name });
480
493
481
494
const pc_counters = pc_counters_start [0 .. pc_counters_end - pc_counters_start ];
482
495
496
+ const pcs_start_name = start_symbol_prefix ++ "sancov_pcs1" ;
483
497
const pcs_start = @extern ([* ]usize , .{
484
- .name = "__start___sancov_pcs1" ,
498
+ .name = pcs_start_name ,
485
499
.linkage = .weak ,
486
- }) orelse fatal ("missing __start___sancov_pcs1 symbol" , .{});
500
+ }) orelse fatal ("missing {s} symbol" , .{pcs_start_name });
487
501
502
+ const pcs_end_name = end_symbol_prefix ++ "sancov_pcs1" ;
488
503
const pcs_end = @extern ([* ]usize , .{
489
- .name = "__stop___sancov_pcs1" ,
504
+ .name = pcs_end_name ,
490
505
.linkage = .weak ,
491
- }) orelse fatal ("missing __stop___sancov_pcs1 symbol" , .{});
506
+ }) orelse fatal ("missing {s} symbol" , .{pcs_end_name });
492
507
493
508
const pcs = pcs_start [0 .. pcs_end - pcs_start ];
494
509
0 commit comments