Skip to content

Synthesize managed ilasm native exports without explicit fixups - #137453

Merged
jkoritzinsky merged 5 commits into
mainfrom
dev/jkoritzinsky/ilasm-synthesized-native-exports
Nov 18, 2026
Merged

jkoritzinsky merged 5 commits into
mainfrom
dev/jkoritzinsky/ilasm-synthesized-native-exports

Conversation

@jkoritzinsky

Copy link
Copy Markdown
Member

Synthesize a pointer-sized, writable vtable fixup table for .export directives when the source has no explicit .vtfixup. Feed the synthesized associations through the existing export validation and PE writer so native stubs, export names/ordinals, and mixed-mode flags are emitted normally.

Explicit fixup declarations retain their existing handling. Synthesized slots are compact even for sparse export ordinals; existing mapped data is preserved. Update regression coverage and remove the documented claim that ignoring these exports was intentional.

Validation:

  • .\build.cmd clr+libs -rc release — passed, clean baseline.
  • .\dotnet.cmd build src\tools\ilasm\src\ILAssembler\ILAssembler.csproj — passed for net10.0, net11.0, and net472, without warnings.
  • .\dotnet.cmd test src\tools\ilasm\tests\ILAssembler.Tests\ILAssembler.Tests.csproj --logger trx --results-directory artifacts\tmp\ilasm-final — passed: 5,317 tests per framework (net10.0 and net11.0).
  • .\dotnet.cmd test src\tools\ilasm\tests\ilasm.Tests\ilasm.Tests.csproj --logger trx --results-directory artifacts\tmp\ilasm-cli-final — passed: 567 tests, 3 existing platform/working-directory skips.
  • Before applying the fix, all five new export-synthesis cases failed on both test frameworks because ILONLY remained set.
  • Assembled the unchanged src/tests/Loader/classloader/MixedMode/AutoExports.il through the CLI using both -DLL -PE64 -X64 and --dll --x64, plus x86 defaults with both flag styles. A standalone caller loaded each assembly on Windows x64 and Windows x86, resolved Twice and Triple, and verified first and repeated calls returned 74 and 111 for input 37. Native ilasm outputs passed the same caller on both architectures. ARM64 output is covered by PE assertions, not execution.

Resolves #137448

Note

This pull request was generated by GitHub Copilot.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Synthesized vtable layouts can assign conflicting slots or leave zero-token slots, allowing invalid mappings to pass validation and produce unloadable images.

1 open issue
What changed in this PR

This PR enables managed ilasm to emit native exports from .export directives without explicit .vtfixup declarations, using the existing export validation and PE-writing pipeline.

Changes:

  • Synthesizes compact, pointer-sized fixup slots while preserving existing mapped data.
  • Expands regression coverage for export metadata, sparse ordinals, diagnostics, and command-line flags.
  • Updates documentation to describe export synthesis rather than intentional omission.
File Description
src/​tools/​ilasm/​tests/​ILAssembler.Tests/​NativeExportTests.cs Tests synthesized exports across architectures and ordinal layouts.
src/​tools/​ilasm/​tests/​ILAssembler.Tests/​ExportedTypeTests.cs Expects mixed-mode output for exports without fixups.
src/​tools/​ilasm/​tests/​ilasm.Tests/​CommandLineTests.cs Tests native exports with legacy and modern CLI flags.
src/​tools/​ilasm/​src/​ILAssembler/​Actions/​GrammarActions.BuildImage.cs Synthesizes fixups and integrates their associations into export validation.
src/​tools/​ilasm/​MANAGED-ILASM-FIXES.md Documents compact synthesized slots for sparse exports.

Review effort: Balanced

@jkoritzinsky
jkoritzinsky requested review from jkotas and removed request for jkotas November 17, 2026 22:04
@jkotas
jkotas requested a balanced review from Copilot November 17, 2026 22:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

An empty-layout return bypasses association validation, allowing a lone native export with an invalid explicit .vtentry and no .vtfixup to be silently dropped without diagnostics.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the change enabling native exports without explicit .vtfixup declarations.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@jkoritzinsky
jkoritzinsky enabled auto-merge (squash) November 18, 2026 02:18
@jkoritzinsky
jkoritzinsky merged commit 0968772 into main Nov 18, 2026
62 checks passed
@jkoritzinsky
jkoritzinsky deleted the dev/jkoritzinsky/ilasm-synthesized-native-exports branch November 18, 2026 08:43
@github-project-automation github-project-automation Bot moved this to Done in AppModel Nov 18, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Managed ilasm omits native exports and synthesized fixups for .export directives

3 participants