Commit c853d945d3e0cadf60da03106f7d9bbf1346a518

Authored by Wu Zhangjin
Committed by Ralf Baechle
1 parent 51f1336d4d

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>

---

Showing 2 changed files with 61 additions and 8 deletions Side-by-side Diff

arch/mips/boot/compressed/Makefile
... ... @@ -48,23 +48,19 @@
48 48 $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
49 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 51 tool_$(CONFIG_KERNEL_GZIP) = gzip
56 52 tool_$(CONFIG_KERNEL_BZIP2) = bzip2
57 53 tool_$(CONFIG_KERNEL_LZMA) = lzma
58 54 tool_$(CONFIG_KERNEL_LZO) = lzo
59 55  
60   -targets += vmlinux.gz vmlinux.bz2 vmlinux.lzma vmlinux.lzo
61   -$(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin FORCE
  56 +targets += vmlinux.bin.z
  57 +$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
62 58 $(call if_changed,$(tool_y))
63 59  
64 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 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 64 $(call if_changed,objcopy)
69 65  
70 66 LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
arch/mips/boot/compressed/calc_vmlinuz_load_addr.c
  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 +}