Skip to content

Commit 1373411

Browse files
jrnmichal42
authored andcommitted
kbuild: really fix bzImage build with non-bash sh
In an x86 build with CONFIG_KERNEL_LZMA enabled and dash as sh, arch/x86/boot/compressed/vmlinux.bin.lzma ends with '\xf0\x7d\x39\x00' (16 bytes) instead of the 4 bytes intended and the resulting vmlinuz fails to boot. This improves on the previous behavior, in which the file contained the characters '-ne ' as well, but not by much. Previous commits replaced "echo -ne" first with "/bin/echo -ne", then "printf" in the hope of improving portability, but none of these commands is guaranteed to support hexadecimal escapes on POSIX systems. So use the shell to convert from hexadecimal to octal. With this change, an LZMA-compressed kernel built with dash as sh boots correctly again. Reported-by: Sebastian Dalfuß <sd@sedf.de> Reported-by: Oliver Hartkopp <oliver@hartkopp.net> Reported-by: Michael Guntsche <mike@it-loops.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Cc: Michael Tokarev <mjt@tls.msk.ru> Cc: Alek Du <alek.du@intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
1 parent 7284ce6 commit 1373411

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎scripts/Makefile.lib‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,13 @@ for F in $1; do \
219219
fsize=$$(stat -c "%s" $$F); \
220220
dec_size=$$(expr $$dec_size + $$fsize); \
221221
done; \
222-
printf "%08x" $$dec_size | \
223-
sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g' \
222+
printf "%08x\n" $$dec_size | \
223+
sed 's/\(..\)/\1 /g' | { \
224+
read ch0 ch1 ch2 ch3; \
225+
for ch in $$ch3 $$ch2 $$ch1 $$ch0; do \
226+
printf '%s%03o' '\\' $$((0x$$ch)); \
227+
done; \
228+
} \
224229
)
225230

226231
quiet_cmd_bzip2 = BZIP2 $@

0 commit comments

Comments
 (0)