* fix(ghidra)!: refuse Xtensa ELF unless .xtensa.info declares PC-relative literals Ghidra's Xtensa language computes every L32R address from the instruction's own address and never reads LITBASE, so a build with absolute (LITBASE) literals decodes to wrong literal values and references without any sign of error. Main admitted every Xtensa ELF without reading the build declaration. Target resolution now reads the `.xtensa.info` note once, by section name, and records its USE_ABSOLUTE_LITERALS and ABI declarations beside the header facts. Ghidra admission refuses absolute literals and any declaration it cannot establish, with architecture_unsupported and a reason that names the declaration. Call0 builds stay admitted and carry a limitation naming the calling-convention mismatch until a call0 lane assigns Ghidra's __call0 prototype. The header-selected language and profile from #11178 are kept. The reader, note parser, fixture and real-Ghidra lane come from #7486; its header gates, pinned language and separate guide page are not ported. BREAKING CHANGE: Ghidra now refuses Xtensa ELF files whose .xtensa.info section declares absolute literals (USE_ABSOLUTE_LITERALS=1), declares a literal or ABI value other than 0 or 1, cannot be read, or is missing. Main opened them and decoded every L32R as PC-relative. No setting restores the old behavior. * refactor(ghidra): move the processor dispatch out of the PSP profile ghidraProcessorUnsupportedReason selects each architecture's profile for every Ghidra target, so it now lives in GhidraProcessorAdmission.ts. GhidraPspProfile.ts keeps only the Allegrex predicate and the PSPSDK declaration checks, as ghidraPspUnsupportedReason. The callers' result is renamed from mipsReason to processorReason. * refactor(targets): read .xtensa.info through the shared ELF section walk The .xtensa.info lookup had its own batched section-header loop and its own cancellable file reader. It is now a declaration reader like the RISC-V one: readXtensaElfDeclarations walks the headers with visitElfSectionHeaders, and target resolution drives it with readElfDeclarations, which owns the descriptor reads and cancellation. The section-name table is copied in reads of at most 64 KiB, within the driver's window. The boundary tests drive the reader with a recording source for the bounded-request check, and check cancellation through parseBinaryTarget at the note payload read. --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
49 KiB
Ghidra provider semantics
REA imports one target into an ephemeral Ghidra database. Linux/macOS support read-only analysis and atomic function-name/entry-comment edits; Windows P0 is read-only. The Windows database-edit boundary and WSL2 fallback explain unavailable annotation, name and type-definition calls. GUI controls and writes to caller-selected source databases are unavailable. Executable bytes remain unchanged.
An opt-in owned Program checkpoint
retains analysis across Linux/macOS processes. It saves initial completed analysis
and normal-close metadata changes to REA_GHIDRA_CHECKPOINT_DIR; cancellation
and process failure recover only the last successfully saved state. The restored
packed Program's digest is reported with restored observations. Initial analysis
keeps one stable generation through its first save; later saved states bind their
content digest in profile identity. Restoration does not turn prior
database state into a fresh discovery. The default remains ephemeral.
Use installation for supported hosts, prerequisites,
configuration, startup deadlines, resource controls, and cleanup recovery.
Linux Ghidra launches also
require a procps-compatible system ps for process ownership checks.
Windows P0 has its own admission and lifecycle boundary;
NativeAOT observations include a built-in read-only PE
snapshot parser and a separate optional annotation extension. Check the
release boundary when using npm.
See import language and analysis seeds
to override the header-detected language or seed analysis. An override that conflicts with a fixed raw, DOS, PSP, MIPS, RISC-V or GameCube DOL import
is a configuration error naming the conflicting settings. It does not make an
otherwise admitted target unsupported; REA preserves the requested settings.
An inaccessible language
catalog remains a read failure; it does not prove that a configured language is
undefined. Installation application.properties has a fixed 1 MiB read allowance
with no runtime override. The failure retains that allowance and directs recovery
at the selected installation metadata.
Xtensa ELF files (EM_XTENSA = 94) use the header-selected Ghidra import
language and report the canonical xtensa architecture in CLI/MCP results.
Ghidra opens an Xtensa ELF only when its .xtensa.info section declares
PC-relative literals (USE_ABSOLUTE_LITERALS=0) and the windowed (ABI=0) or
call0 (ABI=1) ABI. GNU as writes this section and GNU ld keeps it in the
linked file. REA refuses a file that declares absolute literals, because
Ghidra's Xtensa language computes every L32R address from the instruction's
address and never reads LITBASE. It also refuses a file whose section is
missing or unreadable or declares other values. No setting changes this check.
A call0 file opens with a limitation: Ghidra's default calling convention
assumes that a8-a11, not a12-a15, keep their values across a call. A 0
declaration states the toolchain's literal mode; it does not prove that
hand-written code never sets LITBASE. Processor extensions and
calling-convention compatibility remain specific to the selected Ghidra
language; family recognition alone does not establish them.
Retained process diagnostics can report termination by SIGKILL; the signal alone
cannot establish an OOM kill. REA gives neutral recovery guidance and preserves the
signal. Confirm resource causes from process output or host/container records;
operation-scoped JVM OutOfMemoryError observations retain their separate resource
classification. Automatic kernel or cgroup OOM attribution is not implemented.
After the authenticated startup handshake, rejected inputs (invalid_request,
not_found, ambiguous, an invalid function name, or an address without one
exact file offset) use
diagnostics.diagnostic_scope: "request" when their active output checkpoint is
available. They preserve the active request's
failure_output, target/profile identity and runtime/log coordinates, while
omitting cumulative launcher stdout/stderr and launch-support output. Startup,
process, protocol and other remote failures retain full session diagnostics.
The Ghidra client still owns its bounded cumulative output; this projection does
not clear it or alter session readiness. Log paths refer to the owned ephemeral
runtime and are removed by normal cleanup.
Provider selection and profile identity follow MCP contracts. One deep provider stays bound to the target; runtime failure never selects another provider automatically. The contracts below describe Ghidra observations, not equivalence with another engine's pseudocode or analysis database.
Request payload ceiling
Ghidra requests use REA_BRIDGE_MAX_REQUEST_BYTES: default 16 MiB, with a
configurable range of 7,464–536,870,887 bytes. REA measures UTF-8 JSON, including
escaping, before allocating the serialized request or sending it. The framing
newline is excluded. An oversized request returns resource_constraint with
the effective setting, its source, and the exact payload byte count.
bridge.max_request_bytes can be changed at runtime with
update_analysis_settings. The launch seed is REA_BRIDGE_MAX_REQUEST_BYTES.
This setting is enforced by the REA client; the Java bridge has no corresponding
request ceiling.
Admitted inventory semantics
| Concern | Ghidra contract |
|---|---|
| Program identity | One analyzeHeadless import produces exactly one Program; list_documents therefore returns exactly one name. |
| Addresses | Default memory uses lowercase 0x hexadecimal. Non-default and external spaces use <percent-encoded-space>:0x<hex> and remain round-trippable. The handshake commits image base and default address-space name. |
| Symbols | list_names includes address-bearing memory and external symbols, including dynamic symbols, while excluding variable and no-address namespace records. Each item reports primary, dynamic, external, symbol type, and source facts. |
| Procedures | Both non-external and external functions are listed. A local thunk remains distinct from its resolved target; exact and qualified name lookup fails on ambiguity rather than guessing. |
| Strings | Only Ghidra-defined string Data is observed. Items report charset, byte length, and whether a required null terminator is missing. The API cannot distinguish a present terminator from fixed/Pascal layouts when no terminator is missing, so that state is named present_or_not_required. |
| Memory | Memory-block end addresses are exclusive. Read/write/execute, initialization, overlay, address space, and image base are direct Ghidra observations, after any memory-map preparation a lane documents, such as the RISC-V load layout. |
| Inventory | Procedure, symbol, and string listings plus searches return the complete matching collection in one response; callers do not provide offsets or result-count limits. |
| Search | Literal and Java-regex searches return every match in the immutable provider-defined inventory; string search does not cover every text sequence in artifact bytes. Search waits for a reply or caller cancellation; there are no caller-supplied offsets or result-count limits. |
| Analysis state | The socket is exposed only after default auto-analysis completes. Established operations wait for their reply or caller cancellation; there is no fixed response-size ceiling. |
String-search completeness applies only to Ghidra-defined string Data. Packed
or undefined literals, including Rust strings, may be absent; an empty result
does not prove text is absent. Both list and search Evidence carry this
limitation. When an address is known, use read_bytes and xrefs to inspect
bytes and references.
String searches and trace_feature retain each matched row's Ghidra-reported
encoding, termination and byte length. These describe the database's defined
data, not independent proof of the original source encoding. Procedure searches
and trace matches likewise retain Ghidra's external and thunk classification.
The Ghidra analysis profile identifies this search projection, so older
snapshots with unqualified search rows cannot replay under the new profile.
Decompiler and value-flow budgets
Use inspect_analysis_settings or a result's named recovery to inspect
ghidra.value_flow_max_operations (default 3000),
ghidra.value_flow_max_inputs_per_operation (default 64), and
ghidra.value_flow_max_edges (default 12000). Each accepts a positive Java
integer count. update_analysis_settings applies changes to the next operation
on the same Program without restarting REA. Launch seeds use the corresponding
REA_GHIDRA_VALUE_FLOW_MAX_OPERATIONS,
REA_GHIDRA_VALUE_FLOW_MAX_INPUTS_PER_OPERATION, and
REA_GHIDRA_VALUE_FLOW_MAX_EDGES environment settings.
For a one-shot CLI retry, set the named seed in the environment that launches
the next rea invocation; the completed invocation's Program is no longer
active. Runtime MCP changes preserve the current Program. A changed launch seed
only affects a running MCP server after that server restarts.
The returned native_value_flow.limits and limits_reached distinguish accepted
budgets from actual exhaustion. Truncation keeps omitted counts and names the
setting to adjust. The edge budget applies independently to def-use and
parameter-use collections. New function dossiers are reobserved rather than
replayed from snapshots; completed Evidence remains available for historical
inspection. Other observation caches keep their existing policy.
ghidra.decompile_max_payload_mib controls the native decompiler's response
payload, separately from p-code projection and decompile time. Its launch seed
is REA_GHIDRA_DECOMPILE_MAX_PAYLOAD_MIB; explicit values are 1..2047 MiB to
avoid overflow in Ghidra's signed integer byte conversion. Omission or runtime
null preserves the installed provider's default. Changes apply before the
next native decompile, and native option changes clear its old cached function
state. A failed decompile preserves the original diagnostic and reports the
effective payload allowance; payload recovery applies only when that diagnostic
identifies payload exhaustion. Raising these controls does not raise the MCP
client's deadline or receive buffer.
C text for signatures and type definitions
annotate_native_function signature and define_native_data_types
declarations are parsed by Ghidra's C parser, which cannot be cancelled, so
REA bounds that text before parsing it. Each bound has a per-call parameter;
parenthesis_max_depth applies to signature; a declarations text admits parentheses only in a function-pointer declarator, ret (*name)(parameters), which nests one level and needs no bound.
| Bound | Default | Floor | Maximum | Slowest measured parse at the maximum |
|---|---|---|---|---|
signature_max_utf16 (UTF-16 code units) |
2048 | 16 | 4096 | 0.8 s (one chain of pointer declarators) |
declarations_max_utf16 (UTF-16 code units) |
4096 | 16 | 8192 | 6.8 s (one chain of pointer declarators) |
parenthesis_max_depth (signature, levels) |
8 | 1 | 12 | 2.2 s (8192 units of 12-level expressions) |
Measured with Ghidra 12.2 on arm64 macOS; other hosts differ. Parse time is
cubic in the length of a declarator chain (16384 units took 100 s) and doubles
with each level of nested parentheses (12 levels took 2.2 s), so the maxima
are fixed. A text over a bound is refused before parsing with
code: "resource_constraint"; details.limit carries
control_kind: "parameter", the parameter, its effective value, range,
default and required_value: the text's length, or its deepest nesting over
the whole text. The recovery names the larger value to pass, or asks for
shorter or flatter text, or several calls, when the need is above the maximum.
A type chained more than 256 levels deep through pointers, arrays, typedefs
or members, counting existing database types, is refused with
details.refusal.kind: "fixed_ceiling" and the measured depth of the whole
chain. Because the depth counts through typedefs and existing types, naming
intermediate types or splitting definitions across calls does not reduce it;
only fewer nested levels do. Ghidra 12.2 stores, names and
compares types recursively: 1024 levels resolved and 2048 exhausted the stack
inside addDataType while its database lock was held, leaving the Program
unable to save. No caller value raises that stack, so the bound is fixed.
The parser walks a pointer declarator recursively and can exhaust HotSpot's
1 MiB default thread stack before that measurement runs, so caller C is parsed
on a 16 MiB stack: twice the 8 MiB main-thread stack that completed an
8192-unit pointer chain. The refusal is that walk's measured depth. A parse
that still overflows the 16 MiB stack is the same fixed ceiling, without a
measured depth or type name. An overflow while the database lock is held still
ends the session.
The bridge also refuses, with the construct's line and column (CR, LF and CRLF each end a line, as in Ghidra's parser), what its parser would accept without applying; see the native guide.
PE debug-symbol coverage
The post-analysis handshake reports Ghidra's PDB Program Information attributes:
the referenced file, GUID, hexadecimal age, legacy signature, version, and
PDB Loaded state. Absent attributes remain null. PE Evidence carries a
limitation when a PDB reference is present but Ghidra reports it as not loaded,
or its load state is unknown. A bridge without this report leaves PDB coverage
unknown. A reported loaded state is a Ghidra observation, not an independent
PDB identity or complete symbol-coverage attestation, and retains an inline
coverage caveat. Handshake PDB strings share a 4096 UTF-16-unit serialization
budget (at most 24 KiB after JSON escaping); whole attributes that do not fit
are omitted with an explicit resource limitation, rather than truncated.
When the CodeView path's text encoding is unknown, the caveat identifies that
uncertainty and retains the original path bytes in hex when they fit the inline
locator budget. This observation is independent of Ghidra's reported filename.
Original names and types may be missing even when auto-analysis completes.
An empty name search does not establish that a function is absent; use
list_procedures and address-based analysis to inspect recovered functions.
REA imports a private executable copy and does not admit a caller-selected
PDB companion. This reporting does not search symbol servers, copy a sibling
PDB, or change analyzer settings.
Loaded addresses and file offsets
Ghidra computes overview procedure and string counts from the same inventories
used by list_procedures and list_strings, without transporting those rows
solely to count them. Counts include external functions and only Ghidra-defined
strings; they do not establish discovery of unidentified functions or undefined
string bytes. Complete inventories remain available through the list tools.
Overview reuse follows the target/profile snapshot lifetime and is invalidated
by session metadata edits.
rea analyze <path> --provider ghidra --json and MCP binary_overview report
the observed loaded image_base in normalized_result. They retain each
segment's reported image_base and address_space. A provider that does not
report a base, or whose segments disagree, omits the overview field, following
the existing contract on main. REA does not substitute zero or the first
segment's address. All reported bases and address spaces remain visible in the
complete segment inventory, including conflicting observations.
function and most MCP procedure selectors use procedure names or
provider analysis addresses. Ghidra decompile / MCP procedure_pseudo_code
also accept source-file byte offsets. Existing symbols and analysis addresses
take precedence; a 0x-prefixed number that resolves to no procedure falls back
to its observed source mapping. Use --file-offset=0x... on the CLI or
procedure: "file-offset:0x..." through MCP to select file coordinates explicitly.
To select an analysis address without the bare-hex fallback, qualify it with its
Ghidra address space, for example ram:0x.... The inspect-native-load-image
CLI command or MCP inspect_native_load_image reports Ghidra's observed default
address space; use the space appropriate to the address, and retain any
load-image verification limitations.
Multiple mapping candidates fail as ambiguous rather than selecting a bank or
address space. A successful conversion retains the file offset, mapped address
and procedure entry in raw Evidence and locations.
Ghidra can disassemble code without creating a function for it. A range named
only by an exception-frame entry and reached through a data reference is one
case: main in a stripped ELF is passed to __libc_start_main as a pointer
and never called. Such an address is absent from list_procedures. When a
decompile selector names an analysis address that holds disassembled code
outside every function, procedure_pseudo_code decompiles it on the fly from
an entry found by following control flow back from that address, the way
Ghidra's decompiler panel does. The Program and the procedure inventory are
unchanged, and the result's limitations state that the entry and extent are
inferred rather than an analyzed function boundary. This reading takes
precedence over the file-offset fallback. A file offset that maps to such code
resolves the same way as its mapped address; its selection reports the
inferred entry as procedure_address. Other procedure operations still
require a function and say when the address holds code without one.
Completed decompilations are reused while the Program is unchanged, so
repeating procedure_pseudo_code or analyze_function for one function does
not run the native decompiler again. A rename, comment or payload-limit change
discards them.
decompile-all and batch_decompile name the next functions they will
request, up to 32 at a time, and the bridge decompiles them in the background
with up to eight native decompiler processes. Results, per-function failures,
the journal and file order are the same as a serial run. The request that names
them decompiles its own function at once on the session's decompiler and never
waits for a worker to start. Workers start only for the queued functions, one
per function up to eight, and none for a single function. Each takes the next
queued function as soon as its decompiler is open. A later request uses a
finished result for its function, including a failure or timeout, without
decompiling it again; waits for one still running, whose own decompile deadline
bounds the wait; or decompiles a queued one itself. Cancelling that request
cancels the read-ahead. Selectors beyond 32 are ignored. The workers run on
REA's own threads, separate from Ghidra's shared pools, and close their
decompiler processes after 30 seconds without work, a Program edit, a
payload-limit change, cancellation or shutdown. Each worker is a native
decompiler process, so a large batch uses more CPU and memory while it runs.
If an offset maps to loaded target bytes but no procedure starts at or contains the mapped address, the failure preserves both the original file offset and analysis address. This differs from an unmapped offset and does not recommend retrying the same offset syntax. If the function resolves but the backend fails or cancels decompilation, the failure retains the selector, mapped address and procedure entry without changing the backend failure code.
Active request cancellation
Cancelling a request that is still queued removes it without touching the session. Cancelling the request Ghidra is working on depends on the operation:
| Active operation | Cancellation |
|---|---|
| Reads: every operation except the edits below | REA sends the bridge a cancel frame naming the request and waits up to the cancel grace (2,000 ms by default) for that request's reply. A decompilation (procedure_pseudo_code, analyze_function) stops its native decompiler and answers at once; other reads answer when they reach a cancellation check or finish. Once the reply arrives the call returns a cancellation, and the session, its annotations and the requests queued behind it stay. |
Edits: annotate_native_function, set_address_name, set_addresses_names |
Not interrupted. REA closes the session, so a reply that raced the cancel cannot leave a committed edit behind a cancelled call. |
The bridge reads the connection on one extra thread, which only cancels the
named request's Ghidra TaskMonitor; requests still run one at a time on the
script thread, and a cancel frame has no reply of its own. The reply to the
cancelled request is the confirmation. If none arrives within the cancel grace,
or the request fails without a bridge reply, REA closes the session exactly as it
does for an edit: the Ghidra process is stopped, queued requests fail, session
annotations are discarded, and the next provider query starts a new session
(restoring the last checkpoint when one is configured). A result that raced the
cancel is discarded and the call still returns a cancellation; a bridge failure
other than the cancellation that raced it stays the reported failure, with the
session kept.
The cancel grace is 2,000 ms by default. Set REA_GHIDRA_CANCEL_GRACE_MS to
an integer from 100 to 60,000 milliseconds in the environment that starts REA
to change it. The floor is about five times the slowest acknowledgement
measured with real Ghidra 12.2 (19 ms); a shorter grace closes sessions that
would have answered. The maximum is one minute, the pinned MCP client SDK's
default tool-call deadline: while the grace runs, the cancelled call has not
returned and the requests queued behind it wait, so a stuck bridge delays all
of them by the whole grace. REA reads the value when it starts and each session
keeps the grace it opened with, so a change needs a restart;
update_analysis_settings does not change it and inspect_analysis_settings
does not list it. A fresh-import session's cancellation limitation states the
value applied and whether it is the default or was set at launch. When the
grace expires, the requests queued behind the cancelled one fail with a message
naming the control, the value applied, its source and the range. An empty,
malformed or out-of-range value does not fall back to the default:
rea doctor and registration validation report it, REA still starts, and a
Ghidra session refuses to open with configuration_invalid until it is
corrected.
Both mapping directions require a complete original FileBytes source whose
SHA-256 matches the admitted target. Auxiliary files and partial source objects
remain visible in the load-image inventory but do not establish offsets in the
original target. Ghidra's object-local offsets are not silently treated as
original-file coordinates. Original-source identity is checked once per source
object per session; analysis-memory edits do not change the original bytes.
ELF virtual addresses and file offsets are
different coordinates. Ghidra can rebase a PIE ELF during import: in the
source-owned verification fixture, ELF entry 0x1013 becomes Ghidra procedure
0x101013 with image base 0x100000. That example is not a general conversion
rule.
Use list_procedures to select an observed procedure address. To relate file
bytes to loaded memory, call MCP inspect_native_load_image or:
rea search <path> . --kind procedures --mode regex --provider ghidra --json
rea inspect-native-load-image <path> --provider ghidra --json
rea decompile <path> <observed-procedure-address> --provider ghidra --json
rea decompile <path> --file-offset=0x1013 --provider ghidra --json
rea address-to-file-offset <path> <observed-procedure-address> --provider ghidra --json
The load-image result preserves source-file indexes, file offsets, address
spaces, and inclusive mapping ranges. Follow the mapping for the selected
source file and region; adding image_base to an arbitrary file offset is not
valid. For a linear byte-addressed, file-backed mapping, a file offset F in
[mapping.file_offset, mapping.file_offset + mapping.length) maps to
mapping.start + (F - mapping.file_offset) in the reported address_space.
If several mappings cover the same file offset, keep those candidates distinct
and select the procedure from the observed inventory. Uninitialized regions may
have no file backing. ELF mappings are observed
without independent format-specific load-image verification, as the result's
status and limitations state.
Relocation rows retain Ghidra's symbol value, including an empty string or
null when returned by Ghidra. It is a provider observation, not proof of the
runtime-resolved address. Every relocation row records the field.
For large relocation inventories, select MCP inspect_native_load_image with
detail: "summary". It returns verification state, observed identity and counts,
while retaining complete Evidence. Use normalized_result.parent_evidence_id
with inspect_analysis_view and a view such as:
{
"kind": "native-load-image",
"collection": "relocations",
"offset": 0,
"limit": 32,
"fields": ["address", "status", "type"]
}
Collections are source_files, mappings, relocations, entry_points,
entry_context, checks and DOL sections. Optional
indices select original row indices before paging; empty indices select none.
Fields are collection-specific. Relocation defaults omit byte payloads; check defaults omit potentially large expected/observed inventories. Request those fields explicitly when needed. Other collections default to all fields. Metadata recovery remains counted and retained in complete parent Evidence.
Parent Evidence, collection and source_index identify a row, including same-address
relocation alternatives. Null counts or rows mean unrecorded or inapplicable;
they never establish an empty observation. Exhausting a page does not upgrade
unsupported verification or runtime coverage. Pages query immutable retained
facts without reopening the target or repeating Ghidra work.
Each page carries the source's structured verification_status independently
of its page coverage.
CLI summary delivery requires a complete Evidence bundle:
rea inspect-native-load-image <path> --provider ghidra --detail summary --evidence_output /new/load-image.json --json
Read selected pages later through inspect-analysis-view using the returned
parent ID and an evidence-file source pointing to that bundle. Complete
delivery remains the default in both adapters.
An unsuccessful numeric procedure lookup reports the current Ghidra image base
and gives the CLI commands above alongside the corresponding MCP operations.
Repeat any target-format, architecture, and entry-point options used to open the
target. Other procedure operations keep their analysis-address semantics;
file-offset fallback applies only to decompilation. A bare selector outside
every mapped analysis address that also has no file-offset mapping fails with
procedure_not_found. An explicit file-offset: selector, or a mapped address
without code, fails with file_offset_unmapped.
Overview workflow revision 3 binds this output to snapshot identity. Older serialized overview Evidence remains readable; it is not replayed as a current overview merely because its source artifact is unchanged.
Admitted function-analysis semantics
Concurrent callers share one startup while retaining independent cancellation. Only the final departing caller abandons startup and waits for its cleanup. New attempts wait for that cleanup; failed cleanup retains its original error and owned directories until a successful close. Closing the provider reports a provider-state failure to live callers rather than cancelling their signals.
Configured analysis extensions and seeds use owned file reads during profile resolution and launch snapshots. A changed read extent or descriptor state refuses the commitment. Failed source or snapshot descriptor closes remain owned and block new admission until cleanup succeeds; the physical failure and exact cancellation reason remain available. Provider shutdown joins all profile stages before retrying their retained descriptors.
| Concern | Ghidra contract |
|---|---|
| Decompiler lifetime | One persistent DecompInterface is opened for the imported Program and disposed during bridge shutdown. Native decompilation has no fixed per-function deadline unless the launch setting REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS or runtime override ghidra.decompile_timeout_seconds sets one; a decompile that reaches it fails only that request with remote_code decompile_timed_out, the Program and session stay open, and the next decompile uses a fresh decompiler process. External functions or functions without bodies return null; cancellation and native failure remain distinct. |
| Serialization | A FIFO sends one Program request at a time. Caller cancellation removes queued work promptly. Cancelling the active request follows active request cancellation. This is an adapter safety commitment, not a claim that every Ghidra API is thread-safe. |
| Function identity | Every function result carries the entry address and Ghidra FunctionManager classification for external, thunk, and resolved thunk target. These are observations, not proof that unresolved targetless calls have been recovered. |
| Assembly and pseudocode | Assembly is complete Ghidra Listing text; pseudocode is Ghidra decompiler output. Neither is original source, and cross-provider comparison never treats Hopper and Ghidra text as equal or unequal semantic facts. |
| Instruction fast path | read_function_instructions returns every raw Listing instruction for the requested function without invoking the decompiler or whole-program name/string inventories. |
| Calls and references | Callers/callees contain only resolved functions. Reference edges preserve exact ReferenceManager type and call/jump/data/read/write/indirect/computed/conditional/terminal/external facts. Targetless computed flow remains unknown. A computed call's recorded targets stay observed callees, but they are static candidates rather than an exhaustive set, so callee coverage is partial and names those call sites. Synthetic entry-point references without actionable memory sources are omitted explicitly. |
| CFG | Dossiers use BasicBlockModel and retain only non-call successors inside the function body. CFG topology is address-normalized for comparison; provider-specific block construction remains a declared difference. |
| P-code value flow | Function dossiers include up to 3,000 high-p-code operations, at most 64 inputs per operation, and 12,000 def-use edges. Results identify memory reads/writes, branches, and calls by p-code opcode, and mark decompiler-dead operations. Large results report truncation, an omitted-operation lower bound, and known omitted-input/edge counts. The dossier is an intra-function graph; trace_native_values composes derived parameter/argument and return/output dependencies across resolved calls. It does not resolve memory aliasing, call side effects, runtime behavior, persistent state, or business meaning. |
| Result extent | Function instruction scans and native API boundary observations remain complete. P-code flow is the explicit bounded exception; its count fields distinguish exact retained counts from lower-bound or known-omitted counts. Caller cancellation and provider failures remain distinct. |
Runtime updates apply to newly accepted operations on the existing Program. They preserve accepted budgets and do not clear cleanup blockers or change the client deadline. Transient decompile timeout failures remain uncached so the same function can be retried after raising the limit. See the analysis settings and recovery for precedence and lifetime.
Every Ghidra analysis profile commits producer: the REA release and a SHA-256
of the packaged bridge scripts. A snapshot replays only under the same
producer, so after an REA upgrade or a bridge script change an older snapshot is
refused; open the target without it and save a fresh snapshot.
When inspect_native_instruction selects a byte inside a listed instruction,
containing_instruction reports its separate start, length and Ghidra Listing
text, retaining any non-default address space. The requested address remains
unchanged, and a containing function may be absent. For defined data, the same
tool reports its containing object's start, length and type path; use the start
with inspect_native_data_type to inspect its layout. This does not select a
field or union member. These are listing observations, not proof of execution or
an alternate decode. Earlier Evidence can
omit the field. The analysis-profile revision prevents older snapshots from
replaying results without it; open the target without the old snapshot and save
a fresh snapshot when needed.
Function extents and instruction completeness refer to Ghidra's analyzed body.
An inferred no-return call can terminate that body before subsequent bytes.
Pseudocode, assembly, procedure info, instruction windows, incoming and outgoing
references, callee and caller reads, and dossiers report observed terminal call sites in Evidence limitations,
including resolved callee names, addresses, and FunctionManager flags when
available. On x86-32, the same views also report the exact Borland/Delphi-style
FS exception-registration pattern when its handler address falls outside the
function body. This is a static registration observation; it does not establish
handler execution or change the body. Instruction windows and dossiers also
retain these warnings in their result limitations. An unresolved callee or
unestablished terminal-flow basis remains explicit. These observations qualify
the analysis; they do not prove that a no-return flag is incorrect or recover
excluded code. When the callee's entry, or the function a thunk forwards to,
carries the Non-Returning Function Found analysis bookmark that Ghidra's
Non-Returning Functions - Discovered analyzer writes, the call's limitation
says the flag was inferred, and the function's limitations add one statement
that Ghidra excluded that call's fall-through from the body and pseudocode, so
code reachable only through it is missing if the callee returns. That analyzer can mark returning callees, such as an
imported operator new thunk, so a constructor may decompile to a few lines. To
compare, open a fresh import with
REA_GHIDRA_DISABLED_ANALYZERS='Non-Returning Functions - Discovered'; an
existing project (REA_GHIDRA_PROJECT_PATH) keeps the flags its analysis
already stored. A flag without that bookmark keeps an unknown origin; REA does
not treat it as declared. Analysis profiles version this observation contract so older
snapshots cannot replay unqualified results.
On non-Windows hosts, the ephemeral import repair clears no-return flags on the
known returning external ABI names malloc, __tls_get_addr, memcpy, memset,
strlen, and __errno_location. This relies on their expected ABI behavior;
external implementations are not inspected. The repair re-disassembles affected
terminal calls and refits their owning functions, preserving independent function
entries. If a recovered caller reveals a decoded return, its propagated no-return
flag and affected callers are repaired in the same pass. Unknown imports and
genuine no-return imports keep their flags. Analysis profiles version this repair
so snapshots produced before it are not reused. Windows P0 does not run it.
Ghidra applies most loader relocations, but it cannot apply some, such as an
ELF copy relocation into RELRO (for example musl's stderr) or a TLS slot that
only the runtime loader fills. Those destinations keep their file bytes while
the runtime loader writes another value. Before decompiling, a fresh
non-Windows import marks each such destination in a loaded, initialized,
non-writable block volatile in the ephemeral database, so the decompiler
cannot fold the on-disk value into a constant. Volatility is set on the
destination's own data item (an undefined item of the relocation's length is
created where nothing is defined), so applied relocations in the same block,
such as the GOT entries beside a TLS slot, stay foldable and external calls
keep their names. Only when an instruction or a data item starting before the
destination occupies it is the whole block marked volatile instead.
Permissions and source FileBytes are unchanged. A procedure that reads an
unapplied destination adds a limitation naming the relocation. Windows P0 and
existing projects (REA_GHIDRA_PROJECT_PATH) have no database-mutation
authority: they add the same limitation, but their pseudocode may still show
the file-backed value. ELF relocatable objects and core files are excluded.
Analysis profiles version this behavior.
npm run verify:ghidra compiles the versioned C oracle into debug and stripped
host-native targets (x86-64/AArch64 ELF on Linux or Mach-O on macOS), plus a native
DWARF 4 type-layout object. It proves the admitted operations, external functions, resolved thunks, exports, stripped-name
behavior, direct and targetless indirect calls, typed references, strings/xrefs,
multi-block CFG, bounded p-code def-use/effect links, semantic enhanced workflows, cancellation, startup deadlines,
serialized concurrency, malformed-target rejection, profile identity, and
process/project cleanup. Its namespace-annotation check also needs the host's
GNU demangler native component (demangler_gnu_v2_41 under
GPL/DemanglerGnu/os/<platform>/); the Ghidra 12.2 release ships it only for
linux_x86_64 and win_x86_64, and REA does not build it. Recorded on Ghidra
12.1.4 (no longer accepted); not yet re-run on 12.2. A 12.2 run on macOS arm64
stopped at that missing demangler. Unit fixtures separately cover startup deadlines, process
exit, queued cancellation, and malformed wire output.
npm run verify:ghidra:cross-format adds AArch64 ELF, x86-64 PE, and x86-64
Mach-O target coverage. It requires clang, LLD, and lld-link; set
REA_CLANG, REA_LLD, or REA_LLD_LINK to select them. The verifier checks
these tools before compilation. Keeping this matrix separate lets Linux
host/provider acceptance run with only the host compiler.
npm run verify:ghidra:windows checks source-owned native x86-64 PE applications;
-- --x86, -- --arm, or -- --arm64 selects another target architecture;
-- --dll selects DLLs. Choose one architecture and optionally combine it with
--dll. These static fixtures contain source-owned encoded instructions; they
are not compiler-produced programs. See the Windows verification scope
for real-provider coverage and exclusions.
These lanes check all 27 read-only operations, target/snapshot/import SHA-256 linkage,
and project, endpoint, process, and runtime cleanup. The independent native
lane checks DACLs, handle admission, cancellation, and Job Object lifecycle.
npm run verify:ghidra:windows:package packs and installs REA into an isolated
prefix, then checks ordinary-user CLI/MCP operations against canonical contracts.
It accepts the same architecture and DLL flags and verifies the selected PE role
in the analysis profile.
All lanes require matching native controls; package startup alone establishes
only package compatibility.
Masked byte search
search_bytes (rea search-bytes PATH '48 8B ?? ?? 89' --provider ghidra)
searches initialized analyzed memory, including loader fixups. Supply hexadecimal
byte pairs, with ?? for any byte. An optional equal-length hexadecimal mask
selects bits: pattern: "a0", mask: "f0" matches bytes from a0 through af.
Wildcards remain unconstrained even with an explicit mask. At least one bit
must be constrained.
Optional start and end addresses are inclusive and select one address space.
A match must end at or before end, so end set inside a match excludes it.
Without bounds, loaded non-overlay memory blocks are eligible, in Ghidra address
order, including across adjacent initialized blocks. Blocks that are not loaded
(file parts such as .symtab) are listed in searched.skipped_not_loaded;
loaded overlay blocks are listed separately in searched.skipped_overlays.
Neither is searched by default; pass start or end in its address space to
search it. A block that is both unloaded and an overlay is listed once under
skipped_not_loaded.
The separate overlay field changes the byte-search result contract and the
Ghidra analysis profile. Refresh cached MCP schemas; snapshots from the older
profile are not replayed. Previously exported Evidence remains importable as
historical data with its original result shape.
Overlapping matches are included, including across adjacent eligible initialized
blocks in the same address space. Gaps and excluded or uninitialized blocks break
a search run. Each match reports its address, starting segment, unique source file
offset for that starting address (or null), and containing procedure (or null).
A starting offset does not imply the full match is contiguous in the file.
Pages default to 100 matches and accept 1 to 1000. Pass next_cursor as cursor
with the same target, analysis profile or selected project, pattern, mask,
bounds, and document to continue. A cursor from a different binding is
rejected. The message names those bound values and states that the cursor does
not identify which one differs; select the original context or start a new
search without the cursor. The request matches the input schema, so the error
carries no inspect_input_contract recovery. details.issues[0].path is
cursor, and details.issues[0].observed.differing_component is unknown.
complete means no further matches remain. searched.blocks and
searched.bytes describe the inclusive memory ranges examined for this page,
including lookahead for the next match. Coverage can overlap between pages; do
not sum it as unique memory.
searched.skipped_uninitialized lists eligible uninitialized blocks on every
page. These blocks are never searched. Cancellation returns a typed error,
discards the active Ghidra database, and does not return a successful partial page.
Hopper byte search remains unavailable until its implementation is verified.
MIPS16 shared-image admission requires examined dynamic REL declarations.
RELR dynamic tags or nonempty SHT_RELR sections leave relocation coverage
unavailable and the profile unsupported; REA does not infer an empty relocation
set from the absence of REL declarations. RELR loader semantics have not been
verified for this lane.