diff options
author | Wu Zhangjin <wuzhangjin@gmail.com> | 2010-06-02 04:35:24 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-08-05 08:26:31 -0400 |
commit | c853d945d3e0cadf60da03106f7d9bbf1346a518 (patch) | |
tree | ed5b01eda172cb9c7cd7740206aec5e0a0192d4d /arch/mips | |
parent | 51f1336d4dbd0935d873761f7f267c3f5abc9bd6 (diff) |
MIPS: Unify the suffix of compressed vmlinux.bin
The compressed vmlinux.bin is only a temp file so it's ok to use the same
suffix .z for them (.gz,.lzo,.lzma...) to remove several lines and simpify
the maintenance (no need to add the "suffix_$(xxx) := suffix" line).
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
To: linux-mips <linux-mips@linux-mips.org>
Cc: Alexander Clouter <alex@digriz.org.uk>
Cc: Manuel Lauss <manuel.lauss@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Patchwork: https://patchwork.linux-mips.org/patch/1323/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/boot/compressed/Makefile | 12 | ||||
-rw-r--r-- | arch/mips/boot/compressed/calc_vmlinuz_load_addr.c | 57 |
2 files changed, 61 insertions, 8 deletions
diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index edc48adf8845..3bdbeef0e0f5 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 | |||
48 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE | 48 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE |
49 | $(call if_changed,objcopy) | 49 | $(call if_changed,objcopy) |
50 | 50 | ||
51 | suffix_$(CONFIG_KERNEL_GZIP) = gz | ||
52 | suffix_$(CONFIG_KERNEL_BZIP2) = bz2 | ||
53 | suffix_$(CONFIG_KERNEL_LZMA) = lzma | ||
54 | suffix_$(CONFIG_KERNEL_LZO) = lzo | ||
55 | tool_$(CONFIG_KERNEL_GZIP) = gzip | 51 | tool_$(CONFIG_KERNEL_GZIP) = gzip |
56 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 | 52 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 |
57 | tool_$(CONFIG_KERNEL_LZMA) = lzma | 53 | tool_$(CONFIG_KERNEL_LZMA) = lzma |
58 | tool_$(CONFIG_KERNEL_LZO) = lzo | 54 | tool_$(CONFIG_KERNEL_LZO) = lzo |
59 | 55 | ||
60 | targets += vmlinux.gz vmlinux.bz2 vmlinux.lzma vmlinux.lzo | 56 | targets += vmlinux.bin.z |
61 | $(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin FORCE | 57 | $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE |
62 | $(call if_changed,$(tool_y)) | 58 | $(call if_changed,$(tool_y)) |
63 | 59 | ||
64 | targets += piggy.o | 60 | targets += piggy.o |
65 | OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.$(suffix_y) \ | 61 | OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ |
66 | --set-section-flags=.image=contents,alloc,load,readonly,data | 62 | --set-section-flags=.image=contents,alloc,load,readonly,data |
67 | $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.$(suffix_y) FORCE | 63 | $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE |
68 | $(call if_changed,objcopy) | 64 | $(call if_changed,objcopy) |
69 | 65 | ||
70 | LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T | 66 | LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T |
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 000000000000..88c9d963be88 --- /dev/null +++ b/arch/mips/boot/compressed/calc_vmlinuz_load_addr.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010 "Wu Zhangjin" <wuzhangjin@gmail.com> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | */ | ||
9 | |||
10 | #include <sys/types.h> | ||
11 | #include <sys/stat.h> | ||
12 | #include <errno.h> | ||
13 | #include <stdint.h> | ||
14 | #include <stdio.h> | ||
15 | #include <stdlib.h> | ||
16 | |||
17 | int main(int argc, char *argv[]) | ||
18 | { | ||
19 | struct stat sb; | ||
20 | uint64_t vmlinux_size, vmlinux_load_addr, vmlinuz_load_addr; | ||
21 | |||
22 | if (argc != 3) { | ||
23 | fprintf(stderr, "Usage: %s <pathname> <vmlinux_load_addr>\n", | ||
24 | argv[0]); | ||
25 | return EXIT_FAILURE; | ||
26 | } | ||
27 | |||
28 | if (stat(argv[1], &sb) == -1) { | ||
29 | perror("stat"); | ||
30 | return EXIT_FAILURE; | ||
31 | } | ||
32 | |||
33 | /* Convert hex characters to dec number */ | ||
34 | errno = 0; | ||
35 | if (sscanf(argv[2], "%llx", &vmlinux_load_addr) != 1) { | ||
36 | if (errno != 0) | ||
37 | perror("sscanf"); | ||
38 | else | ||
39 | fprintf(stderr, "No matching characters\n"); | ||
40 | |||
41 | return EXIT_FAILURE; | ||
42 | } | ||
43 | |||
44 | vmlinux_size = (uint64_t)sb.st_size; | ||
45 | vmlinuz_load_addr = vmlinux_load_addr + vmlinux_size; | ||
46 | |||
47 | /* | ||
48 | * Align with 16 bytes: "greater than that used for any standard data | ||
49 | * types by a MIPS compiler." -- See MIPS Run Linux (Second Edition). | ||
50 | */ | ||
51 | |||
52 | vmlinuz_load_addr += (16 - vmlinux_size % 16); | ||
53 | |||
54 | printf("0x%llx\n", vmlinuz_load_addr); | ||
55 | |||
56 | return EXIT_SUCCESS; | ||
57 | } | ||