030-allow-to-use-different-magic.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /* Build new header */
  48. - image_set_magic(hdr, IH_MAGIC);
  49. + image_set_magic(hdr, params->magic);
  50. image_set_time(hdr, sbuf->st_mtime);
  51. image_set_size(hdr, sbuf->st_size - sizeof(image_header_t));
  52. image_set_load(hdr, params->addr);
  53. --- a/tools/imagetool.h
  54. +++ b/tools/imagetool.h
  55. @@ -44,6 +44,7 @@
  56. int arch;
  57. int type;
  58. int comp;
  59. + unsigned int magic;
  60. char *dtc;
  61. unsigned int addr;
  62. unsigned int ep;