rbdc 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/dyncall/BUGS +1 -1
  3. data/dyncall/CMakeLists.txt +19 -7
  4. data/dyncall/ChangeLog +61 -20
  5. data/dyncall/LICENSE +1 -1
  6. data/dyncall/Makefile.generic +2 -0
  7. data/dyncall/ToDo +97 -29
  8. data/dyncall/autovar/README.txt +1 -0
  9. data/dyncall/autovar/autovar_ABI.h +4 -2
  10. data/dyncall/autovar/autovar_ARCH.h +9 -5
  11. data/dyncall/autovar/autovar_CC.h +3 -1
  12. data/dyncall/autovar/autovar_OS.h +2 -2
  13. data/dyncall/autovar/autovar_OSFAMILY.h +1 -1
  14. data/dyncall/configure +94 -38
  15. data/dyncall/dyncall/dyncall.3 +8 -4
  16. data/dyncall/dyncall/dyncall.h +1 -1
  17. data/dyncall/dyncall/dyncall_alloc.h +1 -1
  18. data/dyncall/dyncall/dyncall_api.c +3 -1
  19. data/dyncall/dyncall/dyncall_call.S +13 -5
  20. data/dyncall/dyncall/dyncall_call_arm32_arm.S +1 -2
  21. data/dyncall/dyncall/dyncall_call_arm32_arm.h +1 -1
  22. data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.S +24 -26
  23. data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.h +1 -1
  24. data/dyncall/dyncall/dyncall_call_arm32_thumb.h +1 -1
  25. data/dyncall/dyncall/dyncall_call_arm32_thumb_armhf.S +1 -1
  26. data/dyncall/dyncall/dyncall_call_arm32_thumb_gas.s +3 -7
  27. data/dyncall/dyncall/dyncall_call_arm64.S +2 -2
  28. data/dyncall/dyncall/dyncall_call_arm64.h +2 -2
  29. data/dyncall/dyncall/dyncall_call_mips.h +1 -1
  30. data/dyncall/dyncall/dyncall_call_mips_eabi.h +1 -1
  31. data/dyncall/dyncall/dyncall_call_mips_eabi_gas.s +16 -16
  32. data/dyncall/dyncall/dyncall_call_mips_gas.S +2 -2
  33. data/dyncall/dyncall/dyncall_call_mips_n32.h +5 -4
  34. data/dyncall/dyncall/dyncall_call_mips_n32_gas.s +4 -4
  35. data/dyncall/dyncall/dyncall_call_mips_n64.h +3 -3
  36. data/dyncall/dyncall/dyncall_call_mips_n64_gas.s +2 -2
  37. data/dyncall/dyncall/dyncall_call_mips_o32.h +4 -3
  38. data/dyncall/dyncall/dyncall_call_mips_o32_gas.s +1 -3
  39. data/dyncall/dyncall/dyncall_call_ppc32.S +1 -1
  40. data/dyncall/dyncall/dyncall_call_ppc32.h +1 -1
  41. data/dyncall/dyncall/dyncall_call_sparc.h +1 -1
  42. data/dyncall/dyncall/{dyncall_call_sparc.S → dyncall_call_sparc.s} +39 -44
  43. data/dyncall/dyncall/dyncall_call_sparc64.h +5 -5
  44. data/dyncall/dyncall/dyncall_call_sparc64.s +177 -0
  45. data/dyncall/dyncall/dyncall_call_x64.S +83 -86
  46. data/dyncall/dyncall/dyncall_call_x64.h +1 -1
  47. data/dyncall/dyncall/dyncall_call_x86.S +9 -9
  48. data/dyncall/dyncall/dyncall_call_x86.h +1 -1
  49. data/dyncall/dyncall/dyncall_call_x86_nasm.asm +5 -5
  50. data/dyncall/dyncall/dyncall_callf.c +18 -18
  51. data/dyncall/dyncall/dyncall_callf.h +1 -1
  52. data/dyncall/dyncall/dyncall_callvm.c +3 -3
  53. data/dyncall/dyncall/dyncall_callvm.h +1 -1
  54. data/dyncall/dyncall/dyncall_callvm_arm32_arm.c +25 -40
  55. data/dyncall/dyncall/dyncall_callvm_arm32_arm.h +1 -5
  56. data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.c +25 -33
  57. data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.h +1 -5
  58. data/dyncall/dyncall/dyncall_callvm_arm32_thumb.c +24 -36
  59. data/dyncall/dyncall/dyncall_callvm_arm32_thumb.h +1 -5
  60. data/dyncall/dyncall/dyncall_callvm_arm64.c +23 -27
  61. data/dyncall/dyncall/dyncall_callvm_arm64.h +2 -6
  62. data/dyncall/dyncall/dyncall_callvm_arm64_apple.c +23 -30
  63. data/dyncall/dyncall/dyncall_callvm_base.c +1 -1
  64. data/dyncall/dyncall/dyncall_callvm_mips.c +1 -1
  65. data/dyncall/dyncall/dyncall_callvm_mips.h +1 -1
  66. data/dyncall/dyncall/dyncall_callvm_mips_eabi.c +30 -27
  67. data/dyncall/dyncall/dyncall_callvm_mips_eabi.h +1 -5
  68. data/dyncall/dyncall/dyncall_callvm_mips_n32.c +24 -30
  69. data/dyncall/dyncall/{dyncall_call_sparc_v9.h → dyncall_callvm_mips_n32.h} +18 -8
  70. data/dyncall/dyncall/dyncall_callvm_mips_n64.c +23 -30
  71. data/dyncall/dyncall/dyncall_callvm_mips_n64.h +4 -6
  72. data/dyncall/dyncall/dyncall_callvm_mips_o32.c +31 -29
  73. data/dyncall/dyncall/dyncall_callvm_mips_o32.h +1 -3
  74. data/dyncall/dyncall/dyncall_callvm_ppc32.c +22 -20
  75. data/dyncall/dyncall/dyncall_callvm_ppc32.h +1 -3
  76. data/dyncall/dyncall/dyncall_callvm_ppc64.c +54 -15
  77. data/dyncall/dyncall/dyncall_callvm_ppc64.h +0 -2
  78. data/dyncall/dyncall/dyncall_callvm_sparc.c +34 -26
  79. data/dyncall/dyncall/dyncall_callvm_sparc.h +1 -3
  80. data/dyncall/dyncall/dyncall_callvm_sparc64.c +94 -150
  81. data/dyncall/dyncall/dyncall_callvm_sparc64.h +11 -17
  82. data/dyncall/dyncall/dyncall_callvm_x64.c +37 -36
  83. data/dyncall/dyncall/dyncall_callvm_x64.h +1 -4
  84. data/dyncall/dyncall/dyncall_callvm_x86.c +22 -63
  85. data/dyncall/dyncall/dyncall_callvm_x86.h +1 -17
  86. data/dyncall/dyncall/dyncall_config.h +1 -1
  87. data/dyncall/dyncall/dyncall_macros.h +28 -19
  88. data/dyncall/dyncall/dyncall_signature.h +1 -1
  89. data/dyncall/dyncall/dyncall_types.h +17 -18
  90. data/dyncall/dyncall/dyncall_utils.h +1 -1
  91. data/dyncall/dyncall/dyncall_value.h +28 -21
  92. data/dyncall/dyncall/dyncall_vector.c +1 -1
  93. data/dyncall/dyncall/dyncall_vector.h +1 -1
  94. data/dyncall/dyncall/gen-masm.sh +2 -2
  95. data/dyncall/dyncallback/CMakeLists.txt +1 -2
  96. data/dyncall/dyncallback/Makefile.generic +1 -1
  97. data/dyncall/dyncallback/dyncall_alloc_wx.c +1 -1
  98. data/dyncall/dyncallback/dyncall_alloc_wx.h +4 -3
  99. data/dyncall/dyncallback/dyncall_alloc_wx_malloc.c +8 -2
  100. data/dyncall/dyncallback/dyncall_alloc_wx_mmap.c +67 -4
  101. data/dyncall/dyncallback/dyncall_alloc_wx_win32.c +7 -2
  102. data/dyncall/dyncallback/dyncall_args.c +19 -15
  103. data/dyncall/dyncallback/dyncall_args.h +1 -1
  104. data/dyncall/dyncallback/{dyncall_args_arm32_arm.c → dyncall_args_arm32.c} +4 -4
  105. data/dyncall/dyncallback/{dyncall_args_arm32_arm.h → dyncall_args_arm32.h} +6 -6
  106. data/dyncall/dyncallback/dyncall_args_arm64.c +2 -2
  107. data/dyncall/dyncallback/dyncall_args_arm64_apple.c +2 -2
  108. data/dyncall/dyncallback/dyncall_args_mips.c +26 -21
  109. data/dyncall/dyncallback/dyncall_args_mips.h +18 -6
  110. data/dyncall/dyncallback/dyncall_args_mips64.c +81 -0
  111. data/dyncall/dyncallback/dyncall_args_mips_o32.c +104 -0
  112. data/dyncall/dyncallback/dyncall_args_ppc32.c +2 -2
  113. data/dyncall/dyncallback/dyncall_args_ppc32.h +1 -1
  114. data/dyncall/dyncallback/dyncall_args_ppc32_sysv.c +1 -1
  115. data/dyncall/dyncallback/dyncall_args_ppc64.c +24 -3
  116. data/dyncall/dyncallback/dyncall_args_sparc32.c +41 -15
  117. data/dyncall/dyncallback/dyncall_args_sparc32.h +2 -2
  118. data/dyncall/dyncallback/dyncall_args_sparc64.c +28 -15
  119. data/dyncall/dyncallback/dyncall_args_sparc64.h +7 -3
  120. data/dyncall/dyncallback/dyncall_args_x64.c +1 -1
  121. data/dyncall/dyncallback/dyncall_args_x64.h +1 -1
  122. data/dyncall/dyncallback/dyncall_args_x86.c +1 -1
  123. data/dyncall/dyncallback/dyncall_args_x86.h +1 -1
  124. data/dyncall/dyncallback/dyncall_callback.c +10 -12
  125. data/dyncall/dyncallback/dyncall_callback.h +2 -4
  126. data/dyncall/dyncallback/dyncall_callback_arch.S +12 -2
  127. data/dyncall/dyncallback/{dyncall_callback_arm32_arm.c → dyncall_callback_arm32.c} +25 -10
  128. data/dyncall/dyncallback/dyncall_callback_arm32_arm_apple.s +7 -7
  129. data/dyncall/dyncallback/dyncall_callback_arm32_arm_gas.S +9 -9
  130. data/dyncall/dyncallback/dyncall_callback_arm32_thumb_apple.S +1 -1
  131. data/dyncall/dyncallback/dyncall_callback_arm32_thumb_gas.S +1 -1
  132. data/dyncall/dyncallback/dyncall_callback_arm64.S +2 -2
  133. data/dyncall/dyncallback/dyncall_callback_arm64.c +20 -14
  134. data/dyncall/dyncallback/dyncall_callback_mips.c +26 -9
  135. data/dyncall/dyncallback/dyncall_callback_mips_eabi_gas.s +99 -0
  136. data/dyncall/dyncallback/{dyncall_args_arm32_thumb.h → dyncall_callback_mips_gas.S} +14 -9
  137. data/dyncall/dyncallback/{dyncall_callback_arm32_thumb.c → dyncall_callback_mips_n32_gas.s} +12 -7
  138. data/dyncall/dyncallback/dyncall_callback_mips_n64_gas.s +98 -0
  139. data/dyncall/dyncallback/dyncall_callback_mips_o32_gas.s +100 -0
  140. data/dyncall/dyncallback/dyncall_callback_ppc32.S +54 -54
  141. data/dyncall/dyncallback/dyncall_callback_ppc32.c +23 -5
  142. data/dyncall/dyncallback/dyncall_callback_ppc32_apple.s +92 -117
  143. data/dyncall/dyncallback/dyncall_callback_ppc64.S +2 -2
  144. data/dyncall/dyncallback/dyncall_callback_ppc64.c +23 -5
  145. data/dyncall/dyncallback/dyncall_callback_sparc32.c +25 -7
  146. data/dyncall/dyncallback/dyncall_callback_sparc32.s +55 -4
  147. data/dyncall/dyncallback/dyncall_callback_sparc64.c +25 -7
  148. data/dyncall/dyncallback/dyncall_callback_sparc64.s +89 -5
  149. data/dyncall/dyncallback/dyncall_callback_x64.S +8 -8
  150. data/dyncall/dyncallback/dyncall_callback_x64.c +19 -6
  151. data/dyncall/dyncallback/dyncall_callback_x86.S +29 -25
  152. data/dyncall/dyncallback/dyncall_callback_x86.c +24 -11
  153. data/dyncall/dyncallback/dyncall_thunk.c +6 -6
  154. data/dyncall/dyncallback/dyncall_thunk.h +9 -7
  155. data/dyncall/dyncallback/{dyncall_thunk_arm32_arm.c → dyncall_thunk_arm32.c} +5 -3
  156. data/dyncall/dyncallback/{dyncall_thunk_arm32_arm.h → dyncall_thunk_arm32.h} +7 -7
  157. data/dyncall/dyncallback/dyncall_thunk_arm64.c +2 -2
  158. data/dyncall/dyncallback/dyncall_thunk_arm64.h +8 -13
  159. data/dyncall/dyncallback/dyncall_thunk_mips.c +16 -20
  160. data/dyncall/dyncallback/dyncall_thunk_mips.h +4 -2
  161. data/dyncall/dyncallback/dyncall_thunk_mips64.c +103 -0
  162. data/dyncall/dyncallback/{dyncall_callback_arm32_thumb.h → dyncall_thunk_mips64.h} +15 -8
  163. data/dyncall/dyncallback/dyncall_thunk_ppc32.c +4 -4
  164. data/dyncall/dyncallback/dyncall_thunk_ppc32.h +1 -1
  165. data/dyncall/dyncallback/dyncall_thunk_ppc32_sysv.c +9 -9
  166. data/dyncall/dyncallback/dyncall_thunk_ppc64.c +2 -2
  167. data/dyncall/dyncallback/dyncall_thunk_sparc32.c +19 -2
  168. data/dyncall/dyncallback/dyncall_thunk_sparc32.h +5 -4
  169. data/dyncall/dyncallback/dyncall_thunk_sparc64.c +42 -2
  170. data/dyncall/dyncallback/dyncall_thunk_sparc64.h +5 -5
  171. data/dyncall/dyncallback/dyncall_thunk_x64.c +1 -1
  172. data/dyncall/dyncallback/dyncall_thunk_x64.h +2 -2
  173. data/dyncall/dyncallback/dyncall_thunk_x86.c +1 -1
  174. data/dyncall/dyncallback/dyncall_thunk_x86.h +2 -2
  175. data/dyncall/dyncallback/dyncallback.3 +16 -11
  176. data/dyncall/dynload/dynload.3 +63 -8
  177. data/dyncall/dynload/dynload.c +2 -8
  178. data/dyncall/dynload/dynload.h +9 -5
  179. data/dyncall/dynload/dynload_alloc.h +1 -1
  180. data/dyncall/dynload/dynload_syms.c +1 -3
  181. data/dyncall/dynload/dynload_syms_elf.c +19 -11
  182. data/dyncall/dynload/dynload_syms_mach-o.c +151 -75
  183. data/dyncall/dynload/dynload_syms_pe.c +24 -24
  184. data/dyncall/dynload/dynload_unix.c +156 -13
  185. data/dyncall/dynload/dynload_windows.c +15 -11
  186. data/dyncall/portasm/portasm-arm.S +1 -1
  187. data/dyncall/portasm/portasm-ppc.S +1 -1
  188. data/dyncall/portasm/{portasm-x64-att.S → portasm-x64.S} +7 -4
  189. data/dyncall/portasm/portasm-x86.S +4 -2
  190. data/{dyncall-bindings/ruby/rbdc/extconf.rb → extconf.rb} +4 -4
  191. data/{dyncall-bindings/ruby/rbdc/rbdc.c → rbdc.c} +5 -5
  192. metadata +24 -48
  193. data/dyncall/Makefile.M +0 -15
  194. data/dyncall/buildsys/dynmake/Makefile.base.M +0 -82
  195. data/dyncall/buildsys/dynmake/dynmake.bat +0 -2
  196. data/dyncall/buildsys/dynmake/dynmake.sh +0 -4
  197. data/dyncall/dynMakefile +0 -4
  198. data/dyncall/dyncall/Makefile.M +0 -10
  199. data/dyncall/dyncall/TODO +0 -9
  200. data/dyncall/dyncall/dynMakefile +0 -4
  201. data/dyncall/dyncall/dyncall_call_sparc64.S +0 -362
  202. data/dyncall/dyncall/dyncall_call_sparc_v9.S +0 -222
  203. data/dyncall/dyncall/dyncall_call_x64-att.S +0 -147
  204. data/dyncall/dyncall/dyncall_callvm_sparc_v9.c +0 -182
  205. data/dyncall/dyncall/dyncall_callvm_sparc_v9.h +0 -46
  206. data/dyncall/dyncallback/Makefile.M +0 -10
  207. data/dyncall/dyncallback/README.txt +0 -9
  208. data/dyncall/dyncallback/TODO +0 -4
  209. data/dyncall/dyncallback/dynMakefile +0 -4
  210. data/dyncall/dyncallback/dyncall_args_arm32_thumb.c +0 -30
  211. data/dyncall/dyncallback/dyncall_callback_arm32_arm.h +0 -46
  212. data/dyncall/dyncallback/dyncall_callback_mips.h +0 -43
  213. data/dyncall/dyncallback/dyncall_callback_ppc32.h +0 -43
  214. data/dyncall/dyncallback/dyncall_callback_ppc64.h +0 -56
  215. data/dyncall/dyncallback/dyncall_callback_sparc32.h +0 -44
  216. data/dyncall/dyncallback/dyncall_callback_x64.h +0 -45
  217. data/dyncall/dyncallback/dyncall_callback_x86.h +0 -50
  218. data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.c +0 -30
  219. data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.h +0 -36
  220. data/dyncall/dynload/Makefile.M +0 -10
  221. data/dyncall/dynload/TODO +0 -20
  222. data/dyncall/dynload/dynMakefile +0 -4
  223. data/dyncall/dynload/dynload_darwin.c +0 -90
