From f9ff195350d6dc0bf19627cf1f19e36b20890a31 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Thu, 24 Oct 2024 19:17:11 -0400 Subject: Make WARP function guid generation infallible --- plugins/warp/src/lib.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'plugins/warp/src/lib.rs') diff --git a/plugins/warp/src/lib.rs b/plugins/warp/src/lib.rs index ae14ae80..5f8d4a78 100644 --- a/plugins/warp/src/lib.rs +++ b/plugins/warp/src/lib.rs @@ -23,10 +23,10 @@ mod plugin; pub fn build_function( func: &BNFunction, llil: &llil::Function>, -) -> Option { +) -> Function { let bn_fn_ty = func.function_type(); - Some(Function { - guid: cached_function_guid(func, llil)?, + Function { + guid: cached_function_guid(func, llil), symbol: from_bn_symbol(&func.symbol()), // TODO: Confidence should be derived from function type. ty: from_bn_type(&func.view(), bn_fn_ty, 255), @@ -40,7 +40,7 @@ pub fn build_function( }, // TODO: We need more than one entry block. entry: entry_basic_block_guid(func, llil).map(BasicBlock::new), - }) + } } pub fn entry_basic_block_guid( @@ -49,7 +49,7 @@ pub fn entry_basic_block_guid Option { // NOTE: This is not actually the entry point. This is the highest basic block. let first_basic_block = sorted_basic_blocks(func).into_iter().next()?; - basic_block_guid(&first_basic_block, llil) + Some(basic_block_guid(&first_basic_block, llil)) } /// Basic blocks sorted from high to low. @@ -66,20 +66,20 @@ pub fn sorted_basic_blocks(func: &BNFunction) -> Vec( func: &BNFunction, llil: &llil::Function>, -) -> Option { +) -> FunctionGUID { // TODO: Sort the basic blocks. let basic_blocks = sorted_basic_blocks(func); let basic_block_guids = basic_blocks .iter() - .filter_map(|bb| basic_block_guid(bb, llil)) + .map(|bb| basic_block_guid(bb, llil)) .collect::>(); - Some(FunctionGUID::from_basic_blocks(&basic_block_guids)) + FunctionGUID::from_basic_blocks(&basic_block_guids) } pub fn basic_block_guid( basic_block: &BNBasicBlock, llil: &llil::Function>, -) -> Option { +) -> BasicBlockGUID { let func = basic_block.function(); let view = func.view(); let arch = func.arch(); @@ -112,7 +112,7 @@ pub fn basic_block_guid>(); functions.sort_by_key(|guid| guid.guid); insta::assert_debug_snapshot!(functions); -- cgit v1.3.1