From: H. Peter Anvin Date: Wed, 28 Mar 2012 20:11:36 +0000 (-0700) Subject: Merge branch x86/build into x86/efi and fix up arch/x86/boot/tools/build.c X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a9aff3eaaf0966c2a1bb3717d811363d81e52c76;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git Merge branch x86/build into x86/efi and fix up arch/x86/boot/tools/build.c Reason for merge: The updates to the EFI boot stub generation conflicted with the changes to properly use the get/put_unaligned_le*() macros to generate images. This merge commit completes the conversion in arch/x86/boot/tools/build.c including the places in the code which had been changed on the x86/efi branch. Resolved Conflicts: arch/x86/boot/tools/build.c Signed-off-by: H. Peter Anvin --- a9aff3eaaf0966c2a1bb3717d811363d81e52c76 diff --cc arch/x86/boot/tools/build.c index 2aeab3dc9e5f,ed549767a231..45963889891e --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@@ -200,55 -196,37 +196,55 @@@ int main(int argc, char ** argv #ifdef CONFIG_EFI_STUB file_sz = sz + i + ((sys_size * 16) - sz); - pe_header = *(unsigned int *)&buf[0x3c]; + pe_header = get_unaligned_le32(&buf[0x3c]); - /* Size of code */ - put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]); - /* Size of image */ - *(unsigned int *)&buf[pe_header + 0x50] = file_sz; + 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 */ - *(unsigned int *)&buf[pe_header + 0x1c] = file_sz; ++ put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]); + #ifdef CONFIG_X86_32 /* Address of entry point */ - *(unsigned int *)&buf[pe_header + 0x28] = i; + put_unaligned_le32(i, &buf[pe_header + 0x28]); /* .text size */ - *(unsigned int *)&buf[pe_header + 0xb0] = file_sz; + put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]); + /* .text vma */ - *(unsigned int *)&buf[pe_header + 0xb4] = 0x200; ++ put_unaligned_le32(0x200, &buf[pe_header + 0xb4]); + /* .text size of initialised data */ - *(unsigned int *)&buf[pe_header + 0xb8] = file_sz; + put_unaligned_le32(file_sz, &buf[pe_header + 0xb8]); + + /* .text file offset */ - *(unsigned int *)&buf[pe_header + 0xbc] = 0x200; ++ put_unaligned_le32(0x200, &buf[pe_header + 0xbc]); #else /* * Address of entry point. startup_32 is at the beginning and * the 64-bit entry point (startup_64) is always 512 bytes * after. */ - *(unsigned int *)&buf[pe_header + 0x28] = i + 512; + put_unaligned_le32(i + 512, &buf[pe_header + 0x28]); /* .text size */ - *(unsigned int *)&buf[pe_header + 0xc0] = file_sz; + put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]); + /* .text vma */ - *(unsigned int *)&buf[pe_header + 0xc4] = 0x200; ++ put_unaligned_le32(0x200, &buf[pe_header + 0xc4]); + /* .text size of initialised data */ - *(unsigned int *)&buf[pe_header + 0xc8] = file_sz; + put_unaligned_le32(file_sz, &buf[pe_header + 0xc8]); + /* .text file offset */ - *(unsigned int *)&buf[pe_header + 0xcc] = 0x200; ++ put_unaligned_le32(0x200, &buf[pe_header + 0xcc]); #endif /* CONFIG_X86_32 */ #endif /* CONFIG_EFI_STUB */