From ca6ad33055c67e1bfcae34e36c64d50ba7ff9320 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 27 Jan 2016 13:17:19 +0100 Subject: [PATCH] sbsigntool: add support for ARM and Aarch64 PE/COFF images 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 Signed-off-by: James Bottomley --- 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 3a43174..0d1036e 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 a90b0fb..f329c24 100644 --- a/src/image.c +++ b/src/image.c @@ -237,13 +237,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; }