Skip to content

Add ARM64EC support#23

Merged
messense merged 1 commit intomainfrom
arm64ec
Apr 22, 2026
Merged

Add ARM64EC support#23
messense merged 1 commit intomainfrom
arm64ec

Conversation

@messense
Copy link
Copy Markdown
Owner

Implements generation of ARM64EC (Emulation Compatible) Windows import libraries, verified byte-identical to llvm-dlltool output.

Changes:

  • Add ARM64EC variant to MachineType (IMAGE_FILE_MACHINE_ARM64EC = 0xA641)
  • MSVC flavor: use native ARM64 for descriptor objects, ARM64EC for short imports; mangle code import names with # prefix (or $$h insertion for C++ names) and emit them via IMPORT_NAME_EXPORTAS
  • Archive writer: write second linker member (LE, name-sorted with u16 member indices) and /<ECSYMBOLS>/ member required for COFF/EC archives
  • Split symbols across regular and EC tables: descriptors go in regular (duplicated to EC), exports go in EC only
  • GNU flavor: map ARM64EC to Aarch64 with ARM64 jmp stubs/relocations
  • Update object crate to 0.39.1 (replace deprecated U16Bytes/U32Bytes aliases with U16/U32)
  • Add lightweight MSVC mangled-name parser (~130 lines) to find the $$h insertion point without depending on a full demangler

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds ARM64EC support across MSVC and GNU import library generation, including archive-format updates needed for ARM64EC COFF archives.

Changes:

  • Introduces MachineType::ARM64EC and maps it appropriately in MSVC/GNU generation paths.
  • MSVC: adds ARM64EC name mangling + IMPORT_NAME_EXPORTAS, and splits symbols between regular and EC symbol tables.
  • Archive writer: adds /<ECSYMBOLS>/ support and writes a second linker member when generating EC archives; updates object dependency to 0.39.1.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib.rs Adds ARM64EC machine type and a native-machine mapping used by MSVC descriptor objects.
src/msvc.rs Implements ARM64EC import name mangling, EXPORTAS handling, descriptor-vs-EC symbol table splitting, and adds unit tests for mangling logic.
src/gnu.rs Maps ARM64EC to AArch64 and reuses ARM64 stubs/relocations; minor error-construction refactors.
src/ar/write.rs Adds a second linker member for EC archives and emits the /<ECSYMBOLS>/ member; supports dual symbol tables.
src/ar/mod.rs Defines EC_SYMBOL_TABLE_ID constant for the new member.
src/def/parser.rs Minor refactor: derive-based Default for TokenKind and small control-flow cleanup.
tests/test_import_lib.rs Adds ARM64EC tests for MSVC and GNU flavors (light structural assertion for MSVC).
Cargo.toml Bumps object crate to 0.39.1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/msvc.rs
Comment thread src/ar/write.rs Outdated
Comment thread tests/test_import_lib.rs Outdated
Implements generation of ARM64EC (Emulation Compatible) Windows import
libraries, verified byte-identical to `llvm-dlltool` output.

Changes:
- Add `ARM64EC` variant to `MachineType` (`IMAGE_FILE_MACHINE_ARM64EC` = 0xA641)
- MSVC flavor: use native ARM64 for descriptor objects, ARM64EC for short
  imports; mangle code import names with `#` prefix (or `$$h` insertion
  for C++ names) and emit them via `IMPORT_NAME_EXPORTAS`
- Archive writer: write second linker member (LE, name-sorted with `u16`
  member indices) and `/<ECSYMBOLS>/` member required for COFF/EC archives
- Split symbols across regular and EC tables: descriptors go in regular
  (duplicated to EC), exports go in EC only
- GNU flavor: map ARM64EC to Aarch64 with ARM64 jmp stubs/relocations
- Update `object` crate to 0.39.1 (replace deprecated `U16Bytes`/`U32Bytes`
  aliases with `U16`/`U32`)
- Add lightweight MSVC mangled-name parser (~130 lines) to find the
  `$$h` insertion point without depending on a full demangler
@messense messense merged commit 8f2b04b into main Apr 22, 2026
6 checks passed
@messense messense deleted the arm64ec branch April 22, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants