From 1a3874529534750c5b7acfc4366c16db5d96c80e Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sat, 24 Oct 2026 02:57:11 +0800 Subject: [PATCH] refactor(ghidra): centralize shared profile commitments Give raw and header-selected imports one owner for their twelve identical semantic revision declarations. Preserve property order, parameter values, omissions and all provider/language/processor override precedence. Validation: Ghidra behavior and MIPS/RISC-V/PowerPC profile suites passed. Seventy direct before/after cases retained identical Results, serialization, parameter order and digests. No real Ghidra process verification was performed. --- src/ghidra/GhidraAnalysisProfile.ts | 49 +++++++++++------------------ 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/src/ghidra/GhidraAnalysisProfile.ts b/src/ghidra/GhidraAnalysisProfile.ts index 0bee3ec6a3..f21c5b4849 100644 --- a/src/ghidra/GhidraAnalysisProfile.ts +++ b/src/ghidra/GhidraAnalysisProfile.ts @@ -45,10 +45,22 @@ import { NATIVE_AOT_PROFILE_CONTRACT_REVISION, } from "../domain/native/nativeAotPe.js"; -const callRelationshipCoverage = "function-body-call-coverage-v5"; -const functionBoundaryObservations = "ghidra-function-boundary-limitations-v4"; -const instructionReferenceCoverage = - "exact-address-incoming-without-synthetic-entry-v2"; +/** Shared analysis commitments for raw and header-selected imports. */ +const sharedAnalysisSemantics = { + annotation_policy: "atomic-function-entry-metadata-v1", + load_image_observations: "source-mappings-entry-context-v2", + function_body_evidence: "complete-inclusive-ranges-v1", + function_references: "complete-body-and-entry-reference-manager-v2", + call_relationship_coverage: "function-body-call-coverage-v5", + function_dossier_coverage: "observed-facets-and-call-relationships-v1", + string_inventory_evidence: "defined-data-coverage-v1", + location_resolution: "explicit-address-exact-entry-symbol-first-v3", + procedure_file_offset_resolution: + "address-first-unique-target-source-mapping-v2", + instruction_flow_evidence: "decoded-return-pcode-v1", + instruction_references: "exact-address-incoming-without-synthetic-entry-v2", + function_boundary_observations: "ghidra-function-boundary-limitations-v4", +} as const; /** * The processor language REA pins for this target, or undefined when Ghidra may @@ -136,20 +148,7 @@ export const resolveGhidraAnalysisProfile = async ( architecture: target.architecture, available_architectures: [...target.availableArchitectures].sort(), import_mode: "ephemeral-source-immutable", - annotation_policy: "atomic-function-entry-metadata-v1", - load_image_observations: "source-mappings-entry-context-v2", - function_body_evidence: "complete-inclusive-ranges-v1", - function_references: "complete-body-and-entry-reference-manager-v2", - call_relationship_coverage: callRelationshipCoverage, - function_dossier_coverage: - "observed-facets-and-call-relationships-v1", - string_inventory_evidence: "defined-data-coverage-v1", - location_resolution: "explicit-address-exact-entry-symbol-first-v3", - procedure_file_offset_resolution: - "address-first-unique-target-source-mapping-v2", - instruction_flow_evidence: "decoded-return-pcode-v1", - instruction_references: instructionReferenceCoverage, - function_boundary_observations: functionBoundaryObservations, + ...sharedAnalysisSemantics, no_return_repair: installation.platform === "win32" ? "disabled-windows-p0" @@ -247,19 +246,7 @@ export const resolveGhidraAnalysisProfile = async ( windows_arm_pe_machine: target.peMachine ?? null, } : {}), - annotation_policy: "atomic-function-entry-metadata-v1", - load_image_observations: "source-mappings-entry-context-v2", - function_body_evidence: "complete-inclusive-ranges-v1", - function_references: "complete-body-and-entry-reference-manager-v2", - call_relationship_coverage: callRelationshipCoverage, - function_dossier_coverage: "observed-facets-and-call-relationships-v1", - string_inventory_evidence: "defined-data-coverage-v1", - location_resolution: "explicit-address-exact-entry-symbol-first-v3", - procedure_file_offset_resolution: - "address-first-unique-target-source-mapping-v2", - instruction_flow_evidence: "decoded-return-pcode-v1", - instruction_references: instructionReferenceCoverage, - function_boundary_observations: functionBoundaryObservations, + ...sharedAnalysisSemantics, no_return_repair: installation.platform === "win32" ? "disabled-windows-p0"