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,40 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dynload
|
5
|
+
File: dynload/dynload_alloc.h
|
6
|
+
Description: heap memory management interface (header only)
|
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
|
+
#ifndef DL_ALLOC_H
|
28
|
+
#define DL_ALLOC_H
|
29
|
+
|
30
|
+
#ifndef dlAllocMem
|
31
|
+
#include <stdlib.h>
|
32
|
+
#define dlAllocMem malloc
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#ifndef dlFreeMem
|
36
|
+
#define dlFreeMem free
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#endif /* DL_ALLOC_H */
|
40
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dynload
|
5
|
+
File: dynload/dynload_darwin.c
|
6
|
+
Description: dynload module for .dylib (mach-o darwin/OS X) files
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Olivier Chafik <olivier.chafik@gmail.com>
|
10
|
+
Minor bug-fix modifications by Daniel Adler.
|
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
|
+
dynload_darwin.c
|
30
|
+
|
31
|
+
dynload module for .dylib (mach-o darwin/OS X) files
|
32
|
+
|
33
|
+
*/
|
34
|
+
|
35
|
+
|
36
|
+
#include "dynload.h"
|
37
|
+
#include "dynload_alloc.h"
|
38
|
+
#include <dlfcn.h>
|
39
|
+
#include <string.h>
|
40
|
+
|
41
|
+
struct DLLib_
|
42
|
+
{
|
43
|
+
char* libPath;
|
44
|
+
void* handle;
|
45
|
+
};
|
46
|
+
|
47
|
+
|
48
|
+
DLLib* dlLoadLibrary(const char* libPath)
|
49
|
+
{
|
50
|
+
void* handle;
|
51
|
+
size_t len;
|
52
|
+
DLLib* lib;
|
53
|
+
|
54
|
+
handle = dlopen(libPath, RTLD_LAZY);
|
55
|
+
if (!handle)
|
56
|
+
return NULL;
|
57
|
+
|
58
|
+
|
59
|
+
lib = (DLLib*)dlAllocMem(sizeof(DLLib));
|
60
|
+
lib->handle = handle;
|
61
|
+
/* libPath might be null (self reference on image) [Daniel] */
|
62
|
+
if (libPath != NULL) {
|
63
|
+
len = strlen(libPath);
|
64
|
+
lib->libPath = (char*)dlAllocMem(len + 1);
|
65
|
+
strcpy(lib->libPath, libPath);
|
66
|
+
lib->libPath[len] = '\0';
|
67
|
+
} else {
|
68
|
+
lib->libPath = NULL;
|
69
|
+
}
|
70
|
+
return lib;
|
71
|
+
}
|
72
|
+
|
73
|
+
void* dlFindSymbol(DLLib* libHandle, const char* symbol)
|
74
|
+
{
|
75
|
+
return dlsym(libHandle && libHandle->handle ? libHandle->handle : RTLD_DEFAULT, symbol);
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
void dlFreeLibrary(DLLib* libHandle)
|
80
|
+
{
|
81
|
+
if (!libHandle)
|
82
|
+
return;
|
83
|
+
|
84
|
+
dlclose(libHandle->handle);
|
85
|
+
if (libHandle->libPath)
|
86
|
+
dlFreeMem(libHandle->libPath);
|
87
|
+
dlFreeMem(libHandle);
|
88
|
+
}
|
89
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dynload
|
5
|
+
File: dynload/dynload_syms.c
|
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
|
+
#include "dynload.h"
|
28
|
+
#include "../autovar/autovar_ABI.h"
|
29
|
+
#if defined(ABI_PE)
|
30
|
+
#include "dynload_syms_pe.c"
|
31
|
+
#elif defined(ABI_Mach)
|
32
|
+
#include "dynload_syms_mach-o.c"
|
33
|
+
#elif defined(ABI_ELF)
|
34
|
+
#include "dynload_syms_elf.c"
|
35
|
+
#else
|
36
|
+
void dummy() { }
|
37
|
+
#endif
|
38
|
+
|
@@ -0,0 +1,214 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dynload
|
5
|
+
File: dynload/dynload_syms_elf.c
|
6
|
+
Description:
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>,
|
11
|
+
Olivier Chafik <olivier.chafik@gmail.com>
|
12
|
+
|
13
|
+
Permission to use, copy, modify, and distribute this software for any
|
14
|
+
purpose with or without fee is hereby granted, provided that the above
|
15
|
+
copyright notice and this permission notice appear in all copies.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
18
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
19
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
20
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
21
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
22
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
23
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
24
|
+
|
25
|
+
*/
|
26
|
+
|
27
|
+
|
28
|
+
#include "../autovar/autovar_OS.h"
|
29
|
+
|
30
|
+
/*
|
31
|
+
|
32
|
+
dynamic symbol resolver for elf
|
33
|
+
|
34
|
+
*/
|
35
|
+
|
36
|
+
#include "dynload.h"
|
37
|
+
#if defined(OS_OpenBSD)
|
38
|
+
# include <stdint.h>
|
39
|
+
# include <elf_abi.h>
|
40
|
+
#elif defined(OS_SunOS)
|
41
|
+
# include <libelf.h>
|
42
|
+
#elif defined(OS_BeOS)
|
43
|
+
# include <elf32.h>
|
44
|
+
#else
|
45
|
+
# include <elf.h>
|
46
|
+
#endif
|
47
|
+
|
48
|
+
#if defined(__GLIBC__)
|
49
|
+
# define _GNU_SOURCE
|
50
|
+
# define __USE_GNU
|
51
|
+
#endif
|
52
|
+
|
53
|
+
#include "dynload_alloc.h"
|
54
|
+
|
55
|
+
#include <assert.h>
|
56
|
+
#include <fcntl.h>
|
57
|
+
#include <dlfcn.h>
|
58
|
+
#include <stdio.h>
|
59
|
+
#include <string.h>
|
60
|
+
#include <sys/stat.h>
|
61
|
+
#include <sys/types.h>
|
62
|
+
#include <sys/mman.h>
|
63
|
+
#include <unistd.h>
|
64
|
+
|
65
|
+
/* run-time configuration 64/32 */
|
66
|
+
#if defined(OS_OpenBSD)
|
67
|
+
#else
|
68
|
+
# include "../autovar/autovar_ABI.h"
|
69
|
+
# ifdef ABI_ELF64
|
70
|
+
|
71
|
+
typedef Elf64_Ehdr Elf_Ehdr;
|
72
|
+
typedef Elf64_Phdr Elf_Phdr;
|
73
|
+
typedef Elf64_Shdr Elf_Shdr;
|
74
|
+
typedef Elf64_Sym Elf_Sym;
|
75
|
+
# ifndef OS_SunOS
|
76
|
+
typedef Elf64_Dyn Elf_Dyn;
|
77
|
+
# endif
|
78
|
+
typedef Elf64_Sxword Elf_tag;
|
79
|
+
typedef Elf64_Addr Elf_Addr;
|
80
|
+
|
81
|
+
# else
|
82
|
+
# if defined(OS_BeOS)
|
83
|
+
typedef struct Elf32_Ehdr Elf_Ehdr;
|
84
|
+
typedef struct Elf32_Phdr Elf_Phdr;
|
85
|
+
typedef struct Elf32_Shdr Elf_Shdr;
|
86
|
+
typedef struct Elf32_Sym Elf_Sym;
|
87
|
+
typedef struct Elf32_Dyn Elf_Dyn;
|
88
|
+
typedef Elf32_Sword Elf_tag;
|
89
|
+
typedef Elf32_Addr Elf_Addr;
|
90
|
+
|
91
|
+
# else
|
92
|
+
|
93
|
+
typedef Elf32_Ehdr Elf_Ehdr;
|
94
|
+
typedef Elf32_Phdr Elf_Phdr;
|
95
|
+
typedef Elf32_Shdr Elf_Shdr;
|
96
|
+
typedef Elf32_Sym Elf_Sym;
|
97
|
+
# ifndef OS_SunOS
|
98
|
+
typedef Elf32_Dyn Elf_Dyn;
|
99
|
+
# endif
|
100
|
+
typedef Elf32_Sword Elf_tag;
|
101
|
+
typedef Elf32_Addr Elf_Addr;
|
102
|
+
|
103
|
+
# endif
|
104
|
+
# endif
|
105
|
+
#endif
|
106
|
+
|
107
|
+
|
108
|
+
struct DLSyms_
|
109
|
+
{
|
110
|
+
const char* pStrTab;
|
111
|
+
Elf_Sym* pSymTab;
|
112
|
+
size_t strTabSize;
|
113
|
+
size_t nSymbols;
|
114
|
+
Elf_Ehdr* pElf_Ehdr; /* pointer to elf header */
|
115
|
+
int file; /* fd of lib */
|
116
|
+
size_t fileSize; /* filesize of open lib */
|
117
|
+
};
|
118
|
+
|
119
|
+
|
120
|
+
DLSyms* dlSymsInit(const char* libPath)
|
121
|
+
{
|
122
|
+
unsigned char* pMem;
|
123
|
+
void* pSectionContent;
|
124
|
+
int i;
|
125
|
+
struct stat st;
|
126
|
+
Elf_Shdr* pS;
|
127
|
+
DLSyms* pSyms = (DLSyms*)dlAllocMem(sizeof(DLSyms));
|
128
|
+
memset(pSyms, 0, sizeof(DLSyms));
|
129
|
+
pSyms->file = open(libPath, O_RDONLY);
|
130
|
+
stat(libPath, &st);
|
131
|
+
pSyms->fileSize = st.st_size;
|
132
|
+
pSyms->pElf_Ehdr = (Elf_Ehdr*) mmap((void*) NULL, pSyms->fileSize, PROT_READ, MAP_SHARED, pSyms->file, 0);
|
133
|
+
|
134
|
+
#ifdef ABI_ELF32
|
135
|
+
assert(pSyms->pElf_Ehdr->e_ident[EI_CLASS] == ELFCLASS32);
|
136
|
+
#else
|
137
|
+
assert(pSyms->pElf_Ehdr->e_ident[EI_CLASS] == ELFCLASS64);
|
138
|
+
#endif
|
139
|
+
|
140
|
+
assert(pSyms->pElf_Ehdr->e_phoff > 0);
|
141
|
+
assert(pSyms->pElf_Ehdr->e_shoff > 0);
|
142
|
+
|
143
|
+
|
144
|
+
pMem = (unsigned char*)pSyms->pElf_Ehdr;
|
145
|
+
|
146
|
+
/* traverse section headers */
|
147
|
+
pS = (Elf_Shdr*) ( pMem + pSyms->pElf_Ehdr->e_shoff );
|
148
|
+
/* skip section 0 which is always zero due to the Elf standard. */
|
149
|
+
for (i = 1; i < pSyms->pElf_Ehdr->e_shnum; i++)
|
150
|
+
{
|
151
|
+
Elf_Shdr* pSection = &pS[i];
|
152
|
+
pSectionContent = ((char*)pMem) + pSection->sh_offset;
|
153
|
+
switch (pSection->sh_type)
|
154
|
+
{
|
155
|
+
case SHT_DYNSYM:
|
156
|
+
if (!pSyms->pSymTab) {
|
157
|
+
pSyms->pSymTab = (Elf_Sym*)pSectionContent;
|
158
|
+
pSyms->nSymbols = pSection->sh_size / pSection->sh_entsize;
|
159
|
+
}
|
160
|
+
break;
|
161
|
+
case SHT_STRTAB:
|
162
|
+
// Do not trust pSyms->pElf_Ehdr->e_shstrndx!
|
163
|
+
if (!pSyms->pStrTab) {
|
164
|
+
pSyms->pStrTab = (const char*)pSectionContent;
|
165
|
+
pSyms->strTabSize = pSection->sh_size;
|
166
|
+
}
|
167
|
+
break;
|
168
|
+
}
|
169
|
+
if (pSyms->pSymTab && pSyms->pStrTab)
|
170
|
+
break;
|
171
|
+
}
|
172
|
+
return pSyms;
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
void dlSymsCleanup(DLSyms* pSyms)
|
177
|
+
{
|
178
|
+
if(pSyms) {
|
179
|
+
munmap((void*) pSyms->pElf_Ehdr, pSyms->fileSize);
|
180
|
+
close(pSyms->file);
|
181
|
+
dlFreeMem(pSyms);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
int dlSymsCount(DLSyms* pSyms)
|
187
|
+
{
|
188
|
+
if (!pSyms)
|
189
|
+
return 0;
|
190
|
+
return pSyms->nSymbols;
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
const char* dlSymsName(DLSyms* pSyms, int index)
|
195
|
+
{
|
196
|
+
int str_index;
|
197
|
+
if(!pSyms || !pSyms->pSymTab || index < 0 || index >= pSyms->nSymbols)
|
198
|
+
return NULL;
|
199
|
+
|
200
|
+
str_index = pSyms->pSymTab[index].st_name;
|
201
|
+
if (str_index < 0 || str_index >= pSyms->strTabSize)
|
202
|
+
return NULL;
|
203
|
+
return &pSyms->pStrTab[str_index];
|
204
|
+
}
|
205
|
+
|
206
|
+
|
207
|
+
const char* dlSymsNameFromValue(DLSyms* pSyms, void* value)
|
208
|
+
{
|
209
|
+
Dl_info info;
|
210
|
+
return (dladdr(value, &info) && (value == info.dli_saddr))
|
211
|
+
? info.dli_sname
|
212
|
+
: NULL;
|
213
|
+
}
|
214
|
+
|
@@ -0,0 +1,167 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dynload
|
5
|
+
File: dynload/dynload_syms_mach-o.c
|
6
|
+
Description:
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Olivier Chafik <olivier.chafik@gmail.com>
|
10
|
+
|
11
|
+
Permission to use, copy, modify, and distribute this software for any
|
12
|
+
purpose with or without fee is hereby granted, provided that the above
|
13
|
+
copyright notice and this permission notice appear in all copies.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
16
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
17
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
18
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
19
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
20
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
21
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
22
|
+
|
23
|
+
*/
|
24
|
+
|
25
|
+
|
26
|
+
/*
|
27
|
+
|
28
|
+
dynamic symbol resolver for Mach-O
|
29
|
+
|
30
|
+
*/
|
31
|
+
|
32
|
+
#include "dynload.h"
|
33
|
+
#include "dynload_alloc.h"
|
34
|
+
|
35
|
+
#include <mach-o/dyld.h>
|
36
|
+
#include <mach-o/nlist.h>
|
37
|
+
#include <dlfcn.h>
|
38
|
+
#include <string.h>
|
39
|
+
|
40
|
+
#if defined(ARCH_X64)
|
41
|
+
#define MACH_HEADER_TYPE mach_header_64
|
42
|
+
#define SEGMENT_COMMAND segment_command_64
|
43
|
+
#define NLIST_TYPE nlist_64
|
44
|
+
#else
|
45
|
+
#define MACH_HEADER_TYPE mach_header
|
46
|
+
#define SEGMENT_COMMAND segment_command
|
47
|
+
#define NLIST_TYPE nlist
|
48
|
+
#endif
|
49
|
+
|
50
|
+
|
51
|
+
struct DLLib_
|
52
|
+
{
|
53
|
+
char* libPath;
|
54
|
+
void* handle;
|
55
|
+
};
|
56
|
+
|
57
|
+
|
58
|
+
struct DLSyms_
|
59
|
+
{
|
60
|
+
const char* pStringTable;
|
61
|
+
const struct NLIST_TYPE* pSymbolTable;
|
62
|
+
uint32_t symbolCount;
|
63
|
+
};
|
64
|
+
|
65
|
+
|
66
|
+
DLSyms* dlSymsInit(const char* libPath)
|
67
|
+
{
|
68
|
+
DLSyms* pSyms = NULL;
|
69
|
+
uint32_t iImage, nImages;
|
70
|
+
for (iImage = 0, nImages = _dyld_image_count(); iImage < nImages; iImage++)
|
71
|
+
{
|
72
|
+
const char* name = _dyld_get_image_name(iImage);
|
73
|
+
if (name && !strcmp(name, libPath))
|
74
|
+
{
|
75
|
+
const struct MACH_HEADER_TYPE* pHeader = (const struct MACH_HEADER_TYPE*) _dyld_get_image_header(iImage);
|
76
|
+
const char* pBase = ((const char*)pHeader);
|
77
|
+
if (pHeader->filetype != MH_DYLIB)
|
78
|
+
return NULL;
|
79
|
+
if (pHeader->flags & MH_SPLIT_SEGS)
|
80
|
+
return NULL;
|
81
|
+
|
82
|
+
if (pHeader)
|
83
|
+
{
|
84
|
+
uint32_t iCmd, nCmds = pHeader->ncmds;
|
85
|
+
const struct load_command* cmd = (const struct load_command*)(pBase + sizeof(struct MACH_HEADER_TYPE));
|
86
|
+
|
87
|
+
for (iCmd = 0; iCmd < nCmds; iCmd++)
|
88
|
+
{
|
89
|
+
if (cmd->cmd == LC_SYMTAB)
|
90
|
+
{
|
91
|
+
const struct symtab_command* scmd = (const struct symtab_command*)cmd;
|
92
|
+
|
93
|
+
pSyms = (DLSyms*)( dlAllocMem(sizeof(DLSyms)) );
|
94
|
+
pSyms->symbolCount = scmd->nsyms;
|
95
|
+
pSyms->pStringTable = pBase + scmd->stroff;
|
96
|
+
pSyms->pSymbolTable = (struct NLIST_TYPE*)(pBase + scmd->symoff);
|
97
|
+
|
98
|
+
return pSyms;
|
99
|
+
}
|
100
|
+
cmd = (const struct load_command*)(((char*)cmd) + cmd->cmdsize);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
return NULL;
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
void dlSymsCleanup(DLSyms* pSyms)
|
111
|
+
{
|
112
|
+
if (!pSyms)
|
113
|
+
return;
|
114
|
+
|
115
|
+
dlFreeMem(pSyms);
|
116
|
+
}
|
117
|
+
|
118
|
+
int dlSymsCount(DLSyms* pSyms)
|
119
|
+
{
|
120
|
+
if (!pSyms)
|
121
|
+
return 0;
|
122
|
+
return pSyms->symbolCount;
|
123
|
+
}
|
124
|
+
|
125
|
+
static const struct NLIST_TYPE* get_nlist(DLSyms* pSyms, int index)
|
126
|
+
{
|
127
|
+
const struct NLIST_TYPE* nl;
|
128
|
+
if (!pSyms)
|
129
|
+
return NULL;
|
130
|
+
|
131
|
+
nl = pSyms->pSymbolTable + index;
|
132
|
+
if (nl->n_un.n_strx <= 1)
|
133
|
+
return NULL; // would be empty string anyway
|
134
|
+
|
135
|
+
//TODO skip more symbols based on nl->n_desc and nl->n_type ?
|
136
|
+
return nl;
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
const char* dlSymsName(DLSyms* pSyms, int index)
|
141
|
+
{
|
142
|
+
const struct NLIST_TYPE* nl = get_nlist(pSyms, index);
|
143
|
+
if (!nl)
|
144
|
+
return NULL;
|
145
|
+
|
146
|
+
return pSyms->pStringTable + nl->n_un.n_strx;
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
void* dlSymsValue(DLSyms* pSyms, int index)
|
151
|
+
{
|
152
|
+
const struct NLIST_TYPE* nl = get_nlist(pSyms, index);
|
153
|
+
if (!nl)
|
154
|
+
return NULL;
|
155
|
+
|
156
|
+
return (void*) (ptrdiff_t) (nl->n_value);
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
const char* dlSymsNameFromValue(DLSyms* pSyms, void* value)
|
161
|
+
{
|
162
|
+
Dl_info info;
|
163
|
+
if (!dladdr(value, &info) || (value != info.dli_saddr))
|
164
|
+
return NULL;
|
165
|
+
|
166
|
+
return info.dli_sname;
|
167
|
+
}
|