aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp2
-rw-r--r--CHANGELOG.md13
-rw-r--r--Cargo.toml4
-rw-r--r--Cargo.toml.orig4
-rw-r--r--METADATA23
-rw-r--r--README.md23
-rw-r--r--build.rs8
-rw-r--r--src/lib.rs10
9 files changed, 66 insertions, 23 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index f360df2..6e92d7a 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "e07c487220402f5bec2151de2856a7caff0639c6"
+ "sha1": "35f109932c05522e832d9e43a39aeb29aa663cd2"
},
"path_in_vcs": ""
} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 335a89e..9f9e5a6 100644
--- a/Android.bp
+++ b/Android.bp
@@ -39,7 +39,7 @@ rust_library_rlib {
host_supported: true,
crate_name: "libfuzzer_sys",
cargo_env_compat: true,
- cargo_pkg_version: "0.4.6",
+ cargo_pkg_version: "0.4.7",
srcs: ["src/lib.rs"],
edition: "2018",
features: ["arbitrary-derive"],
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0fba42c..697e71b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,19 @@ Released YYYY-MM-DD.
--------------------------------------------------------------------------------
+## 0.4.7
+
+Released 2023-08-10.
+
+### Added
+
+* Added the `link_libfuzzer` cargo feature. This feature is on by default and
+ preserves the existing behavior of statically linking libfuzzer. You can
+ disable it if you are linking your own version of libfuzzer some other way, or
+ another library that provides the same ABI as libfuzzer.
+
+--------------------------------------------------------------------------------
+
## 0.4.6
Released 2023-01-26.
diff --git a/Cargo.toml b/Cargo.toml
index b53945d..75b6a16 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "libfuzzer-sys"
-version = "0.4.6"
+version = "0.4.7"
authors = ["The rust-fuzz Project Developers"]
description = "A wrapper around LLVM's libFuzzer runtime."
readme = "./README.md"
@@ -37,3 +37,5 @@ features = ["parallel"]
[features]
arbitrary-derive = ["arbitrary/derive"]
+default = ["link_libfuzzer"]
+link_libfuzzer = []
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 1552302..9aaf813 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -6,7 +6,7 @@ license = "MIT/Apache-2.0/NCSA"
name = "libfuzzer-sys"
readme = "./README.md"
repository = "https://github.com/rust-fuzz/libfuzzer"
-version = "0.4.6"
+version = "0.4.7"
[dependencies]
arbitrary = "1"
@@ -16,6 +16,8 @@ once_cell = "1"
cc = { version = "1.0", features = ["parallel"] }
[features]
+default = ["link_libfuzzer"]
+link_libfuzzer = []
arbitrary-derive = ["arbitrary/derive"]
[workspace]
diff --git a/METADATA b/METADATA
index 02cbb38..284ba1f 100644
--- a/METADATA
+++ b/METADATA
@@ -1,23 +1,20 @@
# This project was upgraded with external_updater.
-# Usage: tools/external_updater/updater.sh update rust/crates/libfuzzer-sys
-# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+# Usage: tools/external_updater/updater.sh update external/rust/crates/libfuzzer-sys
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
name: "libfuzzer-sys"
description: "A wrapper around LLVM\'s libFuzzer runtime."
third_party {
- url {
- type: HOMEPAGE
- value: "https://crates.io/crates/libfuzzer-sys"
- }
- url {
- type: ARCHIVE
- value: "https://static.crates.io/crates/libfuzzer-sys/libfuzzer-sys-0.4.6.crate"
- }
- version: "0.4.6"
license_type: NOTICE
last_upgrade_date {
- year: 2023
+ year: 2024
month: 2
- day: 16
+ day: 2
+ }
+ homepage: "https://crates.io/crates/libfuzzer-sys"
+ identifier {
+ type: "Archive"
+ value: "https://static.crates.io/crates/libfuzzer-sys/libfuzzer-sys-0.4.7.crate"
+ version: "0.4.7"
}
}
diff --git a/README.md b/README.md
index 8bdba6e..db6f7f5 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,29 @@ And finally, run the fuzzer:
$ ./target/debug/fuzzed
```
+### Linking to a local libfuzzer
+
+When using `libfuzzer-sys`, you can provide your own `libfuzzer` runtime in two ways.
+
+If you are developing a fuzzer, you can set the `CUSTOM_LIBFUZZER_PATH` environment variable to the path of your local
+`libfuzzer` runtime, which will then be linked instead of building libfuzzer as part of the build stage of `libfuzzer-sys`.
+For an example, to link to a prebuilt LLVM 16 `libfuzzer`, you could use:
+
+```bash
+$ export CUSTOM_LIBFUZZER_PATH=/usr/lib64/clang/16/lib/libclang_rt.fuzzer-x86_64.a
+$ cargo fuzz run ...
+```
+
+Alternatively, you may also disable the default `link_libfuzzer` feature:
+
+In `Cargo.toml`:
+```toml
+[dependencies]
+libfuzzer-sys = { path = "../../libfuzzer", default-features = false }
+```
+
+Then link to your own runtime in your `build.rs`.
+
## Updating libfuzzer from upstream
```
diff --git a/build.rs b/build.rs
index ab1bbc5..e549e3f 100644
--- a/build.rs
+++ b/build.rs
@@ -1,4 +1,4 @@
-fn main() {
+fn build_and_link_libfuzzer() {
println!("cargo:rerun-if-env-changed=CUSTOM_LIBFUZZER_PATH");
if let Ok(custom) = ::std::env::var("CUSTOM_LIBFUZZER_PATH") {
println!("cargo:rerun-if-changed={custom}");
@@ -38,3 +38,9 @@ fn main() {
build.compile("libfuzzer.a");
}
}
+
+fn main() {
+ if cfg!(feature = "link_libfuzzer") {
+ build_and_link_libfuzzer();
+ }
+}
diff --git a/src/lib.rs b/src/lib.rs
index 376feb9..b82e031 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -202,7 +202,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
/// `"arbitrary-derive"` cargo feature.
#[macro_export]
macro_rules! fuzz_target {
- (|$bytes:ident| $body:block) => {
+ (|$bytes:ident| $body:expr) => {
const _: () = {
/// Auto-generated function
#[no_mangle]
@@ -244,15 +244,15 @@ macro_rules! fuzz_target {
};
};
- (|$data:ident: &[u8]| $body:block) => {
+ (|$data:ident: &[u8]| $body:expr) => {
$crate::fuzz_target!(|$data| $body);
};
- (|$data:ident: $dty: ty| $body:block) => {
- $crate::fuzz_target!(|$data: $dty| -> () $body);
+ (|$data:ident: $dty:ty| $body:expr) => {
+ $crate::fuzz_target!(|$data: $dty| -> () { $body });
};
- (|$data:ident: $dty: ty| -> $rty: ty $body:block) => {
+ (|$data:ident: $dty:ty| -> $rty:ty $body:block) => {
const _: () = {
/// Auto-generated function
#[no_mangle]