[efi] Fix the 32-bit version of elf2efi64
authorGeoff Lywood <glywood@vmware.com>
Wed, 21 Jul 2010 02:23:02 +0000 (19:23 -0700)
committerStefan Hajnoczi <stefanha@gmail.com>
Sun, 1 Aug 2010 11:44:09 +0000 (12:44 +0100)
commitc542da3f3d167a79903c6d4cfdbd97891513b954
tree83f704c5b7c1db467c6f651bf4d535af8b44faad
parentb8d214cfb66dcb02e2c56fcf1242edc54a81cc50
[efi] Fix the 32-bit version of elf2efi64

Currently, if elf2efi.c is compiled using a 32-bit HOST_CC, then the
resulting elf2efi64 binary will generate 32-bit EFI binaries instead of
64-bit EFI binaries.

The problem is, elf2efi.c uses the MDE_CPU_* definitions to decide
whether to output a 32-bit or 64-bit PE binary. However, MDE_CPU_* gets
defined in ProcessorBind.h, depending on the compiler's target
architecture. Overriding them on the command line doesn't work in the
expected way, and you can end up in cases where both MDE_CPU_IA32 and
MDE_CPU_X64 are defined.

The patch below should fix the problem. I tested this patch by building
with all 4 combinations of 32- and 64-bit toolchains, targeting both 32-
and 64-bit EFI. In each case, I used objdump to verify that the file
format of bin-*-efi/snponly.efi matched what was expected. I also booted
the 64-bit executable that was generated using the 32-bit toolchain.

Signed-off-by: Geoff Lywood <glywood@vmware.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
src/Makefile.housekeeping
src/util/elf2efi.c