libafl_cc: fix configuration support (#1595)
* libafl_cc: fix configuration support * fmt * clippy
This commit is contained in:
parent
f35c59131d
commit
a27553daec
@ -194,7 +194,7 @@ impl ToolWrapper for ClangWrapper {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"--libafl-ignore-configurations" => {
|
"--libafl-ignore-configurations" | "-print-prog-name=ld" => {
|
||||||
self.ignoring_configurations = true;
|
self.ignoring_configurations = true;
|
||||||
i += 1;
|
i += 1;
|
||||||
continue;
|
continue;
|
||||||
@ -346,42 +346,51 @@ impl ToolWrapper for ClangWrapper {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
if let crate::Configuration::Default = configuration {
|
||||||
if let Some(output) = self.output.clone() {
|
if let Some(output) = self.output.clone() {
|
||||||
let output = configuration.replace_extension(&output);
|
let output = configuration.replace_extension(&output);
|
||||||
let new_filename = output.into_os_string().into_string().unwrap();
|
let new_filename = output.into_os_string().into_string().unwrap();
|
||||||
args.push("-o".to_string());
|
args.push("-o".to_string());
|
||||||
args.push(new_filename);
|
args.push(new_filename);
|
||||||
args.extend_from_slice(base_args.as_slice());
|
}
|
||||||
} else {
|
} else if let Some(output) = self.output.clone() {
|
||||||
// No output specified, we need to rewrite the single .c file's name.
|
let output = configuration.replace_extension(&output);
|
||||||
args.extend(
|
let new_filename = output.into_os_string().into_string().unwrap();
|
||||||
base_args
|
args.push("-o".to_string());
|
||||||
.iter()
|
args.push(new_filename);
|
||||||
.map(|r| {
|
|
||||||
let arg_as_path = std::path::PathBuf::from(r);
|
|
||||||
if r.ends_with('.') {
|
|
||||||
r.to_string()
|
|
||||||
} else {
|
} else {
|
||||||
|
// No output specified, we need to rewrite the single .c file's name into a -o
|
||||||
|
// argument.
|
||||||
|
for arg in &base_args {
|
||||||
|
let arg_as_path = std::path::PathBuf::from(arg);
|
||||||
|
if !arg.ends_with('.') && !arg.starts_with('-') {
|
||||||
if let Some(extension) = arg_as_path.extension() {
|
if let Some(extension) = arg_as_path.extension() {
|
||||||
let extension = extension.to_str().unwrap();
|
let extension = extension.to_str().unwrap();
|
||||||
let extension_lowercase = extension.to_lowercase();
|
let extension_lowercase = extension.to_lowercase();
|
||||||
match &extension_lowercase[..] {
|
match &extension_lowercase[..] {
|
||||||
"c" | "cc" | "cxx" | "cpp" => {
|
"c" | "cc" | "cxx" | "cpp" => {
|
||||||
configuration.replace_extension(&arg_as_path)
|
args.push("-o".to_string());
|
||||||
}
|
args.push(if self.linking {
|
||||||
_ => arg_as_path,
|
configuration
|
||||||
}
|
.replace_extension(&std::path::PathBuf::from("a.out"))
|
||||||
} else {
|
|
||||||
arg_as_path
|
|
||||||
}
|
|
||||||
.into_os_string()
|
.into_os_string()
|
||||||
.into_string()
|
.into_string()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
} else {
|
||||||
|
let mut result = configuration.replace_extension(&arg_as_path);
|
||||||
|
result.set_extension("o");
|
||||||
|
result.into_os_string().into_string().unwrap()
|
||||||
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
})
|
_ => {}
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args.extend_from_slice(base_args.as_slice());
|
||||||
|
|
||||||
args.extend_from_slice(&configuration.to_flags()?);
|
args.extend_from_slice(&configuration.to_flags()?);
|
||||||
|
|
||||||
|
@ -178,9 +178,7 @@ impl ToolWrapper for LibtoolWrapper {
|
|||||||
let extension = extension.to_str().unwrap();
|
let extension = extension.to_str().unwrap();
|
||||||
let extension_lowercase = extension.to_lowercase();
|
let extension_lowercase = extension.to_lowercase();
|
||||||
match &extension_lowercase[..] {
|
match &extension_lowercase[..] {
|
||||||
"o" | "lo" | "a" | "la" | "so" => {
|
"lo" | "la" | "so" => configuration.replace_extension(&arg_as_path),
|
||||||
configuration.replace_extension(&arg_as_path)
|
|
||||||
}
|
|
||||||
_ => arg_as_path,
|
_ => arg_as_path,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user