[docs]defis_pc(project:"Project",ins_addr:int,addr:int)->bool:""" Check if the given address is program counter (PC) or not. This function is for handling the case on some bizarre architectures where PC is always the currently executed instruction address plus a constant value. :param project: An angr Project instance. :param ins_addr: The address of an instruction. We calculate PC using this instruction address. :param addr: The address to check against. :return: True if the given instruction address is the PC, False otherwise. """ifarchinfo.arch_arm.is_arm_arch(project.arch):ifins_addr&1==1:# thumb modeins_addr=ins_addr-1returnaddr==ins_addr+4else:# arm modereturnaddr==ins_addr+8returnins_addr==addr
[docs]defis_in_readonly_section(project:"Project",addr:int)->bool:""" Check if the specified address is inside a read-only section. :param project: An angr Project instance. :param addr: The address to check. :return: True if the given address belongs to a read-only section, False otherwise. """sec=project.loader.find_section_containing(addr)ifsecisnotNone:returnnotsec.is_writablereturnFalse
[docs]defis_in_readonly_segment(project:"Project",addr:int)->bool:""" Check if the specified address is inside a read-only segment. :param project: An angr Project instance. :param addr: The address to check. :return: True if the given address belongs to a read-only segment, False otherwise. """seg=project.loader.find_segment_containing(addr)ifsegisnotNone:returnnotseg.is_writablereturnFalse