LibAFL icon indicating copy to clipboard operation
LibAFL copied to clipboard

New Pass Manager Arguments

Open tokatoka opened this issue 2 years ago • 4 comments

https://github.com/llvm/llvm-project/issues/56137

The new pass manager still needs -Xclang -load -Xclang -<pass>.so if we want to load additional arguments

tokatoka avatar Aug 12 '22 18:08 tokatoka

@andreafioraldi I get this warnings with clang-14 ~~(not with clang-13)~~, no matter if it is new pm or legacy pm to reproduce: cargo make fuzzer in libfuzzer_libpng_accounting

/edit it happens with clang-13 too

/bin/sh ./libtool  --tag=CC   --mode=link /Users/toka/LibAFL/fuzzers/libfuzzer_libpng_accounting/target/release/libafl_cc  -g -O2   -o timepng contrib/libtests/timepng.o libpng16.la -lz 
libtool: link: /Users/toka/LibAFL/fuzzers/libfuzzer_libpng_accounting/target/release/libafl_cc -g -O2 -o timepng contrib/libtests/timepng.o  ./.libs/libpng16.a -lz
[/Users/toka/LibAFL/libafl_cc/src/lib.rs:170] &args = [
    "/opt/homebrew/Cellar/llvm/14.0.6_1/bin/clang",
    "-g",
    "-O2",
    "-o",
    "timepng",
    "contrib/libtests/timepng.o",
    "./.libs/libpng16.a",
    "-lz",
    "-g",
    "-O3",
    "-funroll-loops",
    "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1",
    "-undefined",
    "dynamic_lookup",
    "-fsanitize-coverage=trace-pc-guard",
    "-flegacy-pass-manager",
    "-Xclang",
    "-load",
    "-Xclang",
    "/Users/toka/LibAFL/fuzzers/libfuzzer_libpng_accounting/target/release/build/libafl_cc-ec68ca7ce527eb70/out/coverage-accounting-pass.dylib",
    "-mllvm",
    "-granularity=FUNC",
    "/Users/toka/LibAFL/fuzzers/libfuzzer_libpng_accounting/target/release/liblibfuzzer_libpng.a",
    "-pthread",
    "-ldl",
]
clang-14: warning: argument unused during compilation: '-mllvm -granularity=FUNC' [-Wunused-command-line-argument]
[/Users/toka/LibAFL/libafl_cc/src/lib.rs:182] status = ExitStatus(
    unix_wait_status(
        0,
    ),
)

I believe it is not a problem because it happens only when linking, and it's fine when compiling (with -c option) but please double check this issue.

tokatoka avatar Aug 12 '22 18:08 tokatoka

Codecov Report

Merging #724 (b0737e3) into main (c1aafe3) will decrease coverage by 0.00%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #724      +/-   ##
==========================================
- Coverage   14.99%   14.98%   -0.01%     
==========================================
  Files         146      146              
  Lines       17381    17386       +5     
==========================================
  Hits         2606     2606              
- Misses      14775    14780       +5     
Impacted Files Coverage Δ
libafl_cc/src/clang.rs 33.33% <0.00%> (-0.84%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Aug 12 '22 18:08 codecov-commenter

to check if the pass is working simply print the arg in the pass and try to change it. if llvm 14 changed the way to pass args i'm unaware of it atm. you can also simply compile things and check with IDA

andreafioraldi avatar Aug 13 '22 00:08 andreafioraldi

To clarify, here are 2 problems The first one is when using the new pass manager, we still need -Xclang -load -Xclang. I din't notice that when I made a pr for new pass manager, but it is fixed in this PR The second problem is with ~clang-14~ I get argument unused during compilation warnings with accounting pass. probabaly it is because the pass is not used when linking.

/edit: today I found I got the warnings in the second problem with clang-13 too

tokatoka avatar Aug 13 '22 09:08 tokatoka

I noticed the arguments unused warning appears with clang-13 too, so it's not that clang/llvm-14 changed the way arguments are passed. so I guess it is not a problem here. if this pr's change is good for you, let's merge this.

tokatoka avatar Aug 13 '22 09:08 tokatoka

What's the status here?

domenukk avatar Aug 18 '22 17:08 domenukk

I think we can merge

tokatoka avatar Aug 18 '22 17:08 tokatoka