Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ARM64EC #607

Merged
merged 3 commits into from
Dec 12, 2023
Merged

Add support for ARM64EC #607

merged 3 commits into from
Dec 12, 2023

Conversation

dpaoliello
Copy link
Contributor

Arm64EC is a new ABI for Windows binaries that is designed to improve performance of emulated x64 apps on ARM64 devices: https://learn.microsoft.com/en-us/windows/arm/arm64ec

Within the COFF and PE formats, there is a new IMAGE_FILE_MACHINE_ARM64EC enum set to 0xA641: https://github.com/llvm/llvm-project/blob/3d1172813fc640514c6cb421394c34f4b42cb634/llvm/include/llvm/BinaryFormat/COFF.h#L101

For relocations, Arm64EC is treated the same as AArch64.

I also updated the round-trip test for COFF to run for all supported architectures.

@philipc
Copy link
Contributor

philipc commented Dec 7, 2023

This is an ABI, not an architecture, and for the purposes of this crate the only thing it affects is the machine field in the header, so I'm reluctant to add this as a separate architecture. We can if you think it's the best choice, but alternatives to consider are:

  • add Object::set_coff_machine
  • add a machine field to FileFlags::Coff (although this is a breaking change)
  • add Object:::set_subarchitecture and add a new SubArchitecture enum (because LLVM uses Triple::aarch64 with Triple::AArch64SubArch_arm64ec)

@dpaoliello
Copy link
Contributor Author

@philipc I like the idea of using a sub-architecture to match LLVM.

Question about the design though, should this be unified with Object::set_macho_cpu_subtype, or leave them separate for now?

src/write/mod.rs Outdated Show resolved Hide resolved
src/write/coff/object.rs Outdated Show resolved Hide resolved
src/read/any.rs Outdated Show resolved Hide resolved
src/common.rs Show resolved Hide resolved
Copy link
Contributor

@philipc philipc left a comment

Choose a reason for hiding this comment

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

Thanks!

@philipc philipc merged commit f242fe7 into gimli-rs:master Dec 12, 2023
12 checks passed
@dpaoliello dpaoliello deleted the arm64ec branch December 12, 2023 17:23
@dpaoliello
Copy link
Contributor Author

@philipc can we please get a new release that contains this change?

@philipc
Copy link
Contributor

philipc commented Dec 24, 2023

Released 0.32.2

mcbegamerxx954 pushed a commit to mcbegamerxx954/object that referenced this pull request Jun 15, 2024
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.

None yet

2 participants