@@ -194,7 +194,7 @@ impl ToolWrapper for ClangWrapper {
194
194
continue ;
195
195
}
196
196
}
197
- "--libafl-ignore-configurations" => {
197
+ "--libafl-ignore-configurations" | "-print-prog-name=ld" => {
198
198
self . ignoring_configurations = true ;
199
199
i += 1 ;
200
200
continue ;
@@ -346,43 +346,52 @@ impl ToolWrapper for ClangWrapper {
346
346
} )
347
347
. collect :: < Vec < _ > > ( ) ;
348
348
349
- if let Some ( output) = self . output . clone ( ) {
349
+ if let crate :: Configuration :: Default = configuration {
350
+ if let Some ( output) = self . output . clone ( ) {
351
+ let output = configuration. replace_extension ( & output) ;
352
+ let new_filename = output. into_os_string ( ) . into_string ( ) . unwrap ( ) ;
353
+ args. push ( "-o" . to_string ( ) ) ;
354
+ args. push ( new_filename) ;
355
+ }
356
+ } else if let Some ( output) = self . output . clone ( ) {
350
357
let output = configuration. replace_extension ( & output) ;
351
358
let new_filename = output. into_os_string ( ) . into_string ( ) . unwrap ( ) ;
352
359
args. push ( "-o" . to_string ( ) ) ;
353
360
args. push ( new_filename) ;
354
- args. extend_from_slice ( base_args. as_slice ( ) ) ;
355
361
} else {
356
- // No output specified, we need to rewrite the single .c file's name.
357
- args. extend (
358
- base_args
359
- . iter ( )
360
- . map ( |r| {
361
- let arg_as_path = std:: path:: PathBuf :: from ( r) ;
362
- if r. ends_with ( '.' ) {
363
- r. to_string ( )
364
- } else {
365
- if let Some ( extension) = arg_as_path. extension ( ) {
366
- let extension = extension. to_str ( ) . unwrap ( ) ;
367
- let extension_lowercase = extension. to_lowercase ( ) ;
368
- match & extension_lowercase[ ..] {
369
- "c" | "cc" | "cxx" | "cpp" => {
370
- configuration. replace_extension ( & arg_as_path)
371
- }
372
- _ => arg_as_path,
373
- }
374
- } else {
375
- arg_as_path
362
+ // No output specified, we need to rewrite the single .c file's name into a -o
363
+ // argument.
364
+ for arg in & base_args {
365
+ let arg_as_path = std:: path:: PathBuf :: from ( arg) ;
366
+ if !arg. ends_with ( '.' ) && !arg. starts_with ( '-' ) {
367
+ if let Some ( extension) = arg_as_path. extension ( ) {
368
+ let extension = extension. to_str ( ) . unwrap ( ) ;
369
+ let extension_lowercase = extension. to_lowercase ( ) ;
370
+ match & extension_lowercase[ ..] {
371
+ "c" | "cc" | "cxx" | "cpp" => {
372
+ args. push ( "-o" . to_string ( ) ) ;
373
+ args. push ( if self . linking {
374
+ configuration
375
+ . replace_extension ( & std:: path:: PathBuf :: from ( "a.out" ) )
376
+ . into_os_string ( )
377
+ . into_string ( )
378
+ . unwrap ( )
379
+ } else {
380
+ let mut result = configuration. replace_extension ( & arg_as_path) ;
381
+ result. set_extension ( "o" ) ;
382
+ result. into_os_string ( ) . into_string ( ) . unwrap ( )
383
+ } ) ;
384
+ break ;
376
385
}
377
- . into_os_string ( )
378
- . into_string ( )
379
- . unwrap ( )
386
+ _ => { }
380
387
}
381
- } )
382
- . collect :: < Vec < _ > > ( ) ,
383
- ) ;
388
+ }
389
+ }
390
+ }
384
391
}
385
392
393
+ args. extend_from_slice ( base_args. as_slice ( ) ) ;
394
+
386
395
args. extend_from_slice ( & configuration. to_flags ( ) ?) ;
387
396
388
397
if self . need_libafl_arg && !self . has_libafl_arg {
0 commit comments