@@ -6,7 +6,7 @@
6
6
  Description: Thunks on PowerPC 32-bit System V ABI
7
7
  License:
8
8
 
9
- Copyright (c) 2015 Daniel Adler <dadler@uni-goettingen.de>
9
+ Copyright (c) 2015-2018 Daniel Adler <dadler@uni-goettingen.de>
10
10
 
11
11
  Permission to use, copy, modify, and distribute this software for any
12
12
  purpose with or without fee is hereby granted, provided that the above
@@ -25,21 +25,21 @@
25
25
 
26
26
  #include "dyncall_thunk.h"
27
27
 
28
- unsigned short hi16(x) { return ( (unsigned short) (((unsigned int)x)>>16UL) ); }
29
- unsigned short lo16(x) { return ( (unsigned short) ((unsigned int)x) ); }
28
+ static unsigned short hi16(x) { return ( (unsigned short) (((unsigned int)x)>>16UL) ); }
29
+ static unsigned short lo16(x) { return ( (unsigned short) ((unsigned int)x) ); }
30
30
 
31
31
  void dcbInitThunk(DCThunk* p, void (*entry)())
32
32
  {
33
33
  /*
34
- 0: 3d 60 00 00 lis r11,0
35
- 4: 61 6b 00 01 ori r11,r11,1
36
- 8: 81 82 00 14 lwz r12,20(r2)
37
- c: 7d 89 03 a6 mtctr r12
38
- 10: 4e 80 04 20 bctr
34
+ 0: 3d 60 00 00 lis r11,0
35
+ 4: 61 6b 00 01 ori r11,r11,1
36
+ 8: 81 82 00 14 lwz r12,20(r2)
37
+ c: 7d 89 03 a6 mtctr r12
38
+ 10: 4e 80 04 20 bctr
39
39
  */
40
40
  p->code_load_hi = 0x3d60U; /* lis r11, HI16(p) */
41
41
  p->addr_self_hi = hi16(p);
42
- p->code_load_lo = 0x616bU; /* ori r11, r11, LO16(p) */
42
+ p->code_load_lo = 0x616bU; /* ori r11, r11, LO16(p) */
43
43
  p->addr_self_lo = lo16(p);
44
44
  p->code_jump[0] = 0x818b0014U; /* lwz r12, 20(r11) */
45
45
  p->code_jump[1] = 0x7d8903a6U; /* mtclr r12 */
@@ -47,7 +47,7 @@ void dcbInitThunk(DCThunk* p, void (*entry)())
47
47
 
48
48
  p->code_load_hi = 0x644bU; /* oris r11, r2, HI16(p) */
49
49
  p->addr_self_hi = HI16(p);
50
- p->code_load_lo = 0x616bU; /* ori r11,r11, LO16(p) */
50
+ p->code_load_lo = 0x616bU; /* ori r11,r11, LO16(p) */
51
51
  p->addr_self_lo = LO16(p);
52
52
  p->code_jump[0] = 0xe98b0030U; /* ld r12,48(r11) */
53
53
  p->code_jump[1] = 0xe84b0038U; /* ld r2,56(r11) */
@@ -76,7 +76,7 @@ void dcbInitThunk(DCThunk* p, void (*entry)())
76
76
  p->code_rot = 0x796b07c6U; /* rldicr r11,r11,32,31 */
77
77
  p->code_load_hi = 0x656bU; /* oris r11,r11, HI16(p) */
78
78
  p->addr_self_hi = HI16(p);
79
- p->code_load_lo = 0x616bU; /* ori r11,r11, LO16(p) */
79
+ p->code_load_lo = 0x616bU; /* ori r11,r11, LO16(p) */
80
80
  p->addr_self_lo = LO16(p);
81
81
  p->code_jump[0] = 0xe98b0028U; /* ld r12,40(r11) */
82
82
  p->code_jump[1] = 0x7d8903a6U; /* mtclr r12 */
@@ -6,7 +6,7 @@
6
6
  Description: Thunk - Implementation for sparc32
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -28,6 +28,23 @@
28
28
 
29
29
  void dcbInitThunk(DCThunk* p, void (*entry)())
30
30
  {
31
- /* not yet implemented */
31
+ /* example
32
+ ; put thunk pointer in g1
33
+ 0: 03 00 00 00 sethi %hi(0), %g1
34
+ 4: 82 10 60 00 or %g1, 0, %g1
35
+ ; use g2 for entry pointer and "call" it, b/c branch instructions can't handle 32bit addresses
36
+ 8: 05 00 00 00 sethi %hi(0), %g2
37
+ 12: 84 10 a0 00 or %g2, 0, %g2
38
+ ; jump - write link to %g0, effectively discarding it; also nop for delay slot
39
+ 16: 81 c0 80 00 jmpl %g2, %g0
40
+ 20: 01 00 00 00 nop
41
+ */
42
+
43
+ p->code[0] = 0x03000000 | ((unsigned int)p >> 10); /* sethi %hi(p), %g1 -- hi 22 bits */
44
+ p->code[1] = 0x82106000 | ((unsigned int)p & 0x3ff); /* or %g1, <p&0x3ff>, %g1 -- lo 10 bits */
45
+ p->code[2] = 0x05000000 | ((unsigned int)entry >> 10); /* sethi %hi(entry), %g2 */
46
+ p->code[3] = 0x8410a000 | ((unsigned int)entry & 0x3ff); /* or %g2, <entry&0x3ff>, %g2 */
47
+ p->code[4] = 0x81c08000; /* jmpl %g2, %g0 -- discards link addr */
48
+ p->code[5] = 0x01000000; /* nop */
32
49
  }
33
50
 
@@ -3,10 +3,10 @@
3
3
  Package: dyncall
4
4
  Library: dyncallback
5
5
  File: dyncallback/dyncall_thunk_sparc32.h
6
- Description: Thunk - Header for sparc32 - not yet implemented
6
+ Description: Thunk - Header for sparc32
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -29,9 +29,10 @@
29
29
 
30
30
  struct DCThunk_
31
31
  {
32
- int x[4]; /* dummy */
32
+ unsigned int code[6];
33
33
  };
34
34
 
35
- #define DCTHUNK_SIZE_SPARC32 32
35
+ #define DCTHUNK_SIZE_SPARC32 24
36
36
 
37
37
  #endif /* DYNCALL_THUNK_SPARC32_H */
38
+
@@ -6,7 +6,7 @@
6
6
  Description: Thunk - Implementation for sparc64
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -28,6 +28,46 @@
28
28
 
29
29
  void dcbInitThunk(DCThunk* p, void (*entry)())
30
30
  {
31
- /* not yet implemented */
31
+ /* example
32
+ ; put thunk pointer in g1
33
+ 0: 03 00 00 00 sethi %hi(0), %g1
34
+ 4: 82 10 60 00 or %g1, 0, %g1
35
+ 8: 83 28 70 20 sllx %g1, 0x20, %g1
36
+ 12: 21 00 00 00 sethi %hi(0), %l0
37
+ 16: a0 14 20 00 or %l0, 0, %l0
38
+ 20: 82 04 00 01 add %l0, %g1, %g1
39
+ ; use g2 for entry pointer and "call" it, b/c branch instructions can't handle 64bit addresses
40
+ 24: 05 00 00 00 sethi %hi(0), %g2
41
+ 28: 84 10 a0 00 or %g2, 0, %g2
42
+ 32: 85 28 b0 20 sllx %g2, 0x20, %g2
43
+ 36: 21 00 00 00 sethi %hi(0), %l0
44
+ 40: a0 14 20 00 or %l0, 0, %l0
45
+ 44: 84 04 00 02 add %l0, %g2, %g2
46
+ ; jump - write link to %g0, effectively discarding it; also nop for delay slot
47
+ 48: 81 c0 80 00 jmpl %g2, %g0
48
+ 52: 01 00 00 00 nop
49
+ */
50
+
51
+ union {
52
+ unsigned int x[2];
53
+ void* p;
54
+ } t, e;
55
+ t.p = p;
56
+ e.p = entry;
57
+
58
+ p->code[ 0] = 0x03000000 | (t.x[0] >> 10); /* sethi %hi(p), %g1 -- hi 22 bits */
59
+ p->code[ 1] = 0x82106000 | (t.x[0] & 0x3ff); /* or %g1, <p&0x3ff>, %g1 -- lo 10 bits */
60
+ p->code[ 2] = 0x83287020; /* sllx %g1, 0x20, %g1 */
61
+ p->code[ 3] = 0x21000000 | (t.x[1] >> 10); /* sethi %hi(p), %l0 */
62
+ p->code[ 4] = 0xa0142000 | (t.x[1] & 0x3ff); /* or %l0, <p&0x3ff>, %l0 */
63
+ p->code[ 5] = 0x82040001; /* add %l0, %g1, %g1 */
64
+ p->code[ 6] = 0x05000000 | (e.x[0] >> 10); /* sethi %hi(entry), %g2 */
65
+ p->code[ 7] = 0x8410a000 | (e.x[0] & 0x3ff); /* or %g2, <entry&0x3ff>, %g2 */
66
+ p->code[ 8] = 0x8528b020; /* sllx %g2, 0x20, %g2 */
67
+ p->code[ 9] = 0x21000000 | (e.x[1] >> 10); /* sethi %hi(entry), %l0 */
68
+ p->code[10] = 0xa0142000 | (e.x[1] & 0x3ff); /* or %l0, <entry&0x3ff>, %l0 */
69
+ p->code[11] = 0x84040002; /* add %l0, %g2, %g2 */
70
+ p->code[12] = 0x81c08000; /* jmpl %g2, %g0 -- discards link addr */
71
+ p->code[13] = 0x01000000; /* nop */
32
72
  }
33
73
 
@@ -3,10 +3,10 @@
3
3
  Package: dyncall
4
4
  Library: dyncallback
5
5
  File: dyncallback/dyncall_thunk_sparc64.h
6
- Description: Thunk - Header for sparc64 - not yet implemented
6
+ Description: Thunk - Header for sparc64
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -29,9 +29,9 @@
29
29
 
30
30
  struct DCThunk_
31
31
  {
32
- int x[4]; /* dummy */
32
+ unsigned int code[14];
33
33
  };
34
34
 
35
- #define DCTHUNK_SIZE_SPARC64 32
35
+ #define DCTHUNK_SIZE_SPARC64 56
36
36
 
37
- #endif /* DYNCALL_THUNK_SPARC32_H */
37
+ #endif /* DYNCALL_THUNK_SPARC64_H */
@@ -6,7 +6,7 @@
6
6
  Description: Thunk - Implementation for x64
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -6,7 +6,7 @@
6
6
  Description: Thunk - Header for x64
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -33,7 +33,7 @@ struct DCThunk_
33
33
  void (*entry)();
34
34
  };
