linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Michal Marek <mmarek@suse.cz>
Cc: sd@sedf.de, Andrew Morton <akpm@linux-foundation.org>,
	Michael Tokarev <mjt@tls.msk.ru>, Alek Du <alek.du@intel.com>,
	linux-kbuild@vger.kernel.org
Subject: [PATCH] kbuild: really fix bzImage build with non-bash sh
Date: Mon, 28 Dec 2009 19:38:27 +0000	[thread overview]
Message-ID: <20091228193827.GA2157@localhost> (raw)
In-Reply-To: <20091222154935.5da4be37.akpm@linux-foundation.org>

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: sd@sedf.de
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Michael Tokarev <mjt@tls.msk.ru>
Cc: Alek Du <alek.du@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
Andrew Morton wrote:

> switched to email.

Thanks.

sd@sedf.de reported through <http://bugzilla.kernel.org/show_bug.cgi?id=14848>:

>> The kernel fails to boot if compressed with bzip2 or lzma, gzip works.
>> 
>> Commit 4a2ff67c88211026afcbdbc190c13f705dae1b59 does:

Thanks for tracking it down.  The change below works here.

 scripts/Makefile.lib |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cd815ac..eabedbb 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -219,8 +219,13 @@ for F in $1; do								\
 	fsize=$$(stat -c "%s" $$F);					\
 	dec_size=$$(expr $$dec_size + $$fsize);				\
 done;									\
-printf "%08x" $$dec_size |						\
-	sed 's/\(..\)\(..\)\(..\)\(..\)/\\\\x\4\\\\x\3\\\\x\2\\\\x\1/g'	\
+printf "%08x\n" $$dec_size |						\
+	sed 's/\(..\)/\1 /g' | {					\
+		read ch0 ch1 ch2 ch3;					\
+		for ch in $$ch3 $$ch2 $$ch1 $$ch0; do			\
+			printf '%s%03o' '\\' $$((0x$$ch)); 		\
+		done;							\
+	}								\
 )
 
 quiet_cmd_bzip2 = BZIP2   $@
-- 
1.6.5.7


  reply	other threads:[~2009-12-28 19:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-14848-10286@http.bugzilla.kernel.org/>
2009-12-22 23:49 ` [Bugme-new] [Bug 14848] New: Kernel fails to boot if compressed with bzip2 or lzma Andrew Morton
2009-12-28 19:38   ` Jonathan Nieder [this message]
2010-01-04 13:48     ` [PATCH] kbuild: really fix bzImage build with non-bash sh Michal Marek

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=20091228193827.GA2157@localhost \
    --to=jrnieder@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alek.du@intel.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=mjt@tls.msk.ru \
    --cc=mmarek@suse.cz \
    --cc=sd@sedf.de \
    /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).