rust-fuzz / afl.rs

🐇 Fuzzing Rust code with American Fuzzy Lop
https://rust-fuzz.github.io/book/afl.html
Apache License 2.0
1.64k stars 107 forks source link

symbol not found issue when building fuzz target with plugins #539

Open 0xalpharush opened 4 days ago

0xalpharush commented 4 days ago

I ran cargo +nightly afl config --build --plugins successfully in order to use AFL++'s instrumentation passes. When I run cargo afl build, I get the following error:

error: failed to run LLVM passes: Could not load library '~/.local/share/afl.rs/rustc-1.83.0-nightly-6f4ae0f/afl.rs-0.15.10/afl-llvm/cmplog-instructions-pass.so': dlopen(~/.local/share/afl.rs/rustc-1.83.0-nightly-6f4ae0f/afl.rs-0.15.10/afl-llvm/cmplog-instructions-pass.so, 0x0009): symbol not found in flat namespace '__ZN4llvm17PreservedAnalyses14AllAnalysesKeyE'

There is a similarly named symbol in the share library:

$ llvm-nm ~/.local/share/afl.rs/rustc-1.83.0-nightly-6f4ae0f/afl.rs-0.15.10/afl-llvm/cmplog-instructions-pass.so | rustfilt | grep "PreservedAnalyses"
                 U _llvm::PreservedAnalyses::AllAnalysesKey

I'm not sure how to resolve this... Maybe I need to install a specific rustc/llvm/afl-rs for them to cooperate? Any help is greatly appreciated!

If I try to build with LLVM 18.1.8 I get: called `Result::unwrap()` on an `Err` value: llvm-config --version output does not contain expected major version (19)

Fwiw, here's where the name appears in the AFLPlusPlus codebase https://github.com/search?q=repo%3AAFLplusplus%2FAFLplusplus+PreservedAnalyses&type=code

Other background that may be useful:

$ llvm-config --version                                                            
19.1.1
$ rustup show
active toolchain
----------------

nightly-aarch64-apple-darwin (default)
rustc 1.83.0-nightly (6f4ae0f34 2024-10-08)
$ rustup component add llvm-tools-preview
info: component 'llvm-tools' for target 'aarch64-apple-darwin' is up to date
$ echo $LLVM_CONFIG 
llvm-config
smoelius commented 4 days ago

Hi, @0xalpharush. Plugins are currently only supported on Linux (though this needs to be better documented).

We don't test the plugins on macOS in CI for this reason: https://github.com/rust-fuzz/afl.rs/blob/4e02a9721fc33c02d5551eed45160c592fb63fb7/.github/workflows/rust.yml#L37-L39

I hope this hasn't caused you to lose too much time.