35
35
 
36
- #define DCTHUNK_X64_SIZE 24
36
+ #define DCTHUNK_X64_SIZE 24
37
37
 
38
38
 
39
39
  #endif /* DYNCALL_THUNK_X64_H */
@@ -6,7 +6,7 @@
6
6
  Description: Thunk - Implementation for x86
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -6,7 +6,7 @@
6
6
  Description: Thunk - Header for x86
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -35,6 +35,6 @@ struct DCThunk_
35
35
  void (*addr_entry)();
36
36
  };
37
37
 
38
- #define DCTHUNK_X86_SIZE 16
38
+ #define DCTHUNK_X86_SIZE 16
39
39
 
40
40
  #endif /* DYNCALL_THUNK_X86_H */
@@ -15,7 +15,6 @@
15
15
  .\"
16
16
  .Dd $Mdocdate$
17
17
  .Dt dyncallback 3
18
- .Os
19
18
  .Sh NAME
20
19
  .Nm dyncallback
21
20
  .Nd callback interface of dyncall
@@ -40,14 +39,15 @@ dynamically over the arguments once called back.
40
39
  .Fn dcbNewCallback
41
40
  creates a new callback object, where
42
41
  .Ar signature
43
- is a signature string describing the function to be called back (see manual for
44
- format). This is needed for
42
+ is a signature string describing the function to be called back (see manual or
43
+ dyncall_signature.h for format). This is needed for
45
44
  .Nm
