Skip to content

Commit

Permalink
Don't add llvm pass args when there're no passes & Don't pass `-mllvm…
Browse files Browse the repository at this point in the history
…` arguments when compiling asm files (#1266)

* f

* fix

* clp
  • Loading branch information
tokatoka committed May 12, 2023
1 parent 91b10f8 commit b9a5405
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions libafl_cc/src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct ClangWrapper {

name: String,
is_cpp: bool,
is_asm: bool,
linking: bool,
shared: bool,
x_set: bool,
Expand Down Expand Up @@ -143,6 +144,13 @@ impl CompilerWrapper for ClangWrapper {
let mut suppress_linking = 0;
let mut i = 1;
while i < args.len() {
if std::path::Path::new(args[i].as_ref())
.extension()
.map_or(false, |ext| ext.eq_ignore_ascii_case("s"))
{
self.is_asm = true;
}

match args[i].as_ref() {
"--libafl-no-link" => {
suppress_linking += 1;
Expand Down Expand Up @@ -336,9 +344,11 @@ impl CompilerWrapper for ClangWrapper {
args.push(pass.path().into_os_string().into_string().unwrap());
}
}
for passes_arg in &self.passes_args {
args.push("-mllvm".into());
args.push(passes_arg.into());
if !self.is_asm && !self.passes.is_empty() {
for passes_arg in &self.passes_args {
args.push("-mllvm".into());
args.push(passes_arg.into());
}
}
if self.linking {
if self.x_set {
Expand Down Expand Up @@ -399,6 +409,7 @@ impl ClangWrapper {
wrapped_cxx: CLANGXX_PATH.into(),
name: String::new(),
is_cpp: false,
is_asm: false,
linking: false,
shared: false,
x_set: false,
Expand Down

0 comments on commit b9a5405

Please sign in to comment.