Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
spinpx committed Mar 21, 2024
1 parent 8ce2a33 commit a217827
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ After running `compile`, you will find that it generates the following files in
- `HOPPER_TYPE_BLACKLIST`: includes type blacklists that hopper won't compile. `bindgen` will not generate code for the types. e.g. `HOPPER_TYPE_BLACKLIST=type1,type2`.
- `HOPPER_ITEM_BLACKLIST`: includes item(constants/variables) blacklists that hopper won't compile. `bindgen` will not generate code for the items. e.g. `HOPPER_ITEM_BLACKLIST=IPPORT_RESERVED`
- `HOPPER_CUSTOM_OPAQUE_LIST`: includes custom opaque types we defined. e.g. `HOPPER_CUSTOM_OPAQUE_LIST=type1`.
- `HOPPER_FUZZ_INLINE_FUNCTION`: includes inline function as our targets, see [FAQ](https://rust-lang.github.io/rust-bindgen/faq.html#why-isnt-bindgen-generating-bindings-to-inline-functions) in bindgen.

#### Tips
- You can set the arguments and environment variables for compiling and running in a configuration file named `hopper.config`, see `examples/*` for details.
Expand Down
3 changes: 2 additions & 1 deletion hopper
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ cov)
DATA_FILE=$COV_DIR/all.profdata
find ${PROFILE_DIR} -type f > ${COV_DIR}/prof.list
llvm-profdata merge -sparse -f ${COV_DIR}/prof.list -o ${DATA_FILE}
COV_EXCLUDE='(fuzzing|fuzz|test|OT|cre2|oss|examples)/'
# COV_EXCLUDE='(fuzzing|fuzz|test|OT|cre2|oss|examples)/'
COV_EXCLUDE='${COV_EXCLUDE:-}'
llvm-cov show -ignore-filename-regex=$COV_EXCLUDE --format=html $BIN_FILE -instr-profile=${DATA_FILE} >${COV_DIR}/coverage.html
# llvm-cov report -show-functions -ignore-filename-regex=$COV_EXCLUDE -instr-profile=${DATA_FILE} $BIN_FILE $SRC_DIR | tee ${COV_DIR}/coverage_funcs.report
llvm-cov report $BIN_FILE -instr-profile=${DATA_FILE} -ignore-filename-regex=$COV_EXCLUDE | tee ${COV_DIR}/coverage.report
Expand Down
6 changes: 3 additions & 3 deletions hopper-compiler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ pub fn compile(config: &Config) -> Result<()> {
fs::create_dir_all(&config.output).expect("fail to create output directory");
let output = PathBuf::from(&config.output)
.canonicalize()
.expect("cononicalize output path fail");
.context("cononicalize output path fail")?;
eyre::ensure!(!config.header.is_empty(), "require at least one header");
eyre::ensure!(!config.library.is_empty(), "require at least one library");
let header = if config.header.len() == 1 {
let header = PathBuf::from(&config.header[0])
.canonicalize()
.expect("cononicalize header path fail");
.context("cononicalize header path fail")?;
check::check_header(&header)?;
header
} else {
Expand All @@ -41,7 +41,7 @@ pub fn compile(config: &Config) -> Result<()> {
for lib in &config.library {
let lib = PathBuf::from(lib)
.canonicalize()
.expect("cononicalize library path fail");
.context("cononicalize library path fail")?;
check::check_library(&lib)?;
let lib_info = crate::binary_info::BinaryInfo::parse(&lib)?;
let instrumented_lib = instrument(&lib, &output, config, &lib_info)?;
Expand Down
1 change: 0 additions & 1 deletion hopper-core/src/depot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use self::select::*;
use crate::{execute::StatusType, FuzzProgram, FeedbackSummary};
pub use io::*;
use priority::PriorityWrap;
pub use priority::*;

/// Depot for saving all inputs, hangs, and crashes.
pub struct Depot {
Expand Down
1 change: 0 additions & 1 deletion hopper-core/src/fuzz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub use constraints::*;
pub use det::*;
pub use flag::*;
pub use generate::*;
pub use mutate::*;
pub use object::*;
pub use operator::*;
pub use rng::*;
Expand Down
4 changes: 2 additions & 2 deletions hopper-core/src/fuzz/refine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl FuzzProgram {
.use_index();
loop {
let cur_stmt = &self.stmts[index.get()].stmt;
// eyre::ensure!(index.get() < 512, "index is too large");
eyre::ensure!(index.get() < 4096, "index is too large");
match cur_stmt {
FuzzStmt::Call(call) => {
let call_name = call.fg.f_name;
Expand Down Expand Up @@ -154,7 +154,7 @@ impl FuzzProgram {
for citem in constraint.list.iter() {
crate::log!(trace, "stmt: {}, constraint: {:?}", stmt_index.get(), citem);
let lcs = citem.find_all_locations_with_any_index(self, stmt_index, &prefix);
// eyre::ensure!(lcs.len() <= 10000, "fail to refine");
eyre::ensure!(lcs.len() <= 10000, "fail to refine");
for (loc, constraint) in lcs {
crate::log!(trace, "refining loc: {}", loc.serialize().unwrap());
let operator = match &constraint {
Expand Down
1 change: 0 additions & 1 deletion hopper-core/src/fuzz/stmt/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{impl_stmt_match, runtime::*};
pub use call::*;
use super::*;

pub trait StmtMutate: WeightedItem {
Expand Down
1 change: 0 additions & 1 deletion hopper-core/src/runtime/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ mod bitfield;
pub use builder::*;
pub use canary::*;
pub use layout::*;
pub use pointer::*;
pub use state::*;
pub use void::*;
pub use bitfield::*;
Expand Down
4 changes: 4 additions & 0 deletions hopper-harness/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ fn main() {
// Diable layout test
.layout_tests(false);

if option_env!("HOPPER_FUZZ_INLINE_FUNCTION").is_some() {
builder = builder.generate_inline_functions(true);
}

if let Some(allowlist) = option_env!("HOPPER_FUNC_ALLOW_LIST") {
builder = builder.allowlist_function("fopen");
let list: std::str::Split<char> = allowlist.split(',');
Expand Down

0 comments on commit a217827

Please sign in to comment.