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.
- smallworld/analyses/__init__.py +8 -0
- smallworld/analyses/analysis.py +8 -67
- smallworld/analyses/code_coverage.py +1 -2
- smallworld/analyses/colorizer.py +301 -534
- smallworld/analyses/colorizer_def_use.py +217 -0
- smallworld/analyses/colorizer_summary.py +173 -83
- smallworld/analyses/field_detection/field_analysis.py +7 -8
- smallworld/analyses/field_detection/hints.py +1 -1
- smallworld/analyses/field_detection/malloc.py +2 -2
- smallworld/analyses/trace_execution.py +160 -0
- smallworld/analyses/trace_execution_types.py +42 -0
- smallworld/analyses/unstable/angr/divergence.py +1 -2
- smallworld/analyses/unstable/angr/model.py +5 -6
- smallworld/analyses/unstable/angr_nwbt.py +3 -4
- smallworld/analyses/unstable/code_coverage.py +2 -3
- smallworld/analyses/unstable/code_reachable.py +2 -3
- smallworld/analyses/unstable/control_flow_tracer.py +2 -3
- smallworld/analyses/unstable/pointer_finder.py +2 -3
- smallworld/analyses/unstable/utils/tui.py +71 -0
- smallworld/emulators/__init__.py +3 -1
- smallworld/emulators/angr/angr.py +30 -9
- smallworld/emulators/angr/machdefs/__init__.py +2 -0
- smallworld/emulators/angr/machdefs/aarch64.py +1 -1
- smallworld/emulators/angr/machdefs/amd64.py +0 -4
- smallworld/emulators/angr/machdefs/arm.py +0 -2
- smallworld/emulators/angr/machdefs/i386.py +0 -2
- smallworld/emulators/angr/machdefs/loongarch.py +340 -0
- smallworld/emulators/angr/machdefs/machdef.py +1 -8
- smallworld/emulators/angr/machdefs/mips.py +0 -2
- smallworld/emulators/angr/machdefs/mips64.py +0 -2
- smallworld/emulators/angr/machdefs/ppc.py +1 -2
- smallworld/emulators/angr/machdefs/riscv.py +8 -10
- smallworld/emulators/angr/machdefs/xtensa.py +7 -4
- smallworld/emulators/emulator.py +22 -0
- smallworld/emulators/ghidra/__init__.py +37 -0
- smallworld/emulators/ghidra/ghidra.py +513 -0
- smallworld/emulators/ghidra/machdefs/__init__.py +31 -0
- smallworld/emulators/ghidra/machdefs/aarch64.py +289 -0
- smallworld/emulators/ghidra/machdefs/amd64.py +185 -0
- smallworld/emulators/ghidra/machdefs/arm.py +370 -0
- smallworld/emulators/ghidra/machdefs/i386.py +109 -0
- smallworld/emulators/ghidra/machdefs/loongarch.py +162 -0
- smallworld/emulators/ghidra/machdefs/machdef.py +81 -0
- smallworld/emulators/ghidra/machdefs/mips.py +163 -0
- smallworld/emulators/ghidra/machdefs/mips64.py +186 -0
- smallworld/emulators/ghidra/machdefs/ppc.py +98 -0
- smallworld/emulators/ghidra/machdefs/riscv.py +208 -0
- smallworld/emulators/ghidra/machdefs/xtensa.py +21 -0
- smallworld/emulators/ghidra/typing.py +28 -0
- smallworld/emulators/hookable.py +18 -4
- smallworld/emulators/panda/machdefs/__init__.py +2 -2
- smallworld/emulators/panda/machdefs/aarch64.py +186 -11
- smallworld/emulators/panda/machdefs/amd64.py +103 -11
- smallworld/emulators/panda/machdefs/arm.py +216 -20
- smallworld/emulators/panda/machdefs/i386.py +30 -7
- smallworld/emulators/panda/machdefs/machdef.py +9 -16
- smallworld/emulators/panda/machdefs/mips.py +49 -5
- smallworld/emulators/panda/machdefs/mips64.py +57 -5
- smallworld/emulators/panda/machdefs/ppc.py +38 -13
- smallworld/emulators/panda/panda.py +146 -44
- smallworld/emulators/unicorn/__init__.py +2 -0
- smallworld/emulators/unicorn/machdefs/aarch64.py +253 -264
- smallworld/emulators/unicorn/machdefs/amd64.py +254 -259
- smallworld/emulators/unicorn/machdefs/arm.py +200 -212
- smallworld/emulators/unicorn/machdefs/i386.py +84 -90
- smallworld/emulators/unicorn/machdefs/machdef.py +2 -23
- smallworld/emulators/unicorn/machdefs/mips.py +127 -135
- smallworld/emulators/unicorn/unicorn.py +52 -13
- smallworld/helpers.py +4 -19
- smallworld/hinting/hinting.py +22 -192
- smallworld/hinting/hints.py +50 -18
- smallworld/instructions/bsid.py +8 -8
- smallworld/logging.py +4 -2
- smallworld/platforms/__init__.py +12 -0
- smallworld/platforms/defs/__init__.py +36 -0
- smallworld/platforms/defs/aarch64.py +450 -0
- smallworld/platforms/defs/amd64.py +463 -0
- smallworld/platforms/defs/arm.py +519 -0
- smallworld/platforms/defs/i386.py +258 -0
- smallworld/platforms/defs/loongarch.py +270 -0
- smallworld/platforms/defs/mips.py +321 -0
- smallworld/platforms/defs/mips64.py +313 -0
- smallworld/platforms/defs/platformdef.py +97 -0
- smallworld/platforms/defs/powerpc.py +259 -0
- smallworld/platforms/defs/riscv.py +257 -0
- smallworld/platforms/defs/xtensa.py +96 -0
- smallworld/{platforms.py → platforms/platforms.py} +3 -0
- smallworld/state/cpus/__init__.py +2 -0
- smallworld/state/cpus/aarch64.py +0 -9
- smallworld/state/cpus/amd64.py +6 -28
- smallworld/state/cpus/arm.py +0 -11
- smallworld/state/cpus/cpu.py +0 -11
- smallworld/state/cpus/i386.py +0 -7
- smallworld/state/cpus/loongarch.py +299 -0
- smallworld/state/cpus/mips.py +4 -47
- smallworld/state/cpus/mips64.py +18 -58
- smallworld/state/cpus/powerpc.py +2 -9
- smallworld/state/cpus/riscv.py +1 -11
- smallworld/state/cpus/xtensa.py +0 -5
- smallworld/state/memory/code.py +38 -2
- smallworld/state/memory/elf/__init__.py +5 -1
- smallworld/state/memory/elf/coredump/__init__.py +3 -0
- smallworld/state/memory/elf/coredump/coredump.py +46 -0
- smallworld/state/memory/elf/coredump/prstatus/__init__.py +27 -0
- smallworld/state/memory/elf/coredump/prstatus/aarch64.py +46 -0
- smallworld/state/memory/elf/coredump/prstatus/amd64.py +40 -0
- smallworld/state/memory/elf/coredump/prstatus/arm.py +53 -0
- smallworld/state/memory/elf/coredump/prstatus/i386.py +30 -0
- smallworld/state/memory/elf/coredump/prstatus/mips.py +55 -0
- smallworld/state/memory/elf/coredump/prstatus/mips64.py +57 -0
- smallworld/state/memory/elf/coredump/prstatus/ppc.py +82 -0
- smallworld/state/memory/elf/coredump/prstatus/prstatus.py +129 -0
- smallworld/state/memory/elf/elf.py +211 -57
- smallworld/state/memory/elf/register_state.py +36 -0
- smallworld/state/memory/elf/rela/__init__.py +2 -0
- smallworld/state/memory/elf/rela/aarch64.py +3 -1
- smallworld/state/memory/elf/rela/amd64.py +4 -2
- smallworld/state/memory/elf/rela/arm.py +4 -2
- smallworld/state/memory/elf/rela/i386.py +4 -2
- smallworld/state/memory/elf/rela/loongarch.py +32 -0
- smallworld/state/memory/elf/rela/mips.py +39 -18
- smallworld/state/memory/elf/rela/ppc.py +31 -14
- smallworld/state/memory/elf/structs.py +3 -0
- smallworld/state/memory/heap.py +2 -2
- smallworld/state/memory/memory.py +18 -0
- smallworld/state/memory/pe/__init__.py +3 -0
- smallworld/state/memory/pe/pe.py +361 -0
- smallworld/state/memory/pe/structs.py +60 -0
- smallworld/state/memory/stack/__init__.py +2 -0
- smallworld/state/memory/stack/loongarch.py +26 -0
- smallworld/state/models/__init__.py +29 -2
- smallworld/state/models/aarch64/__init__.py +1 -0
- smallworld/state/models/aarch64/systemv/__init__.py +6 -0
- smallworld/state/models/aarch64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/aarch64/systemv/c99/signal.py +16 -0
- smallworld/state/models/aarch64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/aarch64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/aarch64/systemv/c99/string.py +139 -0
- smallworld/state/models/aarch64/systemv/c99/time.py +61 -0
- smallworld/state/models/aarch64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/aarch64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/aarch64/systemv/posix/signal.py +157 -0
- smallworld/state/models/aarch64/systemv/systemv.py +80 -0
- smallworld/state/models/amd64/__init__.py +1 -0
- smallworld/state/models/amd64/systemv/__init__.py +6 -0
- smallworld/state/models/amd64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/amd64/systemv/c99/signal.py +16 -0
- smallworld/state/models/amd64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/amd64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/amd64/systemv/c99/string.py +139 -0
- smallworld/state/models/amd64/systemv/c99/time.py +61 -0
- smallworld/state/models/amd64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/amd64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/amd64/systemv/posix/signal.py +157 -0
- smallworld/state/models/amd64/systemv/systemv.py +78 -0
- smallworld/state/models/armel/__init__.py +1 -0
- smallworld/state/models/armel/systemv/__init__.py +6 -0
- smallworld/state/models/armel/systemv/c99/__init__.py +12 -0
- smallworld/state/models/armel/systemv/c99/signal.py +16 -0
- smallworld/state/models/armel/systemv/c99/stdio.py +265 -0
- smallworld/state/models/armel/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/armel/systemv/c99/string.py +139 -0
- smallworld/state/models/armel/systemv/c99/time.py +61 -0
- smallworld/state/models/armel/systemv/posix/__init__.py +6 -0
- smallworld/state/models/armel/systemv/posix/libgen.py +16 -0
- smallworld/state/models/armel/systemv/posix/signal.py +157 -0
- smallworld/state/models/armel/systemv/systemv.py +82 -0
- smallworld/state/models/armhf/__init__.py +1 -0
- smallworld/state/models/armhf/systemv/__init__.py +6 -0
- smallworld/state/models/armhf/systemv/c99/__init__.py +12 -0
- smallworld/state/models/armhf/systemv/c99/signal.py +16 -0
- smallworld/state/models/armhf/systemv/c99/stdio.py +265 -0
- smallworld/state/models/armhf/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/armhf/systemv/c99/string.py +139 -0
- smallworld/state/models/armhf/systemv/c99/time.py +61 -0
- smallworld/state/models/armhf/systemv/posix/__init__.py +6 -0
- smallworld/state/models/armhf/systemv/posix/libgen.py +16 -0
- smallworld/state/models/armhf/systemv/posix/signal.py +157 -0
- smallworld/state/models/armhf/systemv/systemv.py +77 -0
- smallworld/state/models/c99/__init__.py +12 -0
- smallworld/state/models/c99/fmt_print.py +915 -0
- smallworld/state/models/c99/fmt_scan.py +864 -0
- smallworld/state/models/c99/math.py +362 -0
- smallworld/state/models/c99/signal.py +71 -0
- smallworld/state/models/c99/stdio.py +1305 -0
- smallworld/state/models/c99/stdlib.py +595 -0
- smallworld/state/models/c99/string.py +674 -0
- smallworld/state/models/c99/time.py +340 -0
- smallworld/state/models/c99/utils.py +89 -0
- smallworld/state/models/cstd.py +759 -0
- smallworld/state/models/errno.py +581 -0
- smallworld/state/models/filedesc.py +515 -0
- smallworld/state/models/i386/__init__.py +1 -0
- smallworld/state/models/i386/systemv/__init__.py +6 -0
- smallworld/state/models/i386/systemv/c99/__init__.py +12 -0
- smallworld/state/models/i386/systemv/c99/signal.py +16 -0
- smallworld/state/models/i386/systemv/c99/stdio.py +265 -0
- smallworld/state/models/i386/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/i386/systemv/c99/string.py +139 -0
- smallworld/state/models/i386/systemv/c99/time.py +61 -0
- smallworld/state/models/i386/systemv/posix/__init__.py +6 -0
- smallworld/state/models/i386/systemv/posix/libgen.py +16 -0
- smallworld/state/models/i386/systemv/posix/signal.py +157 -0
- smallworld/state/models/i386/systemv/systemv.py +71 -0
- smallworld/state/models/loongarch64/__init__.py +1 -0
- smallworld/state/models/loongarch64/systemv/__init__.py +6 -0
- smallworld/state/models/loongarch64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/loongarch64/systemv/c99/signal.py +16 -0
- smallworld/state/models/loongarch64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/loongarch64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/loongarch64/systemv/c99/string.py +139 -0
- smallworld/state/models/loongarch64/systemv/c99/time.py +61 -0
- smallworld/state/models/loongarch64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/loongarch64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/loongarch64/systemv/posix/signal.py +157 -0
- smallworld/state/models/loongarch64/systemv/systemv.py +83 -0
- smallworld/state/models/mips/__init__.py +1 -0
- smallworld/state/models/mips/systemv/__init__.py +6 -0
- smallworld/state/models/mips/systemv/c99/__init__.py +12 -0
- smallworld/state/models/mips/systemv/c99/signal.py +16 -0
- smallworld/state/models/mips/systemv/c99/stdio.py +265 -0
- smallworld/state/models/mips/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/mips/systemv/c99/string.py +139 -0
- smallworld/state/models/mips/systemv/c99/time.py +61 -0
- smallworld/state/models/mips/systemv/posix/__init__.py +6 -0
- smallworld/state/models/mips/systemv/posix/libgen.py +16 -0
- smallworld/state/models/mips/systemv/posix/signal.py +157 -0
- smallworld/state/models/mips/systemv/systemv.py +78 -0
- smallworld/state/models/mips64/__init__.py +1 -0
- smallworld/state/models/mips64/systemv/__init__.py +6 -0
- smallworld/state/models/mips64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/mips64/systemv/c99/signal.py +16 -0
- smallworld/state/models/mips64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/mips64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/mips64/systemv/c99/string.py +139 -0
- smallworld/state/models/mips64/systemv/c99/time.py +61 -0
- smallworld/state/models/mips64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/mips64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/mips64/systemv/posix/signal.py +157 -0
- smallworld/state/models/mips64/systemv/systemv.py +98 -0
- smallworld/state/models/mips64el/__init__.py +1 -0
- smallworld/state/models/mips64el/systemv/__init__.py +6 -0
- smallworld/state/models/mips64el/systemv/c99/__init__.py +12 -0
- smallworld/state/models/mips64el/systemv/c99/signal.py +16 -0
- smallworld/state/models/mips64el/systemv/c99/stdio.py +265 -0
- smallworld/state/models/mips64el/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/mips64el/systemv/c99/string.py +139 -0
- smallworld/state/models/mips64el/systemv/c99/time.py +61 -0
- smallworld/state/models/mips64el/systemv/posix/__init__.py +6 -0
- smallworld/state/models/mips64el/systemv/posix/libgen.py +16 -0
- smallworld/state/models/mips64el/systemv/posix/signal.py +157 -0
- smallworld/state/models/mips64el/systemv/systemv.py +96 -0
- smallworld/state/models/mipsel/__init__.py +1 -0
- smallworld/state/models/mipsel/systemv/__init__.py +6 -0
- smallworld/state/models/mipsel/systemv/c99/__init__.py +12 -0
- smallworld/state/models/mipsel/systemv/c99/signal.py +16 -0
- smallworld/state/models/mipsel/systemv/c99/stdio.py +265 -0
- smallworld/state/models/mipsel/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/mipsel/systemv/c99/string.py +139 -0
- smallworld/state/models/mipsel/systemv/c99/time.py +61 -0
- smallworld/state/models/mipsel/systemv/posix/__init__.py +6 -0
- smallworld/state/models/mipsel/systemv/posix/libgen.py +16 -0
- smallworld/state/models/mipsel/systemv/posix/signal.py +157 -0
- smallworld/state/models/mipsel/systemv/systemv.py +78 -0
- smallworld/state/models/model.py +27 -2
- smallworld/state/models/posix/__init__.py +6 -0
- smallworld/state/models/posix/libgen.py +123 -0
- smallworld/state/models/posix/signal.py +690 -0
- smallworld/state/models/powerpc/__init__.py +1 -0
- smallworld/state/models/powerpc/systemv/__init__.py +6 -0
- smallworld/state/models/powerpc/systemv/c99/__init__.py +12 -0
- smallworld/state/models/powerpc/systemv/c99/signal.py +16 -0
- smallworld/state/models/powerpc/systemv/c99/stdio.py +265 -0
- smallworld/state/models/powerpc/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/powerpc/systemv/c99/string.py +139 -0
- smallworld/state/models/powerpc/systemv/c99/time.py +61 -0
- smallworld/state/models/powerpc/systemv/posix/__init__.py +6 -0
- smallworld/state/models/powerpc/systemv/posix/libgen.py +16 -0
- smallworld/state/models/powerpc/systemv/posix/signal.py +157 -0
- smallworld/state/models/powerpc/systemv/systemv.py +93 -0
- smallworld/state/models/riscv64/__init__.py +1 -0
- smallworld/state/models/riscv64/systemv/__init__.py +6 -0
- smallworld/state/models/riscv64/systemv/c99/__init__.py +12 -0
- smallworld/state/models/riscv64/systemv/c99/signal.py +16 -0
- smallworld/state/models/riscv64/systemv/c99/stdio.py +265 -0
- smallworld/state/models/riscv64/systemv/c99/stdlib.py +169 -0
- smallworld/state/models/riscv64/systemv/c99/string.py +139 -0
- smallworld/state/models/riscv64/systemv/c99/time.py +61 -0
- smallworld/state/models/riscv64/systemv/posix/__init__.py +6 -0
- smallworld/state/models/riscv64/systemv/posix/libgen.py +16 -0
- smallworld/state/models/riscv64/systemv/posix/signal.py +157 -0
- smallworld/state/models/riscv64/systemv/systemv.py +85 -0
- smallworld/state/state.py +65 -24
- smallworld/state/unstable/elf.py +16 -31
- smallworld/utils.py +6 -1
- {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/METADATA +74 -42
- smallworld_re-2.0.0.dist-info/RECORD +374 -0
- {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/WHEEL +1 -1
- smallworld/state/models/x86/__init__.py +0 -2
- smallworld/state/models/x86/microsoftcdecl.py +0 -35
- smallworld/state/models/x86/systemv.py +0 -240
- smallworld_re-1.0.3.dist-info/RECORD +0 -166
- /smallworld/state/models/{posix.py → _posix.py} +0 -0
- {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/entry_points.txt +0 -0
- {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/licenses/LICENSE.txt +0 -0
- {smallworld_re-1.0.3.dist-info → smallworld_re-2.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
import abc
|
2
|
+
import typing
|
3
|
+
|
4
|
+
from ghidra.app.plugin.processors.sleigh import SleighLanguageProvider
|
5
|
+
from ghidra.program.model.lang import Language, LanguageID, Register
|
6
|
+
|
7
|
+
from .... import exceptions, platforms, utils
|
8
|
+
|
9
|
+
|
10
|
+
class GhidraMachineDef:
|
11
|
+
"""Container class for ghdra architecture-specific definitions"""
|
12
|
+
|
13
|
+
@property
|
14
|
+
@abc.abstractmethod
|
15
|
+
def arch(self) -> platforms.Architecture:
|
16
|
+
"""The architecture ID"""
|
17
|
+
raise NotImplementedError("This is an abstract method")
|
18
|
+
|
19
|
+
@property
|
20
|
+
@abc.abstractmethod
|
21
|
+
def byteorder(self) -> platforms.Byteorder:
|
22
|
+
"""The byte order"""
|
23
|
+
raise NotImplementedError("This is an abstract method")
|
24
|
+
|
25
|
+
@property
|
26
|
+
@abc.abstractmethod
|
27
|
+
def language_id(self) -> str:
|
28
|
+
"""The Pcode language ID"""
|
29
|
+
raise NotImplementedError("This is an abstract method")
|
30
|
+
|
31
|
+
# Does Pcode support single-instruction stepping for this ISA.
|
32
|
+
#
|
33
|
+
# Instructions with delay slots can't be lifted into Pcode
|
34
|
+
# without also lifting the instruction in the delay slot.
|
35
|
+
#
|
36
|
+
# This flag indicates that this machine uses such instructions,
|
37
|
+
# and is not safe to step in this manner
|
38
|
+
supports_single_step: bool = True
|
39
|
+
|
40
|
+
_registers: typing.Dict[str, typing.Optional[str]]
|
41
|
+
|
42
|
+
def __init__(self):
|
43
|
+
# Load the Pcode language definition
|
44
|
+
slp = SleighLanguageProvider.getSleighLanguageProvider()
|
45
|
+
langID = LanguageID(self.language_id)
|
46
|
+
self.language: Language = slp.getLanguage(langID)
|
47
|
+
assert self.language is not None
|
48
|
+
|
49
|
+
def pcode_reg(self, name: str) -> Register:
|
50
|
+
if name not in self._registers:
|
51
|
+
raise KeyError(f"Unknown register for {self.arch}:{self.byteorder}: {name}")
|
52
|
+
if self._registers[name] is None:
|
53
|
+
raise exceptions.UnsupportedRegisterError(
|
54
|
+
f"Register {name} not recognized by pcode for {self.arch}:{self.byteorder}"
|
55
|
+
)
|
56
|
+
reg = self.language.getRegister(self._registers[name])
|
57
|
+
assert reg is not None, name
|
58
|
+
return reg
|
59
|
+
|
60
|
+
@classmethod
|
61
|
+
def for_platform(cls, platform: platforms.Platform):
|
62
|
+
"""Find the appropriate MachineDef for your architecture
|
63
|
+
|
64
|
+
Arguments:
|
65
|
+
arch: The architecture ID you want
|
66
|
+
byteorder: The byteorderness you want
|
67
|
+
|
68
|
+
Returns:
|
69
|
+
An instance of the appropriate MachineDef
|
70
|
+
|
71
|
+
Raises:
|
72
|
+
ValueError: If no MachineDef subclass matches your request
|
73
|
+
"""
|
74
|
+
try:
|
75
|
+
return utils.find_subclass(
|
76
|
+
cls,
|
77
|
+
lambda x: x.arch == platform.architecture
|
78
|
+
and x.byteorder == platform.byteorder,
|
79
|
+
)
|
80
|
+
except:
|
81
|
+
raise ValueError(f"No machine model for {platform}")
|
@@ -0,0 +1,163 @@
|
|
1
|
+
from ....platforms import Architecture, Byteorder
|
2
|
+
from .machdef import GhidraMachineDef
|
3
|
+
|
4
|
+
|
5
|
+
class MIPSMachineDef(GhidraMachineDef):
|
6
|
+
arch = Architecture.MIPS32
|
7
|
+
|
8
|
+
# NOTE: MIPS registers have a name and a number
|
9
|
+
# angr's machine state doesn't use the number,
|
10
|
+
# so... name.
|
11
|
+
_registers = {
|
12
|
+
# *** General-Purpose Registers ***
|
13
|
+
# Assembler-Temporary Register
|
14
|
+
"at": "at",
|
15
|
+
"1": "at",
|
16
|
+
# Return Value Registers
|
17
|
+
"v0": "v0",
|
18
|
+
"2": "v0",
|
19
|
+
"v1": "v1",
|
20
|
+
"3": "v1",
|
21
|
+
# Argument Registers
|
22
|
+
"a0": "a0",
|
23
|
+
"4": "a0",
|
24
|
+
"a1": "a1",
|
25
|
+
"5": "a1",
|
26
|
+
"a2": "a2",
|
27
|
+
"6": "a2",
|
28
|
+
"a3": "a3",
|
29
|
+
"7": "a3",
|
30
|
+
# Temporary Registers
|
31
|
+
"t0": "t0",
|
32
|
+
"8": "t0",
|
33
|
+
"t1": "t1",
|
34
|
+
"9": "t1",
|
35
|
+
"t2": "t2",
|
36
|
+
"10": "t2",
|
37
|
+
"t3": "t3",
|
38
|
+
"11": "t3",
|
39
|
+
"t4": "t4",
|
40
|
+
"12": "t4",
|
41
|
+
"t5": "t5",
|
42
|
+
"13": "t5",
|
43
|
+
"t6": "t6",
|
44
|
+
"14": "t6",
|
45
|
+
"t7": "t7",
|
46
|
+
"15": "t7",
|
47
|
+
# NOTE: These numbers aren't out of order.
|
48
|
+
# t8 and t9 are later in the register file than t0 - t7.
|
49
|
+
"t8": "t8",
|
50
|
+
"24": "t8",
|
51
|
+
"t9": "t9",
|
52
|
+
"25": "t9",
|
53
|
+
# Saved Registers
|
54
|
+
"s0": "s0",
|
55
|
+
"16": "s0",
|
56
|
+
"s1": "s1",
|
57
|
+
"17": "s1",
|
58
|
+
"s2": "s2",
|
59
|
+
"18": "s2",
|
60
|
+
"s3": "s3",
|
61
|
+
"19": "s3",
|
62
|
+
"s4": "s4",
|
63
|
+
"20": "s4",
|
64
|
+
"s5": "s5",
|
65
|
+
"21": "s5",
|
66
|
+
"s6": "s6",
|
67
|
+
"22": "s6",
|
68
|
+
"s7": "s7",
|
69
|
+
"23": "s7",
|
70
|
+
# NOTE: Register #30 was originally the Frame Pointer.
|
71
|
+
# It's been re-aliased as s8, since many ABIs don't use the frame pointer.
|
72
|
+
# Unicorn and Sleigh prefer to use the alias s8,
|
73
|
+
# so it should be the base register.
|
74
|
+
"s8": "s8",
|
75
|
+
"fp": "s8",
|
76
|
+
"30": "s8",
|
77
|
+
# Kernel-reserved Registers
|
78
|
+
"k0": "k0",
|
79
|
+
"26": "k0",
|
80
|
+
"k1": "k1",
|
81
|
+
"27": "k1",
|
82
|
+
# *** Pointer Registers ***
|
83
|
+
# Zero register
|
84
|
+
"zero": "zero",
|
85
|
+
"0": "zero",
|
86
|
+
# Global Offset Pointer
|
87
|
+
"gp": "gp",
|
88
|
+
"28": "gp",
|
89
|
+
# Stack Pointer
|
90
|
+
"sp": "sp",
|
91
|
+
"29": "sp",
|
92
|
+
# Return Address
|
93
|
+
"ra": "ra",
|
94
|
+
"31": "ra",
|
95
|
+
# Program Counter
|
96
|
+
"pc": "pc",
|
97
|
+
# Floating Point Registers
|
98
|
+
"f0": "f0",
|
99
|
+
"f1": "f1",
|
100
|
+
"f2": "f2",
|
101
|
+
"f3": "f3",
|
102
|
+
"f4": "f4",
|
103
|
+
"f5": "f5",
|
104
|
+
"f6": "f6",
|
105
|
+
"f7": "f7",
|
106
|
+
"f8": "f8",
|
107
|
+
"f9": "f9",
|
108
|
+
"f10": "f10",
|
109
|
+
"f11": "f11",
|
110
|
+
"f12": "f12",
|
111
|
+
"f13": "f13",
|
112
|
+
"f14": "f14",
|
113
|
+
"f15": "f15",
|
114
|
+
"f16": "f16",
|
115
|
+
"f17": "f17",
|
116
|
+
"f18": "f18",
|
117
|
+
"f19": "f19",
|
118
|
+
"f20": "f20",
|
119
|
+
"f21": "f21",
|
120
|
+
"f22": "f22",
|
121
|
+
"f23": "f23",
|
122
|
+
"f24": "f24",
|
123
|
+
"f25": "f25",
|
124
|
+
"f26": "f26",
|
125
|
+
"f27": "f27",
|
126
|
+
"f28": "f28",
|
127
|
+
"f29": "f29",
|
128
|
+
"f30": "f30",
|
129
|
+
"f31": "f31",
|
130
|
+
# *** Floating Point Control Registers ***
|
131
|
+
"fir": "fir",
|
132
|
+
"fcsr": "fcsr",
|
133
|
+
"fexr": "fexr",
|
134
|
+
"fenr": "fenr",
|
135
|
+
"fccr": "fccr",
|
136
|
+
# *** Accumulator Registers ***
|
137
|
+
# MIPS uses these to implement 64-bit results
|
138
|
+
# from 32-bit multiplication, amongst others.
|
139
|
+
"ac0": None,
|
140
|
+
"hi0": None,
|
141
|
+
"lo0": None,
|
142
|
+
"ac1": None,
|
143
|
+
"hi1": None,
|
144
|
+
"lo1": None,
|
145
|
+
"ac2": None,
|
146
|
+
"hi2": None,
|
147
|
+
"lo2": None,
|
148
|
+
"ac3": None,
|
149
|
+
"hi3": None,
|
150
|
+
"lo3": None,
|
151
|
+
}
|
152
|
+
|
153
|
+
supports_single_step = True
|
154
|
+
|
155
|
+
|
156
|
+
class MIPSELMachineDef(MIPSMachineDef):
|
157
|
+
byteorder = Byteorder.LITTLE
|
158
|
+
language_id = "MIPS:LE:32:default"
|
159
|
+
|
160
|
+
|
161
|
+
class MIPSBEMachineDef(MIPSMachineDef):
|
162
|
+
byteorder = Byteorder.BIG
|
163
|
+
language_id = "MIPS:BE:32:default"
|
@@ -0,0 +1,186 @@
|
|
1
|
+
from ....platforms import Architecture, Byteorder
|
2
|
+
from .machdef import GhidraMachineDef
|
3
|
+
|
4
|
+
|
5
|
+
class MIPS64MachineDef(GhidraMachineDef):
|
6
|
+
arch = Architecture.MIPS64
|
7
|
+
|
8
|
+
# NOTE: MIPS registers have a name and a number
|
9
|
+
# angr's machine state doesn't use the number,
|
10
|
+
# so... name.
|
11
|
+
# NOTE: angr's register names are wrong.
|
12
|
+
# It follows Wikipedia's definition of the 64-bit ABI,
|
13
|
+
# which has a4 - a7 and t0 - t3 overlapping.
|
14
|
+
_registers = {
|
15
|
+
# *** General-Purpose Registers ***
|
16
|
+
# NOTE: Ghidra uses the O64 ABI (rather, it reuses the O32 names for both)
|
17
|
+
# SmallWorld uses the N64 ABI for mips64,
|
18
|
+
# so the argument and temporary registers will appear wrong
|
19
|
+
# Assembler-Temporary Register
|
20
|
+
"at": "at",
|
21
|
+
"1": "at",
|
22
|
+
# Return Value Registers
|
23
|
+
"v0": "v0",
|
24
|
+
"2": "v0",
|
25
|
+
"v1": "v1",
|
26
|
+
"3": "v1",
|
27
|
+
# Argument Registers
|
28
|
+
"a0": "a0",
|
29
|
+
"4": "a0",
|
30
|
+
"a1": "a1",
|
31
|
+
"5": "a1",
|
32
|
+
"a2": "a2",
|
33
|
+
"6": "a2",
|
34
|
+
"a3": "a3",
|
35
|
+
"7": "a3",
|
36
|
+
"a4": "t0",
|
37
|
+
"8": "t0",
|
38
|
+
"a5": "t1",
|
39
|
+
"9": "t1",
|
40
|
+
"a6": "t2",
|
41
|
+
"10": "t2",
|
42
|
+
"a7": "t3",
|
43
|
+
"11": "t3",
|
44
|
+
# Temporary Registers
|
45
|
+
"t0": "t4",
|
46
|
+
"12": "t4",
|
47
|
+
"t1": "t5",
|
48
|
+
"13": "t5",
|
49
|
+
"t2": "t6",
|
50
|
+
"14": "t6",
|
51
|
+
"t3": "t7",
|
52
|
+
"15": "t7",
|
53
|
+
# NOTE: These numbers aren't out of order.
|
54
|
+
# t8 and t9 are later in the register file than t0 - t7.
|
55
|
+
"t8": "t8",
|
56
|
+
"24": "t8",
|
57
|
+
"t9": "t9",
|
58
|
+
"25": "t9",
|
59
|
+
# Saved Registers
|
60
|
+
"s0": "s0",
|
61
|
+
"16": "s0",
|
62
|
+
"s1": "s1",
|
63
|
+
"17": "s1",
|
64
|
+
"s2": "s2",
|
65
|
+
"18": "s2",
|
66
|
+
"s3": "s3",
|
67
|
+
"19": "s3",
|
68
|
+
"s4": "s4",
|
69
|
+
"20": "s4",
|
70
|
+
"s5": "s5",
|
71
|
+
"21": "s5",
|
72
|
+
"s6": "s6",
|
73
|
+
"22": "s6",
|
74
|
+
"s7": "s7",
|
75
|
+
"23": "s7",
|
76
|
+
# NOTE: Register #30 was originally the Frame Pointer.
|
77
|
+
# It's been re-aliased as s8, since many ABIs don't use the frame pointer.
|
78
|
+
# Unicorn and Sleigh prefer to use the alias s8,
|
79
|
+
# so it should be the base register.
|
80
|
+
"s8": "s8",
|
81
|
+
"fp": "s8",
|
82
|
+
"30": "s8",
|
83
|
+
# Kernel-reserved Registers
|
84
|
+
"k0": "k0",
|
85
|
+
"26": "k0",
|
86
|
+
"k1": "k1",
|
87
|
+
"27": "k1",
|
88
|
+
# *** Pointer Registers ***
|
89
|
+
# Zero register
|
90
|
+
"zero": "zero",
|
91
|
+
"0": "zero",
|
92
|
+
# Global Offset Pointer
|
93
|
+
"gp": "gp",
|
94
|
+
"28": "gp",
|
95
|
+
# Stack Pointer
|
96
|
+
"sp": "sp",
|
97
|
+
"29": "sp",
|
98
|
+
# Return Address
|
99
|
+
"ra": "ra",
|
100
|
+
"31": "ra",
|
101
|
+
# Program Counter
|
102
|
+
"pc": "pc",
|
103
|
+
# Floating Point Registers
|
104
|
+
"f0": "f0",
|
105
|
+
"f1": "f1",
|
106
|
+
"f2": "f2",
|
107
|
+
"f3": "f3",
|
108
|
+
"f4": "f4",
|
109
|
+
"f5": "f5",
|
110
|
+
"f6": "f6",
|
111
|
+
"f7": "f7",
|
112
|
+
"f8": "f8",
|
113
|
+
"f9": "f9",
|
114
|
+
"f10": "f10",
|
115
|
+
"f11": "f11",
|
116
|
+
"f12": "f12",
|
117
|
+
"f13": "f13",
|
118
|
+
"f14": "f14",
|
119
|
+
"f15": "f15",
|
120
|
+
"f16": "f16",
|
121
|
+
"f17": "f17",
|
122
|
+
"f18": "f18",
|
123
|
+
"f19": "f19",
|
124
|
+
"f20": "f20",
|
125
|
+
"f21": "f21",
|
126
|
+
"f22": "f22",
|
127
|
+
"f23": "f23",
|
128
|
+
"f24": "f24",
|
129
|
+
"f25": "f25",
|
130
|
+
"f26": "f26",
|
131
|
+
"f27": "f27",
|
132
|
+
"f28": "f28",
|
133
|
+
"f29": "f29",
|
134
|
+
"f30": "f30",
|
135
|
+
"f31": "f31",
|
136
|
+
# *** Floating Point Control Registers ***
|
137
|
+
"fir": "fir",
|
138
|
+
"fcsr": "fcsr",
|
139
|
+
"fexr": "fexr",
|
140
|
+
"fenr": "fenr",
|
141
|
+
"fccr": "fccr",
|
142
|
+
# *** Accumulator Registers ***
|
143
|
+
# MIPS uses these to implement 64-bit results
|
144
|
+
# from 32-bit multiplication, amongst others.
|
145
|
+
"ac0": None,
|
146
|
+
"hi0": None,
|
147
|
+
"lo0": None,
|
148
|
+
"ac1": None,
|
149
|
+
"hi1": None,
|
150
|
+
"lo1": None,
|
151
|
+
"ac2": None,
|
152
|
+
"hi2": None,
|
153
|
+
"lo2": None,
|
154
|
+
"ac3": None,
|
155
|
+
"hi3": None,
|
156
|
+
"lo3": None,
|
157
|
+
}
|
158
|
+
|
159
|
+
_delay_slot_opcodes = {
|
160
|
+
"j",
|
161
|
+
"jal",
|
162
|
+
"jalx",
|
163
|
+
"jalr",
|
164
|
+
"jr",
|
165
|
+
"beq",
|
166
|
+
"beqz",
|
167
|
+
"bne" "bnez",
|
168
|
+
"bgez",
|
169
|
+
"bgezal",
|
170
|
+
"bgtz",
|
171
|
+
"blez",
|
172
|
+
"bltz",
|
173
|
+
"bltzal",
|
174
|
+
}
|
175
|
+
|
176
|
+
supports_single_step = True
|
177
|
+
|
178
|
+
|
179
|
+
class MIPS64ELMachineDef(MIPS64MachineDef):
|
180
|
+
byteorder = Byteorder.LITTLE
|
181
|
+
language_id = "MIPS:LE:64:default"
|
182
|
+
|
183
|
+
|
184
|
+
class MIPS64BEMachineDef(MIPS64MachineDef):
|
185
|
+
byteorder = Byteorder.BIG
|
186
|
+
language_id = "MIPS:BE:64:default"
|
@@ -0,0 +1,98 @@
|
|
1
|
+
from ....platforms import Architecture, Byteorder
|
2
|
+
from .machdef import GhidraMachineDef
|
3
|
+
|
4
|
+
|
5
|
+
class PowerPCMachineDef(GhidraMachineDef):
|
6
|
+
byteorder = Byteorder.BIG
|
7
|
+
|
8
|
+
_registers = {
|
9
|
+
"r0": "r0",
|
10
|
+
"r1": "r1",
|
11
|
+
"sp": "r1",
|
12
|
+
"r2": "r2",
|
13
|
+
"r3": "r3",
|
14
|
+
"r4": "r4",
|
15
|
+
"r5": "r5",
|
16
|
+
"r6": "r6",
|
17
|
+
"r7": "r7",
|
18
|
+
"r8": "r8",
|
19
|
+
"r9": "r9",
|
20
|
+
"r10": "r10",
|
21
|
+
"r11": "r11",
|
22
|
+
"r12": "r12",
|
23
|
+
"r13": "r13",
|
24
|
+
"r14": "r14",
|
25
|
+
"r15": "r15",
|
26
|
+
"r16": "r16",
|
27
|
+
"r17": "r17",
|
28
|
+
"r18": "r18",
|
29
|
+
"r19": "r19",
|
30
|
+
"r20": "r20",
|
31
|
+
"r21": "r21",
|
32
|
+
"r22": "r22",
|
33
|
+
"r23": "r23",
|
34
|
+
"r24": "r24",
|
35
|
+
"r25": "r25",
|
36
|
+
"r26": "r26",
|
37
|
+
"r27": "r27",
|
38
|
+
"r28": "r28",
|
39
|
+
"r29": "r29",
|
40
|
+
"r30": "r30",
|
41
|
+
"r31": "r31",
|
42
|
+
"bp": "r31",
|
43
|
+
"pc": "pc",
|
44
|
+
"lr": "lr",
|
45
|
+
"ctr": "ctr",
|
46
|
+
"cr0": "cr0",
|
47
|
+
"cr1": "cr1",
|
48
|
+
"cr2": "cr2",
|
49
|
+
"cr3": "cr3",
|
50
|
+
"cr4": "cr4",
|
51
|
+
"cr5": "cr5",
|
52
|
+
"cr6": "cr6",
|
53
|
+
"cr7": "cr7",
|
54
|
+
"f0": "f0",
|
55
|
+
"f1": "f1",
|
56
|
+
"f2": "f2",
|
57
|
+
"f3": "f3",
|
58
|
+
"f4": "f4",
|
59
|
+
"f5": "f5",
|
60
|
+
"f6": "f6",
|
61
|
+
"f7": "f7",
|
62
|
+
"f8": "f8",
|
63
|
+
"f9": "f9",
|
64
|
+
"f10": "f10",
|
65
|
+
"f11": "f11",
|
66
|
+
"f12": "f12",
|
67
|
+
"f13": "f13",
|
68
|
+
"f14": "f14",
|
69
|
+
"f15": "f15",
|
70
|
+
"f16": "f16",
|
71
|
+
"f17": "f17",
|
72
|
+
"f18": "f18",
|
73
|
+
"f19": "f19",
|
74
|
+
"f20": "f20",
|
75
|
+
"f21": "f21",
|
76
|
+
"f22": "f22",
|
77
|
+
"f23": "f23",
|
78
|
+
"f24": "f24",
|
79
|
+
"f25": "f25",
|
80
|
+
"f26": "f26",
|
81
|
+
"f27": "f27",
|
82
|
+
"f28": "f28",
|
83
|
+
"f29": "f29",
|
84
|
+
"f30": "f30",
|
85
|
+
"f31": "f31",
|
86
|
+
"xer": None,
|
87
|
+
"fpscr": None,
|
88
|
+
}
|
89
|
+
|
90
|
+
|
91
|
+
class PowerPC32MachineDef(PowerPCMachineDef):
|
92
|
+
arch = Architecture.POWERPC32
|
93
|
+
language_id = "PowerPC:BE:32:default"
|
94
|
+
|
95
|
+
|
96
|
+
class PowerPC64MachineDef(PowerPCMachineDef):
|
97
|
+
arch = Architecture.POWERPC64
|
98
|
+
language_id = "PowerPC:BE:64:default"
|