diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2024-02-02 08:35:26 +0100 |
---|---|---|
committer | Jeff Vander Stoep <jeffv@google.com> | 2024-02-02 08:35:26 +0100 |
commit | 9b2cd52a95b2b2c37de13dd68b161fd8e90cd410 (patch) | |
tree | daedb7646b5c58b3c20cc03e341e7478900eb0a8 | |
parent | 74bf7ac500a8d4ec53262f471721f51530a5a2d0 (diff) | |
download | libfuzzer-sys-9b2cd52a95b2b2c37de13dd68b161fd8e90cd410.tar.gz |
Upgrade libfuzzer-sys to 0.4.7
This project was upgraded with external_updater.
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
Test: TreeHugger
Change-Id: I9c6731bc65ee401388bee491955e724c7f69870c
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 13 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Cargo.toml.orig | 4 | ||||
-rw-r--r-- | METADATA | 23 | ||||
-rw-r--r-- | README.md | 23 | ||||
-rw-r--r-- | build.rs | 8 | ||||
-rw-r--r-- | src/lib.rs | 10 |
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 @@ -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. @@ -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] @@ -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" } } @@ -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 ``` @@ -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(); + } +} @@ -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] |