File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 108108 .libcxx = .{
109109 .path = "libcxx" ,
110110 },
111+ .libfuzzer = .{
112+ .path = "libfuzzer" ,
113+ },
111114 .load_dynamic_library = .{
112115 .path = "load_dynamic_library" ,
113116 },
Original file line number Diff line number Diff line change 1+ const std = @import ("std" );
2+ const builtin = @import ("builtin" );
3+
4+ pub fn build (b : * std.Build ) void {
5+ const target = b .standardTargetOptions (.{});
6+ const optimize = b .standardOptimizeOption (.{});
7+
8+ if (builtin .os .tag == .windows ) return ; // TODO: libfuzzer support for windows
9+
10+ const run_step = b .step ("run" , "Run executables" );
11+ const exe = b .addExecutable (.{
12+ .name = "main" ,
13+ .root_module = b .createModule (.{
14+ .root_source_file = b .path ("main.zig" ),
15+ .target = target ,
16+ .optimize = optimize ,
17+ .fuzz = true ,
18+ }),
19+ });
20+
21+ b .installArtifact (exe );
22+ b .default_step = run_step ;
23+
24+ const run_artifact = b .addRunArtifact (exe );
25+ run_step .dependOn (& run_artifact .step );
26+ }
Original file line number Diff line number Diff line change 1+ const std = @import ("std" );
2+
3+ const FuzzerSlice = extern struct {
4+ ptr : [* ]const u8 ,
5+ len : usize ,
6+
7+ fn fromSlice (s : []const u8 ) FuzzerSlice {
8+ return .{ .ptr = s .ptr , .len = s .len };
9+ }
10+ };
11+
12+ extern fn fuzzer_set_name (name_ptr : [* ]const u8 , name_len : usize ) void ;
13+ extern fn fuzzer_init (cache_dir : FuzzerSlice ) void ;
14+ extern fn fuzzer_init_corpus_elem (input_ptr : [* ]const u8 , input_len : usize ) void ;
15+ extern fn fuzzer_coverage_id () u64 ;
16+
17+ pub fn main () ! void {
18+ fuzzer_init (FuzzerSlice .fromSlice ("" ));
19+ fuzzer_init_corpus_elem ("hello" .ptr , "hello" .len );
20+ fuzzer_set_name ("test" .ptr , "test" .len );
21+ _ = fuzzer_coverage_id ();
22+ }
You can’t perform that action at this time.
0 commit comments