linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@armlinux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: Fix zImage file size not aligned with CONFIG_EFI_STUB enabled
Date: Tue, 24 Oct 2017 10:22:29 +0100	[thread overview]
Message-ID: <20171024092229.GA20805@n2100.armlinux.org.uk> (raw)
In-Reply-To: <CAKv+Gu_t=7uZ91MbVUqNfTcxX+3HKPF1+ZjS2-2Mn-Wq6D9H6Q@mail.gmail.com>

On Tue, Oct 24, 2017 at 10:13:09AM +0100, Ard Biesheuvel wrote:
> On 24 October 2017 at 10:09, Russell King - ARM Linux
> <linux@armlinux.org.uk> wrote:
> > The question is: do we want to know when additional sections get
> > emitted into the binary?
> 
> Well, we need to know whether the size of zImage is a multiple of 512
> bytes. We could check that separately by adding the following as well
> 
> #ifdef CONFIG_EFI_STUB
> ASSERT((_edata % 512 == 0), "zImage file size is not a multiple of 512 bytes")

ASSERT((_edata - _text) % 512 == 0, "EFI zImage file size is not a multiple of 512 bytes")

This would only catch them when EFI is enabled, which doesn't give very
good build coverage.  I still prefer my solution over adding the assert
and a section for _edata - my solution catches it with EFI disabled as
well.

A variant on that would be this, which should catch additional sections
for EFI and non-EFI:

diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S
index b38dcef90756..9d0c5d80979a 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.S
+++ b/arch/arm/boot/compressed/vmlinux.lds.S
@@ -95,6 +95,10 @@ SECTIONS
 
   _edata = .;
 
+  .image_end (NOLOAD) : {
+    _image_end = .;
+  }
+
   _magic_sig = ZIMAGE_MAGIC(0x016f2818);
   _magic_start = ZIMAGE_MAGIC(_start);
   _magic_end = ZIMAGE_MAGIC(_edata);
@@ -119,3 +123,5 @@ SECTIONS
   .stab.indexstr 0	: { *(.stab.indexstr) }
   .comment 0		: { *(.comment) }
 }
+
+ASSERT(image_end == end, "zImage file size is incorrect")


-- 
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

  reply	other threads:[~2017-10-24  9:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18  5:01 [PATCH] ARM: Fix zImage file size not aligned with CONFIG_EFI_STUB enabled Jeffy Chen
2017-10-18  6:19 ` Chris Zhong
2017-10-22 11:01 ` Ard Biesheuvel
2017-10-22 12:47   ` Russell King - ARM Linux
2017-10-22 13:01     ` Ard Biesheuvel
2017-10-23  3:26       ` jeffy
2017-10-23  8:50         ` Russell King - ARM Linux
2017-10-23 10:24           ` jeffy
2017-10-23 10:50             ` Russell King - ARM Linux
2017-10-23 11:45               ` Russell King - ARM Linux
2017-10-24  8:09                 ` Ard Biesheuvel
2017-10-24  9:09                   ` Russell King - ARM Linux
2017-10-24  9:13                     ` Ard Biesheuvel
2017-10-24  9:22                       ` Russell King - ARM Linux [this message]
2017-10-24  9:26                         ` Ard Biesheuvel
2017-10-24  9:30                           ` Ard Biesheuvel
2017-10-24  9:38                             ` Russell King - ARM Linux
2017-10-24  9:44                               ` Ard Biesheuvel
2017-10-24  9:54                                 ` Russell King - ARM Linux
2017-10-24 10:03                                   ` Ard Biesheuvel
2017-10-24  9:16                   ` jeffy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171024092229.GA20805@n2100.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).