[tools] mkimage: update to 2014.04
[15.05/openwrt.git] / tools / mkimage / patches / 030-allow-to-use-different-magic.patch
1 --- a/tools/mkimage.c
2 +++ b/tools/mkimage.c
3 @@ -24,6 +24,7 @@
4         .arch = IH_ARCH_PPC,
5         .type = IH_TYPE_KERNEL,
6         .comp = IH_COMP_GZIP,
7 +       .magic = IH_MAGIC,
8         .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
9         .imagename = "",
10         .imagename2 = "",
11 @@ -168,6 +169,16 @@
12                                         genimg_get_comp_id (*++argv)) < 0)
13                                         usage ();
14                                 goto NXTARG;
15 +                       case 'M':
16 +                               if (--argc <=0)
17 +                                       usage ();
18 +                               params.magic = strtoul (*++argv, &ptr, 16);
19 +                               if (*ptr) {
20 +                                       fprintf (stderr,
21 +                                               "%s: invalid magic %s\n",
22 +                                               params.cmdname, *argv);
23 +                               }
24 +                               goto NXTARG;
25                         case 'D':
26                                 if (--argc <= 0)
27                                         usage ();
28 @@ -623,12 +634,13 @@
29         fprintf (stderr, "Usage: %s -l image\n"
30                          "          -l ==> list image header information\n",
31                 params.cmdname);
32 -       fprintf (stderr, "       %s [-x] -A arch -O os -T type -C comp "
33 +       fprintf (stderr, "       %s [-x] -A arch -O os -T type -C comp -M magic "
34                          "-a addr -e ep -n name -d data_file[:data_file...] image\n"
35                          "          -A ==> set architecture to 'arch'\n"
36                          "          -O ==> set operating system to 'os'\n"
37                          "          -T ==> set image type to 'type'\n"
38                          "          -C ==> set compression type 'comp'\n"
39 +                        "          -M ==> set image magic to 'magic'\n"
40                          "          -a ==> set load address to 'addr' (hex)\n"
41                          "          -e ==> set entry point to 'ep' (hex)\n"
42                          "          -n ==> set image name to 'name'\n"
43 --- a/tools/default_image.c
44 +++ b/tools/default_image.c
45 @@ -98,7 +98,7 @@
46                         sbuf->st_size - sizeof(image_header_t));
47  
48         /* Build new header */
49 -       image_set_magic(hdr, IH_MAGIC);
50 +       image_set_magic(hdr, params->magic);
51         image_set_time(hdr, sbuf->st_mtime);
52         image_set_size(hdr, sbuf->st_size - sizeof(image_header_t));
53         image_set_load(hdr, params->addr);
54 --- a/tools/imagetool.h
55 +++ b/tools/imagetool.h
56 @@ -44,6 +44,7 @@
57         int arch;
58         int type;
59         int comp;
60 +       unsigned int magic;
61         char *dtc;
62         unsigned int addr;
63         unsigned int ep;