@@ -79,6 +79,10 @@ def get_ret_pc(self):
7979 elif self .ql .arch .type == QL_ARCH .ARM64 :
8080 return self .ql .arch .regs .x30
8181
82+ # PPC
83+ elif self .ql .arch .type == QL_ARCH .PPC :
84+ return self .ql .arch .regs .lr
85+
8286 # X86
8387 elif self .ql .arch .type == QL_ARCH .X86 :
8488 return self .ql .unpack (self .ql .mem .read (self .ql .arch .regs .esp , self .ql .arch .pointersize ))
@@ -98,6 +102,10 @@ def context_fixup(self):
98102 elif self .ql .arch .type == QL_ARCH .MIPS :
99103 pass
100104
105+ # PPC
106+ elif self .ql .arch .type == QL_ARCH .PPC :
107+ pass
108+
101109 # ARM64
102110 elif self .ql .arch .type == QL_ARCH .ARM64 :
103111 pass
@@ -121,6 +129,10 @@ def set_ret(self, addr):
121129 elif self .ql .arch .type == QL_ARCH .MIPS :
122130 self .ql .arch .regs .ra = addr
123131
132+ # PPC
133+ elif self .ql .arch .type == QL_ARCH .PPC :
134+ self .ql .arch .regs .lr = addr
135+
124136 # ARM64
125137 elif self .ql .arch .type == QL_ARCH .ARM64 :
126138 self .ql .arch .stack_write (0 , addr )
@@ -173,29 +185,6 @@ def call_enter(self):
173185 else :
174186 self .context_fixup ()
175187
176- def ret (self ):
177- # ARM
178- if self .ql .arch .type == QL_ARCH .ARM :
179- self .ql .arch .regs .arch_pc = self .ret_pc
180-
181- # MIPS32
182- elif self .ql .arch .type == QL_ARCH .MIPS :
183- self .ql .arch .regs .arch_pc = self .ret_pc
184-
185- # ARM64
186- elif self .ql .arch .type == QL_ARCH .ARM64 :
187- self .ql .arch .regs .arch_pc = self .ret_pc
188-
189- # X86
190- elif self .ql .arch .type == QL_ARCH .X86 :
191- self .ql .arch .regs .arch_pc = self .ret_pc
192-
193- # X8664
194- elif self .ql .arch .type == QL_ARCH .X8664 :
195- self .ql .arch .regs .arch_pc = self .ret_pc
196- else :
197- raise
198-
199188 def call_exit (self ):
200189 # if self.ql.arch.type == QL_ARCH.ARM or self.ql.arch.type == QL_ARCH.ARM64:
201190 # self.ql.arch.regs.arch_pc = self.ql.arch.regs.arch_pc + 4
@@ -211,7 +200,7 @@ def call_exit(self):
211200 else :
212201 onexit_cb (self .ql , onexit_userdata )
213202
214- self .ret ()
203+ self .ql . arch . regs . arch_pc = self . ret_pc
215204
216205
217206class HookFuncRel (HookFunc ):
@@ -614,6 +603,14 @@ def __init__(self, ql, phoff, phnum, phentsize, load_base, hook_mem):
614603 ins = b'\x00 \x01 '
615604 self .add_function_hook = self .add_function_hook_relocation
616605
606+ # PowerPC
607+ elif self .ql .arch .type == QL_ARCH .PPC :
608+ self .GLOB_DAT = 21
609+ self .JMP_SLOT = 22
610+ # nop
611+ ins = b'\x60 \x00 \x00 \x00 '
612+ self .add_function_hook = self .add_function_hook_relocation
613+
617614 self ._parse ()
618615 if self .rel != None :
619616 self .show_relocation (self .rel )
0 commit comments