MIPS: Unify the suffix of compressed vmlinux.bin
PATCH v2 1/1 MIPS: Unify the suffix of compressed vmlinux.bin
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.
--- arch/mips/boot/compressed/Makefile | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
arch/mips/boot/compressed/Makefile +4 -8
@@ -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
Signature · 1 line
1.6.5
PATCH v4 1/1 MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
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
--- 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
arch/mips/boot/.gitignore +1 -0
@@ -3,3 +3,4 @@ elf2ecoff vmlinux.* zImage zImage.tmp +calc_vmlinuz_load_addr
arch/mips/boot/compressed/Makefile +13 -13
@@ -12,14 +12,6 @@ # Author: Wu Zhangjin <[email protected]> # -# 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
arch/mips/boot/compressed/calc_vmlinuz_load_addr.c new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
1.6.5
Re: [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
Quoted 13 lines · Wu Zhangjin
We have calculated
VMLINUZ_LOAD_ADDRESSin shell, which is indecipherable. This patch rewrites it in C.Changes:
v3 -> v4: (feedback from Sam Ravnborg)
oMakefile: Follow the 80 characters' limit and Remove an un-needed objcopy.
ocalc_vmlinuz_load_addr.c: Use a smaller alignment and Add more commentsv2 -> v3: (feedback from Alexander Clouter)
o Drop the unneeded variable n
o Replace the last "unsigned long long" byuint64_t
Quoted 8 lines
v1 -> v2: (feedback from Alexander Clouter)
o make it more portable
useEXIT_SUCCESSandEXIT_FAILUREas the return value, and useuint64_tinstead of "unsigned long long".
o add a missing return value
returnEXIT_FAILUREifsscanf()not return 1Signed-off-by Wu Zhangjin <[email protected]>
Alexander Clouter
Reviewed-byRe: [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
Quoted 22 lines · Sam Ravnborg
Quoted 20 lines · Wu Zhangjin
We have calculated
VMLINUZ_LOAD_ADDRESSin shell, which is indecipherable. This patch rewrites it in C.Changes:
v3 -> v4: (feedback from Sam Ravnborg)
oMakefile: Follow the 80 characters' limit and Remove an un-needed objcopy.
ocalc_vmlinuz_load_addr.c: Use a smaller alignment and Add more commentsv2 -> v3: (feedback from Alexander Clouter)
o Drop the unneeded variable n
o Replace the last "unsigned long long" byuint64_tv1 -> v2: (feedback from Alexander Clouter)
o make it more portable
useEXIT_SUCCESSandEXIT_FAILUREas the return value, and useuint64_tinstead of "unsigned long long".
o add a missing return value
returnEXIT_FAILUREifsscanf()not return 1
Quoted 2 lines
Quoted 1 line
Signed-off-by Wu Zhangjin <[email protected]>Acked-by Sam Ravnborg <[email protected]>
Signature · 2 lines
Alexander Clouter .sigmonster says: The price of greatness is responsibility.
Re: [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
In reply to Wu ZhangjinApplied - but there was a fuzz when applying the patch. Hope that was harmless...
Thanks,
Ralf
Re: [PATCH v4] MIPS: Clean up the calculation of VMLINUZ_LOAD_ADDRESS
Hi, Ralf
Quoted 2 lines · Ralf Baechle
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
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
Quoted 55 lines · Wu Zhangjin
The compressed vmlinux.bin is only a temp file, we can use the same suffix(.z)
forthem(.gz,.lzo,.lzma...)to remove several lines and simpify themaintaining(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 <[email protected]>--- arch/mips/boot/compressed/Makefile | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)arch/mips/boot/compressed/Makefile +4
-11@@ -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
Signature · 3 lines
MSN+Gtalk: [email protected] Blog: http://falcon.oss.lzu.edu.cn Tel:+86-18710032278
Ralf Baechle
AppliedThanks, applied.
Ralf