(self)
Find all potential function alignments and mark them.

        Note that it is not always correct to simply remove them, because these functions may not be actual alignments
        but part of an actual function, and is incorrectly marked as an individual function because of failures in
        resolving indirect jumps. An example is in the test binary ``x86_64/dir_gcc_-O0`` 0x40541d (indirect jump at
        0x4051b0). If the indirect jump cannot be correctly resolved, removing function 0x40541d will cause a missing
        label failure in reassembler.

        :return: None
Find all potential function alignments and mark them.
Find all potential function alignments and mark them .
def mark_function_alignments(self):
        """
        Find all potential function alignments and mark them.

        Note that it is not always correct to simply remove them, because these functions may not be actual alignments
        but part of an actual function, and is incorrectly marked as an individual function because of failures in
        resolving indirect jumps. An example is in the test binary ``x86_64/dir_gcc_-O0`` 0x40541d (indirect jump at
        0x4051b0). If the indirect jump cannot be correctly resolved, removing function 0x40541d will cause a missing
        label failure in reassembler.

        :return: None
        """

        # This function requires Capstone engine support
        if not self.project.arch.capstone_support:
            return

        for func_addr in self.kb.functions.keys():
            function = self.kb.functions[func_addr]
            if function.is_simprocedure or function.is_syscall:
                continue
            if len(function.block_addrs_set) == 1:
                block = next((b for b in function.blocks), None)
                if block is None:
                    continue
                if all(self._is_noop_insn(insn) for insn in block.capstone.insns):
                    # all nops. mark this function as a function alignment
                    l.debug('Function chunk %#x is probably used as a function alignment (all nops).', func_addr)
                    self.kb.functions[func_addr].alignment = True
                    continue
                node = function.get_node(block.addr)
                successors = list(function.graph.successors(node))
                if len(successors) == 1 and successors[0].addr == node.addr:
                    # self loop. mark this function as a function alignment
                    l.debug('Function chunk %#x is probably used as a function alignment (self-loop).', func_addr)
                    self.kb.functions[func_addr].alignment = True
                    continue
def mark_function_alignments ( self ) : # This function requires Capstone engine support if not self . project . arch . capstone_support : return for func_addr in self . kb . functions . keys ( ) : function = self . kb . functions [ func_addr ] if function . is_simprocedure or function . is_syscall : continue if len ( function . block_addrs_set ) == 1 : block = next ( ( b for b in function . blocks ) , None ) if block is None : continue if all ( self . _is_noop_insn ( insn ) for insn in block . capstone . insns ) : # all nops. mark this function as a function alignment l . debug ( 'Function chunk %#x is probably used as a function alignment (all nops).' , func_addr ) self . kb . functions [ func_addr ] . alignment = True continue node = function . get_node ( block . addr ) successors = list ( function . graph . successors ( node ) ) if len ( successors ) == 1 and successors [ 0 ] . addr == node . addr : # self loop. mark this function as a function alignment l . debug ( 'Function chunk %#x is probably used as a function alignment (self-loop).' , func_addr ) self . kb . functions [ func_addr ] . alignment = True continue