From: Linus Torvalds Date: Wed, 23 May 2012 17:40:34 +0000 (-0700) Subject: Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git... X-Git-Tag: v3.5-rc1~128 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ca038dc10eec80f280d9d483f1835ac2763a787;p=pandora-kernel.git Merge branch 'x86-efi-for-linus' of git://git./linux/kernel/git/tip/tip Pull x86 EFI updates from Ingo Molnar: "This patchset makes changes to the bzImage EFI header, so that it can be signed with a secure boot signature tool. It should not affect anyone who is not using the EFI self-boot feature in any way." * 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86, efi: Fix NumberOfRvaAndSizes field in PE32 header for EFI_STUB x86, efi: Fix .text section overlapping image header for EFI_STUB x86, efi: Fix issue of overlapping .reloc section for EFI_STUB --- 8ca038dc10eec80f280d9d483f1835ac2763a787 diff --cc arch/x86/boot/tools/build.c index 24443a332083,45963889891e..3f61f6e2b46f --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@@ -201,17 -201,19 +201,24 @@@ int main(int argc, char ** argv /* Size of image */ put_unaligned_le32(file_sz, &buf[pe_header + 0x50]); + /* + * Subtract the size of the first section (512 bytes) which + * includes the header and .reloc section. The remaining size + * is that of the .text section. + */ + file_sz -= 512; + + /* Size of code */ + put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]); + #ifdef CONFIG_X86_32 - /* Address of entry point */ - put_unaligned_le32(i, &buf[pe_header + 0x28]); + /* + * Address of entry point. + * + * The EFI stub entry point is +16 bytes from the start of + * the .text section. + */ + put_unaligned_le32(i + 16, &buf[pe_header + 0x28]); /* .text size */ put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]);