Note that for the ARM case, we are using IMAGE_FILE_MACHINE_THUMB (0x1c2) rather than IMAGE_FILE_MACHINE_ARM (0x1c0), as the latter refers to an older calling convention that is incompatible with Tianocore UEFI.
Signed-off-by: Ard Biesheuvel ard.biesheuvel@linaro.org --- src/coff/pe.h | 1 + src/image.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/coff/pe.h b/src/coff/pe.h index 3a43174ecfff..0d1036ebe12e 100644 --- a/src/coff/pe.h +++ b/src/coff/pe.h @@ -151,6 +151,7 @@ #define IMAGE_FILE_MACHINE_THUMB 0x01c2 #define IMAGE_FILE_MACHINE_TRICORE 0x0520 #define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169 +#define IMAGE_FILE_MACHINE_AARCH64 0xaa64
#define IMAGE_SUBSYSTEM_UNKNOWN 0 #define IMAGE_SUBSYSTEM_NATIVE 1 diff --git a/src/image.c b/src/image.c index 5285fbd0d7c3..0fdeb58bd0c3 100644 --- a/src/image.c +++ b/src/image.c @@ -180,13 +180,16 @@ static int image_pecoff_parse(struct image *image) image->opthdr.addr = image->pehdr + 1; magic = pehdr_u16(image->pehdr->f_magic);
- if (magic == IMAGE_FILE_MACHINE_AMD64) { + switch (magic) { + case IMAGE_FILE_MACHINE_AMD64: + case IMAGE_FILE_MACHINE_AARCH64: rc = image_pecoff_parse_64(image); - - } else if (magic == IMAGE_FILE_MACHINE_I386) { + break; + case IMAGE_FILE_MACHINE_I386: + case IMAGE_FILE_MACHINE_THUMB: rc = image_pecoff_parse_32(image); - - } else { + break; + default: fprintf(stderr, "Invalid PE header magic\n"); return -1; }