From 1373411ae4cd0caf2e1a35fb801dd9a00b64dea2 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 28 Dec 2009 19:38:27 +0000 Subject: [PATCH 1/2] kbuild: really fix bzImage build with non-bash sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ß Reported-by: Oliver Hartkopp Reported-by: Michael Guntsche Signed-off-by: Jonathan Nieder Cc: Michael Tokarev Cc: Alek Du Cc: Andrew Morton Signed-off-by: Michal Marek --- scripts/Makefile.lib | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0fe48cd91ff..f9bdf264473 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 $@ From 07105202bdebf6e9a4c72c634cf90398abfad870 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 8 Jan 2010 12:25:37 +0100 Subject: [PATCH 2/2] Makefile: do not override LC_CTYPE Setting LC_CTYPE=C breaks localized messages in some setups. With only LC_COLLATE=C and LC_NUMERIC=C, we get almost all we need, except for not so defined character classes and tolower()/toupper(). The former is not a big issue, because we can assume that e.g. [:alpha:] will always include a-zA-Z and we only ever process ASCII input. The latter seems only affect arch/sh/tools/gen-mach-types, which we can handle separately. So after this patch the meaning of ranges like [a-z], the behavior of sort and join, etc. should be the same everywhere and at the same time gcc should be able to print localized waring and error messages. LC_NUMERIC=C might not be necessary, but setting it doesn't hurt. Reported-by: Simon Horman Reported-by: Sergei Trofimovich Acked-by: H. Peter Anvin Tested-by: Simon Horman Tested-by: Masami Hiramatsu Signed-off-by: Michal Marek --- Makefile | 3 +-- arch/sh/tools/Makefile | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9f64552f09d..5f333bf870f 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,9 @@ MAKEFLAGS += -rR --no-print-directory # Avoid funny character set dependencies unexport LC_ALL -LC_CTYPE=C LC_COLLATE=C LC_NUMERIC=C -export LC_CTYPE LC_COLLATE LC_NUMERIC +export LC_COLLATE LC_NUMERIC # We are using a recursive build, so we need to do a little thinking # to get the ordering right. diff --git a/arch/sh/tools/Makefile b/arch/sh/tools/Makefile index 558a56bcc7c..2082af1f3fe 100644 --- a/arch/sh/tools/Makefile +++ b/arch/sh/tools/Makefile @@ -13,4 +13,4 @@ include/generated/machtypes.h: $(src)/gen-mach-types $(src)/mach-types @echo ' Generating $@' $(Q)mkdir -p $(dir $@) - $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; } + $(Q)LC_ALL=C $(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }