diff options
| author | Camille Mougey <commial@gmail.com> | 2017-04-20 10:51:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-20 10:51:48 +0200 |
| commit | ff981a11ef71960a239ec44295f06bb384124521 (patch) | |
| tree | bc82bef5607c72cf639018f373966ddc7b4a2e53 | |
| parent | ab619c80e3deb7088700e465ec62f917fd18150a (diff) | |
| parent | 6a3b7055de8b022208cd9cbf9914b314c42c7af7 (diff) | |
| download | miasm-ff981a11ef71960a239ec44295f06bb384124521.tar.gz miasm-ff981a11ef71960a239ec44295f06bb384124521.zip | |
Merge pull request #520 from serpilliere/fastcall_abi
X86_32: Add fastcall abi
| -rw-r--r-- | miasm2/arch/x86/jit.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/miasm2/arch/x86/jit.py b/miasm2/arch/x86/jit.py index ef1f162b..e64c610b 100644 --- a/miasm2/arch/x86/jit.py +++ b/miasm2/arch/x86/jit.py @@ -140,6 +140,33 @@ class jitter_x86_32(jitter): get_arg_n_systemv = get_stack_arg + # fastcall + @named_arguments + def func_args_fastcall(self, n_args): + args_regs = ['ECX', 'EDX'] + ret_ad = self.pop_uint32_t() + args = [] + for i in xrange(n_args): + args.append(self.get_arg_n_fastcall(i)) + return ret_ad, args + + def func_prepare_fastcall(self, ret_addr, *args): + args_regs = ['ECX', 'EDX'] + self.push_uint32_t(ret_addr) + for i in xrange(min(len(args), len(args_regs))): + setattr(self.cpu, args_regs[i], args[i]) + remaining_args = args[len(args_regs):] + for arg in reversed(remaining_args): + self.push_uint32_t(arg) + + def get_arg_n_fastcall(self, index): + args_regs = ['ECX', 'EDX'] + if index < len(args_regs): + return getattr(self.cpu, args_regs[index]) + return self.get_stack_arg(index - len(args_regs)) + + + class jitter_x86_64(jitter): C_Gen = x86_64_CGen |