@@ -39,7 +39,7 @@ pub fn check_binary(opt: &mut Opt, shmem_env_var: &str) -> Result<(), Error> {
39
39
}
40
40
} else {
41
41
bin_path = & opt. executable ;
42
- #[ cfg( target_os = "linux " ) ]
42
+ #[ cfg( feature = "nyx " ) ]
43
43
{
44
44
if opt. nyx_mode {
45
45
if !bin_path. is_symlink ( ) && bin_path. is_dir ( ) {
@@ -91,7 +91,7 @@ pub fn check_binary(opt: &mut Opt, shmem_env_var: &str) -> Result<(), Error> {
91
91
}
92
92
93
93
// check if the binary is an ELF file
94
- #[ cfg( target_os = "linux " ) ]
94
+ #[ cfg( feature = "nyx " ) ]
95
95
if mmap[ 0 ..4 ] != [ 0x7f , 0x45 , 0x4c , 0x46 ] {
96
96
return Err ( Error :: illegal_argument ( format ! (
97
97
"Program '{}' is not an ELF binary" ,
@@ -117,7 +117,7 @@ pub fn check_binary(opt: &mut Opt, shmem_env_var: &str) -> Result<(), Error> {
117
117
&& !opt. forkserver_cs
118
118
&& !opt. non_instrumented_mode ;
119
119
120
- #[ cfg( target_os = "linux " ) ]
120
+ #[ cfg( feature = "nyx " ) ]
121
121
let check_instrumentation = check_instrumentation && !opt. nyx_mode ;
122
122
123
123
if check_instrumentation && !is_instrumented ( & mmap, shmem_env_var) {
@@ -252,19 +252,21 @@ fn check_file_found(file: &Path, perm: u32) -> bool {
252
252
false
253
253
}
254
254
255
+ #[ cfg( feature = "nyx" ) ]
255
256
pub enum SupportedExecutors < S , OT , FSV , NYX > {
256
- Forkserver ( FSV , PhantomData < ( S , OT ) > ) ,
257
- #[ cfg( target_os = "linux" ) ]
257
+ Forkserver ( FSV , PhantomData < ( S , OT , NYX ) > ) ,
258
258
Nyx ( NYX ) ,
259
259
}
260
260
261
+ #[ cfg( feature = "nyx" ) ]
261
262
impl < S , OT , FSV , NYX > UsesState for SupportedExecutors < S , OT , FSV , NYX >
262
263
where
263
264
S : State ,
264
265
{
265
266
type State = S ;
266
267
}
267
268
269
+ #[ cfg( feature = "nyx" ) ]
268
270
impl < S , OT , FSV , NYX , EM , Z > Executor < EM , Z > for SupportedExecutors < S , OT , FSV , NYX >
269
271
where
270
272
S : State ,
@@ -282,12 +284,13 @@ where
282
284
) -> Result < ExitKind , Error > {
283
285
match self {
284
286
Self :: Forkserver ( fsrv, _) => fsrv. run_target ( fuzzer, state, mgr, input) ,
285
- #[ cfg( target_os = "linux " ) ]
287
+ #[ cfg( feature = "nyx " ) ]
286
288
Self :: Nyx ( nyx) => nyx. run_target ( fuzzer, state, mgr, input) ,
287
289
}
288
290
}
289
291
}
290
292
293
+ #[ cfg( feature = "nyx" ) ]
291
294
impl < S , OT , FSV , NYX > HasObservers for SupportedExecutors < S , OT , FSV , NYX >
292
295
where
293
296
OT : ObserversTuple < S :: Input , S > ,
@@ -300,7 +303,7 @@ where
300
303
fn observers ( & self ) -> RefIndexable < & Self :: Observers , Self :: Observers > {
301
304
match self {
302
305
Self :: Forkserver ( fsrv, _) => fsrv. observers ( ) ,
303
- #[ cfg( target_os = "linux " ) ]
306
+ #[ cfg( feature = "nyx " ) ]
304
307
Self :: Nyx ( nyx) => nyx. observers ( ) ,
305
308
}
306
309
}
@@ -309,12 +312,13 @@ where
309
312
fn observers_mut ( & mut self ) -> RefIndexable < & mut Self :: Observers , Self :: Observers > {
310
313
match self {
311
314
Self :: Forkserver ( fsrv, _) => fsrv. observers_mut ( ) ,
312
- #[ cfg( target_os = "linux " ) ]
315
+ #[ cfg( feature = "nyx " ) ]
313
316
Self :: Nyx ( nyx) => nyx. observers_mut ( ) ,
314
317
}
315
318
}
316
319
}
317
320
321
+ #[ cfg( feature = "nyx" ) ]
318
322
impl < S , OT , FSV , NYX > HasTimeout for SupportedExecutors < S , OT , FSV , NYX >
319
323
where
320
324
FSV : HasTimeout ,
@@ -323,15 +327,89 @@ where
323
327
fn set_timeout ( & mut self , timeout : std:: time:: Duration ) {
324
328
match self {
325
329
Self :: Forkserver ( fsrv, _) => fsrv. set_timeout ( timeout) ,
326
- #[ cfg( target_os = "linux " ) ]
330
+ #[ cfg( feature = "nyx " ) ]
327
331
Self :: Nyx ( nyx) => nyx. set_timeout ( timeout) ,
328
332
}
329
333
}
330
334
fn timeout ( & self ) -> std:: time:: Duration {
331
335
match self {
332
336
Self :: Forkserver ( fsrv, _) => fsrv. timeout ( ) ,
333
- #[ cfg( target_os = "linux " ) ]
337
+ #[ cfg( feature = "nyx " ) ]
334
338
Self :: Nyx ( nyx) => nyx. timeout ( ) ,
335
339
}
336
340
}
337
341
}
342
+
343
+ #[ cfg( not( feature = "nyx" ) ) ]
344
+ impl < S , OT , FSV > UsesState for SupportedExecutors < S , OT , FSV >
345
+ where
346
+ S : State ,
347
+ {
348
+ type State = S ;
349
+ }
350
+
351
+ #[ cfg( not( feature = "nyx" ) ) ]
352
+ pub enum SupportedExecutors < S , OT , FSV > {
353
+ Forkserver ( FSV , PhantomData < ( S , OT ) > ) ,
354
+ }
355
+
356
+ #[ cfg( not( feature = "nyx" ) ) ]
357
+ impl < S , OT , FSV , EM , Z > Executor < EM , Z > for SupportedExecutors < S , OT , FSV >
358
+ where
359
+ S : State ,
360
+ Z : UsesState < State = S > ,
361
+ EM : UsesState < State = S > ,
362
+ FSV : Executor < EM , Z , State = S > ,
363
+ {
364
+ fn run_target (
365
+ & mut self ,
366
+ fuzzer : & mut Z ,
367
+ state : & mut S ,
368
+ mgr : & mut EM ,
369
+ input : & S :: Input ,
370
+ ) -> Result < ExitKind , Error > {
371
+ match self {
372
+ Self :: Forkserver ( fsrv, _) => fsrv. run_target ( fuzzer, state, mgr, input) ,
373
+ }
374
+ }
375
+ }
376
+
377
+ #[ cfg( not( feature = "nyx" ) ) ]
378
+ impl < S , OT , FSV > HasObservers for SupportedExecutors < S , OT , FSV >
379
+ where
380
+ OT : ObserversTuple < S :: Input , S > ,
381
+ S : State ,
382
+ FSV : HasObservers < Observers = OT > ,
383
+ {
384
+ type Observers = OT ;
385
+ #[ inline]
386
+ fn observers ( & self ) -> RefIndexable < & Self :: Observers , Self :: Observers > {
387
+ match self {
388
+ Self :: Forkserver ( fsrv, _) => fsrv. observers ( ) ,
389
+ }
390
+ }
391
+
392
+ #[ inline]
393
+ fn observers_mut ( & mut self ) -> RefIndexable < & mut Self :: Observers , Self :: Observers > {
394
+ match self {
395
+ Self :: Forkserver ( fsrv, _) => fsrv. observers_mut ( ) ,
396
+ }
397
+ }
398
+ }
399
+
400
+ #[ cfg( not( feature = "nyx" ) ) ]
401
+ impl < S , OT , FSV > HasTimeout for SupportedExecutors < S , OT , FSV >
402
+ where
403
+ FSV : HasTimeout ,
404
+ {
405
+ fn set_timeout ( & mut self , timeout : std:: time:: Duration ) {
406
+ match self {
407
+ Self :: Forkserver ( fsrv, _) => fsrv. set_timeout ( timeout) ,
408
+ }
409
+ }
410
+ fn timeout ( & self ) -> std:: time:: Duration {
411
+ match self {
412
+ Self :: Forkserver ( fsrv, _) => fsrv. timeout ( ) ,
413
+ }
414
+ }
415
+ }
0 commit comments