smallworld-re 1.0.2__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 +44 -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 +225 -61
  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.2.dist-info → smallworld_re-2.0.0.dist-info}/METADATA +76 -43
  297. smallworld_re-2.0.0.dist-info/RECORD +374 -0
  298. {smallworld_re-1.0.2.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.2.dist-info/RECORD +0 -166
  303. /smallworld/state/models/{posix.py → _posix.py} +0 -0
  304. {smallworld_re-1.0.2.dist-info → smallworld_re-2.0.0.dist-info}/entry_points.txt +0 -0
  305. {smallworld_re-1.0.2.dist-info → smallworld_re-2.0.0.dist-info/licenses}/LICENSE.txt +0 -0
  306. {smallworld_re-1.0.2.dist-info → smallworld_re-2.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,289 @@
1
+ from ....platforms import Architecture, Byteorder
2
+ from .machdef import GhidraMachineDef
3
+
4
+
5
+ class AArch64MachineDef(GhidraMachineDef):
6
+ arch = Architecture.AARCH64
7
+ byteorder = Byteorder.LITTLE
8
+ language_id = "AARCH64:LE:64:v8A"
9
+
10
+ _registers = {
11
+ # *** General Purpose Registers ***
12
+ "x0": "x0",
13
+ "w0": "w0",
14
+ "x1": "x1",
15
+ "w1": "w1",
16
+ "x2": "x2",
17
+ "w2": "w2",
18
+ "x3": "x3",
19
+ "w3": "w3",
20
+ "x4": "x4",
21
+ "w4": "w4",
22
+ "x5": "x5",
23
+ "w5": "w5",
24
+ "x6": "x6",
25
+ "w6": "w6",
26
+ "x7": "x7",
27
+ "w7": "w7",
28
+ "x8": "x8",
29
+ "w8": "w8",
30
+ "x9": "x9",
31
+ "w9": "w9",
32
+ "x10": "x10",
33
+ "w10": "w10",
34
+ "x11": "x11",
35
+ "w11": "w11",
36
+ "x12": "x12",
37
+ "w12": "w12",
38
+ "x13": "x13",
39
+ "w13": "w13",
40
+ "x14": "x14",
41
+ "w14": "w14",
42
+ "x15": "x15",
43
+ "w15": "w15",
44
+ "x16": "x16",
45
+ "w16": "w16",
46
+ "x17": "x17",
47
+ "w17": "w17",
48
+ "x18": "x18",
49
+ "w18": "w18",
50
+ "x19": "x19",
51
+ "w19": "w19",
52
+ "x20": "x20",
53
+ "w20": "w20",
54
+ "x21": "x21",
55
+ "w21": "w21",
56
+ "x22": "x22",
57
+ "w22": "w22",
58
+ "x23": "x23",
59
+ "w23": "w23",
60
+ "x24": "x24",
61
+ "w24": "w24",
62
+ "x25": "x25",
63
+ "w25": "w25",
64
+ "x26": "x26",
65
+ "w26": "w26",
66
+ "x27": "x27",
67
+ "w27": "w27",
68
+ "x28": "x28",
69
+ "w28": "w28",
70
+ "x29": "x29",
71
+ "w29": "w29",
72
+ "x30": "x30",
73
+ "w30": "w30",
74
+ "pc": "pc",
75
+ "sp": "sp",
76
+ "wsp": "wsp",
77
+ "fp": "x29",
78
+ "lr": "x30",
79
+ "xzr": "xzr",
80
+ "wzr": "wzr",
81
+ # *** System Control Registers ***
82
+ # NOTE: "_elX" indicates that only exception level X or greater can access this register.
83
+ # NOTE: This list is far from complete; it only covers what Unicorn supports
84
+ # NOTE: angr's aarch64 model is aggressively userspace-only. None of these are supported
85
+ # Condition Code Register
86
+ "fpcr": None,
87
+ # Floating Point Status Register
88
+ "fpsr": None,
89
+ # Banked stack pointers for exception handlers
90
+ "sp_el0": None,
91
+ "sp_el1": None,
92
+ "sp_el2": None,
93
+ "sp_el3": None,
94
+ # Banked link registers for exception handlers
95
+ # NOTE: Unicorn thinks there's an elr_el0; according to docs, it doesn't exist
96
+ "elr_el1": None,
97
+ "elr_el2": None,
98
+ "elr_el3": None,
99
+ # Banked exception syndrome registers for exception handlers
100
+ # NOTE: Unicorn thinks there's a far_el0; according to docs, it doesn't exist
101
+ "far_el1": None,
102
+ "far_el2": None,
103
+ "far_el3": None,
104
+ # Banked vector base address registers for exception handlers
105
+ # NOTE: vbar_el0 and vbar_el1 are aliases for each other.
106
+ # Since vbar_el0 doesn't exist in angr, vbar_el1 has to be the "real" copy.
107
+ "vbar_el1": None,
108
+ "vbar_el0": None,
109
+ "vbar_el2": None,
110
+ "vbar_el3": None,
111
+ # Coprocessor access control register
112
+ "cpacr_el1": None,
113
+ # Memory Attribute Indirection Register
114
+ "mair_el1": None,
115
+ # Physical Address Register
116
+ "par_el1": None,
117
+ # Translation Table Zero Base Register
118
+ "ttbr0_el1": None,
119
+ # Translation Table One Base Register
120
+ "ttbr1_el1": None,
121
+ # Thread ID Register
122
+ # NOTE: According to docs, there should be an el2 and el3 copy, too.
123
+ "tpidr_el0": None,
124
+ "tpidr_el1": None,
125
+ # Userspace-visible Thread ID register
126
+ "tpidrro_el0": None,
127
+ # *** Floating Point Registers ***
128
+ # Scalar Floating Point Registers
129
+ "q0": "q0",
130
+ "d0": "d0",
131
+ "s0": "s0",
132
+ "h0": "h0",
133
+ "b0": "b0",
134
+ "q1": "q1",
135
+ "d1": "d1",
136
+ "s1": "s1",
137
+ "h1": "h1",
138
+ "b1": "b1",
139
+ "q2": "q2",
140
+ "d2": "d2",
141
+ "s2": "s2",
142
+ "h2": "h2",
143
+ "b2": "b2",
144
+ "q3": "q3",
145
+ "d3": "d3",
146
+ "s3": "s3",
147
+ "h3": "h3",
148
+ "b3": "b3",
149
+ "q4": "q4",
150
+ "d4": "d4",
151
+ "s4": "s4",
152
+ "h4": "h4",
153
+ "b4": "b4",
154
+ "q5": "q5",
155
+ "d5": "d5",
156
+ "s5": "s5",
157
+ "h5": "h5",
158
+ "b5": "b5",
159
+ "q6": "q6",
160
+ "d6": "d6",
161
+ "s6": "s6",
162
+ "h6": "h6",
163
+ "b6": "b6",
164
+ "q7": "q7",
165
+ "d7": "d7",
166
+ "s7": "s7",
167
+ "h7": "h7",
168
+ "b7": "b7",
169
+ "q8": "q8",
170
+ "d8": "d8",
171
+ "s8": "s8",
172
+ "h8": "h8",
173
+ "b8": "b8",
174
+ "q9": "q9",
175
+ "d9": "d9",
176
+ "s9": "s9",
177
+ "h9": "h9",
178
+ "b9": "b9",
179
+ "q10": "q10",
180
+ "d10": "d10",
181
+ "s10": "s10",
182
+ "h10": "h10",
183
+ "b10": "b10",
184
+ "q11": "q11",
185
+ "d11": "d11",
186
+ "s11": "s11",
187
+ "h11": "h11",
188
+ "b11": "b11",
189
+ "q12": "q12",
190
+ "d12": "d12",
191
+ "s12": "s12",
192
+ "h12": "h12",
193
+ "b12": "b12",
194
+ "q13": "q13",
195
+ "d13": "d13",
196
+ "s13": "s13",
197
+ "h13": "h13",
198
+ "b13": "b13",
199
+ "q14": "q14",
200
+ "d14": "d14",
201
+ "s14": "s14",
202
+ "h14": "h14",
203
+ "b14": "b14",
204
+ "q15": "q15",
205
+ "d15": "d15",
206
+ "s15": "s15",
207
+ "h15": "h15",
208
+ "b15": "b15",
209
+ "q16": "q16",
210
+ "d16": "d16",
211
+ "s16": "s16",
212
+ "h16": "h16",
213
+ "b16": "b16",
214
+ "q17": "q17",
215
+ "d17": "d17",
216
+ "s17": "s17",
217
+ "h17": "h17",
218
+ "b17": "b17",
219
+ "q18": "q18",
220
+ "d18": "d18",
221
+ "s18": "s18",
222
+ "h18": "h18",
223
+ "b18": "b18",
224
+ "q19": "q19",
225
+ "d19": "d19",
226
+ "s19": "s19",
227
+ "h19": "h19",
228
+ "b19": "b19",
229
+ "q20": "q20",
230
+ "d20": "d20",
231
+ "s20": "s20",
232
+ "h20": "h20",
233
+ "b20": "b20",
234
+ "q21": "q21",
235
+ "d21": "d21",
236
+ "s21": "s21",
237
+ "h21": "h21",
238
+ "b21": "b21",
239
+ "q22": "q22",
240
+ "d22": "d22",
241
+ "s22": "s22",
242
+ "h22": "h22",
243
+ "b22": "b22",
244
+ "q23": "q23",
245
+ "d23": "d23",
246
+ "s23": "s23",
247
+ "h23": "h23",
248
+ "b23": "b23",
249
+ "q24": "q24",
250
+ "d24": "d24",
251
+ "s24": "s24",
252
+ "h24": "h24",
253
+ "b24": "b24",
254
+ "q25": "q25",
255
+ "d25": "d25",
256
+ "s25": "s25",
257
+ "h25": "h25",
258
+ "b25": "b25",
259
+ "q26": "q26",
260
+ "d26": "d26",
261
+ "s26": "s26",
262
+ "h26": "h26",
263
+ "b26": "b26",
264
+ "q27": "q27",
265
+ "d27": "d27",
266
+ "s27": "s27",
267
+ "h27": "h27",
268
+ "b27": "b27",
269
+ "q28": "q28",
270
+ "d28": "d28",
271
+ "s28": "s28",
272
+ "h28": "h28",
273
+ "b28": "b28",
274
+ "q29": "q29",
275
+ "d29": "d29",
276
+ "s29": "s29",
277
+ "h29": "h29",
278
+ "b29": "b29",
279
+ "q30": "q30",
280
+ "d30": "d30",
281
+ "s30": "s30",
282
+ "h30": "h30",
283
+ "b30": "b30",
284
+ "q31": "q31",
285
+ "d31": "d31",
286
+ "s31": "s31",
287
+ "h31": "h31",
288
+ "b31": "b31",
289
+ }
@@ -0,0 +1,185 @@
1
+ import typing
2
+
3
+ from .... import platforms
4
+ from .machdef import GhidraMachineDef
5
+
6
+
7
+ class AMD64MachineDef(GhidraMachineDef):
8
+ arch: platforms.Architecture = platforms.Architecture.X86_64
9
+ byteorder: platforms.Byteorder = platforms.Byteorder.LITTLE
10
+ language_id: str = "x86:LE:64:default"
11
+
12
+ _registers: typing.Dict[str, typing.Optional[str]] = {
13
+ # *** General Purpose Registers ***
14
+ "rax": "rax",
15
+ "eax": "eax",
16
+ "ax": "ax",
17
+ "al": "al",
18
+ "ah": "ah",
19
+ "rbx": "rbx",
20
+ "ebx": "ebx",
21
+ "bx": "bx",
22
+ "bl": "bl",
23
+ "bh": "bh",
24
+ "rcx": "rcx",
25
+ "ecx": "ecx",
26
+ "cx": "cx",
27
+ "cl": "cl",
28
+ "ch": "ch",
29
+ "rdx": "rdx",
30
+ "edx": "edx",
31
+ "dx": "dx",
32
+ "dl": "dl",
33
+ "dh": "dh",
34
+ "r8": "r8",
35
+ "r8d": "r8d",
36
+ "r8w": "r8w",
37
+ "r8b": "r8b",
38
+ "r9": "r9",
39
+ "r9d": "r9d",
40
+ "r9w": "r9w",
41
+ "r9b": "r9b",
42
+ "r10": "r10",
43
+ "r10d": "r10d",
44
+ "r10w": "r10w",
45
+ "r10b": "r10b",
46
+ "r11": "r11",
47
+ "r11d": "r11d",
48
+ "r11w": "r11w",
49
+ "r11b": "r11b",
50
+ "r12": "r12",
51
+ "r12d": "r12d",
52
+ "r12w": "r12w",
53
+ "r12b": "r12b",
54
+ "r13": "r13",
55
+ "r13d": "r13d",
56
+ "r13w": "r13w",
57
+ "r13b": "r13b",
58
+ "r14": "r14",
59
+ "r14d": "r14d",
60
+ "r14w": "r14w",
61
+ "r14b": "r14b",
62
+ "r15": "r15",
63
+ "r15d": "r15d",
64
+ "r15w": "r15w",
65
+ "r15b": "r15b",
66
+ "rsi": "rsi",
67
+ "esi": "esi",
68
+ "si": "si",
69
+ "sil": "sil",
70
+ "rdi": "rdi",
71
+ "edi": "edi",
72
+ "di": "di",
73
+ "dil": "dil",
74
+ "rbp": "rbp",
75
+ "ebp": "ebp",
76
+ "bp": "bp",
77
+ "bpl": "bpl",
78
+ "rsp": "rsp",
79
+ "esp": "esp",
80
+ "sp": "sp",
81
+ "spl": "spl",
82
+ # *** Instruction Pointer ***
83
+ "rip": "rip",
84
+ "eip": "eip",
85
+ "ip": "ip",
86
+ # *** Segment Registers ***
87
+ "cs": "cs",
88
+ "ds": "ds",
89
+ "es": "es",
90
+ "fs": "fs",
91
+ "gs": "gs",
92
+ "ss": "ss",
93
+ # *** Flags Register ***
94
+ "rflags": "rflags",
95
+ "eflags": "eflags",
96
+ "flags": "flags",
97
+ # *** Control Registers ***
98
+ # NOTE: Ghidra happily supports up to cr15
99
+ "cr0": "cr0",
100
+ "cr1": "cr1",
101
+ "cr2": "cr2",
102
+ "cr3": "cr3",
103
+ "cr4": "cr4",
104
+ "cr8": "cr8",
105
+ # *** Debug Registers ***
106
+ "dr0": "dr0",
107
+ "dr1": "dr1",
108
+ "dr2": "dr2",
109
+ "dr3": "dr3",
110
+ "dr6": "dr6",
111
+ "dr7": "dr7",
112
+ "dr8": "dr8",
113
+ "dr9": "dr9",
114
+ "dr10": "dr10",
115
+ "dr11": "dr11",
116
+ "dr12": "dr12",
117
+ "dr13": "dr13",
118
+ "dr14": "dr14",
119
+ "dr15": "dr15",
120
+ # *** Descriptor Table Registers ***
121
+ "gdtr": "gdtr",
122
+ "idtr": "idtr",
123
+ "ldtr": "ldtr",
124
+ # *** Task Register ***
125
+ "tr": "tr",
126
+ # *** x87 Registers ***
127
+ # TODO: Ghidra appears to support x87, but I have no idea how it works
128
+ "fpr0": None,
129
+ "fpr1": None,
130
+ "fpr2": None,
131
+ "fpr3": None,
132
+ "fpr4": None,
133
+ "fpr5": None,
134
+ "fpr6": None,
135
+ "fpr7": None,
136
+ "fctrl": None,
137
+ "fstat": None,
138
+ "ftag": None,
139
+ "fip": None,
140
+ "fdp": None,
141
+ "fop": None,
142
+ # *** MMX Registers ***
143
+ # TODO: Ghidra appears to support mmx, but I have no idea how it works.
144
+ "mm0": None,
145
+ "mm1": None,
146
+ "mm2": None,
147
+ "mm3": None,
148
+ "mm4": None,
149
+ "mm5": None,
150
+ "mm6": None,
151
+ "mm7": None,
152
+ # SSE/AVX registers
153
+ "ymm0": "ymm0",
154
+ "xmm0": "xmm0",
155
+ "ymm1": "ymm1",
156
+ "xmm1": "xmm1",
157
+ "ymm2": "ymm2",
158
+ "xmm2": "xmm2",
159
+ "ymm3": "ymm3",
160
+ "xmm3": "xmm3",
161
+ "ymm4": "ymm4",
162
+ "xmm4": "xmm4",
163
+ "ymm5": "ymm5",
164
+ "xmm5": "xmm5",
165
+ "ymm6": "ymm6",
166
+ "xmm6": "xmm6",
167
+ "ymm7": "ymm7",
168
+ "xmm7": "xmm7",
169
+ "ymm8": "ymm8",
170
+ "xmm8": "xmm8",
171
+ "ymm9": "ymm9",
172
+ "xmm9": "xmm9",
173
+ "ymm10": "ymm10",
174
+ "xmm10": "xmm10",
175
+ "ymm11": "ymm11",
176
+ "xmm11": "xmm11",
177
+ "ymm12": "ymm12",
178
+ "xmm12": "xmm12",
179
+ "ymm13": "ymm13",
180
+ "xmm13": "xmm13",
181
+ "ymm14": "ymm14",
182
+ "xmm14": "xmm14",
183
+ "ymm15": "ymm15",
184
+ "xmm15": "xmm15",
185
+ }