rbdc 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bindings/ruby/rbdc/extconf.rb +57 -0
- data/bindings/ruby/rbdc/rbdc.c +304 -0
- data/dyncall/AUTHORS +4 -0
- data/dyncall/BUGS +3 -0
- data/dyncall/CMakeLists.txt +79 -0
- data/dyncall/ChangeLog +165 -0
- data/dyncall/LICENSE +15 -0
- data/dyncall/Makefile.M +15 -0
- data/dyncall/Makefile.embedded +71 -0
- data/dyncall/Makefile.generic +36 -0
- data/dyncall/Nmakefile +45 -0
- data/dyncall/README +92 -0
- data/dyncall/ToDo +114 -0
- data/dyncall/autovar/LICENSE.txt +15 -0
- data/dyncall/autovar/README.txt +69 -0
- data/dyncall/autovar/autovar_ABI.h +44 -0
- data/dyncall/autovar/autovar_ARCH.h +56 -0
- data/dyncall/autovar/autovar_CC.h +46 -0
- data/dyncall/autovar/autovar_OS.h +78 -0
- data/dyncall/autovar/autovar_OSFAMILY.h +39 -0
- data/dyncall/buildsys/cmake/Modules/FindDynCall.cmake +43 -0
- data/dyncall/buildsys/cmake/Modules/FindDynCallback.cmake +43 -0
- data/dyncall/buildsys/cmake/Modules/FindDynLoad.cmake +45 -0
- data/dyncall/buildsys/cmake/Modules/UseLATEX.cmake +811 -0
- data/dyncall/buildsys/dynmake/Makefile.base.M +82 -0
- data/dyncall/buildsys/dynmake/dynmake.bat +2 -0
- data/dyncall/buildsys/dynmake/dynmake.sh +4 -0
- data/dyncall/buildsys/lua/Makefile +10 -0
- data/dyncall/buildsys/lua/README.txt +4 -0
- data/dyncall/buildsys/lua/bootstrap.sh +34 -0
- data/dyncall/buildsys/lua/cleanup.sh +6 -0
- data/dyncall/buildsys/lua/mkfile +34 -0
- data/dyncall/buildsys/lua/setenv.sh +4 -0
- data/dyncall/buildsys/mk/app.mk +30 -0
- data/dyncall/buildsys/mk/dirs.mk +27 -0
- data/dyncall/buildsys/mk/epilog.mk +30 -0
- data/dyncall/buildsys/mk/lib.mk +23 -0
- data/dyncall/buildsys/mk/pcc.mk +60 -0
- data/dyncall/buildsys/mk/prolog.mk +35 -0
- data/dyncall/buildsys/nmake/common.nmake +61 -0
- data/dyncall/buildsys/nmake/epilog.nmake +28 -0
- data/dyncall/buildsys/nmake/prolog.nmake +76 -0
- data/dyncall/buildsys/nmake/tool_gcc.nmake +82 -0
- data/dyncall/buildsys/nmake/tool_msvc.nmake +67 -0
- data/dyncall/buildsys/scripts/batch-build-linux.sh +11 -0
- data/dyncall/buildsys/scripts/batch-build-minix.sh +11 -0
- data/dyncall/buildsys/scripts/batch-build-psp.sh +11 -0
- data/dyncall/buildsys/scripts/conf-nds.bat +41 -0
- data/dyncall/buildsys/scripts/setenv-cross-ios.sh +8 -0
- data/dyncall/buildsys/scripts/setenv-sdk-ios.sh +22 -0
- data/dyncall/buildsys/vs2005/dyncall/dyncall.vcproj +245 -0
- data/dyncall/buildsys/vs2005/test_plain/test_plain.vcproj +202 -0
- data/dyncall/buildsys/vs2005/vs2005.sln +29 -0
- data/dyncall/configure +152 -0
- data/dyncall/configure.bat +157 -0
- data/dyncall/configure.rc +234 -0
- data/dyncall/dynMakefile +4 -0
- data/dyncall/dyncall/CMakeLists.txt +53 -0
- data/dyncall/dyncall/DynCallConfig.cmake +3 -0
- data/dyncall/dyncall/Makefile.M +10 -0
- data/dyncall/dyncall/Makefile.embedded +20 -0
- data/dyncall/dyncall/Makefile.generic +16 -0
- data/dyncall/dyncall/Nmakefile +62 -0
- data/dyncall/dyncall/README-Developer.txt +45 -0
- data/dyncall/dyncall/README.txt +65 -0
- data/dyncall/dyncall/TODO +9 -0
- data/dyncall/dyncall/dynMakefile +4 -0
- data/dyncall/dyncall/dyncall.3 +189 -0
- data/dyncall/dyncall/dyncall.h +135 -0
- data/dyncall/dyncall/dyncall_alloc.h +40 -0
- data/dyncall/dyncall/dyncall_api.c +167 -0
- data/dyncall/dyncall/dyncall_call.S +72 -0
- data/dyncall/dyncall/dyncall_call_arm32_arm.S +80 -0
- data/dyncall/dyncall/dyncall_call_arm32_arm.h +61 -0
- data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.S +96 -0
- data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.h +44 -0
- data/dyncall/dyncall/dyncall_call_arm32_thumb.h +65 -0
- data/dyncall/dyncall/dyncall_call_arm32_thumb_apple.s +80 -0
- data/dyncall/dyncall/dyncall_call_arm32_thumb_armhf.S +121 -0
- data/dyncall/dyncall/dyncall_call_arm32_thumb_gas.s +101 -0
- data/dyncall/dyncall/dyncall_call_mips.h +50 -0
- data/dyncall/dyncall/dyncall_call_mips_eabi.h +61 -0
- data/dyncall/dyncall/dyncall_call_mips_eabi_gas.s +115 -0
- data/dyncall/dyncall/dyncall_call_mips_gas.S +36 -0
- data/dyncall/dyncall/dyncall_call_mips_n32.h +67 -0
- data/dyncall/dyncall/dyncall_call_mips_n32_gas.s +192 -0
- data/dyncall/dyncall/dyncall_call_mips_n64.h +67 -0
- data/dyncall/dyncall/dyncall_call_mips_n64_gas.s +192 -0
- data/dyncall/dyncall/dyncall_call_mips_o32.h +70 -0
- data/dyncall/dyncall/dyncall_call_mips_o32_gas.s +109 -0
- data/dyncall/dyncall/dyncall_call_ppc32.S +266 -0
- data/dyncall/dyncall/dyncall_call_ppc32.h +62 -0
- data/dyncall/dyncall/dyncall_call_sparc.S +192 -0
- data/dyncall/dyncall/dyncall_call_sparc.h +42 -0
- data/dyncall/dyncall/dyncall_call_sparc64.S +361 -0
- data/dyncall/dyncall/dyncall_call_sparc64.h +42 -0
- data/dyncall/dyncall/dyncall_call_sparc_v9.S +220 -0
- data/dyncall/dyncall/dyncall_call_sparc_v9.h +42 -0
- data/dyncall/dyncall/dyncall_call_x64-att.S +146 -0
- data/dyncall/dyncall/dyncall_call_x64.S +149 -0
- data/dyncall/dyncall/dyncall_call_x64.h +63 -0
- data/dyncall/dyncall/dyncall_call_x64_generic_masm.asm +70 -0
- data/dyncall/dyncall/dyncall_call_x86.S +238 -0
- data/dyncall/dyncall/dyncall_call_x86.h +70 -0
- data/dyncall/dyncall/dyncall_call_x86_8a.s +127 -0
- data/dyncall/dyncall/dyncall_call_x86_generic_masm.asm +136 -0
- data/dyncall/dyncall/dyncall_call_x86_nasm.asm +234 -0
- data/dyncall/dyncall/dyncall_callf.c +112 -0
- data/dyncall/dyncall/dyncall_callf.h +52 -0
- data/dyncall/dyncall/dyncall_callvm.c +68 -0
- data/dyncall/dyncall/dyncall_callvm.h +88 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_arm.c +250 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_arm.h +59 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.c +204 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.h +63 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_thumb.c +271 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_thumb.h +59 -0
- data/dyncall/dyncall/dyncall_callvm_base.c +33 -0
- data/dyncall/dyncall/dyncall_callvm_mips.c +40 -0
- data/dyncall/dyncall/dyncall_callvm_mips.h +37 -0
- data/dyncall/dyncall/dyncall_callvm_mips_eabi.c +181 -0
- data/dyncall/dyncall/dyncall_callvm_mips_eabi.h +61 -0
- data/dyncall/dyncall/dyncall_callvm_mips_n32.c +268 -0
- data/dyncall/dyncall/dyncall_callvm_mips_n64.c +268 -0
- data/dyncall/dyncall/dyncall_callvm_mips_n64.h +53 -0
- data/dyncall/dyncall/dyncall_callvm_mips_o32.c +235 -0
- data/dyncall/dyncall/dyncall_callvm_mips_o32.h +45 -0
- data/dyncall/dyncall/dyncall_callvm_ppc32.c +372 -0
- data/dyncall/dyncall/dyncall_callvm_ppc32.h +61 -0
- data/dyncall/dyncall/dyncall_callvm_sparc.c +155 -0
- data/dyncall/dyncall/dyncall_callvm_sparc.h +44 -0
- data/dyncall/dyncall/dyncall_callvm_sparc64.c +239 -0
- data/dyncall/dyncall/dyncall_callvm_sparc64.h +47 -0
- data/dyncall/dyncall/dyncall_callvm_sparc_v9.c +182 -0
- data/dyncall/dyncall/dyncall_callvm_sparc_v9.h +45 -0
- data/dyncall/dyncall/dyncall_callvm_x64.c +228 -0
- data/dyncall/dyncall/dyncall_callvm_x64.h +111 -0
- data/dyncall/dyncall/dyncall_callvm_x86.c +667 -0
- data/dyncall/dyncall/dyncall_callvm_x86.h +75 -0
- data/dyncall/dyncall/dyncall_config.h +46 -0
- data/dyncall/dyncall/dyncall_macros.h +248 -0
- data/dyncall/dyncall/dyncall_signature.h +71 -0
- data/dyncall/dyncall/dyncall_struct.c +255 -0
- data/dyncall/dyncall/dyncall_struct.h +69 -0
- data/dyncall/dyncall/dyncall_types.h +74 -0
- data/dyncall/dyncall/dyncall_utils.h +38 -0
- data/dyncall/dyncall/dyncall_value.h +73 -0
- data/dyncall/dyncall/dyncall_vector.c +52 -0
- data/dyncall/dyncall/dyncall_vector.h +56 -0
- data/dyncall/dyncall/gen-masm.sh +7 -0
- data/dyncall/dyncall/mkfile +29 -0
- data/dyncall/dyncallback/CMakeLists.txt +55 -0
- data/dyncall/dyncallback/DynCallbackConfig.cmake +2 -0
- data/dyncall/dyncallback/Makefile.M +10 -0
- data/dyncall/dyncallback/Makefile.embedded +15 -0
- data/dyncall/dyncallback/Makefile.generic +20 -0
- data/dyncall/dyncallback/Nmakefile +71 -0
- data/dyncall/dyncallback/README.txt +9 -0
- data/dyncall/dyncallback/TODO +4 -0
- data/dyncall/dyncallback/dynMakefile +4 -0
- data/dyncall/dyncallback/dyncall_alloc_wx.c +35 -0
- data/dyncall/dyncallback/dyncall_alloc_wx.h +46 -0
- data/dyncall/dyncallback/dyncall_alloc_wx_malloc.c +40 -0
- data/dyncall/dyncallback/dyncall_alloc_wx_mmap.c +42 -0
- data/dyncall/dyncallback/dyncall_alloc_wx_win32.c +42 -0
- data/dyncall/dyncallback/dyncall_args.c +45 -0
- data/dyncall/dyncallback/dyncall_args.h +65 -0
- data/dyncall/dyncallback/dyncall_args_arm32_arm.c +112 -0
- data/dyncall/dyncallback/dyncall_args_arm32_arm.h +40 -0
- data/dyncall/dyncallback/dyncall_args_arm32_thumb.c +29 -0
- data/dyncall/dyncallback/dyncall_args_arm32_thumb.h +32 -0
- data/dyncall/dyncallback/dyncall_args_mips.c +81 -0
- data/dyncall/dyncallback/dyncall_args_mips.h +41 -0
- data/dyncall/dyncallback/dyncall_args_ppc32.c +88 -0
- data/dyncall/dyncallback/dyncall_args_ppc32.h +41 -0
- data/dyncall/dyncallback/dyncall_args_sparc32.c +41 -0
- data/dyncall/dyncallback/dyncall_args_sparc32.h +37 -0
- data/dyncall/dyncallback/dyncall_args_sparc64.c +41 -0
- data/dyncall/dyncallback/dyncall_args_sparc64.h +37 -0
- data/dyncall/dyncallback/dyncall_args_x64.c +73 -0
- data/dyncall/dyncallback/dyncall_args_x64.h +44 -0
- data/dyncall/dyncallback/dyncall_args_x86.c +121 -0
- data/dyncall/dyncallback/dyncall_args_x86.h +58 -0
- data/dyncall/dyncallback/dyncall_callback.c +45 -0
- data/dyncall/dyncallback/dyncall_callback.h +51 -0
- data/dyncall/dyncallback/dyncall_callback_arch.S +71 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_arm.c +63 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_arm.h +45 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_arm_apple.s +73 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_arm_gas.s +73 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb.c +29 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb.h +33 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb_apple.s +32 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb_gas.s +32 -0
- data/dyncall/dyncallback/dyncall_callback_mips.c +61 -0
- data/dyncall/dyncallback/dyncall_callback_mips.h +42 -0
- data/dyncall/dyncallback/dyncall_callback_ppc32.S +33 -0
- data/dyncall/dyncallback/dyncall_callback_ppc32.c +60 -0
- data/dyncall/dyncallback/dyncall_callback_ppc32.h +43 -0
- data/dyncall/dyncallback/dyncall_callback_ppc32_apple.s +180 -0
- data/dyncall/dyncallback/dyncall_callback_sparc32.c +57 -0
- data/dyncall/dyncallback/dyncall_callback_sparc32.h +43 -0
- data/dyncall/dyncallback/dyncall_callback_sparc32.s +30 -0
- data/dyncall/dyncallback/dyncall_callback_sparc64.c +57 -0
- data/dyncall/dyncallback/dyncall_callback_sparc64.s +30 -0
- data/dyncall/dyncallback/dyncall_callback_x64.S +187 -0
- data/dyncall/dyncallback/dyncall_callback_x64.c +69 -0
- data/dyncall/dyncallback/dyncall_callback_x64.h +44 -0
- data/dyncall/dyncallback/dyncall_callback_x64_apple.s +122 -0
- data/dyncall/dyncallback/dyncall_callback_x64_gas.s +119 -0
- data/dyncall/dyncallback/dyncall_callback_x64_gas_w64.s +102 -0
- data/dyncall/dyncallback/dyncall_callback_x64_masm.asm +89 -0
- data/dyncall/dyncallback/dyncall_callback_x86.S +115 -0
- data/dyncall/dyncallback/dyncall_callback_x86.c +281 -0
- data/dyncall/dyncallback/dyncall_callback_x86.h +49 -0
- data/dyncall/dyncallback/dyncall_callback_x86_8a.s +100 -0
- data/dyncall/dyncallback/dyncall_callback_x86_masm.asm +74 -0
- data/dyncall/dyncallback/dyncall_thunk.c +47 -0
- data/dyncall/dyncallback/dyncall_thunk.h +84 -0
- data/dyncall/dyncallback/dyncall_thunk_arm32_arm.c +45 -0
- data/dyncall/dyncallback/dyncall_thunk_arm32_arm.h +40 -0
- data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.c +29 -0
- data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.h +35 -0
- data/dyncall/dyncallback/dyncall_thunk_mips.c +52 -0
- data/dyncall/dyncallback/dyncall_thunk_mips.h +37 -0
- data/dyncall/dyncallback/dyncall_thunk_ppc32.c +51 -0
- data/dyncall/dyncallback/dyncall_thunk_ppc32.h +40 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc32.c +32 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc32.h +36 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc64.c +32 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc64.h +36 -0
- data/dyncall/dyncallback/dyncall_thunk_x64.c +48 -0
- data/dyncall/dyncallback/dyncall_thunk_x64.h +39 -0
- data/dyncall/dyncallback/dyncall_thunk_x86.c +44 -0
- data/dyncall/dyncallback/dyncall_thunk_x86.h +39 -0
- data/dyncall/dyncallback/dyncallback.3 +134 -0
- data/dyncall/dyncallback/gen-masm.sh +8 -0
- data/dyncall/dyncallback/mkfile +29 -0
- data/dyncall/dynload/CMakeLists.txt +25 -0
- data/dyncall/dynload/DynLoadConfig.cmake +3 -0
- data/dyncall/dynload/Makefile.M +10 -0
- data/dyncall/dynload/Makefile.embedded +22 -0
- data/dyncall/dynload/Makefile.generic +18 -0
- data/dyncall/dynload/Nmakefile +57 -0
- data/dyncall/dynload/README.txt +113 -0
- data/dyncall/dynload/TODO +20 -0
- data/dyncall/dynload/dynMakefile +4 -0
- data/dyncall/dynload/dynload.3 +64 -0
- data/dyncall/dynload/dynload.c +38 -0
- data/dyncall/dynload/dynload.h +65 -0
- data/dyncall/dynload/dynload_alloc.h +40 -0
- data/dyncall/dynload/dynload_darwin.c +89 -0
- data/dyncall/dynload/dynload_syms.c +38 -0
- data/dyncall/dynload/dynload_syms_elf.c +214 -0
- data/dyncall/dynload/dynload_syms_mach-o.c +167 -0
- data/dyncall/dynload/dynload_syms_pe.c +109 -0
- data/dyncall/dynload/dynload_unix.c +57 -0
- data/dyncall/dynload/dynload_windows.c +59 -0
- data/dyncall/mkfile +36 -0
- data/dyncall/portasm/README.txt +42 -0
- data/dyncall/portasm/gen-masm.sh +3 -0
- data/dyncall/portasm/portasm-arm.S +36 -0
- data/dyncall/portasm/portasm-ppc.S +98 -0
- data/dyncall/portasm/portasm-x64-att.S +155 -0
- data/dyncall/portasm/portasm-x86.S +127 -0
- metadata +311 -0
@@ -0,0 +1,149 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncall
|
5
|
+
File: dyncall/dyncall_call_x64.S
|
6
|
+
Description: All x64 abi call kernel implementation
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
|
+
|
12
|
+
Permission to use, copy, modify, and distribute this software for any
|
13
|
+
purpose with or without fee is hereby granted, provided that the above
|
14
|
+
copyright notice and this permission notice appear in all copies.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
17
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
18
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
19
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
20
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
21
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
22
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
#include "../portasm/portasm-x64.S"
|
28
|
+
|
29
|
+
BEGIN_ASM
|
30
|
+
|
31
|
+
/*---------------------------------------------------------------------------
|
32
|
+
|
33
|
+
Call Kernel for x64 System V
|
34
|
+
|
35
|
+
Input:
|
36
|
+
RDI : size of arguments to be passed via stack
|
37
|
+
RSI : pointer to arguments to be passed via the stack
|
38
|
+
RDX : pointer to arguments of integral/pointer type to be passed via registers
|
39
|
+
RCX : pointer to arguments of floating point type to be passed via registers
|
40
|
+
R8 : target function pointer
|
41
|
+
|
42
|
+
*/
|
43
|
+
|
44
|
+
GLOBAL(dcCall_x64_sysv)
|
45
|
+
BEGIN_PROC(dcCall_x64_sysv)
|
46
|
+
|
47
|
+
push RBP /* Pseudo-prolog - preserve RBP. */
|
48
|
+
push RBX /* Preserve RBX and store pointer to function in it. */
|
49
|
+
|
50
|
+
mov RBP, RSP /* Store stack pointer in RBP. */
|
51
|
+
|
52
|
+
mov RBX, R8
|
53
|
+
|
54
|
+
movsd XMM0, qword ptr[RCX ] /* Copy first 8 floats to XMM0-XMM7 (this makes RCX free to use). */
|
55
|
+
movsd XMM1, qword ptr[RCX+ 8]
|
56
|
+
movsd XMM2, qword ptr[RCX+16]
|
57
|
+
movsd XMM3, qword ptr[RCX+24]
|
58
|
+
movsd XMM4, qword ptr[RCX+32]
|
59
|
+
movsd XMM5, qword ptr[RCX+40]
|
60
|
+
movsd XMM6, qword ptr[RCX+48]
|
61
|
+
movsd XMM7, qword ptr[RCX+56]
|
62
|
+
|
63
|
+
sub RSP, RDI /* Setup stack frame by subtracting the size of the arguments. */
|
64
|
+
|
65
|
+
and RSP, -32 /* Align stack to 32-byte border. */
|
66
|
+
|
67
|
+
mov RCX, RDI /* Store number of bytes to copy to stack in RCX (for rep movsb). */
|
68
|
+
mov RDI, RSP /* Store pointer to beginning of stack arguments in RDI (for rep movsb). */
|
69
|
+
|
70
|
+
rep movsb /* @@@ should be optimized (e.g. movq) */
|
71
|
+
|
72
|
+
mov RDI, qword ptr[RDX ] /* Copy first six int/pointer arguments to RDI, RSI, RDX, RCX, R8, R9. */
|
73
|
+
mov RSI, qword ptr[RDX+ 8]
|
74
|
+
mov RCX, qword ptr[RDX+24]
|
75
|
+
mov R8, qword ptr[RDX+32]
|
76
|
+
mov R9, qword ptr[RDX+40]
|
77
|
+
mov RDX, qword ptr[RDX+16] /* Set RDX last to not overwrite it to soon. */
|
78
|
+
|
79
|
+
mov AL, 8 /* Put upper bound of number of used xmm registers in AL. */
|
80
|
+
call RBX /* Invoke function. */
|
81
|
+
|
82
|
+
mov RSP, RBP /* Restore stack pointer (such that we can pop the preserved vALues). */
|
83
|
+
|
84
|
+
pop RBX /* Restore RBX. */
|
85
|
+
pop RBP /* Pseudo-epilog. */
|
86
|
+
|
87
|
+
ret
|
88
|
+
END_PROC(dcCall_x64_sysv)
|
89
|
+
|
90
|
+
/*---------------------------------------------------------------------------
|
91
|
+
|
92
|
+
Call Kernel for x64 Win64
|
93
|
+
|
94
|
+
Input:
|
95
|
+
RCX : size of arguments to be passed via stack
|
96
|
+
RDX : pointer to arguments to be passed via the stack
|
97
|
+
R8 : pointer to arguments of integral/pointer type to be passed via registers
|
98
|
+
R9 : target function pointer
|
99
|
+
|
100
|
+
*/
|
101
|
+
|
102
|
+
GLOBAL(dcCall_x64_win64)
|
103
|
+
BEGIN_PROC(dcCall_x64_win64)
|
104
|
+
|
105
|
+
push RBP /* Pseudo-prolog - preserve RBP. */
|
106
|
+
push RSI /* Preserve RSI and RDI. */
|
107
|
+
push RDI
|
108
|
+
|
109
|
+
/* and RSP, -16 /* Align frame to 16 bytes. */
|
110
|
+
mov RBP, RSP /* Store stack pointer in RBP. */
|
111
|
+
|
112
|
+
add RCX, 15 /* Align stack size to 16 bytes. */
|
113
|
+
and RCX, -16
|
114
|
+
sub RSP, RCX /* Setup stack frame by subtracting the size of the arguments. */
|
115
|
+
|
116
|
+
mov RSI, RDX /* Let RSI point to the arguments. */
|
117
|
+
mov RDI, RSP /* Store pointer to beginning of stack arguments in RDI (for rep movsb). */
|
118
|
+
mov RAX, R9 /* Put function address in RAX. */
|
119
|
+
|
120
|
+
rep movsb /* @@@ should be optimized (e.g. movq) */
|
121
|
+
|
122
|
+
mov RCX, qword ptr[R8 ] /* Copy first four arguments to RCX, RDX, R8, R9 and XMM0-XMM3. */
|
123
|
+
mov RDX, qword ptr[R8+ 8]
|
124
|
+
mov R9, qword ptr[R8+24] /* Set R9 first to not overwrite R8 too soon. */
|
125
|
+
mov R8, qword ptr[R8+16]
|
126
|
+
movd XMM0, RCX
|
127
|
+
movd XMM1, RDX
|
128
|
+
movd XMM2, R8
|
129
|
+
movd XMM3, R9
|
130
|
+
|
131
|
+
push R9 /* Push first four arguments onto the stack preserve area. */
|
132
|
+
push R8
|
133
|
+
push RDX
|
134
|
+
push RCX
|
135
|
+
|
136
|
+
call RAX /* Invoke function. */
|
137
|
+
|
138
|
+
mov RSP, RBP /* Restore stack pointer (such that we can pop the preserved vALues). */
|
139
|
+
|
140
|
+
pop RDI /* Restore RSI and RDI. */
|
141
|
+
pop RSI
|
142
|
+
pop RBP /* Pseudo-epilog. */
|
143
|
+
|
144
|
+
ret
|
145
|
+
|
146
|
+
END_PROC(dcCall_x64_win64)
|
147
|
+
|
148
|
+
END_ASM
|
149
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncall
|
5
|
+
File: dyncall/dyncall_call_x64.h
|
6
|
+
Description:
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
|
+
|
12
|
+
Permission to use, copy, modify, and distribute this software for any
|
13
|
+
purpose with or without fee is hereby granted, provided that the above
|
14
|
+
copyright notice and this permission notice appear in all copies.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
17
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
18
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
19
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
20
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
21
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
22
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
/*
|
28
|
+
|
29
|
+
dyncall x64
|
30
|
+
|
31
|
+
REVISION
|
32
|
+
2007/12/11 initial
|
33
|
+
|
34
|
+
*/
|
35
|
+
|
36
|
+
|
37
|
+
#ifndef DYNCALL_CALL_X64_H
|
38
|
+
#define DYNCALL_CALL_X64_H
|
39
|
+
|
40
|
+
|
41
|
+
#include "dyncall.h"
|
42
|
+
|
43
|
+
#ifdef __cplusplus
|
44
|
+
extern "C" {
|
45
|
+
#endif
|
46
|
+
|
47
|
+
/*
|
48
|
+
** x64 SystemV calling convention
|
49
|
+
**
|
50
|
+
** - hybrid return-type call (bool ... pointer)
|
51
|
+
**
|
52
|
+
*/
|
53
|
+
|
54
|
+
void dcCall_x64_sysv(DCsize stacksize, DCpointer stackdata, DCpointer regdata_i, DCpointer regdata_f, DCpointer target);
|
55
|
+
void dcCall_x64_win64(DCsize stacksize, DCpointer stackdata, DCpointer regdata, DCpointer target);
|
56
|
+
|
57
|
+
#ifdef __cplusplus
|
58
|
+
}
|
59
|
+
#endif
|
60
|
+
|
61
|
+
|
62
|
+
#endif /* DYNCALL_CALL_X64_H */
|
63
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
; auto-generated by gen-masm.sh
|
2
|
+
.CODE
|
3
|
+
|
4
|
+
dcCall_x64_sysv PROC
|
5
|
+
OPTION PROLOGUE:NONE, EPILOGUE:NONE
|
6
|
+
push RBP
|
7
|
+
push RBX
|
8
|
+
mov RBP,RSP
|
9
|
+
mov RBX,R8
|
10
|
+
movsd XMM0,qword ptr [RCX+0]
|
11
|
+
movsd XMM1,qword ptr [RCX+8]
|
12
|
+
movsd XMM2,qword ptr [RCX+16]
|
13
|
+
movsd XMM3,qword ptr [RCX+24]
|
14
|
+
movsd XMM4,qword ptr [RCX+32]
|
15
|
+
movsd XMM5,qword ptr [RCX+40]
|
16
|
+
movsd XMM6,qword ptr [RCX+48]
|
17
|
+
movsd XMM7,qword ptr [RCX+56]
|
18
|
+
add RDI,31
|
19
|
+
and RDI,-32
|
20
|
+
add RDI,8
|
21
|
+
sub RSP,RDI
|
22
|
+
mov RCX,RDI
|
23
|
+
mov RDI,RSP
|
24
|
+
rep movsb
|
25
|
+
mov RDI,qword ptr [RDX+0]
|
26
|
+
mov RSI,qword ptr [RDX+8]
|
27
|
+
mov RCX,qword ptr [RDX+24]
|
28
|
+
mov R8,qword ptr [RDX+32]
|
29
|
+
mov R9,qword ptr [RDX+40]
|
30
|
+
mov RDX,qword ptr [RDX+16]
|
31
|
+
mov AL,8
|
32
|
+
call RBX
|
33
|
+
mov RSP,RBP
|
34
|
+
pop RBX
|
35
|
+
pop RBP
|
36
|
+
ret
|
37
|
+
dcCALl_x64_sysv ENDP
|
38
|
+
dcCall_x64_win64 PROC
|
39
|
+
OPTION PROLOGUE:NONE, EPILOGUE:NONE
|
40
|
+
push RBP
|
41
|
+
push RSI
|
42
|
+
push RDI
|
43
|
+
mov RBP,RSP
|
44
|
+
add RCX,15
|
45
|
+
and RCX,-16
|
46
|
+
sub RSP,RCX
|
47
|
+
mov RSI,RDX
|
48
|
+
mov RDI,RSP
|
49
|
+
mov RAX,R9
|
50
|
+
rep movsb
|
51
|
+
mov RCX,qword ptr [R8+0]
|
52
|
+
mov RDX,qword ptr [R8+8]
|
53
|
+
mov R9,qword ptr [R8+24]
|
54
|
+
mov R8,qword ptr [R8+16]
|
55
|
+
movd XMM0,RCX
|
56
|
+
movd XMM1,RDX
|
57
|
+
movd XMM2,R8
|
58
|
+
movd XMM3,R9
|
59
|
+
push R9
|
60
|
+
push R8
|
61
|
+
push RDX
|
62
|
+
push RCX
|
63
|
+
call RAX
|
64
|
+
mov RSP,RBP
|
65
|
+
pop RDI
|
66
|
+
pop RSI
|
67
|
+
pop RBP
|
68
|
+
ret
|
69
|
+
dcCall_x64_win64 ENDP
|
70
|
+
END
|
@@ -0,0 +1,238 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncall
|
5
|
+
File: dyncall/dyncall_call_x86.S
|
6
|
+
Description: All - except Plan9 - x86 abi call kernel implementation
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
|
+
|
12
|
+
Permission to use, copy, modify, and distribute this software for any
|
13
|
+
purpose with or without fee is hereby granted, provided that the above
|
14
|
+
copyright notice and this permission notice appear in all copies.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
17
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
18
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
19
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
20
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
21
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
22
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
#include "../portasm/portasm-x86.S"
|
28
|
+
BEGIN_ASM
|
29
|
+
/* ============================================================================
|
30
|
+
DynCall Call Kernels for X86 Architecture
|
31
|
+
----------------------------------------------------------------------------
|
32
|
+
C Interface:
|
33
|
+
dcCall_x86_XXX(void* target, void* args, size_t size);
|
34
|
+
ddCall_x86_sys_XXX(int_ptr target, void* args, size_t size);
|
35
|
+
|
36
|
+
Where XXX is one of calling-conventions,
|
37
|
+
cdecl, win32_msthis, win32_std, win32_fastcall.
|
38
|
+
|
39
|
+
Parameter Stack layout:
|
40
|
+
size := EBP + 16
|
41
|
+
args := EBP + 12
|
42
|
+
target := EBP + 8
|
43
|
+
|
44
|
+
NOTES:
|
45
|
+
- epilog restore ESP serves callee cleanup
|
46
|
+
- 16 byte alignment (to be compatible with darwin).
|
47
|
+
*/
|
48
|
+
|
49
|
+
|
50
|
+
/*--- default / cdecl --------------------------------------------------------
|
51
|
+
|
52
|
+
Details:
|
53
|
+
- caller clean-up
|
54
|
+
|
55
|
+
*/
|
56
|
+
|
57
|
+
GLOBAL(dcCall_x86_cdecl)
|
58
|
+
BEGIN_PROC(dcCall_x86_cdecl)
|
59
|
+
PUSH(EBP) /* prolog. */
|
60
|
+
MOVL(ESP,EBP)
|
61
|
+
PUSH(ESI) /* save preserved registers. */
|
62
|
+
PUSH(EDI)
|
63
|
+
MOVL(DWORD(EBP,12),ESI) /* ESI = arg buffer ptr */
|
64
|
+
MOVL(DWORD(EBP,16),ECX) /* ECX = arg buffer size */
|
65
|
+
ADDL(LIT(15),ECX) /* ECX = align(ECX,16) */
|
66
|
+
ANDL(LIT(-16),ECX)
|
67
|
+
MOVL(ECX,DWORD(EBP,16)) /* save ECX. */
|
68
|
+
SUBL(ECX,ESP) /* allocate stack size */
|
69
|
+
MOVL(ESP,EDI) /* EDI = stack ptr */
|
70
|
+
|
71
|
+
/*
|
72
|
+
work around for rep movsd (not supported by SunPro)
|
73
|
+
|
74
|
+
SHRL(LIT(2),ECX)
|
75
|
+
REP(MOVSD)
|
76
|
+
|
77
|
+
*/
|
78
|
+
|
79
|
+
REP(MOVSB)
|
80
|
+
CALL_DWORD(EBP,8)
|
81
|
+
ADDL(DWORD(EBP,16),ESP)
|
82
|
+
POP(EDI)
|
83
|
+
POP(ESI)
|
84
|
+
MOVL(EBP,ESP)
|
85
|
+
POP(EBP)
|
86
|
+
RET()
|
87
|
+
END_PROC(dcCall_x86_cdecl)
|
88
|
+
/* ---- C++ this calls (microsoft) ------------------------------------------
|
89
|
+
|
90
|
+
Details:
|
91
|
+
- this pointer is in ECX
|
92
|
+
|
93
|
+
*/
|
94
|
+
|
95
|
+
GLOBAL(dcCall_x86_win32_msthis)
|
96
|
+
BEGIN_PROC(dcCall_x86_win32_msthis)
|
97
|
+
PUSH(EBP) /* prolog. */
|
98
|
+
MOVL(ESP,EBP)
|
99
|
+
PUSH(ESI) /* save preserved. */
|
100
|
+
PUSH(EDI)
|
101
|
+
MOVL(DWORD(EBP,12),ESI) /* ESI = pointer on args. */
|
102
|
+
MOVL(DWORD(EBP,16),ECX) /* ECX = size. */
|
103
|
+
MOVL(DWORD(ESI,0),EAX) /* EAX = this pointer. */
|
104
|
+
ADDL(LIT(4),ESI) /* increment args pointer by thisptr. */
|
105
|
+
SUBL(LIT(4),ECX) /* decrement size by sizeof(thisptr). */
|
106
|
+
SUBL(ECX,ESP) /* allocate argument-block on stack. */
|
107
|
+
MOVL(ESP,EDI) /* EDI = stack args. */
|
108
|
+
REP(MOVSB) /* copy arguments. */
|
109
|
+
MOVL(EAX,ECX) /* ECX = this pointer. */
|
110
|
+
CALL_DWORD(EBP,8) /* call function. */
|
111
|
+
POP(EDI) /* restore preserved. */
|
112
|
+
POP(ESI)
|
113
|
+
MOVL(EBP,ESP) /* epilog. */
|
114
|
+
POP(EBP)
|
115
|
+
RET()
|
116
|
+
END_PROC(dcCall_x86_win32_msthis)
|
117
|
+
|
118
|
+
/*---- win32 stdcall ---------------------------------------------------------
|
119
|
+
|
120
|
+
Details:
|
121
|
+
- callee cleans up stack
|
122
|
+
|
123
|
+
*/
|
124
|
+
|
125
|
+
GLOBAL(dcCall_x86_win32_std)
|
126
|
+
BEGIN_PROC(dcCall_x86_win32_std)
|
127
|
+
PUSH(EBP) /* prolog. */
|
128
|
+
MOVL(ESP,EBP)
|
129
|
+
PUSH(ESI) /* save ESI, EDI. */
|
130
|
+
PUSH(EDI)
|
131
|
+
MOVL(DWORD(EBP,12),ESI) /* ESI = args. */
|
132
|
+
MOVL(DWORD(EBP,16),ECX) /* ECX = size. */
|
133
|
+
SUBL(ECX,ESP) /* allocate size bytes on stack. */
|
134
|
+
MOVL(ESP,EDI) /* EDI = copy destination stack. */
|
135
|
+
REP(MOVSB) /* copy BYTEs. */
|
136
|
+
CALL_DWORD(EBP,8) /* call target. */
|
137
|
+
POP(EDI) /* restore EDI, ESI. */
|
138
|
+
POP(ESI)
|
139
|
+
MOVL(EBP,ESP) /* epilog. */
|
140
|
+
POP(EBP)
|
141
|
+
RET()
|
142
|
+
END_PROC(dcCall_x86_win32_std)
|
143
|
+
|
144
|
+
/*---- win32 fastcall (GNU/Microsoft) ----------------------------------------
|
145
|
+
|
146
|
+
Details:
|
147
|
+
- callee cleans up stack
|
148
|
+
- first two integer (up to 32bits) are passed in ECX and EDX
|
149
|
+
|
150
|
+
*/
|
151
|
+
|
152
|
+
GLOBAL(dcCall_x86_win32_fast)
|
153
|
+
BEGIN_PROC(dcCall_x86_win32_fast)
|
154
|
+
PUSH(EBP) /* prolog. */
|
155
|
+
MOVL(ESP,EBP)
|
156
|
+
PUSH(ESI) /* save preserved. */
|
157
|
+
PUSH(EDI)
|
158
|
+
MOVL(DWORD(EBP,12),ESI) /* ESI = copy source args. */
|
159
|
+
MOVL(DWORD(EBP,16),ECX) /* ECX = size. */
|
160
|
+
MOVL(DWORD(ESI,0),EAX) /* EAX = first argument. */
|
161
|
+
MOVL(DWORD(ESI,4),EDX) /* EDX = second argument. */
|
162
|
+
ADDL(LIT(8),ESI) /* skip registers. */
|
163
|
+
SUBL(LIT(8),ECX)
|
164
|
+
MOVL(ECX,DWORD(EBP,16)) /* save stack alloc size. */
|
165
|
+
SUBL(ECX,ESP) /* allocate stack. */
|
166
|
+
MOVL(ESP,EDI) /* EDI = stack args. */
|
167
|
+
REP(MOVSB) /* copy BYTEs. */
|
168
|
+
MOVL(EAX,ECX) /* ECX = first argument. */
|
169
|
+
CALL_DWORD(EBP,8) /* call target. */
|
170
|
+
POP(EDI) /* restore preserved. */
|
171
|
+
POP(ESI)
|
172
|
+
MOVL(EBP,ESP) /* epilog. */
|
173
|
+
POP(EBP)
|
174
|
+
RET()
|
175
|
+
END_PROC(dcCall_x86_win32_fast)
|
176
|
+
|
177
|
+
/*--- syscall int80 linux ---------------------------------------------------
|
178
|
+
|
179
|
+
Details:
|
180
|
+
- all arguments are passed via registers
|
181
|
+
|
182
|
+
*/
|
183
|
+
|
184
|
+
GLOBAL(dcCall_x86_sys_int80h_linux)
|
185
|
+
BEGIN_PROC(dcCall_x86_sys_int80h_linux)
|
186
|
+
PUSH(EBP) /* prolog. */
|
187
|
+
MOVL(ESP,EBP)
|
188
|
+
PUSH(EBX) /* save preserved. */
|
189
|
+
PUSH(ESI)
|
190
|
+
PUSH(EDI)
|
191
|
+
MOVL(DWORD(EBP,12),EAX) /* EAX = argument buffer. */
|
192
|
+
MOVL(DWORD(EAX,0),EBX) /* move first five arguments. */
|
193
|
+
MOVL(DWORD(EAX,4),ECX)
|
194
|
+
MOVL(DWORD(EAX,8),EDX)
|
195
|
+
MOVL(DWORD(EAX,12),ESI)
|
196
|
+
MOVL(DWORD(EAX,16),EDI)
|
197
|
+
MOVL(DWORD(EBP,8),EAX) /* EAX = syscall id. */
|
198
|
+
INT(LIT(HEX(80)))
|
199
|
+
POP(EDI) /* restore preserved. */
|
200
|
+
POP(ESI)
|
201
|
+
POP(EBX)
|
202
|
+
MOVL(EBP,ESP) /* epilog. */
|
203
|
+
POP(EBP)
|
204
|
+
RET()
|
205
|
+
END_PROC(dcCall_x86_sys_int80h_linux)
|
206
|
+
|
207
|
+
/*--- syscall int80 bsd -----------------------------------------------------
|
208
|
+
|
209
|
+
Details:
|
210
|
+
- all arguments are passed via stack
|
211
|
+
|
212
|
+
*/
|
213
|
+
|
214
|
+
GLOBAL(dcCall_x86_sys_int80h_bsd)
|
215
|
+
BEGIN_PROC(dcCall_x86_sys_int80h_bsd)
|
216
|
+
PUSH(EBP) /* prolog. */
|
217
|
+
MOVL(ESP,EBP)
|
218
|
+
PUSH(ESI) /* save preserved. */
|
219
|
+
PUSH(EDI)
|
220
|
+
MOVL(DWORD(EBP,12),ESI) /* ESI = pointer on args. */
|
221
|
+
MOVL(DWORD(EBP,16),ECX) /* ECX = size. */
|
222
|
+
SUBL(ECX,ESP) /* allocate stack space. */
|
223
|
+
MOVL(ESP,EDI) /* EDI = stack args. */
|
224
|
+
REP(MOVSB)
|
225
|
+
MOVL(DWORD(EBP,8),EAX) /* load system call id. */
|
226
|
+
CALL(_do_int)
|
227
|
+
POP(EDI) /* restore preserved. */
|
228
|
+
POP(ESI)
|
229
|
+
MOVL(EBP,ESP) /* epilog. */
|
230
|
+
POP(EBP)
|
231
|
+
RET()
|
232
|
+
_do_int:
|
233
|
+
INT(LIT(HEX(80)))
|
234
|
+
RET()
|
235
|
+
END_PROC(dcCall_x86_sys_int80h_bsd)
|
236
|
+
|
237
|
+
END_ASM
|
238
|
+
|