@@ -78,11 +78,24 @@ pub fn rust_libfuzzer_debug_path() -> &'static Option<String> {
78
78
RUST_LIBFUZZER_DEBUG_PATH . get_or_init ( || std:: env:: var ( "RUST_LIBFUZZER_DEBUG_PATH" ) . ok ( ) )
79
79
}
80
80
81
- /* #[doc(hidden)]
82
- #[export_name = "LLVMFuzzerInitialize"]
81
+ #[ doc( hidden) ]
82
+ // #[export_name = "LLVMFuzzerInitialize"]
83
83
pub fn initialize ( _argc : * const isize , _argv : * const * const * const u8 ) -> isize {
84
+ // Registers a panic hook that aborts the process before unwinding.
85
+ // It is useful to abort before unwinding so that the fuzzer will then be
86
+ // able to analyse the process stack frames to tell different bugs appart.
87
+ //
88
+ // HACK / FIXME: it would be better to use `-C panic=abort` but it's currently
89
+ // impossible to build code using compiler plugins with this flag.
90
+ // We will be able to remove this code when
91
+ // https://github.com/rust-lang/cargo/issues/5423 is fixed.
92
+ let default_hook = std:: panic:: take_hook ( ) ;
93
+ std:: panic:: set_hook ( Box :: new ( move |panic_info| {
94
+ default_hook ( panic_info) ;
95
+ std:: process:: abort ( ) ;
96
+ } ) ) ;
84
97
0
85
- } */
98
+ }
86
99
87
100
/// Define a fuzz target.
88
101
///
@@ -191,19 +204,7 @@ macro_rules! fuzz_target {
191
204
/// LLVMFuzzerInitialize is called once before the fuzzer starts.
192
205
#[ no_mangle]
193
206
pub extern "C" fn LLVMFuzzerInitialize ( _argc: * const isize , _argv: * const * const * const u8 ) -> isize {
194
- // Registers a panic hook that aborts the process before unwinding.
195
- // It is useful to abort before unwinding so that the fuzzer will then be
196
- // able to analyse the process stack frames to tell different bugs appart.
197
- //
198
- // HACK / FIXME: it would be better to use `-C panic=abort` but it's currently
199
- // impossible to build code using compiler plugins with this flag.
200
- // We will be able to remove this code when
201
- // https://github.com/rust-lang/cargo/issues/5423 is fixed.
202
- let default_hook = std:: panic:: take_hook( ) ;
203
- std:: panic:: set_hook( Box :: new( move |panic_info| {
204
- default_hook( panic_info) ;
205
- std:: process:: abort( ) ;
206
- } ) ) ;
207
+ $crate:: initialize( _argc, _argv) ;
207
208
208
209
// Supplied init code
209
210
$init;
@@ -275,19 +276,7 @@ macro_rules! fuzz_target {
275
276
/// LLVMFuzzerInitialize is called once before the fuzzer starts.
276
277
#[ no_mangle]
277
278
pub extern "C" fn LLVMFuzzerInitialize ( _argc: * const isize , _argv: * const * const * const u8 ) -> isize {
278
- // Registers a panic hook that aborts the process before unwinding.
279
- // It is useful to abort before unwinding so that the fuzzer will then be
280
- // able to analyse the process stack frames to tell different bugs appart.
281
- //
282
- // HACK / FIXME: it would be better to use `-C panic=abort` but it's currently
283
- // impossible to build code using compiler plugins with this flag.
284
- // We will be able to remove this code when
285
- // https://github.com/rust-lang/cargo/issues/5423 is fixed.
286
- let default_hook = std:: panic:: take_hook( ) ;
287
- std:: panic:: set_hook( Box :: new( move |panic_info| {
288
- default_hook( panic_info) ;
289
- std:: process:: abort( ) ;
290
- } ) ) ;
279
+ $crate:: initialize( _argc, _argv) ;
291
280
292
281
// Supplied init code
293
282
$init;
0 commit comments