Source code for angr.analyses.cfg.cfg_arch_options
[docs]classCFGArchOptions:""" Stores architecture-specific options and settings, as well as the detailed explanation of those options and settings. Suppose `ao` is the CFGArchOptions object, and there is an option called `ret_jumpkind_heuristics`, you can access it by `ao.ret_jumpkind_heuristics` and set its value via `ao.ret_jumpkind_heuristics = True` :ivar dict OPTIONS: A dict of all default options for different architectures. :ivar archinfo.Arch arch: The architecture object. :ivar dict _options: Values of all CFG options that are specific to the current architecture. """# option name: (option value type, default option value)OPTIONS={"ARMEL":{# Whether to perform some simple heuristics to detect returns that are incorrectly labeled as boring# branches by VEX"ret_jumpkind_heuristics":(bool,True),# Whether to switch between ARM mode and THUMB mode when VEX fails to decode a block"switch_mode_on_nodecode":(bool,True),# Whether we should use byte-based pattern-matching to identify ifuncs"pattern_match_ifuncs":(bool,True),},"ARMHF":{"ret_jumpkind_heuristics":(bool,True),"switch_mode_on_nodecode":(bool,True),"pattern_match_ifuncs":(bool,True),},"ARMCortexM":{"ret_jumpkind_heuristics":(bool,True),"switch_mode_on_nodecode":(bool,False),"pattern_match_ifuncs":(bool,True),},}arch=None_options={}
[docs]def__init__(self,arch,**options):""" Constructor. :param archinfo.Arch arch: The architecture instance. :param dict options: Architecture-specific options, which will be used to initialize this object. """self.arch=archself._options={}ifself.arch.nameinself.OPTIONS:fork,(_,value)inself.OPTIONS[self.arch.name].items():self._options[k]=value# make sure options are validforkinoptions.keys():ifself.arch.namenotinself.OPTIONSorknotinself.OPTIONS[self.arch.name]:raiseKeyError(f'Architecture {self.arch.name} does not support arch-specific option "{k}".')fork,vinoptions.items():self.__setattr__(k,v)
def__getattr__(self,option_name):ifoption_nameinself._options:returnself._options[option_name]returnself.__getattribute__(option_name)def__setattr__(self,option_name,option_value):ifoption_nameinself._options:# Type checkingsort=self.OPTIONS[self.arch.name][option_name][0]ifsortisNoneorisinstance(option_value,sort):self._options[option_name]=option_valueelse:raiseValueError(f'Value for option "{option_name}" must be of type {sort}')else:super().__setattr__(option_name,option_value)