46
45
  dyncallback to correctly prepare the arguments passed in by the function that
47
46
  calls the callback handler. Note that the handler doesn't return the value
48
- specified in the signature, directly, but simply 'i' or 'f' depending on whether
49
- it is a integral or floating point type. The return value itself is stored
50
- where the handler's 3rd parameter points to (see example).
47
+ specified in the signature, directly, but a signature character, specifying the
48
+ return value's type.
49
+ The return value itself is stored where the handler's
50
+ 3rd parameter points to (see below).
51
51
  .Ar funcptr
52
52
  is a pointer to the
53
53
  .Nm
@@ -107,13 +107,12 @@ char cbHandler(DCCallback* cb,
107
107
  // .. do something ..
108
108
 
109
109
  result->s = 1244;
110
- return 'i';
110
+ return 's';
111
111
  }
112
112
  .Ed
113
113
  .Pp
114
114
  Note that the return value of the handler is a signature character, not the
115
- actual return value, itself, and note that the actual return value is of type
116
- short.
115
+ actual return value, itself.
117
116
  Now, let's call it through a DCCallback object:
118
117
  .Bd -literal -offset indent
119
118
  DCCallback* cb;
@@ -124,11 +123,17 @@ Now, let's call it through a DCCallback object:
124
123
  (123, 23.f, 3, 1.82, 9909ll);
