smallworld-re 1.0.3__py3-none-any.whl → 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. smallworld/analyses/__init__.py +8 -0
  2. smallworld/analyses/analysis.py +8 -67
  3. smallworld/analyses/code_coverage.py +1 -2
  4. smallworld/analyses/colorizer.py +301 -534
  5. smallworld/analyses/colorizer_def_use.py +217 -0
  6. smallworld/analyses/colorizer_summary.py +173 -83
  7. smallworld/analyses/field_detection/field_analysis.py +7 -8
  8. smallworld/analyses/field_detection/hints.py +1 -1
  9. smallworld/analyses/field_detection/malloc.py +2 -2
  10. smallworld/analyses/trace_execution.py +160 -0
  11. smallworld/analyses/trace_execution_types.py +42 -0
  12. smallworld/analyses/unstable/angr/divergence.py +1 -2
  13. smallworld/analyses/unstable/angr/model.py +5 -6
  14. smallworld/analyses/unstable/angr_nwbt.py +3 -4
  15. smallworld/analyses/unstable/code_coverage.py +2 -3
  16. smallworld/analyses/unstable/code_reachable.py +2 -3
  17. smallworld/analyses/unstable/control_flow_tracer.py +2 -3
  18. smallworld/analyses/unstable/pointer_finder.py +2 -3
  19. smallworld/analyses/unstable/utils/tui.py +71 -0
  20. smallworld/emulators/__init__.py +3 -1
  21. smallworld/emulators/angr/angr.py +30 -9
  22. smallworld/emulators/angr/machdefs/__init__.py +2 -0
  23. smallworld/emulators/angr/machdefs/aarch64.py +1 -1
  24. smallworld/emulators/angr/machdefs/amd64.py +0 -4
  25. smallworld/emulators/angr/machdefs/arm.py +0 -2
  26. smallworld/emulators/angr/machdefs/i386.py +0 -2
  27. smallworld/emulators/angr/machdefs/loongarch.py +340 -0
  28. smallworld/emulators/angr/machdefs/machdef.py +1 -8
  29. smallworld/emulators/angr/machdefs/mips.py +0 -2
  30. smallworld/emulators/angr/machdefs/mips64.py +0 -2
  31. smallworld/emulators/angr/machdefs/ppc.py +1 -2
  32. smallworld/emulators/angr/machdefs/riscv.py +8 -10
  33. smallworld/emulators/angr/machdefs/xtensa.py +7 -4
  34. smallworld/emulators/emulator.py +22 -0
  35. smallworld/emulators/ghidra/__init__.py +37 -0
  36. smallworld/emulators/ghidra/ghidra.py +513 -0
  37. smallworld/emulators/ghidra/machdefs/__init__.py +31 -0
  38. smallworld/emulators/ghidra/machdefs/aarch64.py +289 -0
  39. smallworld/emulators/ghidra/machdefs/amd64.py +185 -0
  40. smallworld/emulators/ghidra/machdefs/arm.py +370 -0
  41. smallworld/emulators/ghidra/machdefs/i386.py +109 -0
  42. smallworld/emulators/ghidra/machdefs/loongarch.py +162 -0
  43. smallworld/emulators/ghidra/machdefs/machdef.py +81 -0
  44. smallworld/emulators/ghidra/machdefs/mips.py +163 -0
  45. smallworld/emulators/ghidra/machdefs/mips64.py +186 -0
  46. smallworld/emulators/ghidra/machdefs/ppc.py +98 -0
  47. smallworld/emulators/ghidra/machdefs/riscv.py +208 -0
  48. smallworld/emulators/ghidra/machdefs/xtensa.py +21 -0
  49. smallworld/emulators/ghidra/typing.py +28 -0
  50. smallworld/emulators/hookable.py +18 -4
  51. smallworld/emulators/panda/machdefs/__init__.py +2 -2
  52. smallworld/emulators/panda/machdefs/aarch64.py +186 -11
  53. smallworld/emulators/panda/machdefs/amd64.py +103 -11
  54. smallworld/emulators/panda/machdefs/arm.py +216 -20
  55. smallworld/emulators/panda/machdefs/i386.py +30 -7
  56. smallworld/emulators/panda/machdefs/machdef.py +9 -16
  57. smallworld/emulators/panda/machdefs/mips.py +49 -5
  58. smallworld/emulators/panda/machdefs/mips64.py +57 -5
  59. smallworld/emulators/panda/machdefs/ppc.py +38 -13
  60. smallworld/emulators/panda/panda.py +146 -44
  61. smallworld/emulators/unicorn/__init__.py +2 -0
  62. smallworld/emulators/unicorn/machdefs/aarch64.py +253 -264
  63. smallworld/emulators/unicorn/machdefs/amd64.py +254 -259
  64. smallworld/emulators/unicorn/machdefs/arm.py +200 -212
  65. smallworld/emulators/unicorn/machdefs/i386.py +84 -90
  66. smallworld/emulators/unicorn/machdefs/machdef.py +2 -23
  67. smallworld/emulators/unicorn/machdefs/mips.py +127 -135
  68. smallworld/emulators/unicorn/unicorn.py +52 -13
  69. smallworld/helpers.py +4 -19
  70. smallworld/hinting/hinting.py +22 -192
  71. smallworld/hinting/hints.py +50 -18
  72. smallworld/instructions/bsid.py +8 -8
  73. smallworld/logging.py +4 -2
  74. smallworld/platforms/__init__.py +12 -0
  75. smallworld/platforms/defs/__init__.py +36 -0
  76. smallworld/platforms/defs/aarch64.py +450 -0
  77. smallworld/platforms/defs/amd64.py +463 -0
  78. smallworld/platforms/defs/arm.py +519 -0
  79. smallworld/platforms/defs/i386.py +258 -0
  80. smallworld/platforms/defs/loongarch.py +270 -0
  81. smallworld/platforms/defs/mips.py +321 -0
  82. smallworld/platforms/defs/mips64.py +313 -0
  83. smallworld/platforms/defs/platformdef.py +97 -0
  84. smallworld/platforms/defs/powerpc.py +259 -0
  85. smallworld/platforms/defs/riscv.py +257 -0
  86. smallworld/platforms/defs/xtensa.py +96 -0
  87. smallworld/{platforms.py → platforms/platforms.py} +3 -0
  88. smallworld/state/cpus/__init__.py +2 -0
  89. smallworld/state/cpus/aarch64.py +0 -9
  90. smallworld/state/cpus/amd64.py +6 -28
  91. smallworld/state/cpus/arm.py +0 -11
  92. smallworld/state/cpus/cpu.py +0 -11
  93. smallworld/state/cpus/i386.py +0 -7
  94. smallworld/state/cpus/loongarch.py +299 -0
  95. smallworld/state/cpus/mips.py +4 -47
  96. smallworld/state/cpus/mips64.py +18 -58
  97. smallworld/state/cpus/powerpc.py +2 -9
  98. smallworld/state/cpus/riscv.py +1 -11
  99. smallworld/state/cpus/xtensa.py +0 -5
  100. smallworld/state/memory/code.py +38 -2
  101. smallworld/state/memory/elf/__init__.py +5 -1
  102. smallworld/state/memory/elf/coredump/__init__.py +3 -0
  103. smallworld/state/memory/elf/coredump/coredump.py +46 -0
  104. smallworld/state/memory/elf/coredump/prstatus/__init__.py +27 -0
  105. smallworld/state/memory/elf/coredump/prstatus/aarch64.py +46 -0
  106. smallworld/state/memory/elf/coredump/prstatus/amd64.py +40 -0
  107. smallworld/state/memory/elf/coredump/prstatus/arm.py +53 -0
  108. smallworld/state/memory/elf/coredump/prstatus/i386.py +30 -0
  109. smallworld/state/memory/elf/coredump/prstatus/mips.py +55 -0
  110. smallworld/state/memory/elf/coredump/prstatus/mips64.py +57 -0
  111. smallworld/state/memory/elf/coredump/prstatus/ppc.py +82 -0
  112. smallworld/state/memory/elf/coredump/prstatus/prstatus.py +129 -0
  113. smallworld/state/memory/elf/elf.py +211 -57
  114. smallworld/state/memory/elf/register_state.py +36 -0
  115. smallworld/state/memory/elf/rela/__init__.py +2 -0
  116. smallworld/state/memory/elf/rela/aarch64.py +3 -1
  117. smallworld/state/memory/elf/rela/amd64.py +4 -2
  118. smallworld/state/memory/elf/rela/arm.py +4 -2
  119. smallworld/state/memory/elf/rela/i386.py +4 -2
  120. smallworld/state/memory/elf/rela/loongarch.py +32 -0
  121. smallworld/state/memory/elf/rela/mips.py +39 -18
  122. smallworld/state/memory/elf/rela/ppc.py +31 -14
  123. smallworld/state/memory/elf/structs.py +3 -0
  124. smallworld/state/memory/heap.py +2 -2
  125. smallworld/state/memory/memory.py +18 -0
  126. smallworld/state/memory/pe/__init__.py +3 -0
  127. smallworld/state/memory/pe/pe.py +361 -0
  128. smallworld/state/memory/pe/structs.py +60 -0
  129. smallworld/state/memory/stack/__init__.py +2 -0
  130. smallworld/state/memory/stack/loongarch.py +26 -0
  131. smallworld/state/models/__init__.py +29 -2
  132. smallworld/state/models/aarch64/__init__.py +1 -0
  133. smallworld/state/models/aarch64/systemv/__init__.py +6 -0
  134. smallworld/state/models/aarch64/systemv/c99/__init__.py +12 -0
  135. smallworld/state/models/aarch64/systemv/c99/signal.py +16 -0
  136. smallworld/state/models/aarch64/systemv/c99/stdio.py +265 -0
  137. smallworld/state/models/aarch64/systemv/c99/stdlib.py +169 -0
  138. smallworld/state/models/aarch64/systemv/c99/string.py +139 -0
  139. smallworld/state/models/aarch64/systemv/c99/time.py +61 -0
  140. smallworld/state/models/aarch64/systemv/posix/__init__.py +6 -0
  141. smallworld/state/models/aarch64/systemv/posix/libgen.py +16 -0
  142. smallworld/state/models/aarch64/systemv/posix/signal.py +157 -0
  143. smallworld/state/models/aarch64/systemv/systemv.py +80 -0
  144. smallworld/state/models/amd64/__init__.py +1 -0
  145. smallworld/state/models/amd64/systemv/__init__.py +6 -0
  146. smallworld/state/models/amd64/systemv/c99/__init__.py +12 -0
  147. smallworld/state/models/amd64/systemv/c99/signal.py +16 -0
  148. smallworld/state/models/amd64/systemv/c99/stdio.py +265 -0
  149. smallworld/state/models/amd64/systemv/c99/stdlib.py +169 -0
  150. smallworld/state/models/amd64/systemv/c99/string.py +139 -0
  151. smallworld/state/models/amd64/systemv/c99/time.py +61 -0
  152. smallworld/state/models/amd64/systemv/posix/__init__.py +6 -0
  153. smallworld/state/models/amd64/systemv/posix/libgen.py +16 -0
  154. smallworld/state/models/amd64/systemv/posix/signal.py +157 -0
  155. smallworld/state/models/amd64/systemv/systemv.py +78 -0
  156. smallworld/state/models/armel/__init__.py +1 -0
  157. smallworld/state/models/armel/systemv/__init__.py +6 -0
  158. smallworld/state/models/armel/systemv/c99/__init__.py +12 -0
  159. smallworld/state/models/armel/systemv/c99/signal.py +16 -0
  160. smallworld/state/models/armel/systemv/c99/stdio.py +265 -0
  161. smallworld/state/models/armel/systemv/c99/stdlib.py +169 -0
  162. smallworld/state/models/armel/systemv/c99/string.py +139 -0
  163. smallworld/state/models/armel/systemv/c99/time.py +61 -0
  164. smallworld/state/models/armel/systemv/posix/__init__.py +6 -0
  165. smallworld/state/models/armel/systemv/posix/libgen.py +16 -0
  166. smallworld/state/models/armel/systemv/posix/signal.py +157 -0
  167. smallworld/state/models/armel/systemv/systemv.py +82 -0
  168. smallworld/state/models/armhf/__init__.py +1 -0
  169. smallworld/state/models/armhf/systemv/__init__.py +6 -0
  170. smallworld/state/models/armhf/systemv/c99/__init__.py +12 -0
  171. smallworld/state/models/armhf/systemv/c99/signal.py +16 -0
  172. smallworld/state/models/armhf/systemv/c99/stdio.py +265 -0
  173. smallworld/state/models/armhf/systemv/c99/stdlib.py +169 -0
  174. smallworld/state/models/armhf/systemv/c99/string.py +139 -0
  175. smallworld/state/models/armhf/systemv/c99/time.py +61 -0
  176. smallworld/state/models/armhf/systemv/posix/__init__.py +6 -0
  177. smallworld/state/models/armhf/systemv/posix/libgen.py +16 -0
  178. smallworld/state/models/armhf/systemv/posix/signal.py +157 -0
  179. smallworld/state/models/armhf/systemv/systemv.py +77 -0
  180. smallworld/state/models/c99/__init__.py +12 -0
  181. smallworld/state/models/c99/fmt_print.py +915 -0
  182. smallworld/state/models/c99/fmt_scan.py +864 -0
  183. smallworld/state/models/c99/math.py +362 -0
  184. smallworld/state/models/c99/signal.py +71 -0
  185. smallworld/state/models/c99/stdio.py +1305 -0
  186. smallworld/state/models/c99/stdlib.py +595 -0
  187. smallworld/state/models/c99/string.py +674 -0
  188. smallworld/state/models/c99/time.py +340 -0
  189. smallworld/state/models/c99/utils.py +89 -0
  190. smallworld/state/models/cstd.py +759 -0
  191. smallworld/state/models/errno.py +581 -0
  192. smallworld/state/models/filedesc.py +515 -0
  193. smallworld/state/models/i386/__init__.py +1 -0
  194. smallworld/state/models/i386/systemv/__init__.py +6 -0
  195. smallworld/state/models/i386/systemv/c99/__init__.py +12 -0
  196. smallworld/state/models/i386/systemv/c99/signal.py +16 -0
  197. smallworld/state/models/i386/systemv/c99/stdio.py +265 -0
  198. smallworld/state/models/i386/systemv/c99/stdlib.py +169 -0
  199. smallworld/state/models/i386/systemv/c99/string.py +139 -0
  200. smallworld/state/models/i386/systemv/c99/time.py +61 -0
  201. smallworld/state/models/i386/systemv/posix/__init__.py +6 -0
  202. smallworld/state/models/i386/systemv/posix/libgen.py +16 -0
  203. smallworld/state/models/i386/systemv/posix/signal.py +157 -0
  204. smallworld/state/models/i386/systemv/systemv.py +71 -0
  205. smallworld/state/models/loongarch64/__init__.py +1 -0
  206. smallworld/state/models/loongarch64/systemv/__init__.py +6 -0
  207. smallworld/state/models/loongarch64/systemv/c99/__init__.py +12 -0
  208. smallworld/state/models/loongarch64/systemv/c99/signal.py +16 -0
  209. smallworld/state/models/loongarch64/systemv/c99/stdio.py +265 -0
  210. smallworld/state/models/loongarch64/systemv/c99/stdlib.py +169 -0
  211. smallworld/state/models/loongarch64/systemv/c99/string.py +139 -0
  212. smallworld/state/models/loongarch64/systemv/c99/time.py +61 -0
  213. smallworld/state/models/loongarch64/systemv/posix/__init__.py +6 -0
  214. smallworld/state/models/loongarch64/systemv/posix/libgen.py +16 -0
  215. smallworld/state/models/loongarch64/systemv/posix/signal.py +157 -0
  216. smallworld/state/models/loongarch64/systemv/systemv.py +83 -0
  217. smallworld/state/models/mips/__init__.py +1 -0
  218. smallworld/state/models/mips/systemv/__init__.py +6 -0
  219. smallworld/state/models/mips/systemv/c99/__init__.py +12 -0
  220. smallworld/state/models/mips/systemv/c99/signal.py +16 -0
  221. smallworld/state/models/mips/systemv/c99/stdio.py +265 -0
  222. smallworld/state/models/mips/systemv/c99/stdlib.py +169 -0
  223. smallworld/state/models/mips/systemv/c99/string.py +139 -0
  224. smallworld/state/models/mips/systemv/c99/time.py +61 -0
  225. smallworld/state/models/mips/systemv/posix/__init__.py +6 -0
  226. smallworld/state/models/mips/systemv/posix/libgen.py +16 -0
  227. smallworld/state/models/mips/systemv/posix/signal.py +157 -0
  228. smallworld/state/models/mips/systemv/systemv.py +78 -0
  229. smallworld/state/models/mips64/__init__.py +1 -0
  230. smallworld/state/models/mips64/systemv/__init__.py +6 -0
  231. smallworld/state/models/mips64/systemv/c99/__init__.py +12 -0
  232. smallworld/state/models/mips64/systemv/c99/signal.py +16 -0
  233. smallworld/state/models/mips64/systemv/c99/stdio.py +265 -0
  234. smallworld/state/models/mips64/systemv/c99/stdlib.py +169 -0
  235. smallworld/state/models/mips64/systemv/c99/string.py +139 -0
  236. smallworld/state/models/mips64/systemv/c99/time.py +61 -0
  237. smallworld/state/models/mips64/systemv/posix/__init__.py +6 -0
  238. smallworld/state/models/mips64/systemv/posix/libgen.py +16 -0
  239. smallworld/state/models/mips64/systemv/posix/signal.py +157 -0
  240. smallworld/state/models/mips64/systemv/systemv.py +98 -0
  241. smallworld/state/models/mips64el/__init__.py +1 -0
  242. smallworld/state/models/mips64el/systemv/__init__.py +6 -0
  243. smallworld/state/models/mips64el/systemv/c99/__init__.py +12 -0
  244. smallworld/state/models/mips64el/systemv/c99/signal.py +16 -0
  245. smallworld/state/models/mips64el/systemv/c99/stdio.py +265 -0
  246. smallworld/state/models/mips64el/systemv/c99/stdlib.py +169 -0
  247. smallworld/state/models/mips64el/systemv/c99/string.py +139 -0
  248. smallworld/state/models/mips64el/systemv/c99/time.py +61 -0
  249. smallworld/state/models/mips64el/systemv/posix/__init__.py +6 -0
  250. smallworld/state/models/mips64el/systemv/posix/libgen.py +16 -0
  251. smallworld/state/models/mips64el/systemv/posix/signal.py +157 -0
  252. smallworld/state/models/mips64el/systemv/systemv.py +96 -0
  253. smallworld/state/models/mipsel/__init__.py +1 -0
  254. smallworld/state/models/mipsel/systemv/__init__.py +6 -0
  255. smallworld/state/models/mipsel/systemv/c99/__init__.py +12 -0
  256. smallworld/state/models/mipsel/systemv/c99/signal.py +16 -0
  257. smallworld/state/models/mipsel/systemv/c99/stdio.py +265 -0
  258. smallworld/state/models/mipsel/systemv/c99/stdlib.py +169 -0
  259. smallworld/state/models/mipsel/systemv/c99/string.py +139 -0
  260. smallworld/state/models/mipsel/systemv/c99/time.py +61 -0
  261. smallworld/state/models/mipsel/systemv/posix/__init__.py +6 -0
  262. smallworld/state/models/mipsel/systemv/posix/libgen.py +16 -0
  263. smallworld/state/models/mipsel/systemv/posix/signal.py +157 -0
  264. smallworld/state/models/mipsel/systemv/systemv.py +78 -0
  265. smallworld/state/models/model.py +27 -2
  266. smallworld/state/models/posix/__init__.py +6 -0
  267. smallworld/state/models/posix/libgen.py +123 -0
  268. smallworld/state/models/posix/signal.py +690 -0
  269. smallworld/state/models/powerpc/__init__.py +1 -0
  270. smallworld/state/models/powerpc/systemv/__init__.py +6 -0
  271. smallworld/state/models/powerpc/systemv/c99/__init__.py +12 -0
  272. smallworld/state/models/powerpc/systemv/c99/signal.py +16 -0
  273. smallworld/state/models/powerpc/systemv/c99/stdio.py +265 -0
  274. smallworld/state/models/powerpc/systemv/c99/stdlib.py +169 -0
  275. smallworld/state/models/powerpc/systemv/c99/string.py +139 -0
  276. smallworld/state/models/powerpc/systemv/c99/time.py +61 -0
  277. smallworld/state/models/powerpc/systemv/posix/__init__.py +6 -0
  278. smallworld/state/models/powerpc/systemv/posix/libgen.py +16 -0
  279. smallworld/state/models/powerpc/systemv/posix/signal.py +157 -0
  280. smallworld/state/models/powerpc/systemv/systemv.py +93 -0
  281. smallworld/state/models/riscv64/__init__.py +1 -0
  282. smallworld/state/models/riscv64/systemv/__init__.py +6 -0
  283. smallworld/state/models/riscv64/systemv/c99/__init__.py +12 -0
  284. smallworld/state/models/riscv64/systemv/c99/signal.py +16 -0
  285. smallworld/state/models/riscv64/systemv/c99/stdio.py +265 -0
  286. smallworld/state/models/riscv64/systemv/c99/stdlib.py +169 -0
  287. smallworld/state/models/riscv64/systemv/c99/string.py +139 -0
  288. smallworld/state/models/riscv64/systemv/c99/time.py +61 -0
  289. smallworld/state/models/riscv64/systemv/posix/__init__.py +6 -0
  290. smallworld/state/models/riscv64/systemv/posix/libgen.py +16 -0
  291. smallworld/state/models/riscv64/systemv/posix/signal.py +157 -0
  292. smallworld/state/models/riscv64/systemv/systemv.py +85 -0
  293. smallworld/state/state.py +65 -24
  294. smallworld/state/unstable/elf.py +16 -31
  295. smallworld/utils.py +6 -1
  296. {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/METADATA +74 -42
  297. smallworld_re-2.0.0.dist-info/RECORD +374 -0
  298. {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/WHEEL +1 -1
  299. smallworld/state/models/x86/__init__.py +0 -2
  300. smallworld/state/models/x86/microsoftcdecl.py +0 -35
  301. smallworld/state/models/x86/systemv.py +0 -240
  302. smallworld_re-1.0.3.dist-info/RECORD +0 -166
  303. /smallworld/state/models/{posix.py → _posix.py} +0 -0
  304. {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/entry_points.txt +0 -0
  305. {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  306. {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,96 @@
1
+ from ..platforms import Architecture, Byteorder
2
+ from .platformdef import PlatformDef, RegisterAliasDef, RegisterDef
3
+
4
+ # NOTE: Xtensa is designed to be an extensible language
5
+ # There are options for Xtensa chips to implement almost any
6
+ # ISA feature you can bally well think of,
7
+ # some of which are closed-source and closed-spec.
8
+ #
9
+ # Support for any specific extension depends on the emulator.
10
+
11
+
12
+ class Xtensa(PlatformDef):
13
+ architecture = Architecture.XTENSA
14
+ byteorder = Byteorder.LITTLE
15
+
16
+ address_size = 4
17
+
18
+ conditional_branch_mnemonics = {
19
+ # Compare to zero and branch
20
+ "beqz",
21
+ "bnez",
22
+ "bgez",
23
+ "bltz",
24
+ # Compare to immediate and branch
25
+ "beqi",
26
+ "bnei",
27
+ "bgei",
28
+ "blti",
29
+ # Compare to unsigned immediate and branch
30
+ "bgeui",
31
+ "bltui",
32
+ # Compare to register and branch
33
+ "beq",
34
+ "bne",
35
+ "bge",
36
+ "blt",
37
+ # Compare to unsigned register and branch
38
+ "bgeu",
39
+ "bltu",
40
+ # Bit test versus immediate and branch
41
+ "bbci",
42
+ "bbsi",
43
+ # Bit test versus register and branch
44
+ "bbc",
45
+ "bbs",
46
+ # Test against bitmask and branch
47
+ "bany",
48
+ "bnone",
49
+ "ball",
50
+ "bnall",
51
+ }
52
+
53
+ # Xtensa core has no comparison operations;
54
+ # they're built into the branch instructions.
55
+ compare_mnemonics = set()
56
+
57
+ # NOTE: Capstone does not yet support xtensa
58
+ # It looks like it's either planned, or present in a newer version than we use.
59
+ capstone_arch = -1
60
+ capstone_mode = -1
61
+
62
+ pc_register = "pc"
63
+ sp_register = "sp"
64
+
65
+ # Special registers:
66
+ # - a0 is the default link register
67
+ # - a1 is the stack pointer
68
+ general_purpose_registers = [f"a{i}" for i in range(2, 16)]
69
+
70
+ registers = {
71
+ # *** General Purpose Registers ***
72
+ # a0 is also the default link register, but it doesn't get an alias
73
+ "a0": RegisterDef(name="a0", size=4),
74
+ # a1 is also the stack pointer
75
+ "a1": RegisterDef(name="a1", size=4),
76
+ "sp": RegisterAliasDef(name="sp", parent="a1", size=4, offset=0),
77
+ "a2": RegisterDef(name="a2", size=4),
78
+ "a3": RegisterDef(name="a3", size=4),
79
+ "a4": RegisterDef(name="a4", size=4),
80
+ "a5": RegisterDef(name="a5", size=4),
81
+ "a6": RegisterDef(name="a6", size=4),
82
+ "a7": RegisterDef(name="a7", size=4),
83
+ "a8": RegisterDef(name="a8", size=4),
84
+ "a9": RegisterDef(name="a9", size=4),
85
+ "a10": RegisterDef(name="a10", size=4),
86
+ "a11": RegisterDef(name="a11", size=4),
87
+ "a12": RegisterDef(name="a12", size=4),
88
+ "a13": RegisterDef(name="a13", size=4),
89
+ "a14": RegisterDef(name="a14", size=4),
90
+ "a15": RegisterDef(name="a15", size=4),
91
+ # *** Program Counter ***
92
+ "pc": RegisterDef(name="pc", size=4),
93
+ # *** Shift Amount Register ***
94
+ # This thing is actually 6 bits.
95
+ "sar": RegisterDef(name="sar", size=4),
96
+ }
@@ -36,6 +36,9 @@ class Architecture(enum.Enum):
36
36
  ARM_V7R = "arm-v7r"
37
37
  ARM_V7A = "arm-v7a"
38
38
 
39
+ LOONGARCH32 = "loongarch32"
40
+ LOONGARCH64 = "loongarch64"
41
+
39
42
  RISCV64 = "riscv-64"
40
43
 
41
44
  XTENSA = "xtensa"
@@ -4,6 +4,7 @@ from .arm import ARMv5T, ARMv6M, ARMv6MThumb, ARMv7A, ARMv7M, ARMv7R
4
4
  from .cpu import * # noqa: F401, F403
5
5
  from .cpu import __all__ as __cpu__
6
6
  from .i386 import I386
7
+ from .loongarch import LoongArch64
7
8
  from .mips import MIPSBE, MIPSEL
8
9
  from .mips64 import MIPS64BE, MIPS64EL
9
10
  from .powerpc import PowerPC32, PowerPC64
@@ -20,6 +21,7 @@ __all__ = __cpu__ + [
20
21
  "ARMv7R",
21
22
  "ARMv7A",
22
23
  "I386",
24
+ "LoongArch64",
23
25
  "MIPS64EL",
24
26
  "MIPS64BE",
25
27
  "MIPSEL",
@@ -1,5 +1,3 @@
1
- import typing
2
-
3
1
  from ... import platforms, state
4
2
  from . import cpu
5
3
 
@@ -15,13 +13,6 @@ class AArch64(cpu.CPU):
15
13
  platforms.Architecture.AARCH64, platforms.Byteorder.LITTLE
16
14
  )
17
15
 
18
- def get_general_purpose_registers(self) -> typing.List[str]:
19
- # Special registers:
20
- # x29: frame pointer
21
- # x30: link register
22
- # x31: stack pointer or zero, depending on instruction
23
- return [f"x{i}" for i in range(0, 29)]
24
-
25
16
  def __init__(self):
26
17
  super().__init__()
27
18
  # *** General Purpose Registers ***
@@ -1,5 +1,3 @@
1
- import typing
2
-
3
1
  from ... import platforms
4
2
  from .. import state
5
3
  from ..x86_registers import X86MMRRegister
@@ -16,28 +14,6 @@ class AMD64(cpu.CPU):
16
14
  the old ones, we need new platforms.
17
15
  """
18
16
 
19
- _GENERAL_PURPOSE_REGS = [
20
- "rax",
21
- "rbx",
22
- "rcx",
23
- "rdx",
24
- "rdi",
25
- "rsi",
26
- "rbp",
27
- "rsp",
28
- "r8",
29
- "r9",
30
- "r10",
31
- "r11",
32
- "r12",
33
- "r13",
34
- "r14",
35
- "r15",
36
- ]
37
-
38
- def get_general_purpose_registers(self) -> typing.List[str]:
39
- return self._GENERAL_PURPOSE_REGS
40
-
41
17
  def __init__(self):
42
18
  super().__init__()
43
19
  # *** General Purpose Registers ***
@@ -168,7 +144,7 @@ class AMD64(cpu.CPU):
168
144
 
169
145
  self.rsi = state.Register("rsi", 8)
170
146
  self.add(self.rsi)
171
- self.esi = state.RegisterAlias("rsi", self.rsi, 4, 0)
147
+ self.esi = state.RegisterAlias("esi", self.rsi, 4, 0)
172
148
  self.add(self.esi)
173
149
  self.si = state.RegisterAlias("si", self.rsi, 2, 0)
174
150
  self.add(self.si)
@@ -177,7 +153,7 @@ class AMD64(cpu.CPU):
177
153
 
178
154
  self.rsp = state.Register("rsp", 8)
179
155
  self.add(self.rsp)
180
- self.esp = state.RegisterAlias("rsp", self.rsp, 4, 0)
156
+ self.esp = state.RegisterAlias("esp", self.rsp, 4, 0)
181
157
  self.add(self.esp)
182
158
  self.sp = state.RegisterAlias("sp", self.rsp, 2, 0)
183
159
  self.add(self.sp)
@@ -186,7 +162,7 @@ class AMD64(cpu.CPU):
186
162
 
187
163
  self.rbp = state.Register("rbp", 8)
188
164
  self.add(self.rbp)
189
- self.ebp = state.RegisterAlias("rbp", self.rbp, 4, 0)
165
+ self.ebp = state.RegisterAlias("ebp", self.rbp, 4, 0)
190
166
  self.add(self.ebp)
191
167
  self.bp = state.RegisterAlias("bp", self.rbp, 2, 0)
192
168
  self.add(self.bp)
@@ -196,7 +172,7 @@ class AMD64(cpu.CPU):
196
172
  # *** Instruction Pointer ***
197
173
  self.rip = state.Register("rip", 8)
198
174
  self.add(self.rip)
199
- self.eip = state.RegisterAlias("rip", self.rip, 4, 0)
175
+ self.eip = state.RegisterAlias("eip", self.rip, 4, 0)
200
176
  self.add(self.eip)
201
177
  self.ip = state.RegisterAlias("ip", self.rip, 2, 0)
202
178
  self.add(self.ip)
@@ -225,6 +201,8 @@ class AMD64(cpu.CPU):
225
201
  self.add(self.fs)
226
202
  self.gs = state.Register("gs", 8)
227
203
  self.add(self.gs)
204
+ self.ss = state.Register("ss", 8)
205
+ self.add(self.ss)
228
206
 
229
207
  # *** Control Registers ***
230
208
  self.cr0 = state.Register("cr0", 8)
@@ -1,5 +1,3 @@
1
- import typing
2
-
3
1
  from ... import platforms
4
2
  from .. import state
5
3
  from . import cpu
@@ -16,15 +14,6 @@ class ARM(cpu.CPU):
16
14
  dimensions of difference for the available modes.
17
15
  """
18
16
 
19
- # Special registers:
20
- # r13: stack pointer
21
- # r14: link register
22
- # r15: Program counter
23
- _GENERAL_PURPOSE_REGS = [f"r{i}" for i in range(0, 13)]
24
-
25
- def get_general_purpose_registers(self) -> typing.List[str]:
26
- return self._GENERAL_PURPOSE_REGS
27
-
28
17
  def __init__(self):
29
18
  super().__init__()
30
19
  # *** General-purpose registers ***
@@ -1,5 +1,4 @@
1
1
  import abc
2
- import typing
3
2
 
4
3
  from ... import platforms, utils
5
4
  from .. import state
@@ -54,16 +53,6 @@ class CPU(state.StatefulSet):
54
53
  except ValueError:
55
54
  raise ValueError(f"no model for {platform}")
56
55
 
57
- @abc.abstractmethod
58
- def get_general_purpose_registers(self) -> typing.List[str]:
59
- """Get a list of general purpose register names.
60
-
61
- Returns:
62
- A list of the general purpose register names for this CPU.
63
- """
64
-
65
- pass
66
-
67
56
  def __repr__(self) -> str:
68
57
  return f"{self.__class__.__name__}({self.platform})"
69
58
 
@@ -1,5 +1,3 @@
1
- import typing
2
-
3
1
  from ... import platforms
4
2
  from .. import state
5
3
  from ..x86_registers import X86MMRRegister
@@ -13,11 +11,6 @@ class I386(cpu.CPU):
13
11
  platforms.Architecture.X86_32, platforms.Byteorder.LITTLE
14
12
  )
15
13
 
16
- _GENERAL_PURPOSE_REGS = ["eax", "ebx", "ecx", "edx", "edi", "esi", "ebp", "esp"]
17
-
18
- def get_general_purpose_registers(self) -> typing.List[str]:
19
- return self._GENERAL_PURPOSE_REGS
20
-
21
14
  def __init__(self):
22
15
  super().__init__()
23
16
  # *** General Purpose Registers ***
@@ -0,0 +1,299 @@
1
+ from ... import platforms
2
+ from .. import state
3
+ from . import cpu
4
+
5
+
6
+ class LoongArch(cpu.CPU):
7
+ """Abstract CPU state object for all LoongArch targets"""
8
+
9
+ def __init__(self, wordsize: int) -> None:
10
+ super().__init__()
11
+ # Program counter (not a real register)
12
+ self.pc = state.Register("pc", size=wordsize)
13
+ self.add(self.pc)
14
+ # Zero register
15
+ self.r0 = state.Register("r0", size=wordsize)
16
+ self.add(self.r0)
17
+ self.zero = state.RegisterAlias("zero", self.r0, size=wordsize, offset=0)
18
+ self.add(self.zero)
19
+ # Return address
20
+ self.r1 = state.Register("r1", size=wordsize)
21
+ self.add(self.r1)
22
+ self.ra = state.RegisterAlias("ra", self.r1, size=wordsize, offset=0)
23
+ self.add(self.ra)
24
+ # TLS pointer
25
+ self.r2 = state.Register("r2", size=wordsize)
26
+ self.add(self.r2)
27
+ self.tp = state.RegisterAlias("tp", self.r2, size=wordsize, offset=0)
28
+ self.add(self.tp)
29
+ # Stack pointer
30
+ self.r3 = state.Register("r3", size=wordsize)
31
+ self.add(self.r3)
32
+ self.sp = state.RegisterAlias("sp", self.r3, size=wordsize, offset=0)
33
+ self.add(self.sp)
34
+ # Arguments.
35
+ # a0 and a1 are also the return registers
36
+ self.r4 = state.Register("r4", size=wordsize)
37
+ self.add(self.r4)
38
+ self.a0 = state.RegisterAlias("a0", self.r4, size=wordsize, offset=0)
39
+ self.add(self.a0)
40
+ self.v0 = state.RegisterAlias("v0", self.r4, size=wordsize, offset=0)
41
+ self.add(self.v0)
42
+ self.r5 = state.Register("r5", size=wordsize)
43
+ self.add(self.r5)
44
+ self.a1 = state.RegisterAlias("a1", self.r5, size=wordsize, offset=0)
45
+ self.add(self.a1)
46
+ self.v1 = state.RegisterAlias("v1", self.r5, size=wordsize, offset=0)
47
+ self.add(self.v1)
48
+ self.r6 = state.Register("r6", size=wordsize)
49
+ self.add(self.r6)
50
+ self.a2 = state.RegisterAlias("a2", self.r6, size=wordsize, offset=0)
51
+ self.add(self.a2)
52
+ self.r7 = state.Register("r7", size=wordsize)
53
+ self.add(self.r7)
54
+ self.a3 = state.RegisterAlias("a3", self.r7, size=wordsize, offset=0)
55
+ self.add(self.a3)
56
+ self.r8 = state.Register("r8", size=wordsize)
57
+ self.add(self.r8)
58
+ self.a4 = state.RegisterAlias("a4", self.r8, size=wordsize, offset=0)
59
+ self.add(self.a4)
60
+ self.r9 = state.Register("r9", size=wordsize)
61
+ self.add(self.r9)
62
+ self.a5 = state.RegisterAlias("a5", self.r9, size=wordsize, offset=0)
63
+ self.add(self.a5)
64
+ self.r10 = state.Register("r10", size=wordsize)
65
+ self.add(self.r10)
66
+ self.a6 = state.RegisterAlias("a6", self.r10, size=wordsize, offset=0)
67
+ self.add(self.a6)
68
+ self.r11 = state.Register("r11", size=wordsize)
69
+ self.add(self.r11)
70
+ self.a7 = state.RegisterAlias("a7", self.r11, size=wordsize, offset=0)
71
+ self.add(self.a7)
72
+ # Temporary registers
73
+ self.r12 = state.Register("r12", size=wordsize)
74
+ self.add(self.r12)
75
+ self.t0 = state.RegisterAlias("t0", self.r12, size=wordsize, offset=0)
76
+ self.add(self.t0)
77
+ self.r13 = state.Register("r13", size=wordsize)
78
+ self.add(self.r13)
79
+ self.t1 = state.RegisterAlias("t1", self.r13, size=wordsize, offset=0)
80
+ self.add(self.t1)
81
+ self.r14 = state.Register("r14", size=wordsize)
82
+ self.add(self.r14)
83
+ self.t2 = state.RegisterAlias("t2", self.r14, size=wordsize, offset=0)
84
+ self.add(self.t2)
85
+ self.r15 = state.Register("r15", size=wordsize)
86
+ self.add(self.r15)
87
+ self.t3 = state.RegisterAlias("t3", self.r15, size=wordsize, offset=0)
88
+ self.add(self.t3)
89
+ self.r16 = state.Register("r16", size=wordsize)
90
+ self.add(self.r16)
91
+ self.t4 = state.RegisterAlias("t4", self.r16, size=wordsize, offset=0)
92
+ self.add(self.t4)
93
+ self.r17 = state.Register("r17", size=wordsize)
94
+ self.add(self.r17)
95
+ self.t5 = state.RegisterAlias("t5", self.r17, size=wordsize, offset=0)
96
+ self.add(self.t5)
97
+ self.r18 = state.Register("r18", size=wordsize)
98
+ self.add(self.r18)
99
+ self.t6 = state.RegisterAlias("t6", self.r18, size=wordsize, offset=0)
100
+ self.add(self.t6)
101
+ self.r19 = state.Register("r19", size=wordsize)
102
+ self.add(self.r19)
103
+ self.t7 = state.RegisterAlias("t7", self.r19, size=wordsize, offset=0)
104
+ self.add(self.t7)
105
+ self.r20 = state.Register("r20", size=wordsize)
106
+ self.add(self.r20)
107
+ self.t8 = state.RegisterAlias("t8", self.r20, size=wordsize, offset=0)
108
+ self.add(self.t8)
109
+ # Per-CPU Base Address
110
+ self.r21 = state.Register("r21", size=wordsize)
111
+ self.add(self.r21)
112
+ self.u0 = state.RegisterAlias("u0", self.r21, size=wordsize, offset=0)
113
+ self.add(self.u0)
114
+ # Frame Pointer
115
+ self.r22 = state.Register("r22", size=wordsize)
116
+ self.add(self.r22)
117
+ self.fp = state.RegisterAlias("fp", self.r22, size=wordsize, offset=0)
118
+ self.add(self.fp)
119
+ # Static registers
120
+ self.r23 = state.Register("r23", size=wordsize)
121
+ self.add(self.r23)
122
+ self.s0 = state.RegisterAlias("s0", self.r23, size=wordsize, offset=0)
123
+ self.add(self.s0)
124
+ self.r24 = state.Register("r24", size=wordsize)
125
+ self.add(self.r24)
126
+ self.s1 = state.RegisterAlias("s1", self.r24, size=wordsize, offset=0)
127
+ self.add(self.s1)
128
+ self.r25 = state.Register("r25", size=wordsize)
129
+ self.add(self.r25)
130
+ self.s2 = state.RegisterAlias("s2", self.r25, size=wordsize, offset=0)
131
+ self.add(self.s2)
132
+ self.r26 = state.Register("r26", size=wordsize)
133
+ self.add(self.r26)
134
+ self.s3 = state.RegisterAlias("s3", self.r26, size=wordsize, offset=0)
135
+ self.add(self.s3)
136
+ self.r27 = state.Register("r27", size=wordsize)
137
+ self.add(self.r27)
138
+ self.s4 = state.RegisterAlias("s4", self.r27, size=wordsize, offset=0)
139
+ self.add(self.s4)
140
+ self.r28 = state.Register("r28", size=wordsize)
141
+ self.add(self.r28)
142
+ self.s5 = state.RegisterAlias("s5", self.r28, size=wordsize, offset=0)
143
+ self.add(self.s5)
144
+ self.r29 = state.Register("r29", size=wordsize)
145
+ self.add(self.r29)
146
+ self.s6 = state.RegisterAlias("s6", self.r29, size=wordsize, offset=0)
147
+ self.add(self.s6)
148
+ self.r30 = state.Register("r30", size=wordsize)
149
+ self.add(self.r30)
150
+ self.s7 = state.RegisterAlias("s7", self.r30, size=wordsize, offset=0)
151
+ self.add(self.s7)
152
+ self.r31 = state.Register("r31", size=wordsize)
153
+ self.add(self.r31)
154
+ self.s8 = state.RegisterAlias("s8", self.r31, size=wordsize, offset=0)
155
+ self.add(self.s8)
156
+ # Floating-point arguments.
157
+ # fa0 and fa1 are also return values
158
+ self.f0 = state.Register("f0", size=8)
159
+ self.add(self.f0)
160
+ self.fa0 = state.RegisterAlias("fa0", self.f0, size=8, offset=0)
161
+ self.add(self.fa0)
162
+ self.f1 = state.Register("f1", size=8)
163
+ self.add(self.f1)
164
+ self.fa1 = state.RegisterAlias("fa1", self.f1, size=8, offset=0)
165
+ self.add(self.fa1)
166
+ self.f2 = state.Register("f2", size=8)
167
+ self.add(self.f2)
168
+ self.fa2 = state.RegisterAlias("fa2", self.f2, size=8, offset=0)
169
+ self.add(self.fa2)
170
+ self.f3 = state.Register("f3", size=8)
171
+ self.add(self.f3)
172
+ self.fa3 = state.RegisterAlias("fa3", self.f3, size=8, offset=0)
173
+ self.add(self.fa3)
174
+ self.f4 = state.Register("f4", size=8)
175
+ self.add(self.f4)
176
+ self.fa4 = state.RegisterAlias("fa4", self.f4, size=8, offset=0)
177
+ self.add(self.fa4)
178
+ self.f5 = state.Register("f5", size=8)
179
+ self.add(self.f5)
180
+ self.fa5 = state.RegisterAlias("fa5", self.f5, size=8, offset=0)
181
+ self.add(self.fa5)
182
+ self.f6 = state.Register("f6", size=8)
183
+ self.add(self.f6)
184
+ self.fa6 = state.RegisterAlias("fa6", self.f6, size=8, offset=0)
185
+ self.add(self.fa6)
186
+ self.f7 = state.Register("f7", size=8)
187
+ self.add(self.f7)
188
+ self.fa7 = state.RegisterAlias("fa7", self.f7, size=8, offset=0)
189
+ self.add(self.fa7)
190
+ # Floating-point temporary registers
191
+ self.f8 = state.Register("f8", size=8)
192
+ self.add(self.f8)
193
+ self.ft0 = state.RegisterAlias("ft0", self.f8, size=8, offset=0)
194
+ self.add(self.ft0)
195
+ self.f9 = state.Register("f9", size=8)
196
+ self.add(self.f9)
197
+ self.ft1 = state.RegisterAlias("ft1", self.f9, size=8, offset=0)
198
+ self.add(self.ft1)
199
+ self.f10 = state.Register("f10", size=8)
200
+ self.add(self.f10)
201
+ self.ft2 = state.RegisterAlias("ft2", self.f10, size=8, offset=0)
202
+ self.add(self.ft2)
203
+ self.f11 = state.Register("f11", size=8)
204
+ self.add(self.f11)
205
+ self.ft3 = state.RegisterAlias("ft3", self.f11, size=8, offset=0)
206
+ self.add(self.ft3)
207
+ self.f12 = state.Register("f12", size=8)
208
+ self.add(self.f12)
209
+ self.ft4 = state.RegisterAlias("ft4", self.f12, size=8, offset=0)
210
+ self.add(self.ft4)
211
+ self.f13 = state.Register("f13", size=8)
212
+ self.add(self.f13)
213
+ self.ft5 = state.RegisterAlias("ft5", self.f13, size=8, offset=0)
214
+ self.add(self.ft5)
215
+ self.f14 = state.Register("f14", size=8)
216
+ self.add(self.f14)
217
+ self.ft6 = state.RegisterAlias("ft6", self.f14, size=8, offset=0)
218
+ self.add(self.ft6)
219
+ self.f15 = state.Register("f15", size=8)
220
+ self.add(self.f15)
221
+ self.ft7 = state.RegisterAlias("ft7", self.f15, size=8, offset=0)
222
+ self.add(self.ft7)
223
+ self.f16 = state.Register("f16", size=8)
224
+ self.add(self.f16)
225
+ self.ft8 = state.RegisterAlias("ft8", self.f16, size=8, offset=0)
226
+ self.add(self.ft8)
227
+ self.f17 = state.Register("f17", size=8)
228
+ self.add(self.f17)
229
+ self.ft9 = state.RegisterAlias("ft9", self.f17, size=8, offset=0)
230
+ self.add(self.ft9)
231
+ self.f18 = state.Register("f18", size=8)
232
+ self.add(self.f18)
233
+ self.ft10 = state.RegisterAlias("ft10", self.f18, size=8, offset=0)
234
+ self.add(self.ft10)
235
+ self.f19 = state.Register("f19", size=8)
236
+ self.add(self.f19)
237
+ self.ft11 = state.RegisterAlias("ft11", self.f19, size=8, offset=0)
238
+ self.add(self.ft11)
239
+ self.f20 = state.Register("f20", size=8)
240
+ self.add(self.f20)
241
+ self.ft12 = state.RegisterAlias("ft12", self.f20, size=8, offset=0)
242
+ self.add(self.ft12)
243
+ self.f21 = state.Register("f21", size=8)
244
+ self.add(self.f21)
245
+ self.ft13 = state.RegisterAlias("ft13", self.f21, size=8, offset=0)
246
+ self.add(self.ft13)
247
+ self.f22 = state.Register("f22", size=8)
248
+ self.add(self.f22)
249
+ self.ft14 = state.RegisterAlias("ft14", self.f22, size=8, offset=0)
250
+ self.add(self.ft14)
251
+ self.f23 = state.Register("f23", size=8)
252
+ self.add(self.f23)
253
+ self.ft15 = state.RegisterAlias("ft15", self.f23, size=8, offset=0)
254
+ self.add(self.ft15)
255
+ # Floating-point static registers
256
+ self.f24 = state.Register("f24", size=8)
257
+ self.add(self.f24)
258
+ self.fs0 = state.RegisterAlias("fs0", self.f24, size=8, offset=0)
259
+ self.add(self.fs0)
260
+ self.f25 = state.Register("f25", size=8)
261
+ self.add(self.f25)
262
+ self.fs1 = state.RegisterAlias("fs1", self.f25, size=8, offset=0)
263
+ self.add(self.fs1)
264
+ self.f26 = state.Register("f26", size=8)
265
+ self.add(self.f26)
266
+ self.fs2 = state.RegisterAlias("fs2", self.f26, size=8, offset=0)
267
+ self.add(self.fs2)
268
+ self.f27 = state.Register("f27", size=8)
269
+ self.add(self.f27)
270
+ self.fs3 = state.RegisterAlias("fs3", self.f27, size=8, offset=0)
271
+ self.add(self.fs3)
272
+ self.f28 = state.Register("f28", size=8)
273
+ self.add(self.f28)
274
+ self.fs4 = state.RegisterAlias("fs4", self.f28, size=8, offset=0)
275
+ self.add(self.fs4)
276
+ self.f29 = state.Register("f29", size=8)
277
+ self.add(self.f29)
278
+ self.fs5 = state.RegisterAlias("fs5", self.f29, size=8, offset=0)
279
+ self.add(self.fs5)
280
+ self.f30 = state.Register("f30", size=8)
281
+ self.add(self.f30)
282
+ self.fs6 = state.RegisterAlias("fs6", self.f30, size=8, offset=0)
283
+ self.add(self.fs6)
284
+ self.f31 = state.Register("f31", size=8)
285
+ self.add(self.f31)
286
+ self.fs7 = state.RegisterAlias("fs7", self.f31, size=8, offset=0)
287
+ self.add(self.fs7)
288
+
289
+
290
+ class LoongArch64(LoongArch):
291
+ platform = platforms.Platform(
292
+ platforms.Architecture.LOONGARCH64, platforms.Byteorder.LITTLE
293
+ )
294
+
295
+ def __init__(self):
296
+ super().__init__(8)
297
+
298
+
299
+ __all__ = ["LoongArch64"]
@@ -1,5 +1,3 @@
1
- import typing
2
-
3
1
  from ... import platforms
4
2
  from .. import state
5
3
  from . import cpu
@@ -12,43 +10,6 @@ class MIPS(cpu.CPU):
12
10
  unicorn.mips_const.
13
11
  """
14
12
 
15
- # Excluded registers:
16
- # - zero: Hard-wired to zero
17
- # - at: Reserved for assembler
18
- # - kX: Reserved for kernel; used as general in some ABIs
19
- # - fX: Floating-point registers
20
- # - acX: Accumulator registers
21
- _GENERAL_PURPOSE_REGS = [
22
- "v0",
23
- "v1",
24
- "a0",
25
- "a1",
26
- "a2",
27
- "a3",
28
- "t0",
29
- "t1",
30
- "t2",
31
- "t3",
32
- "t4",
33
- "t5",
34
- "t6",
35
- "t7",
36
- "t8",
37
- "t9",
38
- "s0",
39
- "s1",
40
- "s2",
41
- "s3",
42
- "s4",
43
- "s5",
44
- "s6",
45
- "s7",
46
- "s8",
47
- ]
48
-
49
- def get_general_purpose_registers(self) -> typing.List[str]:
50
- return self._GENERAL_PURPOSE_REGS
51
-
52
13
  def __init__(self):
53
14
  super().__init__()
54
15
  # NOTE: MIPS registers have both a name and a number.
@@ -304,10 +265,10 @@ class MIPSEL(MIPS):
304
265
  # from 32-bit multiplication, amongst others.
305
266
  self.ac0 = state.Register("ac0", size=8)
306
267
  self.add(self.ac0)
307
- self.lo = state.RegisterAlias("lo0", self.ac0, size=4, offset=0)
308
- self.add(self.lo)
309
- self.hi = state.RegisterAlias("hi0", self.ac0, size=4, offset=4)
310
- self.add(self.hi)
268
+ self.lo0 = state.RegisterAlias("lo0", self.ac0, size=4, offset=0)
269
+ self.add(self.lo0)
270
+ self.hi0 = state.RegisterAlias("hi0", self.ac0, size=4, offset=4)
271
+ self.add(self.hi0)
311
272
  self.ac1 = state.Register("ac1", size=8)
312
273
  self.add(self.ac1)
313
274
  self.lo1 = state.RegisterAlias("lo1", self.ac1, size=4, offset=0)
@@ -346,8 +307,6 @@ class MIPSBE(MIPS):
346
307
  # from 32-bit multiplication, amongst others.
347
308
  self.ac0 = state.Register("ac0", size=8)
348
309
  self.add(self.ac0)
349
- # NOTE: Be careful: there is also a 'hi' and 'lo' register;
350
- # they do different things.
351
310
  self.hi0 = state.RegisterAlias("hi0", self.ac0, size=4, offset=0)
352
311
  self.add(self.hi0)
353
312
  self.lo0 = state.RegisterAlias("lo0", self.ac0, size=4, offset=4)
@@ -370,5 +329,3 @@ class MIPSBE(MIPS):
370
329
  self.add(self.hi3)
371
330
  self.lo3 = state.RegisterAlias("lo3", self.ac3, size=4, offset=4)
372
331
  self.add(self.lo3)
373
- # TODO: MIPS has a boatload of extensions with their own registers.
374
- # There isn't a clean join between Sleigh, Unicorn, and MIPS docs.