All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: verify size of zImage
@ 2017-11-28 16:27 Russell King
  2017-11-28 16:32 ` Ard Biesheuvel
  0 siblings, 1 reply; 5+ messages in thread
From: Russell King @ 2017-11-28 16:27 UTC (permalink / raw)
  To: linux-arm-kernel

The linker can sometimes add additional sections to the zImage ELF file
which results in the zImage binary being larger than expected.  This
causes appended DT blobs to fail.

Verify that the zImage binary is the expected size, and fail the build
if this is not the case.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
As this patch is different, I've dropped Matthias' tested-by.  I'd
appreciate a replacement, thanks.  Also, I seem to remember that
Ard's toolchain was giving issues - maybe this alternative will
finally resolve them.

 arch/arm/boot/compressed/vmlinux.lds.S | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S
index e6bf6774c4bb..ed53ca9f482e 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.S
+++ b/arch/arm/boot/compressed/vmlinux.lds.S
@@ -101,6 +101,12 @@ SECTIONS
    * this symbol allows further debug in the near future.
    */
   .image_end (NOLOAD) : {
+    /*
+     * EFI requires that the image is aligned to 512 bytes, and appended
+     * DTB requires that we know where the end of the image is.  Ensure
+     * that both are satisfied by ensuring that there are no additional
+     * sections emitted into the decompressor image.
+     */
     _edata_real = .;
   }
 
@@ -128,3 +134,4 @@ SECTIONS
   .stab.indexstr 0	: { *(.stab.indexstr) }
   .comment 0		: { *(.comment) }
 }
+ASSERT(_edata_real == _edata, "error: zImage file size is incorrect");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] ARM: verify size of zImage
  2017-11-28 16:27 [PATCH] ARM: verify size of zImage Russell King
@ 2017-11-28 16:32 ` Ard Biesheuvel
  2017-11-28 16:37   ` Russell King - ARM Linux
  2017-12-12 16:08   ` Gregory CLEMENT
  0 siblings, 2 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2017-11-28 16:32 UTC (permalink / raw)
  To: linux-arm-kernel

(+ Gregory)

On 28 November 2017 at 16:27, Russell King <rmk+kernel@armlinux.org.uk> wrote:
> The linker can sometimes add additional sections to the zImage ELF file
> which results in the zImage binary being larger than expected.  This
> causes appended DT blobs to fail.
>
> Verify that the zImage binary is the expected size, and fail the build
> if this is not the case.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> As this patch is different, I've dropped Matthias' tested-by.  I'd
> appreciate a replacement, thanks.  Also, I seem to remember that
> Ard's toolchain was giving issues - maybe this alternative will
> finally resolve them.
>

$ nm arch/arm/boot/compressed/vmlinux |grep _edata
007b8200 D _edata
007b8200 D _edata_real

Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

although I don't remember seeing this fail. It think it may have been
Gregory who was having these issues?



