Skip to content

fix(dotnet): preserve C identifier underscores in native matching - #685

Closed
rudycelekli wants to merge 1 commit into
morluto:mainfrom
rudycelekli:fix/rea-native-symbol-abi-prefix-20261006
Closed

rudycelekli wants to merge 1 commit into
morluto:mainfrom
rudycelekli:fix/rea-native-symbol-abi-prefix-20261006

Conversation

@rudycelekli

Copy link
Copy Markdown

Problem

Managed/native symbol matching removes all leading underscores from both the managed declaration and native name. This collapses distinct C identifiers. A declaration open_native can be linked to a Mach-O export __open_native, which actually corresponds to C _open_native. The reverse raw-equality shortcut would be wrong too: declaration _open_native must not match export _open_native, which corresponds to C open_native.

Change

Preserve the managed declaration spelling. Remove exactly one ABI underscore from Mach-O export names for candidate comparison; do not apply that normalization to function-dossier names. Existing declared decorations and exact-name evidence behavior remain intact.

Verification

Two owned C dylibs compiled with the host clang provide actual controls:

Dylib C symbol Actual loader open_native Actual loader _open_native Public static workflow
open_native (Mach-O _open_native) returns 9 unavailable first inferred, second unresolved
_open_native (Mach-O __open_native) unavailable returns 7 first unresolved, second inferred

The workflow uses owned PE P/Invoke declarations with exact spelling, actual filesystem target resolution, the public ManagedStaticProvider, real NativeMacOSProvider/xcrun inspection, and authenticated Evidence. Before the fix, the crossed names are incorrectly inferred; after it, all four controls agree with the native loader observations.

  • 9 focused managed/native conformance tests pass.
  • All five npm run check tasks pass with Node 24.18.0 and the exact lock.
  • npm run verify:managed: all 11 source-owned static-format scenarios pass; optional operator manifest/ILSpy verification is unconfigured and not claimed.

The actual native loader controls validate these C export names. Static candidate matching still does not prove CLR binding, marshaling, managed call reachability, or target execution.

AI assistance was used for investigation, implementation, tests, description and independent patch review. Actual provider proof and its limits are stated above.

@morluto morluto left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve: Mach-O-only single-underscore strip with managed spelling preserved fixes the open_native vs _open_native collapse on both sides. Both crossed cases covered by conformance tests, existing decorations flow through unchanged. Checks green.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Superseded by #705, which cherry-picks this change (plus 13 sibling fixes) onto current main with conflict resolution and regenerated catalogs. Closing to keep one reviewable merge unit.

@morluto morluto closed this Oct 6, 2026
@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Thanks, @rudycelekli, for your work on “fix(dotnet): preserve C identifier underscores in native matching.” I appreciate your contribution to REA.

@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants