Skip to content

Commit

Permalink
making ptrsize static for arm, arm64 and mips
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jan 8, 2022
1 parent b95c4ac commit a04cd64
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions gef.py
Expand Up @@ -2326,6 +2326,12 @@ def instruction_length(self):
# Thumb instructions have variable-length (2 or 4-byte)
return None if self.is_thumb() else 4

@property
def ptrsize(self):
if not self.__ptrsize:
self.__ptrsize = 2 if self.is_thumb() else 4
return self.__ptrsize

def is_call(self, insn):
mnemo = insn.mnemonic
call_mnemos = {"bl", "blx"}
Expand Down Expand Up @@ -2443,6 +2449,7 @@ class AARCH64(ARM):
function_parameters = ["$x0", "$x1", "$x2", "$x3", "$x4", "$x5", "$x6", "$x7"]
syscall_register = "$x8"
syscall_instructions = ["svc $x0"]
ptrsize = 8

def is_call(self, insn):
mnemo = insn.mnemonic
Expand Down Expand Up @@ -2546,10 +2553,7 @@ class X86(Architecture):
}
syscall_register = "$eax"
syscall_instructions = ["sysenter", "int 0x80"]

@property
def ptrsize(self):
return 4
ptrsize = 4

def flag_register_to_human(self, val=None):
reg = self.flag_register
Expand Down Expand Up @@ -2668,10 +2672,7 @@ class X86_64(X86):
syscall_instructions = ["syscall"]
# We don't want to inherit x86's stack based param getter
get_ith_parameter = Architecture.get_ith_parameter

@property
def ptrsize(self):
return 8
ptrsize = 8

@classmethod
def mprotect_asm(cls, addr, size, perm):
Expand Down Expand Up @@ -2958,6 +2959,7 @@ class MIPS(Architecture):
"$t8", "$t9", "$k0", "$k1", "$s8", "$pc", "$sp", "$hi",
"$lo", "$fir", "$ra", "$gp", ]
instruction_length = 4
ptrsize = 4
nop_insn = b"\x00\x00\x00\x00" # sll $0,$0,0
return_register = "$v0"
flag_register = "$fcsr"
Expand Down Expand Up @@ -3027,9 +3029,6 @@ def mprotect_asm(cls, addr, size, perm):
return "; ".join(insns)





def copy_to_clipboard(data):
"""Helper function to submit data to the clipboard"""
if sys.platform == "linux":
Expand Down

0 comments on commit a04cd64

Please sign in to comment.