>  arch/arm/boot/compressed/vmlinux.lds.S | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S
> index e6bf6774c4bb..ed53ca9f482e 100644
> --- a/arch/arm/boot/compressed/vmlinux.lds.S
> +++ b/arch/arm/boot/compressed/vmlinux.lds.S
> @@ -101,6 +101,12 @@ SECTIONS
>     * this symbol allows further debug in the near future.
>     */
>    .image_end (NOLOAD) : {
> +    /*
> +     * EFI requires that the image is aligned to 512 bytes, and appended
> +     * DTB requires that we know where the end of the image is.  Ensure
> +     * that both are satisfied by ensuring that there are no additional
> +     * sections emitted into the decompressor image.
> +     */
>      _edata_real = .;
>    }
>
> @@ -128,3 +134,4 @@ SECTIONS
>    .stab.indexstr 0     : { *(.stab.indexstr) }
>    .comment 0           : { *(.comment) }
>  }
> +ASSERT(_edata_real == _edata, "error: zImage file size is incorrect");
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: verify size of zImage
  2017-11-28 16:32 ` Ard Biesheuvel
@ 2017-11-28 16:37   ` Russell King - ARM Linux
  2017-12-12 16:08   ` Gregory CLEMENT
  1 sibling, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux @ 2017-11-28 16:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 28, 2017 at 04:32:42PM +0000, Ard Biesheuvel wrote:
> (+ Gregory)
> 
> On 28 November 2017 at 16:27, Russell King <rmk+kernel@armlinux.org.uk> wrote:
> > The linker can sometimes add additional sections to the zImage ELF file
> > which results in the zImage binary being larger than expected.  This
> > causes appended DT blobs to fail.
> >
> > Verify that the zImage binary is the expected size, and fail the build
> > if this is not the case.
> >
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> > As this patch is different, I've dropped Matthias' tested-by.  I'd
> > appreciate a replacement, thanks.  Also, I seem to remember that
> > Ard's toolchain was giving issues - maybe this alternative will
> > finally resolve them.
> >
> 
> $ nm arch/arm/boot/compressed/vmlinux |grep _edata
> 007b8200 D _edata
> 007b8200 D _edata_real
> 
> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> 
> although I don't remember seeing this fail. It think it may have been
> Gregory who was having these issues?

The failing case was with a few ld versions when we had:

	ASSERT(. == _edata, "error: zImage file size is incorrect");

in place of the _edata_real assignment.  Yet, those very same linkers
have shown that they set _edata_real to the same value as _edata.

I forget who had the problem, sorry.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: verify size of zImage
  2017-11-28 16:32 ` Ard Biesheuvel
  2017-11-28 16:37   ` Russell King - ARM Linux
@ 2017-12-12 16:08   ` Gregory CLEMENT
  2017-12-12 18:02     ` Ard Biesheuvel
  1 sibling, 1 reply; 5+ messages in thread
From: Gregory CLEMENT @ 2017-12-12 16:08 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ard,
 
 On mar., nov. 28 2017, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> (+ Gregory)
>
> On 28 November 2017 at 16:27, Russell King <rmk+kernel@armlinux.org.uk> wrote:
>> The linker can sometimes add additional sections to the zImage ELF file
>> which results in the zImage binary being larger than expected.  This
>> causes appended DT blobs to fail.
>>
>> Verify that the zImage binary is the expected size, and fail the build
>> if this is not the case.
>>
>> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
>> ---
>> As this patch is different, I've dropped Matthias' tested-by.  I'd
>> appreciate a replacement, thanks.  Also, I seem to remember that
>> Ard's toolchain was giving issues - maybe this alternative will
>> finally resolve them.
>>
>
> $ nm arch/arm/boot/compressed/vmlinux |grep _edata
> 007b8200 D _edata
> 007b8200 D _edata_real
>
> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> although I don't remember seeing this fail. It think it may have been
> Gregory who was having these issues?

Thanks to remember me, I finally find time to test it, and with my setup
I didn't have anymore issue while building it for a dtb append zImage
for Armada XP:

Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>

Gregory


>
>
>
>>  arch/arm/boot/compressed/vmlinux.lds.S | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S
>> index e6bf6774c4bb..ed53ca9f482e 100644
>> --- a/arch/arm/boot/compressed/vmlinux.lds.S
>> +++ b/arch/arm/boot/compressed/vmlinux.lds.S
>> @@ -101,6 +101,12 @@ SECTIONS
>>     * this symbol allows further debug in the near future.
>>     */
>>    .image_end (NOLOAD) : {
>> +    /*
>> +     * EFI requires that the image is aligned to 512 bytes, and appended
>> +     * DTB requires that we know where the end of the image is.  Ensure
>> +     * that both are satisfied by ensuring that there are no additional
>> +     * sections emitted into the decompressor image.
>> +     */
>>      _edata_real = .;
>>    }
>>
>> @@ -128,3 +134,4 @@ SECTIONS
>>    .stab.indexstr 0     : { *(.stab.indexstr) }
>>    .comment 0           : { *(.comment) }
>>  }
>> +ASSERT(_edata_real == _edata, "error: zImage file size is incorrect");
>> --
>> 2.7.4
>>

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: verify size of zImage
  2017-12-12 16:08   ` Gregory CLEMENT
@ 2017-12-12 18:02     ` Ard Biesheuvel
  0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2017-12-12 18:02 UTC (permalink / raw)
  To: linux-arm-kernel

On 12 December 2017 at 16:08, Gregory CLEMENT
<gregory.clement@free-electrons.com> wrote:
> Hi Ard,
>
>  On mar., nov. 28 2017, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> (+ Gregory)
>>
>> On 28 November 2017 at 16:27, Russell King <rmk+kernel@armlinux.org.uk> wrote:
>>> The linker can sometimes add additional sections to the zImage ELF file
>>> which results in the zImage binary being larger than expected.  This
>>> causes appended DT blobs to fail.
>>>
>>> Verify that the zImage binary is the expected size, and fail the build
>>> if this is not the case.
>>>
>>> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
>>> ---
>>> As this patch is different, I've dropped Matthias' tested-by.  I'd
>>> appreciate a replacement, thanks.  Also, I seem to remember that
>>> Ard's toolchain was giving issues - maybe this alternative will
>>> finally resolve them.
>>>
>>
>> $ nm arch/arm/boot/compressed/vmlinux |grep _edata
>> 007b8200 D _edata
>> 007b8200 D _edata_real
>>
>> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>
>> although I don't remember seeing this fail. It think it may have been
>> Gregory who was having these issues?
>
> Thanks to remember me, I finally find time to test it, and with my setup
> I didn't have anymore issue while building it for a dtb append zImage
> for Armada XP:
>
> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>

Thanks for confirming.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-12-12 18:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28 16:27 [PATCH] ARM: verify size of zImage Russell King
2017-11-28 16:32 ` Ard Biesheuvel
2017-11-28 16:37   ` Russell King - ARM Linux
2017-12-12 16:08   ` Gregory CLEMENT
2017-12-12 18:02     ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.