This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Add initial support for linking ARM64 binaries
ClosedPublic

Authored by mstorsjo on Jun 29 2017, 1:32 PM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Jun 29 2017, 1:32 PM
ruiu edited edge metadata.Jun 29 2017, 1:34 PM

Can you add a testcase?

This patch seems too simple to submit. Do you think you can improve it so that you can create an executable that does nothing but just exit with 0?

mstorsjo updated this revision to Diff 104733.Jun 29 2017, 2:10 PM
mstorsjo edited the summary of this revision. (Show Details)

Added a testcase, sorted the ARM64 declaration alphabetically.

The test case checks the pe32+ magic value, which llvm-readobj doesn't output (yet), but I'll send a separate patch for that.

The testcase depends on D34836.

mstorsjo updated this revision to Diff 104739.Jun 29 2017, 2:28 PM

Updated the test case to check for a hex printout.

ruiu added a comment.Jun 29 2017, 2:30 PM

Are you able to create an executable that exits 0 using this patch?

In D34833#795864, @ruiu wrote:

Are you able to create an executable that exits 0 using this patch?

Yes; the executable built by the test does that - tested in wine (which is the only arm64 windows environment I've got; prior to this patch it didn't work).

ruiu added inline comments.Jun 29 2017, 2:36 PM
test/COFF/arm64-magic.test
1 ↗(On Diff #104739)

Rename this file arm64-magic.yaml and merge with Inputs/arm64-executable.obj.yaml.

mstorsjo updated this revision to Diff 104741.Jun 29 2017, 2:43 PM

Merged the test files as suggested.

ruiu added a comment.Jun 29 2017, 2:46 PM

Does this patch emits other headers correctly? See lld/test/COFF/hello32.test as an example for i386.

In D34833#795887, @ruiu wrote:

Does this patch emits other headers correctly? See lld/test/COFF/hello32.test as an example for i386.

I think it's mostly right enough so far, although I haven't checked everything in detail yet - at least it seemed right enough for wine to run, and after fixing the is64 function, most of the critical flags seem to match the upstream microsoft arm64 exes I've got to compare to.

ruiu added a comment.Jun 29 2017, 3:01 PM

But at least you want to make sure that these bits are updated for ARM64, right?

HEADER:      Format: COFF-i386
HEADER-NEXT: Arch: i386
HEADER-NEXT: AddressSize: 32bit
HEADER-NEXT: ImageFileHeader {
HEADER-NEXT:   Machine: IMAGE_FILE_MACHINE_I386 (0x14C)
mstorsjo updated this revision to Diff 104828.Jun 30 2017, 12:30 AM

Added a few more trivial cases where the arm64 machine type is mapped, extended the test to check more flags. I've doublechecked the flags that the test checks with binaries from microsoft.

Rui, is this version ok now?

ruiu accepted this revision.Jul 1 2017, 5:21 AM

Yes, it LGTM. Thank you for doing this!

This revision is now accepted and ready to land.Jul 1 2017, 5:21 AM
This revision was automatically updated to reflect the committed changes.