mirror of
https://github.com/logos-blockchain/lez-fuzzing.git
synced 2026-06-07 03:29:26 +00:00
fix: remove the stub code
This commit is contained in:
parent
a2033af30e
commit
a89ba33f3b
1
fuzz/Cargo.lock
generated
1
fuzz/Cargo.lock
generated
@ -2009,7 +2009,6 @@ dependencies = [
|
||||
"afl",
|
||||
"arbitrary",
|
||||
"borsh",
|
||||
"cc",
|
||||
"common",
|
||||
"fuzz_props",
|
||||
"libfuzzer-sys",
|
||||
|
||||
@ -3,8 +3,6 @@ name = "fuzz"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
# Provides sys_alloc_aligned stub for non-RISC-V host builds (see build.rs)
|
||||
build = "build.rs"
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
@ -52,10 +50,6 @@ common = { path = "../../logos-execution-zone/common" }
|
||||
fuzz_props = { path = "../fuzz_props" }
|
||||
testnet_initial_state = { path = "../../logos-execution-zone/testnet_initial_state" }
|
||||
|
||||
[build-dependencies]
|
||||
# Used by build.rs to compile the sys_alloc_aligned stub for non-RISC-V hosts
|
||||
cc = "1"
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
opt-level = 3
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
// fuzz/build.rs
|
||||
//
|
||||
// Provides `sys_alloc_aligned` for non-RISC-V host targets.
|
||||
//
|
||||
// `risc0_zkvm_platform::syscall::sys_alloc_words` calls the bare-metal symbol
|
||||
// `sys_alloc_aligned`, which is normally supplied by the RISC-V zkVM runtime.
|
||||
// When compiling fuzz targets for a host target (x86_64-unknown-linux-gnu,
|
||||
// aarch64-unknown-linux-gnu, …) that symbol is absent, causing a linker error.
|
||||
// This build script compiles a small C stub via the `cc` crate so the symbol
|
||||
// is always available in the final fuzz binary.
|
||||
//
|
||||
// On macOS host builds (used by `cargo fuzz` / libFuzzer) the `cc` crate
|
||||
// compiles the same stub; it is harmlessly dead-stripped if the symbol is not
|
||||
// referenced.
|
||||
|
||||
fn main() {
|
||||
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
|
||||
|
||||
// RISC-V builds get the real symbol from the zkVM runtime — skip the stub.
|
||||
if target_arch != "riscv32" && target_arch != "riscv64" {
|
||||
cc::Build::new()
|
||||
.file("build_stubs/sys_alloc_aligned.c")
|
||||
.compile("sys_alloc_stub");
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* sys_alloc_aligned.c
|
||||
*
|
||||
* Provides `sys_alloc_aligned` for non-RISC-V host targets
|
||||
* (e.g. aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu).
|
||||
*
|
||||
* On RISC-V the real symbol is supplied by the zkVM bare-metal runtime.
|
||||
* On host targets, risc0_zkvm_platform may still reference this symbol via
|
||||
* its `sys_alloc_words` helper; this stub satisfies that reference using
|
||||
* POSIX `posix_memalign`.
|
||||
*/
|
||||
#ifndef __riscv
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void *sys_alloc_aligned(size_t bytes, size_t align) {
|
||||
void *ptr = NULL;
|
||||
/* posix_memalign requires alignment >= sizeof(void*) and a power of 2. */
|
||||
size_t real_align = align < sizeof(void *) ? sizeof(void *) : align;
|
||||
if (posix_memalign(&ptr, real_align, bytes) != 0)
|
||||
return NULL;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif /* !__riscv */
|
||||
Loading…
x
Reference in New Issue
Block a user