Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add llvm pass args when there're no passes & Don't pass -mllvm arguments when compiling asm files #1266

Merged
merged 3 commits into from
May 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading