encorporate rt_target - unique identifier for instructions we will be looking for
This commit is contained in:
parent
4ae333513e
commit
60ded0d85b
3 changed files with 27 additions and 2 deletions
15
genc.py
15
genc.py
|
|
@ -19,6 +19,16 @@ class InstructionType(Enum):
|
|||
elif self == InstructionType.EVEX: return 2
|
||||
|
||||
class Instruction:
|
||||
RT_TARGETS = {
|
||||
"90" : 1,
|
||||
"C3" : 2,
|
||||
"C2 iw" : 3,
|
||||
"CC" : 4,
|
||||
"CD ib" : 5,
|
||||
"0F 34" : 6,
|
||||
"0F 05" : 7,
|
||||
}
|
||||
|
||||
def __init__(self, ins):
|
||||
self._opc = ins.find("opc").text
|
||||
self.x32m = ins.attrib["x32m"]
|
||||
|
|
@ -48,6 +58,9 @@ class Instruction:
|
|||
def has_opreg(self):
|
||||
return False
|
||||
|
||||
def encode_rt_target(self):
|
||||
return Instruction.RT_TARGETS.get(self._opc, 0)
|
||||
|
||||
def __str__(self):
|
||||
return f"<{self.get_type()}> {self.mnemonic} bytes {self.bytes} rex {self.has_rex()} digit {self.has_digit()} modrm {self.has_modrm()} imm {self.has_imm()} value {self.has_value()} opreg {self.has_opreg()}"
|
||||
|
||||
|
|
@ -283,7 +296,7 @@ def generate_table(groups):
|
|||
int(i.w)
|
||||
), end = '')
|
||||
|
||||
print(" .opcode_len = {}, .opcode = {{ {} }} }},".format(opcode_len, opcode))
|
||||
print(" .rt_target = {}, .opcode_len = {}, .opcode = {{ {} }} }},".format(i.encode_rt_target(), opcode_len, opcode))
|
||||
table_len += 1
|
||||
# footer
|
||||
print("}};\n\nconst unsigned rtdisasm_table_len = {};".format(table_len))
|
||||
|
|
|
|||
|
|
@ -24,6 +24,16 @@
|
|||
#define VALUE_O 4
|
||||
#define VALUE_T 5
|
||||
|
||||
// these are target instructions that rtdisasm will look for
|
||||
#define RT_TARGET_NO_MEANING 0
|
||||
#define RT_TARGET_NOP 1 // 90
|
||||
#define RT_TARGET_RET 2 // C3
|
||||
#define RT_TARGET_RET_N 3 // C2 iw
|
||||
#define RT_TARGET_INT3 4 // CC
|
||||
#define RT_TARGET_INT_N 5 // CD ib
|
||||
#define RT_TARGET_SYSENTER 6 // 0F 34
|
||||
#define RT_TARGET_SYSCALL 7 // 0F 05
|
||||
|
||||
#define MAX_OPCODE_LEN 4
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -62,6 +72,8 @@ typedef struct {
|
|||
} evex;
|
||||
};
|
||||
|
||||
uint16_t rt_target;
|
||||
|
||||
uint16_t opcode_len;
|
||||
uint8_t opcode[MAX_OPCODE_LEN];
|
||||
} instruction_t;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
.globl test_1_end
|
||||
|
||||
test_1:
|
||||
push %rbp
|
||||
push (%rbp)
|
||||
|
||||
nop # target that rtdisasm must reach
|
||||
test_1_end:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue