immunio 0.15.4 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (454) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -27
  3. data/ext/immunio/Rakefile +9 -0
  4. data/lib/immunio/plugins/active_record.rb +1 -1
  5. data/lib/immunio/plugins/active_record_relation.rb +1 -1
  6. data/lib/immunio/plugins/environment_reporter.rb +20 -0
  7. data/lib/immunio/rufus_lua_ext/ref.rb +1 -3
  8. data/lib/immunio/version.rb +1 -1
  9. data/lib/immunio/vm.rb +1 -2
  10. data/lua-hooks/Makefile +97 -0
  11. data/lua-hooks/ext/all.c +41 -52
  12. data/lua-hooks/ext/all.o +0 -0
  13. data/lua-hooks/ext/libinjection/libinjection_html5.o +0 -0
  14. data/lua-hooks/ext/libinjection/libinjection_sqli.o +0 -0
  15. data/lua-hooks/ext/libinjection/libinjection_xss.o +0 -0
  16. data/lua-hooks/ext/libinjection/lualib.c +2 -2
  17. data/lua-hooks/ext/lpeg/lpcap.c +2 -2
  18. data/lua-hooks/ext/lpeg/lpcap.o +0 -0
  19. data/lua-hooks/ext/lpeg/lpcode.c +2 -2
  20. data/lua-hooks/ext/lpeg/lpcode.h +1 -1
  21. data/lua-hooks/ext/lpeg/lpcode.o +0 -0
  22. data/lua-hooks/ext/lpeg/lpprint.o +0 -0
  23. data/lua-hooks/ext/lpeg/lptree.c +2 -2
  24. data/lua-hooks/ext/lpeg/lptypes.h +1 -1
  25. data/lua-hooks/ext/lpeg/lpvm.c +2 -2
  26. data/lua-hooks/ext/lpeg/lpvm.o +0 -0
  27. data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +16 -3
  28. data/lua-hooks/ext/lua-snapshot/snapshot.c +14 -7
  29. data/lua-hooks/ext/luajit/COPYRIGHT +56 -0
  30. data/lua-hooks/ext/luajit/Makefile +159 -0
  31. data/lua-hooks/ext/luajit/README +16 -0
  32. data/lua-hooks/ext/luajit/doc/bluequad-print.css +166 -0
  33. data/lua-hooks/ext/luajit/doc/bluequad.css +325 -0
  34. data/lua-hooks/ext/luajit/doc/changes.html +804 -0
  35. data/lua-hooks/ext/luajit/doc/contact.html +104 -0
  36. data/lua-hooks/ext/luajit/doc/ext_c_api.html +189 -0
  37. data/lua-hooks/ext/luajit/doc/ext_ffi.html +332 -0
  38. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +570 -0
  39. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +1261 -0
  40. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +603 -0
  41. data/lua-hooks/ext/luajit/doc/ext_jit.html +201 -0
  42. data/lua-hooks/ext/luajit/doc/ext_profiler.html +365 -0
  43. data/lua-hooks/ext/luajit/doc/extensions.html +448 -0
  44. data/lua-hooks/ext/luajit/doc/faq.html +186 -0
  45. data/lua-hooks/ext/luajit/doc/img/contact.png +0 -0
  46. data/lua-hooks/ext/luajit/doc/install.html +659 -0
  47. data/lua-hooks/ext/luajit/doc/luajit.html +236 -0
  48. data/lua-hooks/ext/luajit/doc/running.html +309 -0
  49. data/lua-hooks/ext/luajit/doc/status.html +118 -0
  50. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +456 -0
  51. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1125 -0
  52. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +518 -0
  53. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1166 -0
  54. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +416 -0
  55. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +953 -0
  56. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +419 -0
  57. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1919 -0
  58. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +83 -0
  59. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +12 -0
  60. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +471 -0
  61. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +1945 -0
  62. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +1094 -0
  63. data/lua-hooks/ext/luajit/etc/luajit.1 +88 -0
  64. data/lua-hooks/ext/luajit/etc/luajit.pc +25 -0
  65. data/lua-hooks/ext/luajit/src/Makefile +697 -0
  66. data/lua-hooks/ext/luajit/src/Makefile.dep +244 -0
  67. data/lua-hooks/ext/luajit/src/host/README +4 -0
  68. data/lua-hooks/ext/luajit/src/host/buildvm +0 -0
  69. data/lua-hooks/ext/luajit/src/host/buildvm.c +518 -0
  70. data/lua-hooks/ext/luajit/src/host/buildvm.h +105 -0
  71. data/lua-hooks/ext/luajit/src/host/buildvm.o +0 -0
  72. data/lua-hooks/ext/luajit/src/host/buildvm_arch.h +7449 -0
  73. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +345 -0
  74. data/lua-hooks/ext/luajit/src/host/buildvm_asm.o +0 -0
  75. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +229 -0
  76. data/lua-hooks/ext/luajit/src/host/buildvm_fold.o +0 -0
  77. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +457 -0
  78. data/lua-hooks/ext/luajit/src/host/buildvm_lib.o +0 -0
  79. data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +45 -0
  80. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +368 -0
  81. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.o +0 -0
  82. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +197 -0
  83. data/lua-hooks/ext/luajit/src/host/genminilua.lua +428 -0
  84. data/lua-hooks/ext/luajit/src/host/minilua +0 -0
  85. data/lua-hooks/ext/luajit/src/host/minilua.c +7770 -0
  86. data/lua-hooks/ext/luajit/src/host/minilua.o +0 -0
  87. data/lua-hooks/ext/luajit/src/jit/bc.lua +190 -0
  88. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +661 -0
  89. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +689 -0
  90. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +428 -0
  91. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +17 -0
  92. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +591 -0
  93. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +17 -0
  94. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +838 -0
  95. data/lua-hooks/ext/luajit/src/jit/dump.lua +706 -0
  96. data/lua-hooks/ext/luajit/src/jit/p.lua +310 -0
  97. data/lua-hooks/ext/luajit/src/jit/v.lua +170 -0
  98. data/lua-hooks/ext/luajit/src/jit/vmdef.lua +362 -0
  99. data/lua-hooks/ext/luajit/src/jit/zone.lua +45 -0
  100. data/lua-hooks/ext/{lua → luajit/src}/lauxlib.h +10 -17
  101. data/lua-hooks/ext/luajit/src/lib_aux.c +356 -0
  102. data/lua-hooks/ext/luajit/src/lib_aux.o +0 -0
  103. data/lua-hooks/ext/luajit/src/lib_aux_dyn.o +0 -0
  104. data/lua-hooks/ext/luajit/src/lib_base.c +664 -0
  105. data/lua-hooks/ext/luajit/src/lib_base.o +0 -0
  106. data/lua-hooks/ext/luajit/src/lib_base_dyn.o +0 -0
  107. data/lua-hooks/ext/luajit/src/lib_bit.c +180 -0
  108. data/lua-hooks/ext/luajit/src/lib_bit.o +0 -0
  109. data/lua-hooks/ext/luajit/src/lib_bit_dyn.o +0 -0
  110. data/lua-hooks/ext/luajit/src/lib_debug.c +405 -0
  111. data/lua-hooks/ext/luajit/src/lib_debug.o +0 -0
  112. data/lua-hooks/ext/luajit/src/lib_debug_dyn.o +0 -0
  113. data/lua-hooks/ext/luajit/src/lib_ffi.c +872 -0
  114. data/lua-hooks/ext/luajit/src/lib_ffi.o +0 -0
  115. data/lua-hooks/ext/luajit/src/lib_ffi_dyn.o +0 -0
  116. data/lua-hooks/ext/luajit/src/lib_init.c +55 -0
  117. data/lua-hooks/ext/luajit/src/lib_init.o +0 -0
  118. data/lua-hooks/ext/luajit/src/lib_init_dyn.o +0 -0
  119. data/lua-hooks/ext/luajit/src/lib_io.c +541 -0
  120. data/lua-hooks/ext/luajit/src/lib_io.o +0 -0
  121. data/lua-hooks/ext/luajit/src/lib_io_dyn.o +0 -0
  122. data/lua-hooks/ext/luajit/src/lib_jit.c +767 -0
  123. data/lua-hooks/ext/luajit/src/lib_jit.o +0 -0
  124. data/lua-hooks/ext/luajit/src/lib_jit_dyn.o +0 -0
  125. data/lua-hooks/ext/luajit/src/lib_math.c +230 -0
  126. data/lua-hooks/ext/luajit/src/lib_math.o +0 -0
  127. data/lua-hooks/ext/luajit/src/lib_math_dyn.o +0 -0
  128. data/lua-hooks/ext/luajit/src/lib_os.c +292 -0
  129. data/lua-hooks/ext/luajit/src/lib_os.o +0 -0
  130. data/lua-hooks/ext/luajit/src/lib_os_dyn.o +0 -0
  131. data/lua-hooks/ext/luajit/src/lib_package.c +610 -0
  132. data/lua-hooks/ext/luajit/src/lib_package.o +0 -0
  133. data/lua-hooks/ext/luajit/src/lib_package_dyn.o +0 -0
  134. data/lua-hooks/ext/luajit/src/lib_string.c +752 -0
  135. data/lua-hooks/ext/luajit/src/lib_string.o +0 -0
  136. data/lua-hooks/ext/luajit/src/lib_string_dyn.o +0 -0
  137. data/lua-hooks/ext/luajit/src/lib_table.c +307 -0
  138. data/lua-hooks/ext/luajit/src/lib_table.o +0 -0
  139. data/lua-hooks/ext/luajit/src/lib_table_dyn.o +0 -0
  140. data/lua-hooks/ext/luajit/src/libluajit.a +0 -0
  141. data/lua-hooks/ext/luajit/src/libluajit.so +0 -0
  142. data/lua-hooks/ext/luajit/src/lj.supp +26 -0
  143. data/lua-hooks/ext/luajit/src/lj_alloc.c +1398 -0
  144. data/lua-hooks/ext/luajit/src/lj_alloc.h +17 -0
  145. data/lua-hooks/ext/luajit/src/lj_alloc.o +0 -0
  146. data/lua-hooks/ext/luajit/src/lj_alloc_dyn.o +0 -0
  147. data/lua-hooks/ext/luajit/src/lj_api.c +1210 -0
  148. data/lua-hooks/ext/luajit/src/lj_api.o +0 -0
  149. data/lua-hooks/ext/luajit/src/lj_api_dyn.o +0 -0
  150. data/lua-hooks/ext/luajit/src/lj_arch.h +509 -0
  151. data/lua-hooks/ext/luajit/src/lj_asm.c +2278 -0
  152. data/lua-hooks/ext/luajit/src/lj_asm.h +17 -0
  153. data/lua-hooks/ext/luajit/src/lj_asm.o +0 -0
  154. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +2217 -0
  155. data/lua-hooks/ext/luajit/src/lj_asm_dyn.o +0 -0
  156. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +1833 -0
  157. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2015 -0
  158. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2634 -0
  159. data/lua-hooks/ext/luajit/src/lj_bc.c +14 -0
  160. data/lua-hooks/ext/luajit/src/lj_bc.h +265 -0
  161. data/lua-hooks/ext/luajit/src/lj_bc.o +0 -0
  162. data/lua-hooks/ext/luajit/src/lj_bc_dyn.o +0 -0
  163. data/lua-hooks/ext/luajit/src/lj_bcdef.h +220 -0
  164. data/lua-hooks/ext/luajit/src/lj_bcdump.h +68 -0
  165. data/lua-hooks/ext/luajit/src/lj_bcread.c +457 -0
  166. data/lua-hooks/ext/luajit/src/lj_bcread.o +0 -0
  167. data/lua-hooks/ext/luajit/src/lj_bcread_dyn.o +0 -0
  168. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +361 -0
  169. data/lua-hooks/ext/luajit/src/lj_bcwrite.o +0 -0
  170. data/lua-hooks/ext/luajit/src/lj_bcwrite_dyn.o +0 -0
  171. data/lua-hooks/ext/luajit/src/lj_buf.c +234 -0
  172. data/lua-hooks/ext/luajit/src/lj_buf.h +105 -0
  173. data/lua-hooks/ext/luajit/src/lj_buf.o +0 -0
  174. data/lua-hooks/ext/luajit/src/lj_buf_dyn.o +0 -0
  175. data/lua-hooks/ext/luajit/src/lj_carith.c +429 -0
  176. data/lua-hooks/ext/luajit/src/lj_carith.h +37 -0
  177. data/lua-hooks/ext/luajit/src/lj_carith.o +0 -0
  178. data/lua-hooks/ext/luajit/src/lj_carith_dyn.o +0 -0
  179. data/lua-hooks/ext/luajit/src/lj_ccall.c +984 -0
  180. data/lua-hooks/ext/luajit/src/lj_ccall.h +178 -0
  181. data/lua-hooks/ext/luajit/src/lj_ccall.o +0 -0
  182. data/lua-hooks/ext/luajit/src/lj_ccall_dyn.o +0 -0
  183. data/lua-hooks/ext/luajit/src/lj_ccallback.c +712 -0
  184. data/lua-hooks/ext/luajit/src/lj_ccallback.h +25 -0
  185. data/lua-hooks/ext/luajit/src/lj_ccallback.o +0 -0
  186. data/lua-hooks/ext/luajit/src/lj_ccallback_dyn.o +0 -0
  187. data/lua-hooks/ext/luajit/src/lj_cconv.c +752 -0
  188. data/lua-hooks/ext/luajit/src/lj_cconv.h +70 -0
  189. data/lua-hooks/ext/luajit/src/lj_cconv.o +0 -0
  190. data/lua-hooks/ext/luajit/src/lj_cconv_dyn.o +0 -0
  191. data/lua-hooks/ext/luajit/src/lj_cdata.c +288 -0
  192. data/lua-hooks/ext/luajit/src/lj_cdata.h +76 -0
  193. data/lua-hooks/ext/luajit/src/lj_cdata.o +0 -0
  194. data/lua-hooks/ext/luajit/src/lj_cdata_dyn.o +0 -0
  195. data/lua-hooks/ext/luajit/src/lj_char.c +43 -0
  196. data/lua-hooks/ext/luajit/src/lj_char.h +42 -0
  197. data/lua-hooks/ext/luajit/src/lj_char.o +0 -0
  198. data/lua-hooks/ext/luajit/src/lj_char_dyn.o +0 -0
  199. data/lua-hooks/ext/luajit/src/lj_clib.c +418 -0
  200. data/lua-hooks/ext/luajit/src/lj_clib.h +29 -0
  201. data/lua-hooks/ext/luajit/src/lj_clib.o +0 -0
  202. data/lua-hooks/ext/luajit/src/lj_clib_dyn.o +0 -0
  203. data/lua-hooks/ext/luajit/src/lj_cparse.c +1862 -0
  204. data/lua-hooks/ext/luajit/src/lj_cparse.h +65 -0
  205. data/lua-hooks/ext/luajit/src/lj_cparse.o +0 -0
  206. data/lua-hooks/ext/luajit/src/lj_cparse_dyn.o +0 -0
  207. data/lua-hooks/ext/luajit/src/lj_crecord.c +1834 -0
  208. data/lua-hooks/ext/luajit/src/lj_crecord.h +38 -0
  209. data/lua-hooks/ext/luajit/src/lj_crecord.o +0 -0
  210. data/lua-hooks/ext/luajit/src/lj_crecord_dyn.o +0 -0
  211. data/lua-hooks/ext/luajit/src/lj_ctype.c +635 -0
  212. data/lua-hooks/ext/luajit/src/lj_ctype.h +461 -0
  213. data/lua-hooks/ext/luajit/src/lj_ctype.o +0 -0
  214. data/lua-hooks/ext/luajit/src/lj_ctype_dyn.o +0 -0
  215. data/lua-hooks/ext/luajit/src/lj_debug.c +699 -0
  216. data/lua-hooks/ext/luajit/src/lj_debug.h +65 -0
  217. data/lua-hooks/ext/luajit/src/lj_debug.o +0 -0
  218. data/lua-hooks/ext/luajit/src/lj_debug_dyn.o +0 -0
  219. data/lua-hooks/ext/luajit/src/lj_def.h +365 -0
  220. data/lua-hooks/ext/luajit/src/lj_dispatch.c +557 -0
  221. data/lua-hooks/ext/luajit/src/lj_dispatch.h +138 -0
  222. data/lua-hooks/ext/luajit/src/lj_dispatch.o +0 -0
  223. data/lua-hooks/ext/luajit/src/lj_dispatch_dyn.o +0 -0
  224. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +356 -0
  225. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +211 -0
  226. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +238 -0
  227. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +462 -0
  228. data/lua-hooks/ext/luajit/src/lj_err.c +794 -0
  229. data/lua-hooks/ext/luajit/src/lj_err.h +41 -0
  230. data/lua-hooks/ext/luajit/src/lj_err.o +0 -0
  231. data/lua-hooks/ext/luajit/src/lj_err_dyn.o +0 -0
  232. data/lua-hooks/ext/luajit/src/lj_errmsg.h +190 -0
  233. data/lua-hooks/ext/luajit/src/lj_ff.h +18 -0
  234. data/lua-hooks/ext/luajit/src/lj_ffdef.h +209 -0
  235. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +1247 -0
  236. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +24 -0
  237. data/lua-hooks/ext/luajit/src/lj_ffrecord.o +0 -0
  238. data/lua-hooks/ext/luajit/src/lj_ffrecord_dyn.o +0 -0
  239. data/lua-hooks/ext/luajit/src/lj_folddef.h +1138 -0
  240. data/lua-hooks/ext/luajit/src/lj_frame.h +259 -0
  241. data/lua-hooks/ext/luajit/src/lj_func.c +185 -0
  242. data/lua-hooks/ext/luajit/src/lj_func.h +24 -0
  243. data/lua-hooks/ext/luajit/src/lj_func.o +0 -0
  244. data/lua-hooks/ext/luajit/src/lj_func_dyn.o +0 -0
  245. data/lua-hooks/ext/luajit/src/lj_gc.c +845 -0
  246. data/lua-hooks/ext/luajit/src/lj_gc.h +134 -0
  247. data/lua-hooks/ext/luajit/src/lj_gc.o +0 -0
  248. data/lua-hooks/ext/luajit/src/lj_gc_dyn.o +0 -0
  249. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +787 -0
  250. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +22 -0
  251. data/lua-hooks/ext/luajit/src/lj_gdbjit.o +0 -0
  252. data/lua-hooks/ext/luajit/src/lj_gdbjit_dyn.o +0 -0
  253. data/lua-hooks/ext/luajit/src/lj_ir.c +505 -0
  254. data/lua-hooks/ext/luajit/src/lj_ir.h +577 -0
  255. data/lua-hooks/ext/luajit/src/lj_ir.o +0 -0
  256. data/lua-hooks/ext/luajit/src/lj_ir_dyn.o +0 -0
  257. data/lua-hooks/ext/luajit/src/lj_ircall.h +321 -0
  258. data/lua-hooks/ext/luajit/src/lj_iropt.h +161 -0
  259. data/lua-hooks/ext/luajit/src/lj_jit.h +440 -0
  260. data/lua-hooks/ext/luajit/src/lj_lex.c +482 -0
  261. data/lua-hooks/ext/luajit/src/lj_lex.h +86 -0
  262. data/lua-hooks/ext/luajit/src/lj_lex.o +0 -0
  263. data/lua-hooks/ext/luajit/src/lj_lex_dyn.o +0 -0
  264. data/lua-hooks/ext/luajit/src/lj_lib.c +303 -0
  265. data/lua-hooks/ext/luajit/src/lj_lib.h +115 -0
  266. data/lua-hooks/ext/luajit/src/lj_lib.o +0 -0
  267. data/lua-hooks/ext/luajit/src/lj_lib_dyn.o +0 -0
  268. data/lua-hooks/ext/luajit/src/lj_libdef.h +414 -0
  269. data/lua-hooks/ext/luajit/src/lj_load.c +168 -0
  270. data/lua-hooks/ext/luajit/src/lj_load.o +0 -0
  271. data/lua-hooks/ext/luajit/src/lj_load_dyn.o +0 -0
  272. data/lua-hooks/ext/luajit/src/lj_mcode.c +386 -0
  273. data/lua-hooks/ext/luajit/src/lj_mcode.h +30 -0
  274. data/lua-hooks/ext/luajit/src/lj_mcode.o +0 -0
  275. data/lua-hooks/ext/luajit/src/lj_mcode_dyn.o +0 -0
  276. data/lua-hooks/ext/luajit/src/lj_meta.c +477 -0
  277. data/lua-hooks/ext/luajit/src/lj_meta.h +38 -0
  278. data/lua-hooks/ext/luajit/src/lj_meta.o +0 -0
  279. data/lua-hooks/ext/luajit/src/lj_meta_dyn.o +0 -0
  280. data/lua-hooks/ext/luajit/src/lj_obj.c +50 -0
  281. data/lua-hooks/ext/luajit/src/lj_obj.h +976 -0
  282. data/lua-hooks/ext/luajit/src/lj_obj.o +0 -0
  283. data/lua-hooks/ext/luajit/src/lj_obj_dyn.o +0 -0
  284. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +78 -0
  285. data/lua-hooks/ext/luajit/src/lj_opt_dce.o +0 -0
  286. data/lua-hooks/ext/luajit/src/lj_opt_dce_dyn.o +0 -0
  287. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +2488 -0
  288. data/lua-hooks/ext/luajit/src/lj_opt_fold.o +0 -0
  289. data/lua-hooks/ext/luajit/src/lj_opt_fold_dyn.o +0 -0
  290. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +449 -0
  291. data/lua-hooks/ext/luajit/src/lj_opt_loop.o +0 -0
  292. data/lua-hooks/ext/luajit/src/lj_opt_loop_dyn.o +0 -0
  293. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +935 -0
  294. data/lua-hooks/ext/luajit/src/lj_opt_mem.o +0 -0
  295. data/lua-hooks/ext/luajit/src/lj_opt_mem_dyn.o +0 -0
  296. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +652 -0
  297. data/lua-hooks/ext/luajit/src/lj_opt_narrow.o +0 -0
  298. data/lua-hooks/ext/luajit/src/lj_opt_narrow_dyn.o +0 -0
  299. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +245 -0
  300. data/lua-hooks/ext/luajit/src/lj_opt_sink.o +0 -0
  301. data/lua-hooks/ext/luajit/src/lj_opt_sink_dyn.o +0 -0
  302. data/lua-hooks/ext/luajit/src/lj_opt_split.c +856 -0
  303. data/lua-hooks/ext/luajit/src/lj_opt_split.o +0 -0
  304. data/lua-hooks/ext/luajit/src/lj_opt_split_dyn.o +0 -0
  305. data/lua-hooks/ext/luajit/src/lj_parse.c +2725 -0
  306. data/lua-hooks/ext/luajit/src/lj_parse.h +18 -0
  307. data/lua-hooks/ext/luajit/src/lj_parse.o +0 -0
  308. data/lua-hooks/ext/luajit/src/lj_parse_dyn.o +0 -0
  309. data/lua-hooks/ext/luajit/src/lj_profile.c +368 -0
  310. data/lua-hooks/ext/luajit/src/lj_profile.h +21 -0
  311. data/lua-hooks/ext/luajit/src/lj_profile.o +0 -0
  312. data/lua-hooks/ext/luajit/src/lj_profile_dyn.o +0 -0
  313. data/lua-hooks/ext/luajit/src/lj_recdef.h +270 -0
  314. data/lua-hooks/ext/luajit/src/lj_record.c +2554 -0
  315. data/lua-hooks/ext/luajit/src/lj_record.h +45 -0
  316. data/lua-hooks/ext/luajit/src/lj_record.o +0 -0
  317. data/lua-hooks/ext/luajit/src/lj_record_dyn.o +0 -0
  318. data/lua-hooks/ext/luajit/src/lj_snap.c +870 -0
  319. data/lua-hooks/ext/luajit/src/lj_snap.h +34 -0
  320. data/lua-hooks/ext/luajit/src/lj_snap.o +0 -0
  321. data/lua-hooks/ext/luajit/src/lj_snap_dyn.o +0 -0
  322. data/lua-hooks/ext/luajit/src/lj_state.c +300 -0
  323. data/lua-hooks/ext/luajit/src/lj_state.h +35 -0
  324. data/lua-hooks/ext/luajit/src/lj_state.o +0 -0
  325. data/lua-hooks/ext/luajit/src/lj_state_dyn.o +0 -0
  326. data/lua-hooks/ext/luajit/src/lj_str.c +197 -0
  327. data/lua-hooks/ext/luajit/src/lj_str.h +27 -0
  328. data/lua-hooks/ext/luajit/src/lj_str.o +0 -0
  329. data/lua-hooks/ext/luajit/src/lj_str_dyn.o +0 -0
  330. data/lua-hooks/ext/luajit/src/lj_strfmt.c +554 -0
  331. data/lua-hooks/ext/luajit/src/lj_strfmt.h +125 -0
  332. data/lua-hooks/ext/luajit/src/lj_strfmt.o +0 -0
  333. data/lua-hooks/ext/luajit/src/lj_strfmt_dyn.o +0 -0
  334. data/lua-hooks/ext/luajit/src/lj_strscan.c +547 -0
  335. data/lua-hooks/ext/luajit/src/lj_strscan.h +39 -0
  336. data/lua-hooks/ext/luajit/src/lj_strscan.o +0 -0
  337. data/lua-hooks/ext/luajit/src/lj_strscan_dyn.o +0 -0
  338. data/lua-hooks/ext/luajit/src/lj_tab.c +666 -0
  339. data/lua-hooks/ext/luajit/src/lj_tab.h +73 -0
  340. data/lua-hooks/ext/luajit/src/lj_tab.o +0 -0
  341. data/lua-hooks/ext/luajit/src/lj_tab_dyn.o +0 -0
  342. data/lua-hooks/ext/luajit/src/lj_target.h +164 -0
  343. data/lua-hooks/ext/luajit/src/lj_target_arm.h +270 -0
  344. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +97 -0
  345. data/lua-hooks/ext/luajit/src/lj_target_mips.h +260 -0
  346. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +280 -0
  347. data/lua-hooks/ext/luajit/src/lj_target_x86.h +345 -0
  348. data/lua-hooks/ext/luajit/src/lj_trace.c +859 -0
  349. data/lua-hooks/ext/luajit/src/lj_trace.h +54 -0
  350. data/lua-hooks/ext/luajit/src/lj_trace.o +0 -0
  351. data/lua-hooks/ext/luajit/src/lj_trace_dyn.o +0 -0
  352. data/lua-hooks/ext/luajit/src/lj_traceerr.h +63 -0
  353. data/lua-hooks/ext/luajit/src/lj_udata.c +34 -0
  354. data/lua-hooks/ext/luajit/src/lj_udata.h +14 -0
  355. data/lua-hooks/ext/luajit/src/lj_udata.o +0 -0
  356. data/lua-hooks/ext/luajit/src/lj_udata_dyn.o +0 -0
  357. data/lua-hooks/ext/luajit/src/lj_vm.S +2730 -0
  358. data/lua-hooks/ext/luajit/src/lj_vm.h +114 -0
  359. data/lua-hooks/ext/luajit/src/lj_vm.o +0 -0
  360. data/lua-hooks/ext/luajit/src/lj_vm_dyn.o +0 -0
  361. data/lua-hooks/ext/luajit/src/lj_vmevent.c +58 -0
  362. data/lua-hooks/ext/luajit/src/lj_vmevent.h +59 -0
  363. data/lua-hooks/ext/luajit/src/lj_vmevent.o +0 -0
  364. data/lua-hooks/ext/luajit/src/lj_vmevent_dyn.o +0 -0
  365. data/lua-hooks/ext/luajit/src/lj_vmmath.c +152 -0
  366. data/lua-hooks/ext/luajit/src/lj_vmmath.o +0 -0
  367. data/lua-hooks/ext/luajit/src/lj_vmmath_dyn.o +0 -0
  368. data/lua-hooks/ext/luajit/src/ljamalg.c +96 -0
  369. data/lua-hooks/ext/{lua → luajit/src}/lua.h +12 -7
  370. data/lua-hooks/ext/luajit/src/lua.hpp +9 -0
  371. data/lua-hooks/ext/luajit/src/luaconf.h +156 -0
  372. data/lua-hooks/ext/luajit/src/luajit +0 -0
  373. data/lua-hooks/ext/luajit/src/luajit.c +570 -0
  374. data/lua-hooks/ext/luajit/src/luajit.h +79 -0
  375. data/lua-hooks/ext/luajit/src/luajit.o +0 -0
  376. data/lua-hooks/ext/luajit/src/lualib.h +43 -0
  377. data/lua-hooks/ext/luajit/src/msvcbuild.bat +114 -0
  378. data/lua-hooks/ext/luajit/src/ps4build.bat +103 -0
  379. data/lua-hooks/ext/luajit/src/psvitabuild.bat +93 -0
  380. data/lua-hooks/ext/luajit/src/vm_arm.dasc +4585 -0
  381. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +3764 -0
  382. data/lua-hooks/ext/luajit/src/vm_mips.dasc +4355 -0
  383. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +5252 -0
  384. data/lua-hooks/ext/luajit/src/vm_x64.dasc +4902 -0
  385. data/lua-hooks/ext/luajit/src/vm_x86.dasc +5710 -0
  386. data/lua-hooks/ext/luajit/src/xb1build.bat +101 -0
  387. data/lua-hooks/ext/luajit/src/xedkbuild.bat +92 -0
  388. data/lua-hooks/ext/luautf8/lutf8lib.c +3 -3
  389. data/lua-hooks/lib/boot.lua +37 -2
  390. metadata +372 -69
  391. data/lua-hooks/ext/bitop/README +0 -22
  392. data/lua-hooks/ext/bitop/bit.c +0 -189
  393. data/lua-hooks/ext/extconf.rb +0 -38
  394. data/lua-hooks/ext/lua/COPYRIGHT +0 -34
  395. data/lua-hooks/ext/lua/lapi.c +0 -1087
  396. data/lua-hooks/ext/lua/lapi.h +0 -16
  397. data/lua-hooks/ext/lua/lauxlib.c +0 -652
  398. data/lua-hooks/ext/lua/lbaselib.c +0 -659
  399. data/lua-hooks/ext/lua/lcode.c +0 -831
  400. data/lua-hooks/ext/lua/lcode.h +0 -76
  401. data/lua-hooks/ext/lua/ldblib.c +0 -398
  402. data/lua-hooks/ext/lua/ldebug.c +0 -638
  403. data/lua-hooks/ext/lua/ldebug.h +0 -33
  404. data/lua-hooks/ext/lua/ldo.c +0 -519
  405. data/lua-hooks/ext/lua/ldo.h +0 -57
  406. data/lua-hooks/ext/lua/ldump.c +0 -164
  407. data/lua-hooks/ext/lua/lfunc.c +0 -174
  408. data/lua-hooks/ext/lua/lfunc.h +0 -34
  409. data/lua-hooks/ext/lua/lgc.c +0 -710
  410. data/lua-hooks/ext/lua/lgc.h +0 -110
  411. data/lua-hooks/ext/lua/linit.c +0 -38
  412. data/lua-hooks/ext/lua/liolib.c +0 -556
  413. data/lua-hooks/ext/lua/llex.c +0 -463
  414. data/lua-hooks/ext/lua/llex.h +0 -81
  415. data/lua-hooks/ext/lua/llimits.h +0 -128
  416. data/lua-hooks/ext/lua/lmathlib.c +0 -263
  417. data/lua-hooks/ext/lua/lmem.c +0 -86
  418. data/lua-hooks/ext/lua/lmem.h +0 -49
  419. data/lua-hooks/ext/lua/loadlib.c +0 -705
  420. data/lua-hooks/ext/lua/loadlib_rel.c +0 -760
  421. data/lua-hooks/ext/lua/lobject.c +0 -214
  422. data/lua-hooks/ext/lua/lobject.h +0 -381
  423. data/lua-hooks/ext/lua/lopcodes.c +0 -102
  424. data/lua-hooks/ext/lua/lopcodes.h +0 -268
  425. data/lua-hooks/ext/lua/loslib.c +0 -243
  426. data/lua-hooks/ext/lua/lparser.c +0 -1339
  427. data/lua-hooks/ext/lua/lparser.h +0 -82
  428. data/lua-hooks/ext/lua/lstate.c +0 -214
  429. data/lua-hooks/ext/lua/lstate.h +0 -169
  430. data/lua-hooks/ext/lua/lstring.c +0 -111
  431. data/lua-hooks/ext/lua/lstring.h +0 -31
  432. data/lua-hooks/ext/lua/lstrlib.c +0 -871
  433. data/lua-hooks/ext/lua/ltable.c +0 -588
  434. data/lua-hooks/ext/lua/ltable.h +0 -40
  435. data/lua-hooks/ext/lua/ltablib.c +0 -287
  436. data/lua-hooks/ext/lua/ltm.c +0 -75
  437. data/lua-hooks/ext/lua/ltm.h +0 -54
  438. data/lua-hooks/ext/lua/lua.c +0 -392
  439. data/lua-hooks/ext/lua/lua.def +0 -131
  440. data/lua-hooks/ext/lua/lua.rc +0 -28
  441. data/lua-hooks/ext/lua/lua_dll.rc +0 -26
  442. data/lua-hooks/ext/lua/luac.c +0 -200
  443. data/lua-hooks/ext/lua/luac.rc +0 -1
  444. data/lua-hooks/ext/lua/luaconf.h +0 -763
  445. data/lua-hooks/ext/lua/luaconf.h.in +0 -724
  446. data/lua-hooks/ext/lua/luaconf.h.orig +0 -763
  447. data/lua-hooks/ext/lua/lualib.h +0 -53
  448. data/lua-hooks/ext/lua/lundump.c +0 -227
  449. data/lua-hooks/ext/lua/lundump.h +0 -36
  450. data/lua-hooks/ext/lua/lvm.c +0 -767
  451. data/lua-hooks/ext/lua/lvm.h +0 -36
  452. data/lua-hooks/ext/lua/lzio.c +0 -82
  453. data/lua-hooks/ext/lua/lzio.h +0 -67
  454. data/lua-hooks/ext/lua/print.c +0 -227
