diff mbox series

[v3,1/4] mkimage: Simplify header size logic

Message ID 20190114152718.60629-2-agraf@suse.de
State New
Headers show
Series arm64: Support HP Envy X2 | expand

Commit Message

Alexander Graf Jan. 14, 2019, 3:27 p.m. UTC
For EFI images, we always have the following layout:

  [PE header]
  [padding]
  [first section (which also is the entry point)]

Currently there are 2 places where we define how big header+padding are:
in the .vaddr_offset member of our target image definition struct as well
as in code in grub_install_generate_image().

Remove the latter, so that we only have a single place to modify if we
need to change the padding.

Signed-off-by: Alexander Graf <agraf@suse.de>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

---
 util/mkimage.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

-- 
2.12.3


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Comments

Daniel Kiper Jan. 15, 2019, 12:23 p.m. UTC | #1
On Mon, Jan 14, 2019 at 04:27:15PM +0100, Alexander Graf wrote:
> For EFI images, we always have the following layout:

>

>   [PE header]

>   [padding]

>   [first section (which also is the entry point)]

>

> Currently there are 2 places where we define how big header+padding are:

> in the .vaddr_offset member of our target image definition struct as well

> as in code in grub_install_generate_image().

>

> Remove the latter, so that we only have a single place to modify if we

> need to change the padding.

>

> Signed-off-by: Alexander Graf <agraf@suse.de>

> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

> ---

>  util/mkimage.c | 5 +----

>  1 file changed, 1 insertion(+), 4 deletions(-)

>

> diff --git a/util/mkimage.c b/util/mkimage.c

> index 353bb1098..88b991764 100644

> --- a/util/mkimage.c

> +++ b/util/mkimage.c

> @@ -1226,10 +1226,7 @@ grub_install_generate_image (const char *dir, const char *prefix,

>  	int header_size;

>  	int reloc_addr;

>

> -	if (image_target->voidp_sizeof == 4)

> -	  header_size = EFI32_HEADER_SIZE;

> -	else

> -	  header_size = EFI64_HEADER_SIZE;

> +	header_size = image_target->vaddr_offset;


After some thinking it seems to me that this patch is wrong and should
be dropped. It, at least, increases needlessly header size. More in the
comments for the other patches.

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
diff mbox series

Patch

diff --git a/util/mkimage.c b/util/mkimage.c
index 353bb1098..88b991764 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -1226,10 +1226,7 @@  grub_install_generate_image (const char *dir, const char *prefix,
 	int header_size;
 	int reloc_addr;
 
-	if (image_target->voidp_sizeof == 4)
-	  header_size = EFI32_HEADER_SIZE;
-	else
-	  header_size = EFI64_HEADER_SIZE;
+	header_size = image_target->vaddr_offset;
 
 	reloc_addr = ALIGN_UP (header_size + core_size,
 			       image_target->section_align);