summaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-23 10:40:34 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-23 10:40:34 -0700
commit8ca038dc10eec80f280d9d483f1835ac2763a787 (patch)
tree3394e1c028782b1a8d06455096c0516842fb62af /arch/x86/boot/tools
parente7b30a17c1ef5cbc67c5381407d2d03484b8def3 (diff)
parenta9aff3eaaf0966c2a1bb3717d811363d81e52c76 (diff)
downloadlinux-8ca038dc10eec80f280d9d483f1835ac2763a787.tar.bz2
Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/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
Diffstat (limited to 'arch/x86/boot/tools')
-rw-r--r--arch/x86/boot/tools/build.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c
index 24443a332083..3f61f6e2b46f 100644
--- a/arch/x86/boot/tools/build.c
+++ b/arch/x86/boot/tools/build.c
@@ -198,12 +198,19 @@ int main(int argc, char ** argv)
pe_header = get_unaligned_le32(&buf[0x3c]);
- /* Size of code */
- put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]);
-
/* 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.
@@ -216,8 +223,14 @@ int main(int argc, char ** argv)
/* .text size */
put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]);
+ /* .text vma */
+ put_unaligned_le32(0x200, &buf[pe_header + 0xb4]);
+
/* .text size of initialised data */
put_unaligned_le32(file_sz, &buf[pe_header + 0xb8]);
+
+ /* .text file offset */
+ put_unaligned_le32(0x200, &buf[pe_header + 0xbc]);
#else
/*
* Address of entry point. startup_32 is at the beginning and
@@ -231,9 +244,14 @@ int main(int argc, char ** argv)
/* .text size */
put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]);
+ /* .text vma */
+ put_unaligned_le32(0x200, &buf[pe_header + 0xc4]);
+
/* .text size of initialised data */
put_unaligned_le32(file_sz, &buf[pe_header + 0xc8]);
+ /* .text file offset */
+ put_unaligned_le32(0x200, &buf[pe_header + 0xcc]);
#endif /* CONFIG_X86_32 */
#endif /* CONFIG_EFI_STUB */