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,428 @@
1
+ ----------------------------------------------------------------------------
2
+ -- LuaJIT MIPS disassembler module.
3
+ --
4
+ -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
5
+ -- Released under the MIT/X license. See Copyright Notice in luajit.h
6
+ ----------------------------------------------------------------------------
7
+ -- This is a helper module used by the LuaJIT machine code dumper module.
8
+ --
9
+ -- It disassembles all standard MIPS32R1/R2 instructions.
10
+ -- Default mode is big-endian, but see: dis_mipsel.lua
11
+ ------------------------------------------------------------------------------
12
+
13
+ local type = type
14
+ local sub, byte, format = string.sub, string.byte, string.format
15
+ local match, gmatch, gsub = string.match, string.gmatch, string.gsub
16
+ local concat = table.concat
17
+ local bit = require("bit")
18
+ local band, bor, tohex = bit.band, bit.bor, bit.tohex
19
+ local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift
20
+
21
+ ------------------------------------------------------------------------------
22
+ -- Primary and extended opcode maps
23
+ ------------------------------------------------------------------------------
24
+
25
+ local map_movci = { shift = 16, mask = 1, [0] = "movfDSC", "movtDSC", }
26
+ local map_srl = { shift = 21, mask = 1, [0] = "srlDTA", "rotrDTA", }
27
+ local map_srlv = { shift = 6, mask = 1, [0] = "srlvDTS", "rotrvDTS", }
28
+
29
+ local map_special = {
30
+ shift = 0, mask = 63,
31
+ [0] = { shift = 0, mask = -1, [0] = "nop", _ = "sllDTA" },
32
+ map_movci, map_srl, "sraDTA",
33
+ "sllvDTS", false, map_srlv, "sravDTS",
34
+ "jrS", "jalrD1S", "movzDST", "movnDST",
35
+ "syscallY", "breakY", false, "sync",
36
+ "mfhiD", "mthiS", "mfloD", "mtloS",
37
+ false, false, false, false,
38
+ "multST", "multuST", "divST", "divuST",
39
+ false, false, false, false,
40
+ "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T",
41
+ "andDST", "orDST", "xorDST", "nor|notDST0",
42
+ false, false, "sltDST", "sltuDST",
43
+ false, false, false, false,
44
+ "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ",
45
+ "teqSTZ", false, "tneSTZ",
46
+ }
47
+
48
+ local map_special2 = {
49
+ shift = 0, mask = 63,
50
+ [0] = "maddST", "madduST", "mulDST", false,
51
+ "msubST", "msubuST",
52
+ [32] = "clzDS", [33] = "cloDS",
53
+ [63] = "sdbbpY",
54
+ }
55
+
56
+ local map_bshfl = {
57
+ shift = 6, mask = 31,
58
+ [2] = "wsbhDT",
59
+ [16] = "sebDT",
60
+ [24] = "sehDT",
61
+ }
62
+
63
+ local map_special3 = {
64
+ shift = 0, mask = 63,
65
+ [0] = "extTSAK", [4] = "insTSAL",
66
+ [32] = map_bshfl,
67
+ [59] = "rdhwrTD",
68
+ }
69
+
70
+ local map_regimm = {
71
+ shift = 16, mask = 31,
72
+ [0] = "bltzSB", "bgezSB", "bltzlSB", "bgezlSB",
73
+ false, false, false, false,
74
+ "tgeiSI", "tgeiuSI", "tltiSI", "tltiuSI",
75
+ "teqiSI", false, "tneiSI", false,
76
+ "bltzalSB", "bgezalSB", "bltzallSB", "bgezallSB",
77
+ false, false, false, false,
78
+ false, false, false, false,
79
+ false, false, false, "synciSO",
80
+ }
81
+
82
+ local map_cop0 = {
83
+ shift = 25, mask = 1,
84
+ [0] = {
85
+ shift = 21, mask = 15,
86
+ [0] = "mfc0TDW", [4] = "mtc0TDW",
87
+ [10] = "rdpgprDT",
88
+ [11] = { shift = 5, mask = 1, [0] = "diT0", "eiT0", },
89
+ [14] = "wrpgprDT",
90
+ }, {
91
+ shift = 0, mask = 63,
92
+ [1] = "tlbr", [2] = "tlbwi", [6] = "tlbwr", [8] = "tlbp",
93
+ [24] = "eret", [31] = "deret",
94
+ [32] = "wait",
95
+ },
96
+ }
97
+
98
+ local map_cop1s = {
99
+ shift = 0, mask = 63,
100
+ [0] = "add.sFGH", "sub.sFGH", "mul.sFGH", "div.sFGH",
101
+ "sqrt.sFG", "abs.sFG", "mov.sFG", "neg.sFG",
102
+ "round.l.sFG", "trunc.l.sFG", "ceil.l.sFG", "floor.l.sFG",
103
+ "round.w.sFG", "trunc.w.sFG", "ceil.w.sFG", "floor.w.sFG",
104
+ false,
105
+ { shift = 16, mask = 1, [0] = "movf.sFGC", "movt.sFGC" },
106
+ "movz.sFGT", "movn.sFGT",
107
+ false, "recip.sFG", "rsqrt.sFG", false,
108
+ false, false, false, false,
109
+ false, false, false, false,
110
+ false, "cvt.d.sFG", false, false,
111
+ "cvt.w.sFG", "cvt.l.sFG", "cvt.ps.sFGH", false,
112
+ false, false, false, false,
113
+ false, false, false, false,
114
+ "c.f.sVGH", "c.un.sVGH", "c.eq.sVGH", "c.ueq.sVGH",
115
+ "c.olt.sVGH", "c.ult.sVGH", "c.ole.sVGH", "c.ule.sVGH",
116
+ "c.sf.sVGH", "c.ngle.sVGH", "c.seq.sVGH", "c.ngl.sVGH",
117
+ "c.lt.sVGH", "c.nge.sVGH", "c.le.sVGH", "c.ngt.sVGH",
118
+ }
119
+
120
+ local map_cop1d = {
121
+ shift = 0, mask = 63,
122
+ [0] = "add.dFGH", "sub.dFGH", "mul.dFGH", "div.dFGH",
123
+ "sqrt.dFG", "abs.dFG", "mov.dFG", "neg.dFG",
124
+ "round.l.dFG", "trunc.l.dFG", "ceil.l.dFG", "floor.l.dFG",
125
+ "round.w.dFG", "trunc.w.dFG", "ceil.w.dFG", "floor.w.dFG",
126
+ false,
127
+ { shift = 16, mask = 1, [0] = "movf.dFGC", "movt.dFGC" },
128
+ "movz.dFGT", "movn.dFGT",
129
+ false, "recip.dFG", "rsqrt.dFG", false,
130
+ false, false, false, false,
131
+ false, false, false, false,
132
+ "cvt.s.dFG", false, false, false,
133
+ "cvt.w.dFG", "cvt.l.dFG", false, false,
134
+ false, false, false, false,
135
+ false, false, false, false,
136
+ "c.f.dVGH", "c.un.dVGH", "c.eq.dVGH", "c.ueq.dVGH",
137
+ "c.olt.dVGH", "c.ult.dVGH", "c.ole.dVGH", "c.ule.dVGH",
138
+ "c.df.dVGH", "c.ngle.dVGH", "c.deq.dVGH", "c.ngl.dVGH",
139
+ "c.lt.dVGH", "c.nge.dVGH", "c.le.dVGH", "c.ngt.dVGH",
140
+ }
141
+
142
+ local map_cop1ps = {
143
+ shift = 0, mask = 63,
144
+ [0] = "add.psFGH", "sub.psFGH", "mul.psFGH", false,
145
+ false, "abs.psFG", "mov.psFG", "neg.psFG",
146
+ false, false, false, false,
147
+ false, false, false, false,
148
+ false,
149
+ { shift = 16, mask = 1, [0] = "movf.psFGC", "movt.psFGC" },
150
+ "movz.psFGT", "movn.psFGT",
151
+ false, false, false, false,
152
+ false, false, false, false,
153
+ false, false, false, false,
154
+ "cvt.s.puFG", false, false, false,
155
+ false, false, false, false,
156
+ "cvt.s.plFG", false, false, false,
157
+ "pll.psFGH", "plu.psFGH", "pul.psFGH", "puu.psFGH",
158
+ "c.f.psVGH", "c.un.psVGH", "c.eq.psVGH", "c.ueq.psVGH",
159
+ "c.olt.psVGH", "c.ult.psVGH", "c.ole.psVGH", "c.ule.psVGH",
160
+ "c.psf.psVGH", "c.ngle.psVGH", "c.pseq.psVGH", "c.ngl.psVGH",
161
+ "c.lt.psVGH", "c.nge.psVGH", "c.le.psVGH", "c.ngt.psVGH",
162
+ }
163
+
164
+ local map_cop1w = {
165
+ shift = 0, mask = 63,
166
+ [32] = "cvt.s.wFG", [33] = "cvt.d.wFG",
167
+ }
168
+
169
+ local map_cop1l = {
170
+ shift = 0, mask = 63,
171
+ [32] = "cvt.s.lFG", [33] = "cvt.d.lFG",
172
+ }
173
+
174
+ local map_cop1bc = {
175
+ shift = 16, mask = 3,
176
+ [0] = "bc1fCB", "bc1tCB", "bc1flCB", "bc1tlCB",
177
+ }
178
+
179
+ local map_cop1 = {
180
+ shift = 21, mask = 31,
181
+ [0] = "mfc1TG", false, "cfc1TG", "mfhc1TG",
182
+ "mtc1TG", false, "ctc1TG", "mthc1TG",
183
+ map_cop1bc, false, false, false,
184
+ false, false, false, false,
185
+ map_cop1s, map_cop1d, false, false,
186
+ map_cop1w, map_cop1l, map_cop1ps,
187
+ }
188
+
189
+ local map_cop1x = {
190
+ shift = 0, mask = 63,
191
+ [0] = "lwxc1FSX", "ldxc1FSX", false, false,
192
+ false, "luxc1FSX", false, false,
193
+ "swxc1FSX", "sdxc1FSX", false, false,
194
+ false, "suxc1FSX", false, "prefxMSX",
195
+ false, false, false, false,
196
+ false, false, false, false,
197
+ false, false, false, false,
198
+ false, false, "alnv.psFGHS", false,
199
+ "madd.sFRGH", "madd.dFRGH", false, false,
200
+ false, false, "madd.psFRGH", false,
201
+ "msub.sFRGH", "msub.dFRGH", false, false,
202
+ false, false, "msub.psFRGH", false,
203
+ "nmadd.sFRGH", "nmadd.dFRGH", false, false,
204
+ false, false, "nmadd.psFRGH", false,
205
+ "nmsub.sFRGH", "nmsub.dFRGH", false, false,
206
+ false, false, "nmsub.psFRGH", false,
207
+ }
208
+
209
+ local map_pri = {
210
+ [0] = map_special, map_regimm, "jJ", "jalJ",
211
+ "beq|beqz|bST00B", "bne|bnezST0B", "blezSB", "bgtzSB",
212
+ "addiTSI", "addiu|liTS0I", "sltiTSI", "sltiuTSI",
213
+ "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU",
214
+ map_cop0, map_cop1, false, map_cop1x,
215
+ "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB",
216
+ false, false, false, false,
217
+ map_special2, false, false, map_special3,
218
+ "lbTSO", "lhTSO", "lwlTSO", "lwTSO",
219
+ "lbuTSO", "lhuTSO", "lwrTSO", false,
220
+ "sbTSO", "shTSO", "swlTSO", "swTSO",
221
+ false, false, "swrTSO", "cacheNSO",
222
+ "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO",
223
+ false, "ldc1HSO", "ldc2TSO", false,
224
+ "scTSO", "swc1HSO", "swc2TSO", false,
225
+ false, "sdc1HSO", "sdc2TSO", false,
226
+ }
227
+
228
+ ------------------------------------------------------------------------------
229
+
230
+ local map_gpr = {
231
+ [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
232
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
233
+ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
234
+ "r24", "r25", "r26", "r27", "r28", "sp", "r30", "ra",
235
+ }
236
+
237
+ ------------------------------------------------------------------------------
238
+
239
+ -- Output a nicely formatted line with an opcode and operands.
240
+ local function putop(ctx, text, operands)
241
+ local pos = ctx.pos
242
+ local extra = ""
243
+ if ctx.rel then
244
+ local sym = ctx.symtab[ctx.rel]
245
+ if sym then extra = "\t->"..sym end
246
+ end
247
+ if ctx.hexdump > 0 then
248
+ ctx.out(format("%08x %s %-7s %s%s\n",
249
+ ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra))
250
+ else
251
+ ctx.out(format("%08x %-7s %s%s\n",
252
+ ctx.addr+pos, text, concat(operands, ", "), extra))
253
+ end
254
+ ctx.pos = pos + 4
255
+ end
256
+
257
+ -- Fallback for unknown opcodes.
258
+ local function unknown(ctx)
259
+ return putop(ctx, ".long", { "0x"..tohex(ctx.op) })
260
+ end
261
+
262
+ local function get_be(ctx)
263
+ local pos = ctx.pos
264
+ local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4)
265
+ return bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3)
266
+ end
267
+
268
+ local function get_le(ctx)
269
+ local pos = ctx.pos
270
+ local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4)
271
+ return bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0)
272
+ end
273
+
274
+ -- Disassemble a single instruction.
275
+ local function disass_ins(ctx)
276
+ local op = ctx:get()
277
+ local operands = {}
278
+ local last = nil
279
+ ctx.op = op
280
+ ctx.rel = nil
281
+
282
+ local opat = map_pri[rshift(op, 26)]
283
+ while type(opat) ~= "string" do
284
+ if not opat then return unknown(ctx) end
285
+ opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._
286
+ end
287
+ local name, pat = match(opat, "^([a-z0-9_.]*)(.*)")
288
+ local altname, pat2 = match(pat, "|([a-z0-9_.|]*)(.*)")
289
+ if altname then pat = pat2 end
290
+
291
+ for p in gmatch(pat, ".") do
292
+ local x = nil
293
+ if p == "S" then
294
+ x = map_gpr[band(rshift(op, 21), 31)]
295
+ elseif p == "T" then
296
+ x = map_gpr[band(rshift(op, 16), 31)]
297
+ elseif p == "D" then
298
+ x = map_gpr[band(rshift(op, 11), 31)]
299
+ elseif p == "F" then
300
+ x = "f"..band(rshift(op, 6), 31)
301
+ elseif p == "G" then
302
+ x = "f"..band(rshift(op, 11), 31)
303
+ elseif p == "H" then
304
+ x = "f"..band(rshift(op, 16), 31)
305
+ elseif p == "R" then
306
+ x = "f"..band(rshift(op, 21), 31)
307
+ elseif p == "A" then
308
+ x = band(rshift(op, 6), 31)
309
+ elseif p == "M" then
310
+ x = band(rshift(op, 11), 31)
311
+ elseif p == "N" then
312
+ x = band(rshift(op, 16), 31)
313
+ elseif p == "C" then
314
+ x = band(rshift(op, 18), 7)
315
+ if x == 0 then x = nil end
316
+ elseif p == "K" then
317
+ x = band(rshift(op, 11), 31) + 1
318
+ elseif p == "L" then
319
+ x = band(rshift(op, 11), 31) - last + 1
320
+ elseif p == "I" then
321
+ x = arshift(lshift(op, 16), 16)
322
+ elseif p == "U" then
323
+ x = band(op, 0xffff)
324
+ elseif p == "O" then
325
+ local disp = arshift(lshift(op, 16), 16)
326
+ operands[#operands] = format("%d(%s)", disp, last)
327
+ elseif p == "X" then
328
+ local index = map_gpr[band(rshift(op, 16), 31)]
329
+ operands[#operands] = format("%s(%s)", index, last)
330
+ elseif p == "B" then
331
+ x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4
332
+ ctx.rel = x
333
+ x = "0x"..tohex(x)
334
+ elseif p == "J" then
335
+ x = band(ctx.addr + ctx.pos, 0xf0000000) + band(op, 0x03ffffff)*4
336
+ ctx.rel = x
337
+ x = "0x"..tohex(x)
338
+ elseif p == "V" then
339
+ x = band(rshift(op, 8), 7)
340
+ if x == 0 then x = nil end
341
+ elseif p == "W" then
342
+ x = band(op, 7)
343
+ if x == 0 then x = nil end
344
+ elseif p == "Y" then
345
+ x = band(rshift(op, 6), 0x000fffff)
346
+ if x == 0 then x = nil end
347
+ elseif p == "Z" then
348
+ x = band(rshift(op, 6), 1023)
349
+ if x == 0 then x = nil end
350
+ elseif p == "0" then
351
+ if last == "r0" or last == 0 then
352
+ local n = #operands
353
+ operands[n] = nil
354
+ last = operands[n-1]
355
+ if altname then
356
+ local a1, a2 = match(altname, "([^|]*)|(.*)")
357
+ if a1 then name, altname = a1, a2
358
+ else name = altname end
359
+ end
360
+ end
361
+ elseif p == "1" then
362
+ if last == "ra" then
363
+ operands[#operands] = nil
364
+ end
365
+ else
366
+ assert(false)
367
+ end
368
+ if x then operands[#operands+1] = x; last = x end
369
+ end
370
+
371
+ return putop(ctx, name, operands)
372
+ end
373
+
374
+ ------------------------------------------------------------------------------
375
+
376
+ -- Disassemble a block of code.
377
+ local function disass_block(ctx, ofs, len)
378
+ if not ofs then ofs = 0 end
379
+ local stop = len and ofs+len or #ctx.code
380
+ stop = stop - stop % 4
381
+ ctx.pos = ofs - ofs % 4
382
+ ctx.rel = nil
383
+ while ctx.pos < stop do disass_ins(ctx) end
384
+ end
385
+
386
+ -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len).
387
+ local function create(code, addr, out)
388
+ local ctx = {}
389
+ ctx.code = code
390
+ ctx.addr = addr or 0
391
+ ctx.out = out or io.write
392
+ ctx.symtab = {}
393
+ ctx.disass = disass_block
394
+ ctx.hexdump = 8
395
+ ctx.get = get_be
396
+ return ctx
397
+ end
398
+
399
+ local function create_el(code, addr, out)
400
+ local ctx = create(code, addr, out)
401
+ ctx.get = get_le
402
+ return ctx
403
+ end
404
+
405
+ -- Simple API: disassemble code (a string) at address and output via out.
406
+ local function disass(code, addr, out)
407
+ create(code, addr, out):disass()
408
+ end
409
+
410
+ local function disass_el(code, addr, out)
411
+ create_el(code, addr, out):disass()
412
+ end
413
+
414
+ -- Return register name for RID.
415
+ local function regname(r)
416
+ if r < 32 then return map_gpr[r] end
417
+ return "f"..(r-32)
418
+ end
419
+
420
+ -- Public module functions.
421
+ return {
422
+ create = create,
423
+ create_el = create_el,
424
+ disass = disass,
425
+ disass_el = disass_el,
426
+ regname = regname
427
+ }
428
+
@@ -0,0 +1,17 @@
1
+ ----------------------------------------------------------------------------
2
+ -- LuaJIT MIPSEL disassembler wrapper module.
3
+ --
4
+ -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
5
+ -- Released under the MIT license. See Copyright Notice in luajit.h
6
+ ----------------------------------------------------------------------------
7
+ -- This module just exports the little-endian functions from the
8
+ -- MIPS disassembler module. All the interesting stuff is there.
9
+ ------------------------------------------------------------------------------
10
+
11
+ local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips")
12
+ return {
13
+ create = dis_mips.create_el,
14
+ disass = dis_mips.disass_el,
15
+ regname = dis_mips.regname
16
+ }
17
+
@@ -0,0 +1,591 @@
1
+ ----------------------------------------------------------------------------
2
+ -- LuaJIT PPC disassembler module.
3
+ --
4
+ -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
5
+ -- Released under the MIT/X license. See Copyright Notice in luajit.h
6
+ ----------------------------------------------------------------------------
7
+ -- This is a helper module used by the LuaJIT machine code dumper module.
8
+ --
9
+ -- It disassembles all common, non-privileged 32/64 bit PowerPC instructions
10
+ -- plus the e500 SPE instructions and some Cell/Xenon extensions.
11
+ --
12
+ -- NYI: VMX, VMX128
13
+ ------------------------------------------------------------------------------
14
+
15
+ local type = type
16
+ local sub, byte, format = string.sub, string.byte, string.format
17
+ local match, gmatch, gsub = string.match, string.gmatch, string.gsub
18
+ local concat = table.concat
19
+ local bit = require("bit")
20
+ local band, bor, tohex = bit.band, bit.bor, bit.tohex
21
+ local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift
22
+
23
+ ------------------------------------------------------------------------------
24
+ -- Primary and extended opcode maps
25
+ ------------------------------------------------------------------------------
26
+
27
+ local map_crops = {
28
+ shift = 1, mask = 1023,
29
+ [0] = "mcrfXX",
30
+ [33] = "crnor|crnotCCC=", [129] = "crandcCCC",
31
+ [193] = "crxor|crclrCCC%", [225] = "crnandCCC",
32
+ [257] = "crandCCC", [289] = "creqv|crsetCCC%",
33
+ [417] = "crorcCCC", [449] = "cror|crmoveCCC=",
34
+ [16] = "b_lrKB", [528] = "b_ctrKB",
35
+ [150] = "isync",
36
+ }
37
+
38
+ local map_rlwinm = setmetatable({
39
+ shift = 0, mask = -1,
40
+ },
41
+ { __index = function(t, x)
42
+ local rot = band(rshift(x, 11), 31)
43
+ local mb = band(rshift(x, 6), 31)
44
+ local me = band(rshift(x, 1), 31)
45
+ if mb == 0 and me == 31-rot then
46
+ return "slwiRR~A."
47
+ elseif me == 31 and mb == 32-rot then
48
+ return "srwiRR~-A."
49
+ else
50
+ return "rlwinmRR~AAA."
51
+ end
52
+ end
53
+ })
54
+
55
+ local map_rld = {
56
+ shift = 2, mask = 7,
57
+ [0] = "rldiclRR~HM.", "rldicrRR~HM.", "rldicRR~HM.", "rldimiRR~HM.",
58
+ {
59
+ shift = 1, mask = 1,
60
+ [0] = "rldclRR~RM.", "rldcrRR~RM.",
61
+ },
62
+ }
63
+
64
+ local map_ext = setmetatable({
65
+ shift = 1, mask = 1023,
66
+
67
+ [0] = "cmp_YLRR", [32] = "cmpl_YLRR",
68
+ [4] = "twARR", [68] = "tdARR",
69
+
70
+ [8] = "subfcRRR.", [40] = "subfRRR.",
71
+ [104] = "negRR.", [136] = "subfeRRR.",
72
+ [200] = "subfzeRR.", [232] = "subfmeRR.",
73
+ [520] = "subfcoRRR.", [552] = "subfoRRR.",
74
+ [616] = "negoRR.", [648] = "subfeoRRR.",
75
+ [712] = "subfzeoRR.", [744] = "subfmeoRR.",
76
+
77
+ [9] = "mulhduRRR.", [73] = "mulhdRRR.", [233] = "mulldRRR.",
78
+ [457] = "divduRRR.", [489] = "divdRRR.",
79
+ [745] = "mulldoRRR.",
80
+ [969] = "divduoRRR.", [1001] = "divdoRRR.",
81
+
82
+ [10] = "addcRRR.", [138] = "addeRRR.",
83
+ [202] = "addzeRR.", [234] = "addmeRR.", [266] = "addRRR.",
84
+ [522] = "addcoRRR.", [650] = "addeoRRR.",
85
+ [714] = "addzeoRR.", [746] = "addmeoRR.", [778] = "addoRRR.",
86
+
87
+ [11] = "mulhwuRRR.", [75] = "mulhwRRR.", [235] = "mullwRRR.",
88
+ [459] = "divwuRRR.", [491] = "divwRRR.",
89
+ [747] = "mullwoRRR.",
90
+ [971] = "divwouRRR.", [1003] = "divwoRRR.",
91
+
92
+ [15] = "iselltRRR", [47] = "iselgtRRR", [79] = "iseleqRRR",
93
+
94
+ [144] = { shift = 20, mask = 1, [0] = "mtcrfRZ~", "mtocrfRZ~", },
95
+ [19] = { shift = 20, mask = 1, [0] = "mfcrR", "mfocrfRZ", },
96
+ [371] = { shift = 11, mask = 1023, [392] = "mftbR", [424] = "mftbuR", },
97
+ [339] = {
98
+ shift = 11, mask = 1023,
99
+ [32] = "mferR", [256] = "mflrR", [288] = "mfctrR", [16] = "mfspefscrR",
100
+ },
101
+ [467] = {
102
+ shift = 11, mask = 1023,
103
+ [32] = "mtxerR", [256] = "mtlrR", [288] = "mtctrR", [16] = "mtspefscrR",
104
+ },
105
+
106
+ [20] = "lwarxRR0R", [84] = "ldarxRR0R",
107
+
108
+ [21] = "ldxRR0R", [53] = "lduxRRR",
109
+ [149] = "stdxRR0R", [181] = "stduxRRR",
110
+ [341] = "lwaxRR0R", [373] = "lwauxRRR",
111
+
112
+ [23] = "lwzxRR0R", [55] = "lwzuxRRR",
113
+ [87] = "lbzxRR0R", [119] = "lbzuxRRR",
114
+ [151] = "stwxRR0R", [183] = "stwuxRRR",
115
+ [215] = "stbxRR0R", [247] = "stbuxRRR",
116
+ [279] = "lhzxRR0R", [311] = "lhzuxRRR",
117
+ [343] = "lhaxRR0R", [375] = "lhauxRRR",
118
+ [407] = "sthxRR0R", [439] = "sthuxRRR",
119
+
120
+ [54] = "dcbst-R0R", [86] = "dcbf-R0R",
121
+ [150] = "stwcxRR0R.", [214] = "stdcxRR0R.",
122
+ [246] = "dcbtst-R0R", [278] = "dcbt-R0R",
123
+ [310] = "eciwxRR0R", [438] = "ecowxRR0R",
124
+ [470] = "dcbi-RR",
125
+
126
+ [598] = {
127
+ shift = 21, mask = 3,
128
+ [0] = "sync", "lwsync", "ptesync",
129
+ },
130
+ [758] = "dcba-RR",
131
+ [854] = "eieio", [982] = "icbi-R0R", [1014] = "dcbz-R0R",
132
+
133
+ [26] = "cntlzwRR~", [58] = "cntlzdRR~",
134
+ [122] = "popcntbRR~",
135
+ [154] = "prtywRR~", [186] = "prtydRR~",
136
+
137
+ [28] = "andRR~R.", [60] = "andcRR~R.", [124] = "nor|notRR~R=.",
138
+ [284] = "eqvRR~R.", [316] = "xorRR~R.",
139
+ [412] = "orcRR~R.", [444] = "or|mrRR~R=.", [476] = "nandRR~R.",
140
+ [508] = "cmpbRR~R",
141
+
142
+ [512] = "mcrxrX",
143
+
144
+ [532] = "ldbrxRR0R", [660] = "stdbrxRR0R",
145
+
146
+ [533] = "lswxRR0R", [597] = "lswiRR0A",
147
+ [661] = "stswxRR0R", [725] = "stswiRR0A",
148
+
149
+ [534] = "lwbrxRR0R", [662] = "stwbrxRR0R",
150
+ [790] = "lhbrxRR0R", [918] = "sthbrxRR0R",
151
+
152
+ [535] = "lfsxFR0R", [567] = "lfsuxFRR",
153
+ [599] = "lfdxFR0R", [631] = "lfduxFRR",
154
+ [663] = "stfsxFR0R", [695] = "stfsuxFRR",
155
+ [727] = "stfdxFR0R", [759] = "stfduxFR0R",
156
+ [855] = "lfiwaxFR0R",
157
+ [983] = "stfiwxFR0R",
158
+
159
+ [24] = "slwRR~R.",
160
+
161
+ [27] = "sldRR~R.", [536] = "srwRR~R.",
162
+ [792] = "srawRR~R.", [824] = "srawiRR~A.",
163
+
164
+ [794] = "sradRR~R.", [826] = "sradiRR~H.", [827] = "sradiRR~H.",
165
+ [922] = "extshRR~.", [954] = "extsbRR~.", [986] = "extswRR~.",
166
+
167
+ [539] = "srdRR~R.",
168
+ },
169
+ { __index = function(t, x)
170
+ if band(x, 31) == 15 then return "iselRRRC" end
171
+ end
172
+ })
173
+
174
+ local map_ld = {
175
+ shift = 0, mask = 3,
176
+ [0] = "ldRRE", "lduRRE", "lwaRRE",
177
+ }
178
+
179
+ local map_std = {
180
+ shift = 0, mask = 3,
181
+ [0] = "stdRRE", "stduRRE",
182
+ }
183
+
184
+ local map_fps = {
185
+ shift = 5, mask = 1,
186
+ {
187
+ shift = 1, mask = 15,
188
+ [0] = false, false, "fdivsFFF.", false,
189
+ "fsubsFFF.", "faddsFFF.", "fsqrtsF-F.", false,
190
+ "fresF-F.", "fmulsFF-F.", "frsqrtesF-F.", false,
191
+ "fmsubsFFFF~.", "fmaddsFFFF~.", "fnmsubsFFFF~.", "fnmaddsFFFF~.",
192
+ }
193
+ }
194
+
195
+ local map_fpd = {
196
+ shift = 5, mask = 1,
197
+ [0] = {
198
+ shift = 1, mask = 1023,
199
+ [0] = "fcmpuXFF", [32] = "fcmpoXFF", [64] = "mcrfsXX",
200
+ [38] = "mtfsb1A.", [70] = "mtfsb0A.", [134] = "mtfsfiA>>-A>",
201
+ [8] = "fcpsgnFFF.", [40] = "fnegF-F.", [72] = "fmrF-F.",
202
+ [136] = "fnabsF-F.", [264] = "fabsF-F.",
203
+ [12] = "frspF-F.",
204
+ [14] = "fctiwF-F.", [15] = "fctiwzF-F.",
205
+ [583] = "mffsF.", [711] = "mtfsfZF.",
206
+ [392] = "frinF-F.", [424] = "frizF-F.",
207
+ [456] = "fripF-F.", [488] = "frimF-F.",
208
+ [814] = "fctidF-F.", [815] = "fctidzF-F.", [846] = "fcfidF-F.",
209
+ },
210
+ {
211
+ shift = 1, mask = 15,
212
+ [0] = false, false, "fdivFFF.", false,
213
+ "fsubFFF.", "faddFFF.", "fsqrtF-F.", "fselFFFF~.",
214
+ "freF-F.", "fmulFF-F.", "frsqrteF-F.", false,
215
+ "fmsubFFFF~.", "fmaddFFFF~.", "fnmsubFFFF~.", "fnmaddFFFF~.",
216
+ }
217
+ }
218
+
219
+ local map_spe = {
220
+ shift = 0, mask = 2047,
221
+
222
+ [512] = "evaddwRRR", [514] = "evaddiwRAR~",
223
+ [516] = "evsubwRRR~", [518] = "evsubiwRAR~",
224
+ [520] = "evabsRR", [521] = "evnegRR",
225
+ [522] = "evextsbRR", [523] = "evextshRR", [524] = "evrndwRR",
226
+ [525] = "evcntlzwRR", [526] = "evcntlswRR",
227
+
228
+ [527] = "brincRRR",
229
+
230
+ [529] = "evandRRR", [530] = "evandcRRR", [534] = "evxorRRR",
231
+ [535] = "evor|evmrRRR=", [536] = "evnor|evnotRRR=",
232
+ [537] = "eveqvRRR", [539] = "evorcRRR", [542] = "evnandRRR",
233
+
234
+ [544] = "evsrwuRRR", [545] = "evsrwsRRR",
235
+ [546] = "evsrwiuRRA", [547] = "evsrwisRRA",
236
+ [548] = "evslwRRR", [550] = "evslwiRRA",
237
+ [552] = "evrlwRRR", [553] = "evsplatiRS",
238
+ [554] = "evrlwiRRA", [555] = "evsplatfiRS",
239
+ [556] = "evmergehiRRR", [557] = "evmergeloRRR",
240
+ [558] = "evmergehiloRRR", [559] = "evmergelohiRRR",
241
+
242
+ [560] = "evcmpgtuYRR", [561] = "evcmpgtsYRR",
243
+ [562] = "evcmpltuYRR", [563] = "evcmpltsYRR",
244
+ [564] = "evcmpeqYRR",
245
+
246
+ [632] = "evselRRR", [633] = "evselRRRW",
247
+ [634] = "evselRRRW", [635] = "evselRRRW",
248
+ [636] = "evselRRRW", [637] = "evselRRRW",
249
+ [638] = "evselRRRW", [639] = "evselRRRW",
250
+
251
+ [640] = "evfsaddRRR", [641] = "evfssubRRR",
252
+ [644] = "evfsabsRR", [645] = "evfsnabsRR", [646] = "evfsnegRR",
253
+ [648] = "evfsmulRRR", [649] = "evfsdivRRR",
254
+ [652] = "evfscmpgtYRR", [653] = "evfscmpltYRR", [654] = "evfscmpeqYRR",
255
+ [656] = "evfscfuiR-R", [657] = "evfscfsiR-R",
256
+ [658] = "evfscfufR-R", [659] = "evfscfsfR-R",
257
+ [660] = "evfsctuiR-R", [661] = "evfsctsiR-R",
258
+ [662] = "evfsctufR-R", [663] = "evfsctsfR-R",
259
+ [664] = "evfsctuizR-R", [666] = "evfsctsizR-R",
260
+ [668] = "evfststgtYRR", [669] = "evfststltYRR", [670] = "evfststeqYRR",
261
+
262
+ [704] = "efsaddRRR", [705] = "efssubRRR",
263
+ [708] = "efsabsRR", [709] = "efsnabsRR", [710] = "efsnegRR",
264
+ [712] = "efsmulRRR", [713] = "efsdivRRR",
265
+ [716] = "efscmpgtYRR", [717] = "efscmpltYRR", [718] = "efscmpeqYRR",
266
+ [719] = "efscfdR-R",
267
+ [720] = "efscfuiR-R", [721] = "efscfsiR-R",
268
+ [722] = "efscfufR-R", [723] = "efscfsfR-R",
269
+ [724] = "efsctuiR-R", [725] = "efsctsiR-R",
270
+ [726] = "efsctufR-R", [727] = "efsctsfR-R",
271
+ [728] = "efsctuizR-R", [730] = "efsctsizR-R",
272
+ [732] = "efststgtYRR", [733] = "efststltYRR", [734] = "efststeqYRR",
273
+
274
+ [736] = "efdaddRRR", [737] = "efdsubRRR",
275
+ [738] = "efdcfuidR-R", [739] = "efdcfsidR-R",
276
+ [740] = "efdabsRR", [741] = "efdnabsRR", [742] = "efdnegRR",
277
+ [744] = "efdmulRRR", [745] = "efddivRRR",
278
+ [746] = "efdctuidzR-R", [747] = "efdctsidzR-R",
279
+ [748] = "efdcmpgtYRR", [749] = "efdcmpltYRR", [750] = "efdcmpeqYRR",
280
+ [751] = "efdcfsR-R",
281
+ [752] = "efdcfuiR-R", [753] = "efdcfsiR-R",
282
+ [754] = "efdcfufR-R", [755] = "efdcfsfR-R",
283
+ [756] = "efdctuiR-R", [757] = "efdctsiR-R",
284
+ [758] = "efdctufR-R", [759] = "efdctsfR-R",
285
+ [760] = "efdctuizR-R", [762] = "efdctsizR-R",
286
+ [764] = "efdtstgtYRR", [765] = "efdtstltYRR", [766] = "efdtsteqYRR",
287
+
288
+ [768] = "evlddxRR0R", [769] = "evlddRR8",
289
+ [770] = "evldwxRR0R", [771] = "evldwRR8",
290
+ [772] = "evldhxRR0R", [773] = "evldhRR8",
291
+ [776] = "evlhhesplatxRR0R", [777] = "evlhhesplatRR2",
292
+ [780] = "evlhhousplatxRR0R", [781] = "evlhhousplatRR2",
293
+ [782] = "evlhhossplatxRR0R", [783] = "evlhhossplatRR2",
294
+ [784] = "evlwhexRR0R", [785] = "evlwheRR4",
295
+ [788] = "evlwhouxRR0R", [789] = "evlwhouRR4",
296
+ [790] = "evlwhosxRR0R", [791] = "evlwhosRR4",
297
+ [792] = "evlwwsplatxRR0R", [793] = "evlwwsplatRR4",
298
+ [796] = "evlwhsplatxRR0R", [797] = "evlwhsplatRR4",
299
+
300
+ [800] = "evstddxRR0R", [801] = "evstddRR8",
301
+ [802] = "evstdwxRR0R", [803] = "evstdwRR8",
302
+ [804] = "evstdhxRR0R", [805] = "evstdhRR8",
303
+ [816] = "evstwhexRR0R", [817] = "evstwheRR4",
304
+ [820] = "evstwhoxRR0R", [821] = "evstwhoRR4",
305
+ [824] = "evstwwexRR0R", [825] = "evstwweRR4",
306
+ [828] = "evstwwoxRR0R", [829] = "evstwwoRR4",
307
+
308
+ [1027] = "evmhessfRRR", [1031] = "evmhossfRRR", [1032] = "evmheumiRRR",
309
+ [1033] = "evmhesmiRRR", [1035] = "evmhesmfRRR", [1036] = "evmhoumiRRR",
310
+ [1037] = "evmhosmiRRR", [1039] = "evmhosmfRRR", [1059] = "evmhessfaRRR",
311
+ [1063] = "evmhossfaRRR", [1064] = "evmheumiaRRR", [1065] = "evmhesmiaRRR",
312
+ [1067] = "evmhesmfaRRR", [1068] = "evmhoumiaRRR", [1069] = "evmhosmiaRRR",
313
+ [1071] = "evmhosmfaRRR", [1095] = "evmwhssfRRR", [1096] = "evmwlumiRRR",
314
+ [1100] = "evmwhumiRRR", [1101] = "evmwhsmiRRR", [1103] = "evmwhsmfRRR",
315
+ [1107] = "evmwssfRRR", [1112] = "evmwumiRRR", [1113] = "evmwsmiRRR",
316
+ [1115] = "evmwsmfRRR", [1127] = "evmwhssfaRRR", [1128] = "evmwlumiaRRR",
317
+ [1132] = "evmwhumiaRRR", [1133] = "evmwhsmiaRRR", [1135] = "evmwhsmfaRRR",
318
+ [1139] = "evmwssfaRRR", [1144] = "evmwumiaRRR", [1145] = "evmwsmiaRRR",
319
+ [1147] = "evmwsmfaRRR",
320
+
321
+ [1216] = "evaddusiaawRR", [1217] = "evaddssiaawRR",
322
+ [1218] = "evsubfusiaawRR", [1219] = "evsubfssiaawRR",
323
+ [1220] = "evmraRR",
324
+ [1222] = "evdivwsRRR", [1223] = "evdivwuRRR",
325
+ [1224] = "evaddumiaawRR", [1225] = "evaddsmiaawRR",
326
+ [1226] = "evsubfumiaawRR", [1227] = "evsubfsmiaawRR",
327
+
328
+ [1280] = "evmheusiaawRRR", [1281] = "evmhessiaawRRR",
329
+ [1283] = "evmhessfaawRRR", [1284] = "evmhousiaawRRR",
330
+ [1285] = "evmhossiaawRRR", [1287] = "evmhossfaawRRR",
331
+ [1288] = "evmheumiaawRRR", [1289] = "evmhesmiaawRRR",
332
+ [1291] = "evmhesmfaawRRR", [1292] = "evmhoumiaawRRR",
333
+ [1293] = "evmhosmiaawRRR", [1295] = "evmhosmfaawRRR",
334
+ [1320] = "evmhegumiaaRRR", [1321] = "evmhegsmiaaRRR",
335
+ [1323] = "evmhegsmfaaRRR", [1324] = "evmhogumiaaRRR",
336
+ [1325] = "evmhogsmiaaRRR", [1327] = "evmhogsmfaaRRR",
337
+ [1344] = "evmwlusiaawRRR", [1345] = "evmwlssiaawRRR",
338
+ [1352] = "evmwlumiaawRRR", [1353] = "evmwlsmiaawRRR",
339
+ [1363] = "evmwssfaaRRR", [1368] = "evmwumiaaRRR",
340
+ [1369] = "evmwsmiaaRRR", [1371] = "evmwsmfaaRRR",
341
+ [1408] = "evmheusianwRRR", [1409] = "evmhessianwRRR",
342
+ [1411] = "evmhessfanwRRR", [1412] = "evmhousianwRRR",
343
+ [1413] = "evmhossianwRRR", [1415] = "evmhossfanwRRR",
344
+ [1416] = "evmheumianwRRR", [1417] = "evmhesmianwRRR",
345
+ [1419] = "evmhesmfanwRRR", [1420] = "evmhoumianwRRR",
346
+ [1421] = "evmhosmianwRRR", [1423] = "evmhosmfanwRRR",
347
+ [1448] = "evmhegumianRRR", [1449] = "evmhegsmianRRR",
348
+ [1451] = "evmhegsmfanRRR", [1452] = "evmhogumianRRR",
349
+ [1453] = "evmhogsmianRRR", [1455] = "evmhogsmfanRRR",
350
+ [1472] = "evmwlusianwRRR", [1473] = "evmwlssianwRRR",
351
+ [1480] = "evmwlumianwRRR", [1481] = "evmwlsmianwRRR",
352
+ [1491] = "evmwssfanRRR", [1496] = "evmwumianRRR",
353
+ [1497] = "evmwsmianRRR", [1499] = "evmwsmfanRRR",
354
+ }
355
+
356
+ local map_pri = {
357
+ [0] = false, false, "tdiARI", "twiARI",
358
+ map_spe, false, false, "mulliRRI",
359
+ "subficRRI", false, "cmpl_iYLRU", "cmp_iYLRI",
360
+ "addicRRI", "addic.RRI", "addi|liRR0I", "addis|lisRR0I",
361
+ "b_KBJ", "sc", "bKJ", map_crops,
362
+ "rlwimiRR~AAA.", map_rlwinm, false, "rlwnmRR~RAA.",
363
+ "oriNRR~U", "orisRR~U", "xoriRR~U", "xorisRR~U",
364
+ "andi.RR~U", "andis.RR~U", map_rld, map_ext,
365
+ "lwzRRD", "lwzuRRD", "lbzRRD", "lbzuRRD",
366
+ "stwRRD", "stwuRRD", "stbRRD", "stbuRRD",
367
+ "lhzRRD", "lhzuRRD", "lhaRRD", "lhauRRD",
368
+ "sthRRD", "sthuRRD", "lmwRRD", "stmwRRD",
369
+ "lfsFRD", "lfsuFRD", "lfdFRD", "lfduFRD",
370
+ "stfsFRD", "stfsuFRD", "stfdFRD", "stfduFRD",
371
+ false, false, map_ld, map_fps,
372
+ false, false, map_std, map_fpd,
373
+ }
374
+
375
+ ------------------------------------------------------------------------------
376
+
377
+ local map_gpr = {
378
+ [0] = "r0", "sp", "r2", "r3", "r4", "r5", "r6", "r7",
379
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
380
+ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
381
+ "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
382
+ }
383
+
384
+ local map_cond = { [0] = "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", }
385
+
386
+ -- Format a condition bit.
387
+ local function condfmt(cond)
388
+ if cond <= 3 then
389
+ return map_cond[band(cond, 3)]
390
+ else
391
+ return format("4*cr%d+%s", rshift(cond, 2), map_cond[band(cond, 3)])
392
+ end
393
+ end
394
+
395
+ ------------------------------------------------------------------------------
396
+
397
+ -- Output a nicely formatted line with an opcode and operands.
398
+ local function putop(ctx, text, operands)
399
+ local pos = ctx.pos
400
+ local extra = ""
401
+ if ctx.rel then
402
+ local sym = ctx.symtab[ctx.rel]
403
+ if sym then extra = "\t->"..sym end
404
+ end
405
+ if ctx.hexdump > 0 then
406
+ ctx.out(format("%08x %s %-7s %s%s\n",
407
+ ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra))
408
+ else
409
+ ctx.out(format("%08x %-7s %s%s\n",
410
+ ctx.addr+pos, text, concat(operands, ", "), extra))
411
+ end
412
+ ctx.pos = pos + 4
413
+ end
414
+
415
+ -- Fallback for unknown opcodes.
416
+ local function unknown(ctx)
417
+ return putop(ctx, ".long", { "0x"..tohex(ctx.op) })
418
+ end
419
+
420
+ -- Disassemble a single instruction.
421
+ local function disass_ins(ctx)
422
+ local pos = ctx.pos
423
+ local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4)
424
+ local op = bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3)
425
+ local operands = {}
426
+ local last = nil
427
+ local rs = 21
428
+ ctx.op = op
429
+ ctx.rel = nil
430
+
431
+ local opat = map_pri[rshift(b0, 2)]
432
+ while type(opat) ~= "string" do
433
+ if not opat then return unknown(ctx) end
434
+ opat = opat[band(rshift(op, opat.shift), opat.mask)]
435
+ end
436
+ local name, pat = match(opat, "^([a-z0-9_.]*)(.*)")
437
+ local altname, pat2 = match(pat, "|([a-z0-9_.]*)(.*)")
438
+ if altname then pat = pat2 end
439
+
440
+ for p in gmatch(pat, ".") do
441
+ local x = nil
442
+ if p == "R" then
443
+ x = map_gpr[band(rshift(op, rs), 31)]
444
+ rs = rs - 5
445
+ elseif p == "F" then
446
+ x = "f"..band(rshift(op, rs), 31)
447
+ rs = rs - 5
448
+ elseif p == "A" then
449
+ x = band(rshift(op, rs), 31)
450
+ rs = rs - 5
451
+ elseif p == "S" then
452
+ x = arshift(lshift(op, 27-rs), 27)
453
+ rs = rs - 5
454
+ elseif p == "I" then
455
+ x = arshift(lshift(op, 16), 16)
456
+ elseif p == "U" then
457
+ x = band(op, 0xffff)
458
+ elseif p == "D" or p == "E" then
459
+ local disp = arshift(lshift(op, 16), 16)
460
+ if p == "E" then disp = band(disp, -4) end
461
+ if last == "r0" then last = "0" end
462
+ operands[#operands] = format("%d(%s)", disp, last)
463
+ elseif p >= "2" and p <= "8" then
464
+ local disp = band(rshift(op, rs), 31) * p
465
+ if last == "r0" then last = "0" end
466
+ operands[#operands] = format("%d(%s)", disp, last)
467
+ elseif p == "H" then
468
+ x = band(rshift(op, rs), 31) + lshift(band(op, 2), 4)
469
+ rs = rs - 5
470
+ elseif p == "M" then
471
+ x = band(rshift(op, rs), 31) + band(op, 0x20)
472
+ elseif p == "C" then
473
+ x = condfmt(band(rshift(op, rs), 31))
474
+ rs = rs - 5
475
+ elseif p == "B" then
476
+ local bo = rshift(op, 21)
477
+ local cond = band(rshift(op, 16), 31)
478
+ local cn = ""
479
+ rs = rs - 10
480
+ if band(bo, 4) == 0 then
481
+ cn = band(bo, 2) == 0 and "dnz" or "dz"
482
+ if band(bo, 0x10) == 0 then
483
+ cn = cn..(band(bo, 8) == 0 and "f" or "t")
484
+ end
485
+ if band(bo, 0x10) == 0 then x = condfmt(cond) end
486
+ name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+")
487
+ elseif band(bo, 0x10) == 0 then
488
+ cn = map_cond[band(cond, 3) + (band(bo, 8) == 0 and 4 or 0)]
489
+ if cond > 3 then x = "cr"..rshift(cond, 2) end
490
+ name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+")
491
+ end
492
+ name = gsub(name, "_", cn)
493
+ elseif p == "J" then
494
+ x = arshift(lshift(op, 27-rs), 29-rs)*4
495
+ if band(op, 2) == 0 then x = ctx.addr + pos + x end
496
+ ctx.rel = x
497
+ x = "0x"..tohex(x)
498
+ elseif p == "K" then
499
+ if band(op, 1) ~= 0 then name = name.."l" end
500
+ if band(op, 2) ~= 0 then name = name.."a" end
501
+ elseif p == "X" or p == "Y" then
502
+ x = band(rshift(op, rs+2), 7)
503
+ if x == 0 and p == "Y" then x = nil else x = "cr"..x end
504
+ rs = rs - 5
505
+ elseif p == "W" then
506
+ x = "cr"..band(op, 7)
507
+ elseif p == "Z" then
508
+ x = band(rshift(op, rs-4), 255)
509
+ rs = rs - 10
510
+ elseif p == ">" then
511
+ operands[#operands] = rshift(operands[#operands], 1)
512
+ elseif p == "0" then
513
+ if last == "r0" then
514
+ operands[#operands] = nil
515
+ if altname then name = altname end
516
+ end
517
+ elseif p == "L" then
518
+ name = gsub(name, "_", band(op, 0x00200000) ~= 0 and "d" or "w")
519
+ elseif p == "." then
520
+ if band(op, 1) == 1 then name = name.."." end
521
+ elseif p == "N" then
522
+ if op == 0x60000000 then name = "nop"; break end
523
+ elseif p == "~" then
524
+ local n = #operands
525
+ operands[n-1], operands[n] = operands[n], operands[n-1]
526
+ elseif p == "=" then
527
+ local n = #operands
528
+ if last == operands[n-1] then
529
+ operands[n] = nil
530
+ name = altname
531
+ end
532
+ elseif p == "%" then
533
+ local n = #operands
534
+ if last == operands[n-1] and last == operands[n-2] then
535
+ operands[n] = nil
536
+ operands[n-1] = nil
537
+ name = altname
538
+ end
539
+ elseif p == "-" then
540
+ rs = rs - 5
541
+ else
542
+ assert(false)
543
+ end
544
+ if x then operands[#operands+1] = x; last = x end
545
+ end
546
+
547
+ return putop(ctx, name, operands)
548
+ end
549
+
550
+ ------------------------------------------------------------------------------
551
+
552
+ -- Disassemble a block of code.
553
+ local function disass_block(ctx, ofs, len)
554
+ if not ofs then ofs = 0 end
555
+ local stop = len and ofs+len or #ctx.code
556
+ stop = stop - stop % 4
557
+ ctx.pos = ofs - ofs % 4
558
+ ctx.rel = nil
559
+ while ctx.pos < stop do disass_ins(ctx) end
560
+ end
561
+
562
+ -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len).
563
+ local function create(code, addr, out)
564
+ local ctx = {}
565
+ ctx.code = code
566
+ ctx.addr = addr or 0
567
+ ctx.out = out or io.write
568
+ ctx.symtab = {}
569
+ ctx.disass = disass_block
570
+ ctx.hexdump = 8
571
+ return ctx
572
+ end
573
+
574
+ -- Simple API: disassemble code (a string) at address and output via out.
575
+ local function disass(code, addr, out)
576
+ create(code, addr, out):disass()
577
+ end
578
+
579
+ -- Return register name for RID.
580
+ local function regname(r)
581
+ if r < 32 then return map_gpr[r] end
582
+ return "f"..(r-32)
583
+ end
584
+
585
+ -- Public module functions.
586
+ return {
587
+ create = create,
588
+ disass = disass,
589
+ regname = regname
590
+ }
591
+