125
124
  dcbFreeCallback(cb);
126
125
  .Ed
126
+ .Sh CONFORMING TO
127
+ The dyncallback library needs at least a c99 compiler with additional support
128
+ for anonymous structs/unions (which were introduced officially in c11). Given
129
+ that those are generally supported by pretty much all major c99 conforming
130
+ compilers (as default extension), it should build fine with a c99 toolchain.
131
+ Strictly speaking, dyncall conforms to c11, though.
132
+ .Ed
127
133
  .Sh SEE ALSO
128
134
  .Xr dyncall 3 ,
129
135
  .Xr dynload 3
130
- and the dyncall manual (available in PDF format) for a way more detailed documentation of this
131
- library.
136
+ and the dyncall manual (available in HTML and PDF format) for more information.
132
137
  .Sh AUTHORS
133
138
  .An "Daniel Adler" Aq dadler@uni-goettingen.de
134
139
  .An "Tassilo Philipp" Aq tphilipp@potion-studios.com
@@ -1,4 +1,4 @@
1
- .\" Copyright (c) 2007-2014 Daniel Adler <dadler AT uni-goettingen DOT de>,
1
+ .\" Copyright (c) 2007-2017 Daniel Adler <dadler AT uni-goettingen DOT de>,
2
2
  .\" Tassilo Philipp <tphilipp AT potion-studios DOT com>
