From mboxrd@z Thu Jan 1 00:00:00 1970 From: jeffy.chen@rock-chips.com (jeffy) Date: Tue, 24 Oct 2017 17:16:02 +0800 Subject: [PATCH] ARM: Fix zImage file size not aligned with CONFIG_EFI_STUB enabled In-Reply-To: References: <20171018050108.10352-1-jeffy.chen@rock-chips.com> <20171022124757.GL20805@n2100.armlinux.org.uk> <59ED6179.5020301@rock-chips.com> <20171023085006.GM20805@n2100.armlinux.org.uk> <59EDC34C.40109@rock-chips.com> <20171023105046.GT20805@n2100.armlinux.org.uk> <20171023114549.GU20805@n2100.armlinux.org.uk> Message-ID: <59EF04D2.20102@rock-chips.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi guys, On 10/24/2017 04:09 PM, Ard Biesheuvel wrote: > The following patch appears to fix the issue as well: > > diff --git a/arch/arm/boot/compressed/vmlinux.lds.S > b/arch/arm/boot/compressed/vmlinux.lds.S > index 7a4c59154361..0e0f504e256e 100644 > --- a/arch/arm/boot/compressed/vmlinux.lds.S > +++ b/arch/arm/boot/compressed/vmlinux.lds.S > @@ -83,7 +83,9 @@ SECTIONS > __pecoff_data_rawsize = . - ADDR(.data); > #endif > > - _edata = .; > + .edata (NOLOAD) : { > + _edata = .; > + } > > _magic_sig = ZIMAGE_MAGIC(0x016f2818); > _magic_start = ZIMAGE_MAGIC(_start); > > because the NOLOAD triggers the linker to emit all PROGBITS sections > before _edata, including unknown ones. > > E.g., in my binary, it gives me > > 00798020 D __pecoff_data_end > 00798200 d __ksymtab_sort > 00798208 B __bss_start > 00798208 D _edata this works too: +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -70,10 +70,6 @@ SECTIONS .got : { *(.got) } _got_end = .; - /* ensure the zImage file size is always a multiple of 64 bits */ - /* (without a dummy byte, ld just ignores the empty section) */ - .pad : { BYTE(0); . = ALIGN(8); } - #ifdef CONFIG_EFI_STUB .data : ALIGN(4096) { __pecoff_data_start = .; @@ -93,7 +89,10 @@ SECTIONS __pecoff_data_rawsize = . - ADDR(.data); #endif - _edata = .; + /* ensure the zImage file size is always a multiple of 64 bits */ + .edata : ALIGN(8) { + _edata = .; + } 339: 006cf200 8 OBJECT LOCAL DEFAULT 9 __ksymtab_sort ... 528: 006cf208 0 NOTYPE GLOBAL DEFAULT 9 _edata From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751837AbdJXJQY (ORCPT ); Tue, 24 Oct 2017 05:16:24 -0400 Received: from regular1.263xmail.com ([211.150.99.134]:33552 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751363AbdJXJQX (ORCPT ); Tue, 24 Oct 2017 05:16:23 -0400 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: ard.biesheuvel@linaro.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Message-ID: <59EF04D2.20102@rock-chips.com> Date: Tue, 24 Oct 2017 17:16:02 +0800 From: jeffy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20130126 Thunderbird/19.0 MIME-Version: 1.0 To: Ard Biesheuvel , Russell King - ARM Linux CC: Ingo Molnar , Chris Zhong , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH] ARM: Fix zImage file size not aligned with CONFIG_EFI_STUB enabled References: <20171018050108.10352-1-jeffy.chen@rock-chips.com> <20171022124757.GL20805@n2100.armlinux.org.uk> <59ED6179.5020301@rock-chips.com> <20171023085006.GM20805@n2100.armlinux.org.uk> <59EDC34C.40109@rock-chips.com> <20171023105046.GT20805@n2100.armlinux.org.uk> <20171023114549.GU20805@n2100.armlinux.org.uk> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi guys, On 10/24/2017 04:09 PM, Ard Biesheuvel wrote: > The following patch appears to fix the issue as well: > > diff --git a/arch/arm/boot/compressed/vmlinux.lds.S > b/arch/arm/boot/compressed/vmlinux.lds.S > index 7a4c59154361..0e0f504e256e 100644 > --- a/arch/arm/boot/compressed/vmlinux.lds.S > +++ b/arch/arm/boot/compressed/vmlinux.lds.S > @@ -83,7 +83,9 @@ SECTIONS > __pecoff_data_rawsize = . - ADDR(.data); > #endif > > - _edata = .; > + .edata (NOLOAD) : { > + _edata = .; > + } > > _magic_sig = ZIMAGE_MAGIC(0x016f2818); > _magic_start = ZIMAGE_MAGIC(_start); > > because the NOLOAD triggers the linker to emit all PROGBITS sections > before _edata, including unknown ones. > > E.g., in my binary, it gives me > > 00798020 D __pecoff_data_end > 00798200 d __ksymtab_sort > 00798208 B __bss_start > 00798208 D _edata this works too: +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -70,10 +70,6 @@ SECTIONS .got : { *(.got) } _got_end = .; - /* ensure the zImage file size is always a multiple of 64 bits */ - /* (without a dummy byte, ld just ignores the empty section) */ - .pad : { BYTE(0); . = ALIGN(8); } - #ifdef CONFIG_EFI_STUB .data : ALIGN(4096) { __pecoff_data_start = .; @@ -93,7 +89,10 @@ SECTIONS __pecoff_data_rawsize = . - ADDR(.data); #endif - _edata = .; + /* ensure the zImage file size is always a multiple of 64 bits */ + .edata : ALIGN(8) { + _edata = .; + } 339: 006cf200 8 OBJECT LOCAL DEFAULT 9 __ksymtab_sort ... 528: 006cf208 0 NOTYPE GLOBAL DEFAULT 9 _edata