Index: llvm/include/llvm/Object/COFF.h =================================================================== --- llvm/include/llvm/Object/COFF.h +++ llvm/include/llvm/Object/COFF.h @@ -888,8 +888,17 @@ } uint16_t getMachine() const { - if (COFFHeader) + if (COFFHeader) { + if (CHPEMetadata) { + switch (COFFHeader->Machine) { + case COFF::IMAGE_FILE_MACHINE_AMD64: + return COFF::IMAGE_FILE_MACHINE_ARM64EC; + case COFF::IMAGE_FILE_MACHINE_ARM64: + return COFF::IMAGE_FILE_MACHINE_ARM64X; + } + } return COFFHeader->Machine; + } if (COFFBigObjHeader) return COFFBigObjHeader->Machine; llvm_unreachable("no COFF header!"); Index: llvm/test/tools/llvm-objdump/arm64ec.yaml =================================================================== --- /dev/null +++ llvm/test/tools/llvm-objdump/arm64ec.yaml @@ -0,0 +1,45 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-objdump -d %t | FileCheck -check-prefix=DISAS %s + +# DISAS: file format coff-arm64ec +# DISAS: 180001000: 52800040 mov w0, #0x2 +# DISAS-NEXT: 180001004: d65f03c0 ret +# DISAS-NEXT: ... +# DISAS: 180002020: 528000a0 mov w0, #0x5 +# DISAS-NEXT: 180002024: d65f03c0 ret + +--- !COFF +OptionalHeader: + ImageBase: 0x180000000 + SectionAlignment: 4096 + FileAlignment: 512 + DLLCharacteristics: [ ] + LoadConfigTable: + RelativeVirtualAddress: 0x3000 + Size: 320 +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + VirtualAddress: 0x1000 + VirtualSize: 38 + SectionData: 40008052C0035FD6000000000000000000000000000000000000000000000000B803000000C3 + - Name: .test + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + VirtualAddress: 0x2000 + VirtualSize: 40 + SectionData: B806000000C3CC00000000000000000000000000000000000000000000000000A0008052C0035FD6 + - Name: .rdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + VirtualAddress: 0x3000 + VirtualSize: 328 + SectionData: '40010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040008001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + VirtualAddress: 0x4000 + VirtualSize: 112 + SectionData: '0100000050400000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000800000022100000e70f00002120000008000000' +symbols: [] +...