3
3
  .\"
4
4
  .\" Permission to use, copy, modify, and distribute this software for any
@@ -15,8 +15,6 @@
15
15
  .\"
16
16
  .Dd $Mdocdate$
17
17
  .Dt dynload 3
18
- .Os
19
-
20
18
  .Sh NAME
21
19
  .Nm dynload
22
20
  .Nd encapsulates dynamic loading mechanisms and
@@ -28,7 +26,19 @@ gives access to functions in foreign dynamic libraries and code modules.
28
26
  .Ft void
29
27
  .Fn dlFreeLibrary "DLLib * pLib"
30
28
  .Ft void *
31
- .Fn dlFindSymbol "DLLib pLibode" "const char * pSymbolName"
29
+ .Fn dlFindSymbol "DLLib * pLib" "const char * pSymbolName"
30
+ .Ft int
31
+ .Fn dlGetLibraryPath "DLLib * pLib" "char * sOut" "int bufSize"
32
+ .Ft DLSyms*
33
+ .Fn dlSymsInit "const char * libPath"
34
+ .Ft void
35
+ .Fn dlSymsCleanup "DLSyms * pSyms"
36
+ .Ft int
37
+ .Fn dlSymsCount "DLSyms * pSyms"
38
+ .Ft const char*
39
+ .Fn dlSymsName "DLSyms * pSyms" "int index"
40
+ .Ft const char*
41
+ .Fn dlSymsNameFromValue "DLSyms * pSyms" "void * value"
32
42
  .Sh DESCRIPTION
