* feat(ghidra): admit raw 8051 images Add 8051 as a raw-only architecture: byte-aligned entry, mapping within 0x0000..0xffff, analyzed by Ghidra with 8051:BE:16:default in the CODE space. Hopper, IDA, Kuna and Windows Ghidra P0 keep refusing it. Document the lane, including that bank-switch thunks and Keil ?C?CCASE switch arms are not followed by auto-analysis and need REA_GHIDRA_SEED_FILE entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(mcp): update the advertised open_binary schema summary for raw 8051 The architecture enum gained 8051, so the committed input schema digest for open_binary changed. Regenerated with `npm run verify:advertised-schemas -- --update-summary`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(ghidra): pin the 8051 CODE binding and correct the 8051 docs - Assert the 8051 language binding (8051:BE:16:default, CODE) and that load-image attestation requires the CODE default space; replacing CODE with ram now fails three tests. - Assert that Windows Ghidra P0 refuses raw 8051. - Derive the raw-binary architecture refusal from BINARY_ARCHITECTURES with Intl.ListFormat; the wording, and so the admission grid digest, is unchanged. - Docs: list the memory blocks Ghidra really creates for 8051 (no external RAM block), explain bank addressing for paged banks and the entry-decode requirement, state when the seed file is read, and add 8051 to the n64 guide's family list. Fix a duplicated "and" in the generic-language limitation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Alex Petrochenko <5717309+petrochen@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
19 KiB
Headerless raw-binary analysis with Ghidra
Headerless images are covered here. GameCube/Wii DOL images have a header and use their own format selection; see GameCube DOL analysis.
REA admits a headerless executable when the caller supplies the CPU family and
the address where file offset 0 should be mapped. That interpretation is not
inferred from a .bin suffix or from unrecognized bytes. ARM M-profile images
can also name their profile and take their entry from the vector table; see
ARM M-profile images.
Open and inspect
rea inspect /absolute/path/to/kernel.img --target-format raw-binary --architecture arm --entry-point 0x8000 --provider ghidra --json
rea function /absolute/path/to/kernel.img 0x8000 --target-format raw-binary --architecture arm --entry-point 0x8000 --provider ghidra --json
rea inspect-native-load-image /absolute/path/to/kernel.img --target-format raw-binary --architecture arm --entry-point 0x8000 --provider ghidra --json
{
"name": "open_binary",
"arguments": {
"path": "/absolute/path/to/kernel.img",
"format": "raw-binary",
"architecture": "arm",
"entry_point": "0x8000",
"provider_id": "ghidra"
}
}
The example maps a 32-bit ARM-state image at 0x8000. For arm, decoding
starts at the entry in ARM (A32) state, so Thumb-only images, including Cortex-M
firmware, are not supported. See Limitations.
architecture is one of x86, x86_64, arm, arm64, 6502, m68k, or 8051. entry_point is a
hexadecimal address of the form 0x…. The complete file is mapped starting at
that address, and Ghidra seeds an entry function there before auto-analysis.
ARM and AArch64 entries must be 4-byte aligned; m68k entries must be 2-byte
aligned; x86, 6502 and 8051 entries may be byte-aligned.
For 6502 and 8051, the entry and complete mapped file must fit within 0x0000..0xffff;
images that cross the 16-bit boundary are rejected before provider startup.
For m68k, the mapping must fit within 0x0..0xffffffff.
open_binary and an open binary_session return the canonical entry_point
for raw targets so callers can verify the selected mapping directly.
Omitted format keeps header-based detection; architecture and entry without
format=raw-binary are rejected.
Ghidra imports a private snapshot with BinaryLoader and these generic
languages and compiler specifications. Each family has one fixed byte order:
m68k and 8051 are big-endian and the others are little-endian.
| architecture | language_id | compiler_spec_id |
|---|---|---|
| x86 | x86:LE:32:default |
gcc |
| x86_64 | x86:LE:64:default |
gcc |
| arm | ARM:LE:32:v7 |
default |
| arm64 | AARCH64:LE:64:v8A |
default |
| 6502 | 6502:LE:16:default |
default |
| m68k | 68000:BE:32:default |
default |
| 8051 | 8051:BE:16:default |
default |
Compiler specifications select analysis conventions; they do not identify the
original compiler or ABI of a headerless target. Ghidra's x86 languages do not
provide a compiler specification named default.
Those settings, the caller-supplied entry, and language_selection: caller-supplied are committed in the analysis profile. A different entry
or architecture is a different profile; snapshots from header-detected targets
do not replay.
The mapped start is independent of Ghidra's program image base, which remains
0x0 for BinaryLoader. Ghidra may report additional language-defined entry
points, including unmapped ARM vectors. Load-image verification requires the
caller-supplied entry and preserves those other entries as observations.
For 6502, BinaryLoader maps the file before adding its language-defined zero-page
and stack blocks. Conflicting default blocks are skipped; low-address files stay
in the default address space rather than an overlay. Non-conflicting uninitialized
blocks remain observations, not file-backed bytes.
Independent raw verification streams the complete private snapshot digest and
extent with bounded memory and supports cancellation during the read.
It also requires the source-backed block to be initialized, loaded, and
non-overlay in the bound language's default address space. Contradictory mapping
observations are retained with mismatch, even when the source hashes agree.
Hopper and IDA refuse raw-binary targets. Windows Ghidra P0 admits native PE applications/DLLs and explicitly selected raw 6502 images. Other raw CPU families remain outside the Windows boundary. Native path admission, private DACLs, Job Object ownership, immutable snapshots, and the no-mutation policy still apply.
ARM M-profile images
Cortex-M flash images start with a vector table and run only Thumb code. A dump
read from a device, for example with st-flash read dump.bin 0x08000000 <size>,
records neither the address it was read from nor the M profile of the core.
Name both:
rea inspect /absolute/path/to/dump.bin --target-format raw-binary --architecture arm --architecture-variant armv7-m --base-address 0x08000000 --provider ghidra --json
{
"name": "open_binary",
"arguments": {
"path": "/absolute/path/to/dump.bin",
"format": "raw-binary",
"architecture": "arm",
"architecture_variant": "armv7-m",
"base_address": "0x08000000",
"provider_id": "ghidra"
}
}
architecture_variant names the M profile and selects the Ghidra decoder:
| architecture_variant | Profile | language_id | compiler_spec_id |
|---|---|---|---|
armv6-m |
ARMv6-M | ARM:LE:32:Cortex |
default |
armv7-m |
ARMv7-M | ARM:LE:32:Cortex |
default |
armv7e-m |
ARMv7E-M | ARM:LE:32:Cortex |
default |
armv8-m.base |
ARMv8-M Baseline | ARM:LE:32:v8-m |
default |
armv8-m.main |
ARMv8-M Mainline | ARM:LE:32:v8-m |
default |
armv8.1-m.main |
ARMv8.1-M Mainline | ARM:LE:32:v8-m |
default |
ARM:LE:32:Cortex is Ghidra's ARMv7 decoder with Thumb as the default state. It
has no ARMv8-M encodings, such as the MSPLIM and PSPLIM system registers that
v8-M startup code sets, so the v8-M and v8.1-M variants use ARM:LE:32:v8-m.
Ghidra 12.2's ARM.ldefs lists armv8.1-m.main for that language, which also
decodes ARMv8.1-M encodings such as MVE and the low-overhead loops (wls, le);
the loop branches' flow is wrong, as Limitations describes.
Neither decoder refuses instructions that a smaller profile lacks: armv6-m
code is decoded with the ARMv7-M instruction set, and armv8-m.main code with
the ARMv8.1-M one.
base_addressmaps file offset 0 at its own address, andentry_pointmust then lie inside the mapped image. It is required witharchitecture_variantand refused without it, the one lane whose verifier covers a separate base. A dump records neither its load address nor where Reset is, and mapping it at the entry would put a vector table at Reset; a code fragment that starts at its entry passes that address asbase_address.- Without
entry_point, REA reads the vector table atvector_table_address, or atbase_addresswhen that is omitted. Word 1 is the Reset handler with bit 0 set for Thumb state. The vector value is observed, and the entry is derived by clearing bit 0. Word 0, the initial stack pointer, is recorded as observed and is not validated. - Use
vector_table_addresswhen a header precedes the vector table, such as the 256-byte boot2 stage of an RP2040 image or an MCUboot header. It applies only whenentry_pointis omitted. The table, whether named or at the base, must be 128-byte aligned, as VTOR requires (TBLOFFholds address bits 31:7), and it must lie inside the mapped image. - REA refuses a Reset word that is even, that points outside the mapped image or
into the 8 table bytes it read, or that lies past the end of the file. These
are
load_selection_rejectedrefusals with the observed words indetails.diagnostics: a raw dump has no format they can violate, and the usual cause is a wrongbase_address,vector_table_addressor variant. - An explicit
entry_pointmust be even. An odd value is a Thumb interworking address, such as a word copied from the vector table. REA refuses it instead of clearing bit 0;details.diagnosticsin the error give the evencode_addressand suggest omittingentry_point. - Each refusal of a load selection is an
invalid_requestwithdetails.constraint: "load_selection_rejected"and, when one input is to blame, that input indetails.field, such asentry_pointfor an odd Thumb entry. The Reset-word refusals name none.
Before auto-analysis, REA's preparation script requires Ghidra's Thumb context
(TMode=1) at the entry and seeds the entry there; inspect_native_load_image
attests that context independently. Ghidra imports the file without its
processor-defined labels. ARMCortex.pspec names the vector table at
0x0-0x40 and marks every handler slot an entry, reserved slots included, so
at base 0x0 its names would cover the table and the code after it. The load
image attests that the seeded entry is the only one.
npm run verify:ghidra:cortex-m checks this lane against real Ghidra 12.2
with source-owned fixtures and LLVM as the decoding oracle; see
testing lanes.
Identity and Evidence
A load whose base is its caller-selected entry and that names no variant is the
same load as before these inputs existed, decided on these resolved values. Its
analysis profile, snapshot target, session reuse and raw-binary load image are
unchanged. Any other raw load:
- reports
base_address,architecture_variantand, when Reset was read from the vector table,vector_table_addressinopen_binaryandbinary_session; - commits
raw_load(version: 1) to its analysis profile and snapshot target: the base, the variant, the vector table that Reset was read from, and the entry's address, instruction set,roleandbasis; - returns the
segmentsload image (layout: "segments",version: 1): one segment backed by the whole file at the base, one entry with itsisa_mode,roleandbasis, and, when the basis is the vector table,vector_tablewith the table address and the two words read from it, as full-width 32-bit words such as0x080001c5; the entry holds the canonical code address.
An entry's role names its function: entry for an entry the caller named,
reset for the Reset handler. Its basis records how REA chose it: caller
or vector-table. Ghidra names the function it seeds there entry whatever
the role, as its loaders name a program entry; the role, not that name, says
which handler it is.
Identity has two levels:
- Coordinate identity (
function_coordinate_context) covers only resolved values that move coordinates: the decoder, the base, and the entry's decode context. Every entry of one image at one base gets the same coordinate context, so functions found from a caller-named entry and from Reset compare. A legacy load maps file offset 0 at its entry, so there the entry address is the base. - Session and snapshot identity also cover the provenance that results report:
raw_loadadds the variant, the vector-table address, and the entry's role and basis. The vector words need no place of their own: they are the file bytes at the table address, which the file digest and the base fix. A reused session never reports a basis or vector words that the current request did not produce.
Neither level covers spellings: 0x08000000 and 0x8000000 are the same base,
an omitted vector_table_address equals an explicit one at the base, and REA
reports canonical addresses only. No result retains the spelling a caller used
yet. A caller that needs its spelling keeps its own request: an MCP client
already holds its arguments, and a CLI caller can save its command beside the
Evidence it writes, together with its evidence_id.
These inputs leave a load without them exactly as REA loaded it before: its
analysis profile inputs, snapshot target and raw-binary load image are
unchanged, so its saved load images stay readable. Snapshots still follow the
producer rule: every
analysis profile commits to the REA release and its packaged bridge scripts, so
a snapshot that an earlier REA release saved is refused after an upgrade, with
or without these inputs. Open the target again and save a fresh snapshot. A
snapshot of a load that uses these inputs also has a different analysis profile,
so REA versions without these inputs cannot replay it.
NMOS 6502
rea function /absolute/path/to/image.bin 0x8001 --target-format raw-binary --architecture 6502 --entry-point 0x8001 --provider ghidra --json
rea inspect-native-load-image /absolute/path/to/image.bin --target-format raw-binary --architecture 6502 --entry-point 0x8001 --provider ghidra --json
Select only headerless NMOS 6502 code with a known entry at file offset 0.
The built-in Ghidra processor supplies static instructions, functions,
pseudocode, and references. Evidence preserves architecture: "6502", the
selected language, entry, file digest, and verified source mapping. Register and
calling conventions are analysis conventions, not a recovered source ABI.
This lane does not interpret iNES headers, cartridge mappers, bank switching, or other console-specific memory layouts. 65C02 and 65816 programs need different processor semantics and are not admitted as those variants. REA does not infer the CPU from the file suffix, guess the reset vector, or emulate the target.
npm run verify:ghidra:6502 assembles and links the source-owned fixture with
ca65 and ld65 (tested from cc65 tag V2.19, whose tools report V2.18).
Set REA_CA65 and REA_LD65 to explicit executable paths if needed. The lane
checks real CLI/MCP load-image parity, mapped bytes, decoded calls, decompilation,
invalid mappings, unchanged source bytes and runtime cleanup.
Low-memory checks include a file spanning the zero-page/stack boundary at 0xff
and a complete 64-KiB image at 0x0, with verified default-space mappings through
both CLI and MCP. On Windows, the lane also checks that a caller-selected
junction path is rejected at snapshot admission through CLI and MCP, with
unchanged source bytes and complete runtime cleanup. Windows requires the
matching native addon; the POSIX provider path has not been exercised by the
Windows run.
Motorola 68000
rea function /absolute/path/to/image.bin 0x1000 --target-format raw-binary --architecture m68k --entry-point 0x1000 --provider ghidra --json
rea inspect-native-load-image /absolute/path/to/image.bin --target-format raw-binary --architecture m68k --entry-point 0x1000 --provider ghidra --json
Select only headerless big-endian 68000-family code with a known, even entry at
file offset 0. Ghidra's 68000:BE:32:default language decodes the 68040
superset in the 32-bit ram address space. Instructions that a real MC68000
would not execute are therefore not rejected, and 68020, 68030, CPU32, and
ColdFire programs are not admitted as those variants. Addresses are not masked
to the MC68000 24-bit bus. Evidence preserves architecture: "m68k", the
selected language, entry, file digest, and verified source mapping. Register and
calling conventions are analysis conventions, not a recovered source ABI.
This lane does not interpret Amiga hunks, Atari ST, or other container headers, cartridge or console memory maps, or bank switching. REA does not read the initial stack pointer and reset vector from the first eight bytes; select the entry explicitly. Windows Ghidra P0 does not admit m68k.
npm run verify:ghidra:m68k uses a source-owned 22-byte fixture written as
annotated hex in the verifier, so it needs no assembler. The lane checks real
CLI/MCP load-image parity, mapped bytes, a decoded call, decompilation by address
and file offset, misaligned and out-of-range mappings, unchanged source bytes and
runtime cleanup. It passed on Ghidra 12.2 with JDK 25 on macOS arm64; Linux has
not been exercised.
Intel 8051 (MCS-51)
rea inspect /absolute/path/to/bank03.bin --target-format raw-binary --architecture 8051 --entry-point 0x0 --provider ghidra --json
rea decompile /absolute/path/to/bank03.bin 0x1000 --target-format raw-binary --architecture 8051 --entry-point 0x0 --provider ghidra --json
Select headerless classic 8051 code mapped into the 16-bit CODE space.
Ghidra's 8051:BE:16:default language places the file in CODE and adds its
processor-defined REG_BANK_1…REG_BANK_4, INTMEM and SFR blocks, plus
bit-mapped BITS and SFR-BITS blocks, as uninitialized observations. No
external RAM block is created: references to external data appear as EXTMEM
addresses, but their bytes are not readable. The 80251, 80390, MX51 and CIP-51
variants are not selectable.
Evidence preserves architecture: "8051", the selected language, entry, file
digest and verified source mapping.
The lane loads one image of at most 64 KiB, mapped from the entry address.
REA does not model a bank register, overlay spaces or cross-bank calls, so a
banked image is opened one bank at a time after splitting it into bank-sized
files. When each bank is a complete 64 KiB code image, open it at 0x0. When
banks share a common area and switch only a window (for example 32 KiB pages
at 0x8000), open the bank file at the window address; the common area is a
separate target. The entry byte must decode as an instruction, since the lane
seeds an entry function there. Auto-analysis starts at that entry only, so
code reached through bank-switch thunks or Keil C51 ?C?CCASE switch tables
is not discovered. Supply known entries through REA_GHIDRA_SEED_FILE.
Windows Ghidra P0 does not admit 8051.
There is no source-owned verify:ghidra:8051 lane yet.
Limitations
- Headers are not discovered from file bytes. REA does not guess load addresses, profiles, vector-table locations, or memory maps.
- Big-endian ARM is unsupported; m68k and 8051 are the big-endian families.
architecture_variantnames only the ARM M profiles; no other processor of a family, such as the 65C02 or ColdFire, can be selected. - An M-profile load maps one segment: the file at its base. SRAM, peripheral and
system blocks are not created, and only the Reset vector is read. Ghidra's
processor-defined vector labels are not applied, so other vectors are neither
entries nor labels; use
inspect_firmware_vector_tableto decode the full vector table and optional CMSIS-SVD IRQ names offline. Floating-point state, TrustZone and device memory maps are not modelled. - Ghidra 12.2, like 12.1.4, decodes the ARMv8.1-M low-overhead-loop branches
wlsandlewith the right mnemonics, but not their flow. In the verifier's Cortex-M55 image,wlsbranched 2 bytes short of its target,lebranched 4 bytes past the loop start, andlehad no fall-through. Code after such a loop may be left undisassembled;armv8.1-m.mainresults say so. - Reset vectors, memory-mapped I/O, and firmware boot sequences are not emulated.
- Independent load-image verification covers source identity, mapped file bytes, the bound language, and the caller-supplied entry. Original bytes stay unchanged.