* [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin
@ 2010-06-02 8:35 Wu Zhangjin
2010-06-02 8:35 ` [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS Wu Zhangjin
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Wu Zhangjin @ 2010-06-02 8:35 UTC (permalink / raw)
To: Ralf Baechle, linux-mips
Cc: Alexander Clouter, Manuel Lauss, Sam Ravnborg, Wu Zhangjin
The compressed vmlinux.bin is only a temp file, we can use the same suffix(.z)
for them(.gz,.lzo,.lzma...) to remove several lines and simpify the
maintaining(no need to add the "suffix_$(xxx) := suffix" line).
Changes:
v1 -> v2:
o Rename vmlinux.z to vmlinux.bin.z for vmlinux.z here is the compressed
vmlinux.bin, not compressed vmlinux.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
arch/mips/boot/compressed/Makefile | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
index 74a52d7..a517f58 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -48,23 +48,19 @@ OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
$(call if_changed,objcopy)
-suffix_$(CONFIG_KERNEL_GZIP) = gz
-suffix_$(CONFIG_KERNEL_BZIP2) = bz2
-suffix_$(CONFIG_KERNEL_LZMA) = lzma
-suffix_$(CONFIG_KERNEL_LZO) = lzo
tool_$(CONFIG_KERNEL_GZIP) = gzip
tool_$(CONFIG_KERNEL_BZIP2) = bzip2
tool_$(CONFIG_KERNEL_LZMA) = lzma
tool_$(CONFIG_KERNEL_LZO) = lzo
-targets += vmlinux.gz vmlinux.bz2 vmlinux.lzma vmlinux.lzo
-$(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin FORCE
+targets += vmlinux.bin.z
+$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
$(call if_changed,$(tool_y))
targets += piggy.o
-OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.$(suffix_y) \
+OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
--set-section-flags=.image=contents,alloc,load,readonly,data
-$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.$(suffix_y) FORCE
+$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
$(call if_changed,objcopy)
LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
--
1.6.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
2010-06-02 8:35 [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin Wu Zhangjin
@ 2010-06-02 8:35 ` Wu Zhangjin
2010-06-02 19:48 ` Sam Ravnborg
2010-08-05 1:32 ` Ralf Baechle
2010-07-29 1:32 ` [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin wu zhangjin
2010-08-05 3:10 ` Ralf Baechle
2 siblings, 2 replies; 8+ messages in thread
From: Wu Zhangjin @ 2010-06-02 8:35 UTC (permalink / raw)
To: Ralf Baechle, linux-mips
Cc: Alexander Clouter, Manuel Lauss, Sam Ravnborg, Wu Zhangjin
We have calculated VMLINUZ_LOAD_ADDRESS in shell, which is indecipherable. This
patch rewrites it in C.
Changes:
v3 -> v4: (feedback from Sam Ravnborg)
o Makefile: Follow the 80 characters' limit and Remove an un-needed objcopy.
o calc_vmlinuz_load_addr.c: Use a smaller alignment and Add more comments
v2 -> v3: (feedback from Alexander Clouter)
o Drop the unneeded variable n
o Replace the last "unsigned long long" by uint64_t
v1 -> v2: (feedback from Alexander Clouter)
o make it more portable
use EXIT_SUCCESS and EXIT_FAILURE as the return value, and use uint64_t
instead of "unsigned long long".
o add a missing return value
return EXIT_FAILURE if sscanf() not return 1
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
arch/mips/boot/.gitignore | 1 +
arch/mips/boot/compressed/Makefile | 26 +++++-----
arch/mips/boot/compressed/calc_vmlinuz_load_addr.c | 57 ++++++++++++++++++++
3 files changed, 71 insertions(+), 13 deletions(-)
create mode 100644 arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
diff --git a/arch/mips/boot/.gitignore b/arch/mips/boot/.gitignore
index 4667a5f..f210b09 100644
--- a/arch/mips/boot/.gitignore
+++ b/arch/mips/boot/.gitignore
@@ -3,3 +3,4 @@ elf2ecoff
vmlinux.*
zImage
zImage.tmp
+calc_vmlinuz_load_addr
diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
index a517f58..9ef6e2f 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -12,14 +12,6 @@
# Author: Wu Zhangjin <wuzhangjin@gmail.com>
#
-# compressed kernel load addr: VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE
-VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | cut -d' ' -f1)
-VMLINUX_SIZE := $(shell [ -n "$(VMLINUX_SIZE)" ] && echo -n $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))
-# VMLINUZ_LOAD_ADDRESS = concat "high32 of VMLINUX_LOAD_ADDRESS" and "(low32 of VMLINUX_LOAD_ADDRESS) + VMLINUX_SIZE"
-HIGH32 := $(shell A=$(VMLINUX_LOAD_ADDRESS); [ $${\#A} -gt 10 ] && expr substr "$(VMLINUX_LOAD_ADDRESS)" 3 $$(($${\#A} - 10)))
-LOW32 := $(shell [ -n "$(HIGH32)" ] && A=11 || A=3; expr substr "$(VMLINUX_LOAD_ADDRESS)" $${A} 8)
-VMLINUZ_LOAD_ADDRESS := 0x$(shell [ -n "$(VMLINUX_SIZE)" -a -n "$(LOW32)" ] && printf "$(HIGH32)%08x" $$(($(VMLINUX_SIZE) + 0x$(LOW32))))
-
# set the default size of the mallocing area for decompressing
BOOT_HEAP_SIZE := 0x400000
@@ -63,10 +55,18 @@ OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
$(call if_changed,objcopy)
-LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
-vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/piggy.o
- $(call cmd,ld)
- $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@
+# Calculate the load address of the compressed kernel image
+hostprogs-y := calc_vmlinuz_load_addr
+
+VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
+ $(objtree)/$(KBUILD_IMAGE) $(VMLINUX_LOAD_ADDRESS))
+
+vmlinuzobjs-y += $(obj)/piggy.o
+
+quiet_cmd_zld = LD $@
+ cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
+vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
+ $(call cmd,zld)
#
# Some DECstations need all possible sections of an ECOFF executable
@@ -76,7 +76,7 @@ ifdef CONFIG_MACH_DECSTATION
endif
# elf2ecoff can only handle 32bit image
-hostprogs-y := ../elf2ecoff
+hostprogs-y += ../elf2ecoff
ifdef CONFIG_32BIT
VMLINUZ = vmlinuz
diff --git a/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c b/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
new file mode 100644
index 0000000..88c9d96
--- /dev/null
+++ b/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 "Wu Zhangjin" <wuzhangjin@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+ struct stat sb;
+ uint64_t vmlinux_size, vmlinux_load_addr, vmlinuz_load_addr;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: %s <pathname> <vmlinux_load_addr>\n",
+ argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if (stat(argv[1], &sb) == -1) {
+ perror("stat");
+ return EXIT_FAILURE;
+ }
+
+ /* Convert hex characters to dec number */
+ errno = 0;
+ if (sscanf(argv[2], "%llx", &vmlinux_load_addr) != 1) {
+ if (errno != 0)
+ perror("sscanf");
+ else
+ fprintf(stderr, "No matching characters\n");
+
+ return EXIT_FAILURE;
+ }
+
+ vmlinux_size = (uint64_t)sb.st_size;
+ vmlinuz_load_addr = vmlinux_load_addr + vmlinux_size;
+
+ /*
+ * Align with 16 bytes: "greater than that used for any standard data
+ * types by a MIPS compiler." -- See MIPS Run Linux (Second Edition).
+ */
+
+ vmlinuz_load_addr += (16 - vmlinux_size % 16);
+
+ printf("0x%llx\n", vmlinuz_load_addr);
+
+ return EXIT_SUCCESS;
+}
--
1.6.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
2010-06-02 8:35 ` [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS Wu Zhangjin
@ 2010-06-02 19:48 ` Sam Ravnborg
2010-06-02 21:50 ` Alexander Clouter
2010-08-05 1:32 ` Ralf Baechle
1 sibling, 1 reply; 8+ messages in thread
From: Sam Ravnborg @ 2010-06-02 19:48 UTC (permalink / raw)
To: Wu Zhangjin; +Cc: Ralf Baechle, linux-mips, Alexander Clouter, Manuel Lauss
On Wed, Jun 02, 2010 at 04:35:25PM +0800, Wu Zhangjin wrote:
> We have calculated VMLINUZ_LOAD_ADDRESS in shell, which is indecipherable. This
> patch rewrites it in C.
>
> Changes:
>
> v3 -> v4: (feedback from Sam Ravnborg)
> o Makefile: Follow the 80 characters' limit and Remove an un-needed objcopy.
> o calc_vmlinuz_load_addr.c: Use a smaller alignment and Add more comments
>
> v2 -> v3: (feedback from Alexander Clouter)
> o Drop the unneeded variable n
> o Replace the last "unsigned long long" by uint64_t
>
> v1 -> v2: (feedback from Alexander Clouter)
> o make it more portable
> use EXIT_SUCCESS and EXIT_FAILURE as the return value, and use uint64_t
> instead of "unsigned long long".
> o add a missing return value
> return EXIT_FAILURE if sscanf() not return 1
>
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
2010-06-02 19:48 ` Sam Ravnborg
@ 2010-06-02 21:50 ` Alexander Clouter
0 siblings, 0 replies; 8+ messages in thread
From: Alexander Clouter @ 2010-06-02 21:50 UTC (permalink / raw)
To: wuzhangjin; +Cc: Ralf Baechle, linux-mips, Manuel Lauss, sam
* Sam Ravnborg <sam@ravnborg.org> [2010-06-02 21:48:17+0200]:
>
> On Wed, Jun 02, 2010 at 04:35:25PM +0800, Wu Zhangjin wrote:
> > We have calculated VMLINUZ_LOAD_ADDRESS in shell, which is indecipherable. This
> > patch rewrites it in C.
> >
> > Changes:
> >
> > v3 -> v4: (feedback from Sam Ravnborg)
> > o Makefile: Follow the 80 characters' limit and Remove an un-needed objcopy.
> > o calc_vmlinuz_load_addr.c: Use a smaller alignment and Add more comments
> >
> > v2 -> v3: (feedback from Alexander Clouter)
> > o Drop the unneeded variable n
> > o Replace the last "unsigned long long" by uint64_t
> >
> > v1 -> v2: (feedback from Alexander Clouter)
> > o make it more portable
> > use EXIT_SUCCESS and EXIT_FAILURE as the return value, and use uint64_t
> > instead of "unsigned long long".
> > o add a missing return value
> > return EXIT_FAILURE if sscanf() not return 1
> >
> > Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Alexander Clouter <alex@digriz.org.uk>
--
Alexander Clouter
.sigmonster says: The price of greatness is responsibility.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin
2010-06-02 8:35 [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin Wu Zhangjin
2010-06-02 8:35 ` [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS Wu Zhangjin
@ 2010-07-29 1:32 ` wu zhangjin
2010-08-05 3:10 ` Ralf Baechle
2 siblings, 0 replies; 8+ messages in thread
From: wu zhangjin @ 2010-07-29 1:32 UTC (permalink / raw)
To: Ralf Baechle, linux-mips
Cc: Alexander Clouter, Manuel Lauss, Sam Ravnborg, Wu Zhangjin
[-- Attachment #1: Type: text/plain, Size: 2897 bytes --]
Hi, Ralf
ping ...
Is it possible to queue the following several cleanups of the compressed
kernel support to 2.6.36?
1. [v2] MIPS: Unify the suffix of compressed vmlinux.bin
http://patchwork.linux-mips.org/patch/1323/
2. [v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
http://patchwork.linux-mips.org/patch/1324/
3. MIPS: Clean up arch/mips/boot/compressed/ld.script
http://patchwork.linux-mips.org/patch/1381/
4. MIPS: Clean up arch/mips/boot/compressed/decompress.c
http://patchwork.linux-mips.org/patch/1382/
5. MIPS: strip the un-needed sections of vmlinuz
http://patchwork.linux-mips.org/patch/1383/
All of them only include cleanups, no functional changes.
Seems you need to apply them one by one as the above order.
Best Regards,
Wu Zhangjin
On Wed, Jun 2, 2010 at 4:35 PM, Wu Zhangjin <wuzhangjin@gmail.com> wrote:
> The compressed vmlinux.bin is only a temp file, we can use the same
> suffix(.z)
> for them(.gz,.lzo,.lzma...) to remove several lines and simpify the
> maintaining(no need to add the "suffix_$(xxx) := suffix" line).
>
> Changes:
>
> v1 -> v2:
> o Rename vmlinux.z to vmlinux.bin.z for vmlinux.z here is the compressed
> vmlinux.bin, not compressed vmlinux.
>
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
> arch/mips/boot/compressed/Makefile | 12 ++++--------
> 1 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/arch/mips/boot/compressed/Makefile
> b/arch/mips/boot/compressed/Makefile
> index 74a52d7..a517f58 100644
> --- a/arch/mips/boot/compressed/Makefile
> +++ b/arch/mips/boot/compressed/Makefile
> @@ -48,23 +48,19 @@ OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary
> -R .comment -S
> $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
> $(call if_changed,objcopy)
>
> -suffix_$(CONFIG_KERNEL_GZIP) = gz
> -suffix_$(CONFIG_KERNEL_BZIP2) = bz2
> -suffix_$(CONFIG_KERNEL_LZMA) = lzma
> -suffix_$(CONFIG_KERNEL_LZO) = lzo
> tool_$(CONFIG_KERNEL_GZIP) = gzip
> tool_$(CONFIG_KERNEL_BZIP2) = bzip2
> tool_$(CONFIG_KERNEL_LZMA) = lzma
> tool_$(CONFIG_KERNEL_LZO) = lzo
>
> -targets += vmlinux.gz vmlinux.bz2 vmlinux.lzma vmlinux.lzo
> -$(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin FORCE
> +targets += vmlinux.bin.z
> +$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
> $(call if_changed,$(tool_y))
>
> targets += piggy.o
> -OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.$(suffix_y) \
> +OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
>
> --set-section-flags=.image=contents,alloc,load,readonly,data
> -$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.$(suffix_y) FORCE
> +$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
> $(call if_changed,objcopy)
>
> LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
> --
> 1.6.5
>
>
--
MSN+Gtalk: wuzhangjin@gmail.com
Blog: http://falcon.oss.lzu.edu.cn
Tel:+86-18710032278
[-- Attachment #2: Type: text/html, Size: 3908 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
2010-06-02 8:35 ` [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS Wu Zhangjin
2010-06-02 19:48 ` Sam Ravnborg
@ 2010-08-05 1:32 ` Ralf Baechle
2010-08-05 4:50 ` wu zhangjin
1 sibling, 1 reply; 8+ messages in thread
From: Ralf Baechle @ 2010-08-05 1:32 UTC (permalink / raw)
To: Wu Zhangjin; +Cc: linux-mips, Alexander Clouter, Manuel Lauss, Sam Ravnborg
Applied - but there was a fuzz when applying the patch. Hope that was
harmless...
Thanks,
Ralf
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin
2010-06-02 8:35 [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin Wu Zhangjin
2010-06-02 8:35 ` [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS Wu Zhangjin
2010-07-29 1:32 ` [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin wu zhangjin
@ 2010-08-05 3:10 ` Ralf Baechle
2 siblings, 0 replies; 8+ messages in thread
From: Ralf Baechle @ 2010-08-05 3:10 UTC (permalink / raw)
To: Wu Zhangjin; +Cc: linux-mips, Alexander Clouter, Manuel Lauss, Sam Ravnborg
Thanks, applied.
Ralf
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
2010-08-05 1:32 ` Ralf Baechle
@ 2010-08-05 4:50 ` wu zhangjin
0 siblings, 0 replies; 8+ messages in thread
From: wu zhangjin @ 2010-08-05 4:50 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, Alexander Clouter, Manuel Lauss, Sam Ravnborg
Hi, Ralf
On Thu, Aug 5, 2010 at 9:32 AM, Ralf Baechle <ralf@linux-mips.org> wrote:
> Applied - but there was a fuzz when applying the patch. Hope that was
> harmless...
Sorry to disturb you again.
Just found the key file calc_vmlinuz_load_addr.c is not in your
upstream-linus.git, I guess a "git add" was missing for it ;)
the commit in upstream:
http://git.linux-mips.org/?p=upstream-linus.git;a=commit;h=af86de3e5347c114afd978fbfc16af9a77e24c47
the original patch:
http://patchwork.linux-mips.org/patch/1324/
Thanks & Regards,
Wu Zhangjin
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-08-05 4:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-02 8:35 [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin Wu Zhangjin
2010-06-02 8:35 ` [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS Wu Zhangjin
2010-06-02 19:48 ` Sam Ravnborg
2010-06-02 21:50 ` Alexander Clouter
2010-08-05 1:32 ` Ralf Baechle
2010-08-05 4:50 ` wu zhangjin
2010-07-29 1:32 ` [PATCH v2] MIPS: Unify the suffix of compressed vmlinux.bin wu zhangjin
2010-08-05 3:10 ` Ralf Baechle
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).