33
43
  The
34
44
  .Nm
@@ -42,7 +52,9 @@ and returns a handle to it for use in
42
52
  .Fn dlFreeLibrary
43
53
  and
44
54
  .Fn dlFindSymbol
45
- calls.
55
+ calls. Passing a null pointer for the
56
+ .Ar libpath
57
+ argument is valid, and returns a handle to the main executable of the calling code. Also, searching libraries in library paths (e.g. by just passing the library's leaf name) should work, however, they are OS specific. Returns a null pointer on error.
46
58
  .Pp
47
59
  .Fn dlFreeLibrary
48
60
  frees the loaded library with handle
@@ -53,12 +65,55 @@ returns a pointer to a symbol with name
53
65
  .Ar pSymbolName
54
66
  in the library with handle
55
67
  .Ar pLib ,
56
- or returns a null pointer if the symbol cannot be found.
68
+ or returns a null pointer if the symbol cannot be found. The name is specified as it would appear in C source code (mangled if C++, etc.).
69
+ .Pp
70
+ .Fn dlGetLibraryPath
71
+ can be used to get a copy of the path to the library loaded with handle
72
+ .Ar pLib .
73
+ The parameter
74
+ .Ar sOut
75
+ is a pointer to a buffer of size
76
+ .Ar bufSize
77
+ (in bytes), to hold the output string. The return value is the size of the buffer (in bytes) needed to hold the null-terminated string, or 0 if it can't be looked up. If
78
+ .Ar bufSize
79
+ >= return value > 1, a null-terminted string with the path to the library should be in
80
+ .Ar sOut .
81
+ If it returns 0, the library name wasn't able to be found. Please note that this might happen in some rare cases, so make sure to always check.
82
+ .Pp
83
+ The dlSyms* functions can be used to iterate over symbols. Since they can be used on libraries that are not linked, they are made
84
+ for symbol name lookups, not to get symbols' addresses. For that refer to
85
+ .Fn dlFindSymbol .
86
+ .Fn dlSymsInit
87
+ will return a handle (or null pointer on error) to the shared object specified by
88
+ .Ar libPath ,
89
+ to be used with the other dlSyms* functions. Note that contrary to loading and linking libraries, no (OS-specific) rules for searching libraries in library paths, etc. apply. The handle must be freed with
90
+ .Fn dlSymsCleanup .
91
+ .Fn dlSymsCount
92
+ returns the number of symbols in the shared object,
93
+ .Fn dlSymsName
94
+ and
95
+ .Fn dlSymsNameFromValue
96
+ are used to lookup symbol names using an index or symbol's address, respectively, returning a null pointer on error. The names are returned as they would appear in C source code (mangled if C++, etc.). The address passed to
97
+ .Fn dlSymsNameFromValue
98
+ must point to a loaded symbol.
99
+ .Sh BUGS
100
+ .Fn dlGetLibraryPath
101
+ is not thread-safe on Darwin (macOS, iOS, ...) and OpenBSD.
102
+ .Fn dlSymsInit
103
+ is not thread-safe on Darwin.
104
+ .Fn dlGetLibraryPath
105
+ will not work on the following platforms when the library in question doesn't have the (default)
106
+ .Fn _init
107
+ and
108
+ .Fn _fini
109
+ symbols exported (rare, but possible): Haiku (all versions), OpenBSD < 3.7, NetBSD < 5.1, FreeBSD < 4.8
110
+ .Sh CONFORMING TO
111
+ The dynload library conforms to c99.
112
+ .Ed
57
113
  .Sh SEE ALSO
58
114
  .Xr dyncall 3 ,
59
115
  .Xr dyncallback 3
60
- and the dyncall manual (available in PDF format) for a way more detailed documentation of this
61
- library.
116
+ and the dyncall manual (available in HTML and PDF format) for more information.
62
117
  .Sh AUTHORS
63
118
  .An "Daniel Adler" Aq dadler@uni-goettingen.de
64
119
  .An "Tassilo Philipp" Aq tphilipp@potion-studios.com
@@ -6,7 +6,7 @@
6
6
  Description: Auto-include delegate to windows/posix-based dynamic linker.
7
7
  License:
8
8
 
9
- Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
9
+ Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
10
10
  Tassilo Philipp <tphilipp@potion-studios.com>
11
11
 
12
12
  Permission to use, copy, modify, and distribute this software for any
@@ -24,16 +24,10 @@
24
24
  */
25
25
 
26
26
 
27
-
28
27
  #include "../autovar/autovar_OSFAMILY.h"
29
28
  #if defined(OSFAMILY_Windows)
30
29
  # include "dynload_windows.c"
31
30
  #elif defined(OSFAMILY_Unix)
32
- # include "../autovar/autovar_OS.h"
33
- # if defined(OS_Darwin)
34
- # include "dynload_darwin.c"
35
- # else
36
- # include "dynload_unix.c"
37
- # endif
31
+ # include "dynload_unix.c"
38
32
  #endif
39
33