Maratyszcza / PeachPy

x86-64 assembler embedded in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RIP call

tsarpaul opened this issue · comments

commented

Hi, I'm trying to assemble a position independent piece of code.
I'm trying to create a CALL with a relative pointer using PC/IP:

from peachpy.x86_64 import *
from peachpy.x86_64.registers import rip

call = CALL([rip+8])

and I'm getting:

~/.local/lib/python3.6/site-packages/peachpy/x86_64/generic.py in __init__(self, *args, **kwargs)
   9875             origin = inspect.stack()
   9876         super(CALL, self).__init__("CALL", origin=origin, prototype=prototype)
-> 9877         self.operands = tuple(map(check_operand, args))
   9878         if len(self.operands) != 1:
   9879             raise SyntaxError("Instruction \"CALL\" requires 1 operands")

~/.local/lib/python3.6/site-packages/peachpy/x86_64/operand.py in check_operand(operand)
     26         if len(operand) != 1:
     27             raise ValueError("Memory operands must be represented by a list with only one element")
---> 28         return MemoryOperand(operand[0])
     29     elif isinstance(operand, Constant):
     30         from copy import copy, deepcopy

~/.local/lib/python3.6/site-packages/peachpy/x86_64/operand.py in __init__(self, address, size, mask, broadcast)
    249             isinstance(address.register, (XMMRegister, YMMRegister, ZMMRegister)) and \
    250             not address.mask.is_zeroing, \
--> 251             "Only MemoryAddress, 64-bit general-purpose registers, XMM/YMM/ZMM registers, " \
    252             "and merge-masked XMM/YMM/ZMM registers may be specified as an address"
    253         from peachpy.util import is_int

AssertionError: Only MemoryAddress, 64-bit general-purpose registers, XMM/YMM/ZMM registers, and merge-masked XMM/YMM/ZMM registers may be specified as an address

Am I doing something wrong?

commented

From reviewing some pull requests I'm supposed to do:

CALL(RIPRelativeOffset(8))
commented

Added a pull request to simplify this syntax