feat(ghidra): add function analysis and conformance
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# Ghidra conformance corpus
|
||||
|
||||
These source-owned fixtures are compiled at verification time; generated
|
||||
binaries and Ghidra projects are never committed.
|
||||
|
||||
- `inventory.c` produces separate x86-64 debug and stripped ELF executables.
|
||||
It covers imports, an external `puts` function, linker thunks, source symbols,
|
||||
direct calls, a targetless callback call, two referenced strings, and a
|
||||
multi-block branch.
|
||||
- `cross-format.c` is freestanding so the verifier can produce AArch64 ELF,
|
||||
x86-64 PE, and x86-64 Mach-O targets from the same semantics. It preserves an
|
||||
exported entry, direct and indirect calls, a volatile string reference, and a
|
||||
multi-block branch across loaders.
|
||||
|
||||
`scripts/verify-real-ghidra.mjs` uses `cc`, `clang`, and `lld-link` by default;
|
||||
`REA_CC`, `REA_CLANG`, and `REA_LLD_LINK` can select alternate commands. The
|
||||
verifier requires an exact bring-your-own Ghidra 12.1.2 installation through
|
||||
`GHIDRA_INSTALL_DIR` and validates header classification before starting the
|
||||
provider.
|
||||
|
||||
Conformance compares semantic facts: provider/profile identity, function
|
||||
classification, resolved call edges, typed references, strings/xrefs, and CFG
|
||||
topology. It only requires provider pseudocode and assembly to be non-empty,
|
||||
bounded, and address-bearing; it never compares their text with Hopper. The
|
||||
callback fixture also proves that an unresolved targetless flow is not silently
|
||||
promoted to a direct callee. Every target runs in a separate owned project and
|
||||
must leave no process, socket, project, or runtime root after close.
|
||||
@@ -0,0 +1,31 @@
|
||||
typedef int (*rea_cross_callback)(int);
|
||||
|
||||
volatile int rea_cross_global = 7;
|
||||
const volatile char rea_cross_message[] = "REA_GHIDRA_CROSS_FORMAT";
|
||||
|
||||
__attribute__((noinline, used)) int rea_cross_leaf(int value) {
|
||||
return value + rea_cross_global + rea_cross_message[0] - 'R';
|
||||
}
|
||||
|
||||
__attribute__((noinline, used)) int rea_cross_branch(int value) {
|
||||
if (value > 10) {
|
||||
return rea_cross_leaf(value);
|
||||
}
|
||||
return rea_cross_leaf(-value);
|
||||
}
|
||||
|
||||
__attribute__((noinline, used)) int rea_cross_indirect(
|
||||
rea_cross_callback callback, int value) {
|
||||
return callback(value);
|
||||
}
|
||||
|
||||
__attribute__((noinline, used, visibility("default"))) int rea_cross_entry(void) {
|
||||
return rea_cross_branch(35) + rea_cross_indirect(rea_cross_leaf, 0);
|
||||
}
|
||||
|
||||
__attribute__((used, visibility("default"))) void rea_cross_start(void) {
|
||||
volatile int result = rea_cross_entry();
|
||||
(void)result;
|
||||
for (;;) {
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,22 @@ __attribute__((noinline, used)) int rea_ghidra_inventory_leaf(int value) {
|
||||
return value + rea_ghidra_inventory_global;
|
||||
}
|
||||
|
||||
__attribute__((noinline, used)) int rea_ghidra_inventory_entry(void) {
|
||||
puts("REA_GHIDRA_INVENTORY_ENTRY");
|
||||
return rea_ghidra_inventory_leaf(35);
|
||||
__attribute__((noinline, used)) int rea_ghidra_inventory_branch(int value) {
|
||||
if (value > 10) {
|
||||
return rea_ghidra_inventory_leaf(value);
|
||||
}
|
||||
return rea_ghidra_inventory_leaf(-value);
|
||||
}
|
||||
|
||||
int main(void) { return rea_ghidra_inventory_entry() == 42 ? 0 : 1; }
|
||||
__attribute__((noinline, used)) int rea_ghidra_inventory_indirect(
|
||||
int (*callback)(int), int value) {
|
||||
return callback(value);
|
||||
}
|
||||
|
||||
__attribute__((noinline, used)) int rea_ghidra_inventory_entry(void) {
|
||||
puts("REA_GHIDRA_INVENTORY_ENTRY");
|
||||
return rea_ghidra_inventory_branch(35) +
|
||||
rea_ghidra_inventory_indirect(rea_ghidra_inventory_leaf, 0);
|
||||
}
|
||||
|
||||
int main(void) { return rea_ghidra_inventory_entry() == 49 ? 0 : 1; }
|
||||
|
||||
Reference in New Issue
Block a user