diff mbox series

[5/5] kbuild: add cmd_file_size

Message ID 20220109181529.351420-5-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/5] sh: rename suffix-y to suffix_y | expand

Commit Message

Masahiro Yamada Jan. 9, 2022, 6:15 p.m. UTC
Some architectures support self-extracting kernel, which embeds the
compressed vmlinux.

It has 4 byte data at the end so the decompressor can know the vmlinux
size beforehand.

GZIP natively has it in the trailer, but for the other compression
algorithms, the hand-crafted trailer is added.

It is unneeded to generate such _corrupted_ compressed files because
it is possible to pass the size data separately.

For example, the assembly code:

     .incbin "compressed-vmlinux-with-size-data-appended"

can be transformed to:

     .incbin "compressed-vmlinux"
     .incbin "size-data"

My hope is, after some reworks of the decompressors, the macros
cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22} will go away.

This new macro, cmd_file_size, will be useful to generate a separate
size-data file.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.lib | 3 +++
 1 file changed, 3 insertions(+)

Comments

Nicolas Schier Jan. 10, 2022, 11:33 a.m. UTC | #1
On Mon, Jan 10, 2022 at 03:15:29AM +0900, Masahiro Yamada wrote:
> Some architectures support self-extracting kernel, which embeds the
> compressed vmlinux.
> 
> It has 4 byte data at the end so the decompressor can know the vmlinux
> size beforehand.
> 
> GZIP natively has it in the trailer, but for the other compression
> algorithms, the hand-crafted trailer is added.
> 
> It is unneeded to generate such _corrupted_ compressed files because
> it is possible to pass the size data separately.
> 
> For example, the assembly code:
> 
>      .incbin "compressed-vmlinux-with-size-data-appended"
> 
> can be transformed to:
> 
>      .incbin "compressed-vmlinux"
>      .incbin "size-data"
> 
> My hope is, after some reworks of the decompressors, the macros
> cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22} will go away.
> 
> This new macro, cmd_file_size, will be useful to generate a separate
> size-data file.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

Reviewed-by: Nicolas Schier <n.schier@avm.de>

> 
>  scripts/Makefile.lib | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 4207a72d429f..05ca77706f6b 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -394,6 +394,9 @@ printf "%08x\n" $$dec_size |						\
>  	}								\
>  )
>  
> +quiet_cmd_file_size = GEN     $@
> +      cmd_file_size = $(size_append) > $@
> +
>  quiet_cmd_bzip2 = BZIP2   $@
>        cmd_bzip2 = cat $(real-prereqs) | $(KBZIP2) -9 > $@
>  
> -- 
> 2.32.0
>
diff mbox series

Patch

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 4207a72d429f..05ca77706f6b 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -394,6 +394,9 @@  printf "%08x\n" $$dec_size |						\
 	}								\
 )
 
+quiet_cmd_file_size = GEN     $@
+      cmd_file_size = $(size_append) > $@
+
 quiet_cmd_bzip2 = BZIP2   $@
       cmd_bzip2 = cat $(real-prereqs) | $(KBZIP2) -9 > $@