コード例 #1
0
ファイル: nacl.py プロジェクト: liuluyang530/gpt-pytorch
    def __init__(self, *args, **kwargs):
        """Supported forms:

            * NACLRESTBP(r32)
        """

        origin = kwargs.get("origin")
        prototype = kwargs.get("prototype")
        if origin is None and prototype is None and peachpy.x86_64.options.get_debug_level(
        ) > 0:
            origin = inspect.stack()
        super(NACLRESTBP, self).__init__("NACLRESTBP",
                                         origin=origin,
                                         prototype=prototype)
        self.operands = tuple(map(check_operand, args))
        if len(self.operands) != 1:
            raise SyntaxError("Instruction \"NACLRESTBP\" requires 1 operand")
        self.in_regs = (True, )
        self.out_regs = (False, )
        self.out_operands = (True, )
        self._gas_name = "naclrestbp"
        if is_r32(self.operands[0]):
            pass
        else:
            raise SyntaxError(
                "Invalid operand types: NACLRESTBP " +
                ", ".join(map(format_operand_type, self.operands)))
        if peachpy.stream.active_stream is not None:
            peachpy.stream.active_stream.add_instruction(self)
コード例 #2
0
    def __init__(self, *args, **kwargs):
        """Supported forms:

            * RDRAND(r16)    [RDRAND]
            * RDRAND(r32)    [RDRAND]
            * RDRAND(r64)    [RDRAND]
        """

        origin = kwargs.get("origin")
        prototype = kwargs.get("prototype")
        if origin is None and prototype is None and peachpy.x86_64.options.get_debug_level(
        ) > 0:
            origin = inspect.stack()
        super(RDRAND, self).__init__("RDRAND",
                                     origin=origin,
                                     prototype=prototype)
        self.operands = tuple(map(check_operand, args))
        if len(self.operands) != 1:
            raise SyntaxError("Instruction \"RDRAND\" requires 1 operands")
        self.in_regs = (False, )
        self.out_regs = (True, )
        self.out_operands = (True, )
        self.isa_extensions = frozenset([peachpy.x86_64.isa.rdrand])
        if is_r16(self.operands[0]):
            self.encodings.append(
                (0x20, lambda op, rex=False: bytearray([0x66]) + optional_rex(
                    0, op[0], rex) + bytearray(
                        [0x0F, 0xC7, 0xF0 | op[0].lcode])))
        elif is_r32(self.operands[0]):
            self.encodings.append((0x20, lambda op, rex=False: optional_rex(
                0, op[0], rex) + bytearray([0x0F, 0xC7, 0xF0 | op[0].lcode])))
        elif is_r64(self.operands[0]):
            self.encodings.append((0x00, lambda op: bytearray(
                [0x48 | op[0].hcode, 0x0F, 0xC7, 0xF0 | op[0].lcode])))
        else:
            raise SyntaxError(
                "Invalid operand types: RDRAND " +
                ", ".join(map(format_operand_type, self.operands)))
        if peachpy.stream.active_stream is not None:
            peachpy.stream.active_stream.add_instruction(self)
コード例 #3
0
ファイル: nacl.py プロジェクト: Rinoahu/PeachPy
    def __init__(self, *args, **kwargs):
        """Supported forms:

            * NACLJMP(r32)
        """

        origin = kwargs.get("origin")
        prototype = kwargs.get("prototype")
        if origin is None and prototype is None and peachpy.x86_64.options.get_debug_level() > 0:
            origin = inspect.stack()
        super(NACLJMP, self).__init__("NACLJMP", origin=origin, prototype=prototype)
        self.operands = tuple(map(check_operand, args))
        if len(self.operands) != 1:
            raise SyntaxError("Instruction \"NACLJMP\" requires 1 operand")
        self.in_regs = (True,)
        self.out_regs = (False,)
        self.out_operands = (True,)
        self._gas_name = "nacljmp"
        if not is_r32(self.operands[0]):
            raise SyntaxError("Invalid operand types: NACLJMP " + ", ".join(map(format_operand_type, self.operands)))
        if peachpy.stream.active_stream is not None:
            peachpy.stream.active_stream.add_instruction(self)
コード例 #4
0
ファイル: nacl.py プロジェクト: moneytech/PeachPy
    def __init__(self, *args, **kwargs):
        """Supported forms:

            * NACLJMP(r32)
            * NACLJMP(r32, rZP)
        """

        # - nacljmp %eXX,%rZP (sandboxed indirect jump)
        #       AND(eXX, -32)
        #       ADD(rXX, rZP)
        #       JMP(rxx)

        origin = kwargs.get("origin")
        if origin is None and peachpy.x86_64.options.get_debug_level() > 0:
            origin = inspect.stack()
        super(NACLJMP, self).__init__("NACLJMP", origin=origin)
        self.operands = tuple(map(check_operand, args))
        self.encodings = []
        if len(self.operands) not in {1, 2}:
            raise SyntaxError(
                "Instruction \"NACLJMP\" requires 1 or 2 operands")
        from peachpy.x86_64.registers import r15
        if len(self.operands) == 1:
            self.operands = tuple(list(self.operands) + [r15])
        if is_r32(self.operands[0]) and r15 == self.operands[1]:
            self._gas_name = "nacljmp"
            self.out_regs = (False, False)
            self.in_regs = (True, False)
            self.out_operands = (False, False)
        else:
            raise SyntaxError(
                "Invalid operand types: NACLJMP " +
                ", ".join(map(format_operand_type, self.operands)))
        self._instructions = self._lower()
        if peachpy.stream.active_stream is not None:
            peachpy.stream.active_stream.add_instruction(self)