@@ -0,0 +1,45 @@
1
+ /* This is a generated file. DO NOT EDIT! */
2
+
3
+ static const int libbc_endian = 0;
4
+
5
+ static const uint8_t libbc_code[] = {
6
+ #if LJ_FR2
7
+ 0,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0,
8
+ 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3,
9
+ 16,0,5,0,21,1,0,0,76,1,2,0,0,2,10,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3,
10
+ 0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,8,5,0,59,9,5,0,66,6,3,2,10,6,0,0,88,7,1,
11
+ 128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,11,0,0,0,16,16,0,12,0,16,1,9,0,43,2,
12
+ 0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,9,5,0,18,10,6,0,66,7,3,2,10,7,
13
+ 0,0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12,
14
+ 0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128,
15
+ 8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14,
16
+ 0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2,
17
+ 0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4,
18
+ 2,0,76,3,2,0,75,0,1,0,0,2,0
19
+ #else
20
+ 0,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0,
21
+ 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3,
22
+ 16,0,5,0,21,1,0,0,76,1,2,0,0,2,9,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3,
23
+ 0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,7,5,0,59,8,5,0,66,6,3,2,10,6,0,0,88,7,1,
24
+ 128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,10,0,0,0,16,16,0,12,0,16,1,9,0,43,2,
25
+ 0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,8,5,0,18,9,6,0,66,7,3,2,10,7,0,
26
+ 0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12,
27
+ 0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128,
28
+ 8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14,
29
+ 0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2,
30
+ 0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4,
31
+ 2,0,76,3,2,0,75,0,1,0,0,2,0
32
+ #endif
33
+ };
34
+
35
+ static const struct { const char *name; int ofs; } libbc_map[] = {
36
+ {"math_deg",0},
37
+ {"math_rad",25},
38
+ {"string_len",50},
39
+ {"table_foreachi",69},
40
+ {"table_foreach",136},
41
+ {"table_getn",207},
42
+ {"table_remove",226},
43
+ {NULL,355}
44
+ };
45
+
@@ -0,0 +1,368 @@
1
+ /*
2
+ ** LuaJIT VM builder: PE object emitter.
3
+ ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
4
+ **
5
+ ** Only used for building on Windows, since we cannot assume the presence
6
+ ** of a suitable assembler. The host and target byte order must match.
7
+ */
8
+
9
+ #include "buildvm.h"
10
+ #include "lj_bc.h"
11
+
12
+ #if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC
13
+
14
+ /* Context for PE object emitter. */
15
+ static char *strtab;
16
+ static size_t strtabofs;
17
+
18
+ /* -- PE object definitions ----------------------------------------------- */
19
+
20
+ /* PE header. */
21
+ typedef struct PEheader {
22
+ uint16_t arch;
23
+ uint16_t nsects;
24
+ uint32_t time;
25
+ uint32_t symtabofs;
26
+ uint32_t nsyms;
27
+ uint16_t opthdrsz;
28
+ uint16_t flags;
29
+ } PEheader;
30
+
31
+ /* PE section. */
32
+ typedef struct PEsection {
33
+ char name[8];
34
+ uint32_t vsize;
35
+ uint32_t vaddr;
36
+ uint32_t size;
37
+ uint32_t ofs;
38
+ uint32_t relocofs;
39
+ uint32_t lineofs;
40
+ uint16_t nreloc;
41
+ uint16_t nline;
42
+ uint32_t flags;
43
+ } PEsection;
44
+
45
+ /* PE relocation. */
46
+ typedef struct PEreloc {
47
+ uint32_t vaddr;
48
+ uint32_t symidx;
49
+ uint16_t type;
50
+ } PEreloc;
51
+
52
+ /* Cannot use sizeof, because it pads up to the max. alignment. */
53
+ #define PEOBJ_RELOC_SIZE (4+4+2)
54
+
55
+ /* PE symbol table entry. */
56
+ typedef struct PEsym {
57
+ union {
58
+ char name[8];
59
+ uint32_t nameref[2];
60
+ } n;
61
+ uint32_t value;
62
+ int16_t sect;
63
+ uint16_t type;
64
+ uint8_t scl;
65
+ uint8_t naux;
66
+ } PEsym;
67
+
68
+ /* PE symbol table auxiliary entry for a section. */
69
+ typedef struct PEsymaux {
70
+ uint32_t size;
71
+ uint16_t nreloc;
72
+ uint16_t nline;
73
+ uint32_t cksum;
74
+ uint16_t assoc;
75
+ uint8_t comdatsel;
76
+ uint8_t unused[3];
77
+ } PEsymaux;
78
+
79
+ /* Cannot use sizeof, because it pads up to the max. alignment. */
80
+ #define PEOBJ_SYM_SIZE (8+4+2+2+1+1)
81
+
82
+ /* PE object CPU specific defines. */
83
+ #if LJ_TARGET_X86
84
+ #define PEOBJ_ARCH_TARGET 0x014c
85
+ #define PEOBJ_RELOC_REL32 0x14 /* MS: REL32, GNU: DISP32. */
86
+ #define PEOBJ_RELOC_DIR32 0x06
87
+ #define PEOBJ_RELOC_OFS 0
88
+ #define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */
89
+ #elif LJ_TARGET_X64
90
+ #define PEOBJ_ARCH_TARGET 0x8664
91
+ #define PEOBJ_RELOC_REL32 0x04 /* MS: REL32, GNU: DISP32. */
92
+ #define PEOBJ_RELOC_DIR32 0x02
93
+ #define PEOBJ_RELOC_ADDR32NB 0x03
94
+ #define PEOBJ_RELOC_OFS 0
95
+ #define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */
96
+ #elif LJ_TARGET_PPC
97
+ #define PEOBJ_ARCH_TARGET 0x01f2
98
+ #define PEOBJ_RELOC_REL32 0x06
99
+ #define PEOBJ_RELOC_DIR32 0x02
100
+ #define PEOBJ_RELOC_OFS (-4)
101
+ #define PEOBJ_TEXT_FLAGS 0x60400020 /* 60=r+x, 40=align8, 20=code. */
102
+ #endif
103
+
104
+ /* Section numbers (0-based). */
105
+ enum {
106
+ PEOBJ_SECT_ABS = -2,
107
+ PEOBJ_SECT_UNDEF = -1,
108
+ PEOBJ_SECT_TEXT,
109
+ #if LJ_TARGET_X64
110
+ PEOBJ_SECT_PDATA,
111
+ PEOBJ_SECT_XDATA,
112
+ #endif
113
+ PEOBJ_SECT_RDATA_Z,
114
+ PEOBJ_NSECTIONS
115
+ };
116
+
117
+ /* Symbol types. */
118
+ #define PEOBJ_TYPE_NULL 0
119
+ #define PEOBJ_TYPE_FUNC 0x20
120
+
121
+ /* Symbol storage class. */
122
+ #define PEOBJ_SCL_EXTERN 2
123
+ #define PEOBJ_SCL_STATIC 3
124
+
125
+ /* -- PE object emitter --------------------------------------------------- */
126
+
127
+ /* Emit PE object symbol. */
128
+ static void emit_peobj_sym(BuildCtx *ctx, const char *name, uint32_t value,
129
+ int sect, int type, int scl)
130
+ {
131
+ PEsym sym;
132
+ size_t len = strlen(name);
133
+ if (!strtab) { /* Pass 1: only calculate string table length. */
134
+ if (len > 8) strtabofs += len+1;
135
+ return;
136
+ }
137
+ if (len <= 8) {
138
+ memcpy(sym.n.name, name, len);
139
+ memset(sym.n.name+len, 0, 8-len);
140
+ } else {
141
+ sym.n.nameref[0] = 0;
142
+ sym.n.nameref[1] = (uint32_t)strtabofs;
143
+ memcpy(strtab + strtabofs, name, len);
144
+ strtab[strtabofs+len] = 0;
145
+ strtabofs += len+1;
146
+ }
147
+ sym.value = value;
148
+ sym.sect = (int16_t)(sect+1); /* 1-based section number. */
149
+ sym.type = (uint16_t)type;
150
+ sym.scl = (uint8_t)scl;
151
+ sym.naux = 0;
152
+ owrite(ctx, &sym, PEOBJ_SYM_SIZE);
153
+ }
154
+
155
+ /* Emit PE object section symbol. */
156
+ static void emit_peobj_sym_sect(BuildCtx *ctx, PEsection *pesect, int sect)
157
+ {
158
+ PEsym sym;
159
+ PEsymaux aux;
160
+ if (!strtab) return; /* Pass 1: no output. */
161
+ memcpy(sym.n.name, pesect[sect].name, 8);
162
+ sym.value = 0;
163
+ sym.sect = (int16_t)(sect+1); /* 1-based section number. */
164
+ sym.type = PEOBJ_TYPE_NULL;
165
+ sym.scl = PEOBJ_SCL_STATIC;
166
+ sym.naux = 1;
167
+ owrite(ctx, &sym, PEOBJ_SYM_SIZE);
168
+ memset(&aux, 0, sizeof(PEsymaux));
169
+ aux.size = pesect[sect].size;
170
+ aux.nreloc = pesect[sect].nreloc;
171
+ owrite(ctx, &aux, PEOBJ_SYM_SIZE);
172
+ }
173
+
174
+ /* Emit Windows PE object file. */
175
+ void emit_peobj(BuildCtx *ctx)
176
+ {
177
+ PEheader pehdr;
178
+ PEsection pesect[PEOBJ_NSECTIONS];
179
+ uint32_t sofs;
180
+ int i, nrsym;
181
+ union { uint8_t b; uint32_t u; } host_endian;
182
+
183
+ sofs = sizeof(PEheader) + PEOBJ_NSECTIONS*sizeof(PEsection);
184
+
185
+ /* Fill in PE sections. */
186
+ memset(&pesect, 0, PEOBJ_NSECTIONS*sizeof(PEsection));
187
+ memcpy(pesect[PEOBJ_SECT_TEXT].name, ".text", sizeof(".text")-1);
188
+ pesect[PEOBJ_SECT_TEXT].ofs = sofs;
189
+ sofs += (pesect[PEOBJ_SECT_TEXT].size = (uint32_t)ctx->codesz);
190
+ pesect[PEOBJ_SECT_TEXT].relocofs = sofs;
191
+ sofs += (pesect[PEOBJ_SECT_TEXT].nreloc = (uint16_t)ctx->nreloc) * PEOBJ_RELOC_SIZE;
192
+ /* Flags: 60 = read+execute, 50 = align16, 20 = code. */
193
+ pesect[PEOBJ_SECT_TEXT].flags = PEOBJ_TEXT_FLAGS;
194
+
195
+ #if LJ_TARGET_X64
196
+ memcpy(pesect[PEOBJ_SECT_PDATA].name, ".pdata", sizeof(".pdata")-1);
197
+ pesect[PEOBJ_SECT_PDATA].ofs = sofs;
198
+ sofs += (pesect[PEOBJ_SECT_PDATA].size = 6*4);
199
+ pesect[PEOBJ_SECT_PDATA].relocofs = sofs;
200
+ sofs += (pesect[PEOBJ_SECT_PDATA].nreloc = 6) * PEOBJ_RELOC_SIZE;
201
+ /* Flags: 40 = read, 30 = align4, 40 = initialized data. */
202
+ pesect[PEOBJ_SECT_PDATA].flags = 0x40300040;
203
+
204
+ memcpy(pesect[PEOBJ_SECT_XDATA].name, ".xdata", sizeof(".xdata")-1);
205
+ pesect[PEOBJ_SECT_XDATA].ofs = sofs;
206
+ sofs += (pesect[PEOBJ_SECT_XDATA].size = 8*2+4+6*2); /* See below. */
207
+ pesect[PEOBJ_SECT_XDATA].relocofs = sofs;
208
+ sofs += (pesect[PEOBJ_SECT_XDATA].nreloc = 1) * PEOBJ_RELOC_SIZE;
209
+ /* Flags: 40 = read, 30 = align4, 40 = initialized data. */
210
+ pesect[PEOBJ_SECT_XDATA].flags = 0x40300040;
211
+ #endif
212
+
213
+ memcpy(pesect[PEOBJ_SECT_RDATA_Z].name, ".rdata$Z", sizeof(".rdata$Z")-1);
214
+ pesect[PEOBJ_SECT_RDATA_Z].ofs = sofs;
215
+ sofs += (pesect[PEOBJ_SECT_RDATA_Z].size = (uint32_t)strlen(ctx->dasm_ident)+1);
216
+ /* Flags: 40 = read, 30 = align4, 40 = initialized data. */
217
+ pesect[PEOBJ_SECT_RDATA_Z].flags = 0x40300040;
218
+
219
+ /* Fill in PE header. */
220
+ pehdr.arch = PEOBJ_ARCH_TARGET;
221
+ pehdr.nsects = PEOBJ_NSECTIONS;
222
+ pehdr.time = 0; /* Timestamp is optional. */
223
+ pehdr.symtabofs = sofs;
224
+ pehdr.opthdrsz = 0;
225
+ pehdr.flags = 0;
226
+
227
+ /* Compute the size of the symbol table:
228
+ ** @feat.00 + nsections*2
229
+ ** + asm_start + nsym
230
+ ** + nrsym
231
+ */
232
+ nrsym = ctx->nrelocsym;
233
+ pehdr.nsyms = 1+PEOBJ_NSECTIONS*2 + 1+ctx->nsym + nrsym;
234
+ #if LJ_TARGET_X64
235
+ pehdr.nsyms += 1; /* Symbol for lj_err_unwind_win64. */
236
+ #endif
237
+
238
+ /* Write PE object header and all sections. */
239
+ owrite(ctx, &pehdr, sizeof(PEheader));
240
+ owrite(ctx, &pesect, sizeof(PEsection)*PEOBJ_NSECTIONS);
241
+
242
+ /* Write .text section. */
243
+ host_endian.u = 1;
244
+ if (host_endian.b != LJ_ENDIAN_SELECT(1, 0)) {
245
+ #if LJ_TARGET_PPC
246
+ uint32_t *p = (uint32_t *)ctx->code;
247
+ int n = (int)(ctx->codesz >> 2);
248
+ for (i = 0; i < n; i++, p++)
249
+ *p = lj_bswap(*p); /* Byteswap .text section. */
250
+ #else
251
+ fprintf(stderr, "Error: different byte order for host and target\n");
252
+ exit(1);
253
+ #endif
254
+ }
255
+ owrite(ctx, ctx->code, ctx->codesz);
256
+ for (i = 0; i < ctx->nreloc; i++) {
257
+ PEreloc reloc;
258
+ reloc.vaddr = (uint32_t)ctx->reloc[i].ofs + PEOBJ_RELOC_OFS;
259
+ reloc.symidx = 1+2+ctx->reloc[i].sym; /* Reloc syms are after .text sym. */
260
+ reloc.type = ctx->reloc[i].type ? PEOBJ_RELOC_REL32 : PEOBJ_RELOC_DIR32;
261
+ owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
262
+ }
263
+
264
+ #if LJ_TARGET_X64
265
+ { /* Write .pdata section. */
266
+ uint32_t fcofs = (uint32_t)ctx->sym[ctx->nsym-1].ofs;
267
+ uint32_t pdata[3]; /* Start of .text, end of .text and .xdata. */
268
+ PEreloc reloc;
269
+ pdata[0] = 0; pdata[1] = fcofs; pdata[2] = 0;
270
+ owrite(ctx, &pdata, sizeof(pdata));
271
+ pdata[0] = fcofs; pdata[1] = (uint32_t)ctx->codesz; pdata[2] = 20;
272
+ owrite(ctx, &pdata, sizeof(pdata));
273
+ reloc.vaddr = 0; reloc.symidx = 1+2+nrsym+2+2+1;
274
+ reloc.type = PEOBJ_RELOC_ADDR32NB;
275
+ owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
276
+ reloc.vaddr = 4; reloc.symidx = 1+2+nrsym+2+2+1;
277
+ reloc.type = PEOBJ_RELOC_ADDR32NB;
278
+ owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
279
+ reloc.vaddr = 8; reloc.symidx = 1+2+nrsym+2;
280
+ reloc.type = PEOBJ_RELOC_ADDR32NB;
281
+ owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
282
+ reloc.vaddr = 12; reloc.symidx = 1+2+nrsym+2+2+1;
283
+ reloc.type = PEOBJ_RELOC_ADDR32NB;
284
+ owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
285
+ reloc.vaddr = 16; reloc.symidx = 1+2+nrsym+2+2+1;
286
+ reloc.type = PEOBJ_RELOC_ADDR32NB;
287
+ owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
288
+ reloc.vaddr = 20; reloc.symidx = 1+2+nrsym+2;
289
+ reloc.type = PEOBJ_RELOC_ADDR32NB;
290
+ owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
291
+ }
292
+ { /* Write .xdata section. */
293
+ uint16_t xdata[8+2+6];
294
+ PEreloc reloc;
295
+ xdata[0] = 0x01|0x08|0x10; /* Ver. 1, uhandler/ehandler, prolog size 0. */
296
+ xdata[1] = 0x0005; /* Number of unwind codes, no frame pointer. */
297
+ xdata[2] = 0x4200; /* Stack offset 4*8+8 = aword*5. */
298
+ xdata[3] = 0x3000; /* Push rbx. */
299
+ xdata[4] = 0x6000; /* Push rsi. */
300
+ xdata[5] = 0x7000; /* Push rdi. */
301
+ xdata[6] = 0x5000; /* Push rbp. */
302
+ xdata[7] = 0; /* Alignment. */
303
+ xdata[8] = xdata[9] = 0; /* Relocated address of exception handler. */
304
+ xdata[10] = 0x01; /* Ver. 1, no handler, prolog size 0. */
305
+ xdata[11] = 0x1504; /* Number of unwind codes, fp = rbp, fpofs = 16. */
306
+ xdata[12] = 0x0300; /* set_fpreg. */
307
+ xdata[13] = 0x0200; /* stack offset 0*8+8 = aword*1. */
308
+ xdata[14] = 0x3000; /* Push rbx. */
309
+ xdata[15] = 0x5000; /* Push rbp. */
310
+ owrite(ctx, &xdata, sizeof(xdata));
311
+ reloc.vaddr = 2*8; reloc.symidx = 1+2+nrsym+2+2;
312
+ reloc.type = PEOBJ_RELOC_ADDR32NB;
313
+ owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
314
+ }
315
+ #endif
316
+
317
+ /* Write .rdata$Z section. */
318
+ owrite(ctx, ctx->dasm_ident, strlen(ctx->dasm_ident)+1);
319
+
320
+ /* Write symbol table. */
321
+ strtab = NULL; /* 1st pass: collect string sizes. */
322
+ for (;;) {
323
+ strtabofs = 4;
324
+ /* Mark as SafeSEH compliant. */
325
+ emit_peobj_sym(ctx, "@feat.00", 1,
326
+ PEOBJ_SECT_ABS, PEOBJ_TYPE_NULL, PEOBJ_SCL_STATIC);
327
+
328
+ emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_TEXT);
329
+ for (i = 0; i < nrsym; i++)
330
+ emit_peobj_sym(ctx, ctx->relocsym[i], 0,
331
+ PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN);
332
+
333
+ #if LJ_TARGET_X64
334
+ emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_PDATA);
335
+ emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_XDATA);
336
+ emit_peobj_sym(ctx, "lj_err_unwind_win64", 0,
337
+ PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN);
338
+ #endif
339
+
340
+ emit_peobj_sym(ctx, ctx->beginsym, 0,
341
+ PEOBJ_SECT_TEXT, PEOBJ_TYPE_NULL, PEOBJ_SCL_EXTERN);
342
+ for (i = 0; i < ctx->nsym; i++)
343
+ emit_peobj_sym(ctx, ctx->sym[i].name, (uint32_t)ctx->sym[i].ofs,
344
+ PEOBJ_SECT_TEXT, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN);
345
+
346
+ emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA_Z);
347
+
348
+ if (strtab)
349
+ break;
350
+ /* 2nd pass: alloc strtab, write syms and copy strings. */
351
+ strtab = (char *)malloc(strtabofs);
352
+ *(uint32_t *)strtab = (uint32_t)strtabofs;
353
+ }
354
+
355
+ /* Write string table. */
356
+ owrite(ctx, strtab, strtabofs);
357
+ }
358
+
359
+ #else
360
+
361
+ void emit_peobj(BuildCtx *ctx)
362
+ {
363
+ UNUSED(ctx);
364
+ fprintf(stderr, "Error: no PE object support for this target\n");
365
+ exit(1);
366
+ }
367
+
368
+ #endif
@@ -0,0 +1,197 @@
1
+ ----------------------------------------------------------------------------
2
+ -- Lua script to dump the bytecode of the library functions written in Lua.
3
+ -- The resulting 'buildvm_libbc.h' is used for the build process of LuaJIT.
4
+ ----------------------------------------------------------------------------
5
+ -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
6
+ -- Released under the MIT license. See Copyright Notice in luajit.h
7
+ ----------------------------------------------------------------------------
8
+
9
+ local ffi = require("ffi")
10
+ local bit = require("bit")
11
+ local vmdef = require("jit.vmdef")
12
+ local bcnames = vmdef.bcnames
13
+
14
+ local format = string.format
15
+
16
+ local isbe = (string.byte(string.dump(function() end), 5) % 2 == 1)
17
+
18
+ local function usage(arg)
19
+ io.stderr:write("Usage: ", arg and arg[0] or "genlibbc",
20
+ " [-o buildvm_libbc.h] lib_*.c\n")
21
+ os.exit(1)
22
+ end
23
+
24
+ local function parse_arg(arg)
25
+ local outfile = "-"
26
+ if not (arg and arg[1]) then
27
+ usage(arg)
28
+ end
29
+ if arg[1] == "-o" then
30
+ outfile = arg[2]
31
+ if not outfile then usage(arg) end
32
+ table.remove(arg, 1)
33
+ table.remove(arg, 1)
34
+ end
35
+ return outfile
36
+ end
37
+
38
+ local function read_files(names)
39
+ local src = ""
40
+ for _,name in ipairs(names) do
41
+ local fp = assert(io.open(name))
42
+ src = src .. fp:read("*a")
43
+ fp:close()
44
+ end
45
+ return src
46
+ end
47
+
48
+ local function transform_lua(code)
49
+ local fixup = {}
50
+ local n = -30000
51
+ code = string.gsub(code, "CHECK_(%w*)%((.-)%)", function(tp, var)
52
+ n = n + 1
53
+ fixup[n] = { "CHECK", tp }
54
+ return format("%s=%d", var, n)
55
+ end)
56
+ code = string.gsub(code, "PAIRS%((.-)%)", function(var)
57
+ fixup.PAIRS = true
58
+ return format("nil, %s, 0", var)
59
+ end)
60
+ return "return "..code, fixup
61
+ end
62
+
63
+ local function read_uleb128(p)
64
+ local v = p[0]; p = p + 1
65
+ if v >= 128 then
66
+ local sh = 7; v = v - 128
67
+ repeat
68
+ local r = p[0]
69
+ v = v + bit.lshift(bit.band(r, 127), sh)
70
+ sh = sh + 7
71
+ p = p + 1
72
+ until r < 128
73
+ end
74
+ return p, v
75
+ end
76
+
77
+ -- ORDER LJ_T
78
+ local name2itype = {
79
+ str = 5, func = 9, tab = 12, int = 14, num = 15
80
+ }
81
+
82
+ local BC = {}
83
+ for i=0,#bcnames/6-1 do
84
+ BC[string.gsub(string.sub(bcnames, i*6+1, i*6+6), " ", "")] = i
85
+ end
86
+ local xop, xra = isbe and 3 or 0, isbe and 2 or 1
87
+ local xrc, xrb = isbe and 1 or 2, isbe and 0 or 3
88
+
89
+ local function fixup_dump(dump, fixup)
90
+ local buf = ffi.new("uint8_t[?]", #dump+1, dump)
91
+ local p = buf+5
92
+ local n, sizebc
93
+ p, n = read_uleb128(p)
94
+ local start = p
95
+ p = p + 4
96
+ p = read_uleb128(p)
97
+ p = read_uleb128(p)
98
+ p, sizebc = read_uleb128(p)
99
+ local rawtab = {}
100
+ for i=0,sizebc-1 do
101
+ local op = p[xop]
102
+ if op == BC.KSHORT then
103
+ local rd = p[xrc] + 256*p[xrb]
104
+ rd = bit.arshift(bit.lshift(rd, 16), 16)
105
+ local f = fixup[rd]
106
+ if f then
107
+ if f[1] == "CHECK" then
108
+ local tp = f[2]
109
+ if tp == "tab" then rawtab[p[xra]] = true end
110
+ p[xop] = tp == "num" and BC.ISNUM or BC.ISTYPE
111
+ p[xrb] = 0
112
+ p[xrc] = name2itype[tp]
113
+ else
114
+ error("unhandled fixup type: "..f[1])
115
+ end
116
+ end
117
+ elseif op == BC.TGETV then
118
+ if rawtab[p[xrb]] then
119
+ p[xop] = BC.TGETR
120
+ end
121
+ elseif op == BC.TSETV then
122
+ if rawtab[p[xrb]] then
123
+ p[xop] = BC.TSETR
124
+ end
125
+ elseif op == BC.ITERC then
126
+ if fixup.PAIRS then
127
+ p[xop] = BC.ITERN
128
+ end
129
+ end
130
+ p = p + 4
131
+ end
132
+ return ffi.string(start, n)
133
+ end
134
+
135
+ local function find_defs(src)
136
+ local defs = {}
137
+ for name, code in string.gmatch(src, "LJLIB_LUA%(([^)]*)%)%s*/%*(.-)%*/") do
138
+ local env = {}
139
+ local tcode, fixup = transform_lua(code)
140
+ local func = assert(load(tcode, "", nil, env))()
141
+ defs[name] = fixup_dump(string.dump(func, true), fixup)
142
+ defs[#defs+1] = name
143
+ end
144
+ return defs
145
+ end
146
+
147
+ local function gen_header(defs)
148
+ local t = {}
149
+ local function w(x) t[#t+1] = x end
150
+ w("/* This is a generated file. DO NOT EDIT! */\n\n")
151
+ w("static const int libbc_endian = ") w(isbe and 1 or 0) w(";\n\n")
152
+ local s = ""
153
+ for _,name in ipairs(defs) do
154
+ s = s .. defs[name]
155
+ end
156
+ w("static const uint8_t libbc_code[] = {\n")
157
+ local n = 0
158
+ for i=1,#s do
159
+ local x = string.byte(s, i)
160
+ w(x); w(",")
161
+ n = n + (x < 10 and 2 or (x < 100 and 3 or 4))
162
+ if n >= 75 then n = 0; w("\n") end
163
+ end
164
+ w("0\n};\n\n")
165
+ w("static const struct { const char *name; int ofs; } libbc_map[] = {\n")
166
+ local m = 0
167
+ for _,name in ipairs(defs) do
168
+ w('{"'); w(name); w('",'); w(m) w('},\n')
169
+ m = m + #defs[name]
170
+ end
171
+ w("{NULL,"); w(m); w("}\n};\n\n")
172
+ return table.concat(t)
173
+ end
174
+
175
+ local function write_file(name, data)
176
+ if name == "-" then
177
+ assert(io.write(data))
178
+ assert(io.flush())
179
+ else
180
+ local fp = io.open(name)
181
+ if fp then
182
+ local old = fp:read("*a")
183
+ fp:close()
184
+ if data == old then return end
185
+ end
186
+ fp = assert(io.open(name, "w"))
187
+ assert(fp:write(data))
188
+ assert(fp:close())
189
+ end
190
+ end
191
+
192
+ local outfile = parse_arg(arg)
193
+ local src = read_files(arg)
194
+ local defs = find_defs(src)
195
+ local hdr = gen_header(defs)
196
+ write_file(outfile, hdr)
197
+