All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: grub-devel@gnu.org
Cc: Daniel Kiper <dkiper@net-space.pl>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	Peter Jones <pjones@redhat.com>, Jon Masters <jcm@redhat.com>
Subject: [PATCH v5 3/3] mkimage: Clarify file alignment in efi case
Date: Fri, 25 Jan 2019 12:45:16 +0100	[thread overview]
Message-ID: <20190125114516.12127-4-agraf@suse.de> (raw)
In-Reply-To: <20190125114516.12127-1-agraf@suse.de>

There are a few spots in the PE generation code for EFI binaries that uses
the section alignment rather than file alignment, even though the alignment
is really only file bound.

Replace those cases with the file alignment constant instead.

Reported-by: Daniel Kiper <dkiper@net-space.pl>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 util/mkimage.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/util/mkimage.c b/util/mkimage.c
index 16af12e0c..6631bfe45 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -1227,10 +1227,10 @@ grub_install_generate_image (const char *dir, const char *prefix,
 	  header_size = EFI64_HEADER_SIZE;
 
 	reloc_addr = ALIGN_UP (header_size + core_size,
-			       image_target->section_align);
+			       GRUB_PE32_FILE_ALIGNMENT);
 
 	pe_size = ALIGN_UP (reloc_addr + layout.reloc_size,
-			    image_target->section_align);
+			    GRUB_PE32_FILE_ALIGNMENT);
 	pe_img = xmalloc (reloc_addr + layout.reloc_size);
 	memset (pe_img, 0, header_size);
 	memcpy ((char *) pe_img + header_size, core_img, core_size);
@@ -1280,7 +1280,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
 
 	    o->image_base = 0;
 	    o->section_alignment = grub_host_to_target32 (image_target->section_align);
-	    o->file_alignment = grub_host_to_target32 (image_target->section_align);
+	    o->file_alignment = grub_host_to_target32 (GRUB_PE32_FILE_ALIGNMENT);
 	    o->image_size = grub_host_to_target32 (pe_size);
 	    o->header_size = grub_host_to_target32 (header_size);
 	    o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
@@ -1315,7 +1315,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
 	    o->code_base = grub_cpu_to_le32 (header_size);
 	    o->image_base = 0;
 	    o->section_alignment = grub_host_to_target32 (image_target->section_align);
-	    o->file_alignment = grub_host_to_target32 (image_target->section_align);
+	    o->file_alignment = grub_host_to_target32 (GRUB_PE32_FILE_ALIGNMENT);
 	    o->image_size = grub_host_to_target32 (pe_size);
 	    o->header_size = grub_host_to_target32 (header_size);
 	    o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
-- 
2.12.3



  parent reply	other threads:[~2019-01-25 11:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25 11:45 [PATCH v5 0/3] arm64: Support HP Envy X2 Alexander Graf
2019-01-25 11:45 ` [PATCH v5 1/3] mkimage: Use EFI32_HEADER_SIZE define in arm-efi case Alexander Graf
2019-01-28 12:18   ` Daniel Kiper
2019-01-25 11:45 ` [PATCH v5 2/3] mkimage: Align efi sections on 4k boundary Alexander Graf
2019-01-28 12:22   ` Daniel Kiper
2019-01-28 12:33     ` Alexander Graf
2019-01-28 13:03       ` Daniel Kiper
2019-01-25 11:45 ` Alexander Graf [this message]
2019-01-28 12:27   ` [PATCH v5 3/3] mkimage: Clarify file alignment in efi case Daniel Kiper
2019-01-28 12:34     ` Alexander Graf
2019-01-28 13:17       ` Daniel Kiper

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=20190125114516.12127-4-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=jcm@redhat.com \
    --cc=leif.lindholm@linaro.org \
    --cc=pjones@redhat.com \
    /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 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.