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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --- a/tools/mkimage.c
  2. +++ b/tools/mkimage.c
  3. @@ -21,6 +21,7 @@ static struct image_tool_params params =
  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. @@ -77,11 +78,12 @@ static void usage(const char *msg)
  12. " -l ==> list image header information\n",
  13. params.cmdname);
  14. fprintf(stderr,
  15. - " %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n"
  16. + " %s [-x] -A arch -O os -T type -C comp -M magic -a addr -e ep -n name -d data_file[:data_file...] image\n"
  17. " -A ==> set architecture to 'arch'\n"
  18. " -O ==> set operating system to 'os'\n"
  19. " -T ==> set image type to 'type'\n"
  20. " -C ==> set compression type 'comp'\n"
  21. + " -M ==> set image magic to 'magic'\n"
  22. " -a ==> set load address to 'addr' (hex)\n"
  23. " -e ==> set entry point to 'ep' (hex)\n"
  24. " -n ==> set image name to 'name'\n"
  25. @@ -144,7 +146,7 @@ static void process_args(int argc, char
  26. int opt;
  27. while ((opt = getopt(argc, argv,
  28. - "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) != -1) {
  29. + "a:A:b:c:C:d:D:e:Ef:Fk:i:K:lM:n:N:p:O:rR:qsT:vVx")) != -1) {
  30. switch (opt) {
  31. case 'a':
  32. params.addr = strtoull(optarg, &ptr, 16);
  33. @@ -222,6 +224,14 @@ static void process_args(int argc, char
  34. case 'l':
  35. params.lflag = 1;
  36. break;
  37. + case 'M':
  38. + params.magic = strtoull(optarg, &ptr, 16);
  39. + if (*ptr) {
  40. + fprintf(stderr, "%s: invalid magic %s\n",
  41. + params.cmdname, optarg);
  42. + exit(EXIT_FAILURE);
  43. + }
  44. + break;
  45. case 'n':
  46. params.imagename = optarg;
  47. break;
  48. --- a/tools/default_image.c
  49. +++ b/tools/default_image.c
  50. @@ -106,7 +106,7 @@ static void image_set_header(void *ptr,
  51. imagesize = sbuf->st_size - sizeof(image_header_t);
  52. /* Build new header */
  53. - image_set_magic(hdr, IH_MAGIC);
  54. + image_set_magic(hdr, params->magic);
  55. image_set_time(hdr, time);
  56. image_set_size(hdr, imagesize);
  57. image_set_load(hdr, params->addr);
  58. --- a/tools/imagetool.h
  59. +++ b/tools/imagetool.h
  60. @@ -54,6 +54,7 @@ struct image_tool_params {
  61. int arch;
  62. int type;
  63. int comp;
  64. + unsigned int magic;
  65. char *dtc;
  66. unsigned int addr;
  67. unsigned int ep;