@@ -51,8 +51,8 @@ def __init__(self,
5151 str , function_profile .FunctionProfile ] = dict ()
5252 self .all_class_constructors : Dict [
5353 str , function_profile .FunctionProfile ] = dict ()
54- self .branch_blockers : List [Any ] = []
5554
55+ self .branch_blockers : List [Any ] = []
5656 self ._target_lang = target_lang
5757 self .introspector_data_file = cfg_file
5858
@@ -100,6 +100,12 @@ def entrypoint_function(self):
100100 cname = self .fuzzer_source_file
101101 mname = self .entrypoint_method
102102 return f"[{ cname } ].{ mname } "
103+ elif self .target_lang == "rust" :
104+ # For rust, there is no entry function
105+ # Instead, it is wrapped by the fuzz_target
106+ # macro and we manually considered it as
107+ # function in the frontend.
108+ return "fuzz_target"
103109 else :
104110 return None
105111
@@ -131,7 +137,7 @@ def max_func_call_depth(self):
131137
132138 def has_entry_point (self ) -> bool :
133139 """Returns whether an entrypoint is identified"""
134- if self .target_lang == "c-cpp" :
140+ if self .target_lang == "c-cpp" or self . target_lang == "rust" :
135141 return self .entrypoint_function in self .all_class_functions
136142
137143 elif self .target_lang == "python" :
@@ -440,8 +446,8 @@ def _set_all_reached_functions(self) -> None:
440446 the fuzzer. This is based on identifying all functions reached by the
441447 fuzzer entrypoint function, e.g. LLVMFuzzerTestOneInput in C/C++.
442448 """
443- # Find C/CPP entry point
444- if self ._target_lang == "c-cpp" :
449+ # Find C/CPP/Rust entry point
450+ if self ._target_lang == "c-cpp" or self . target_lang == "rust" :
445451 if self .entrypoint_function in self .all_class_functions :
446452 self .functions_reached_by_fuzzer = (self .all_class_functions [
447453 self .entrypoint_function ].functions_reached )
@@ -485,7 +491,7 @@ def _set_all_unreached_functions(self) -> None:
485491 def _load_coverage (self , target_folder : str ) -> None :
486492 """Load coverage data for this profile"""
487493 logger .info (f"Loading coverage of type { self .target_lang } " )
488- if self .target_lang == "c-cpp" :
494+ if self .target_lang == "c-cpp" or self . target_lang == "rust" :
489495 if os .getenv ('FI_KERNEL_COV' , '' ):
490496 self .coverage = code_coverage .load_kernel_cov (
491497 os .getenv ('FI_KERNEL_COV' ))
0 commit comments