cpu-cris.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* BFD support for the Axis CRIS architecture.
  2. Copyright (C) 2000-2022 Free Software Foundation, Inc.
  3. Contributed by Axis Communications AB.
  4. Written by Hans-Peter Nilsson.
  5. This file is part of BFD, the Binary File Descriptor library.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17. MA 02110-1301, USA. */
  18. #include "sysdep.h"
  19. #include "bfd.h"
  20. #include "libbfd.h"
  21. /* This routine is provided two arch_infos and returns the lowest common
  22. denominator. CRIS v0..v10 vs. v32 are not compatible in general, but
  23. there's a compatible subset for which we provide an arch_info. */
  24. static const bfd_arch_info_type * get_compatible
  25. (const bfd_arch_info_type *, const bfd_arch_info_type *);
  26. static const bfd_arch_info_type *
  27. get_compatible (const bfd_arch_info_type *a,
  28. const bfd_arch_info_type *b)
  29. {
  30. /* Arches must match. */
  31. if (a->arch != b->arch)
  32. return NULL;
  33. /* If either is the compatible mach, return the other. */
  34. if (a->mach == bfd_mach_cris_v10_v32)
  35. return b;
  36. if (b->mach == bfd_mach_cris_v10_v32)
  37. return a;
  38. #if 0
  39. /* The code below is disabled but kept as a warning.
  40. See ldlang.c:lang_check. Quite illogically, incompatible arches
  41. (as signalled by this function) are only *warned* about, while with
  42. this function signalling compatible ones, we can have the
  43. cris_elf_merge_private_bfd_data function return an error. This is
  44. undoubtedly a FIXME: in general. Also, the
  45. command_line.warn_mismatch flag and the --no-warn-mismatch option
  46. are misnamed for the multitude of ports that signal compatibility:
  47. it is there an error, not a warning. We work around it by
  48. pretending matching machs here. */
  49. /* Except for the compatible mach, machs must match. */
  50. if (a->mach != b->mach)
  51. return NULL;
  52. #endif
  53. return a;
  54. }
  55. #define N(NUMBER, PRINT, NEXT) \
  56. { 32, 32, 8, bfd_arch_cris, NUMBER, "cris", PRINT, 1, false, \
  57. get_compatible, bfd_default_scan, bfd_arch_default_fill, NEXT, 0 }
  58. static const bfd_arch_info_type bfd_cris_arch_compat_v10_v32 =
  59. N (bfd_mach_cris_v10_v32, "cris:common_v10_v32", NULL);
  60. static const bfd_arch_info_type bfd_cris_arch_v32 =
  61. N (bfd_mach_cris_v32, "crisv32", &bfd_cris_arch_compat_v10_v32);
  62. const bfd_arch_info_type bfd_cris_arch =
  63. {
  64. 32, /* There's 32 bits_per_word. */
  65. 32, /* There's 32 bits_per_address. */
  66. 8, /* There's 8 bits_per_byte. */
  67. bfd_arch_cris, /* One of enum bfd_architecture, defined
  68. in archures.c and provided in
  69. generated header files. */
  70. bfd_mach_cris_v0_v10, /* Random BFD-internal number for this
  71. machine, similarly listed in
  72. archures.c. Not emitted in output. */
  73. "cris", /* The arch_name. */
  74. "cris", /* The printable name is the same. */
  75. 1, /* Section alignment power; each section
  76. is aligned to (only) 2^1 bytes. */
  77. true, /* This is the default "machine". */
  78. get_compatible, /* A function for testing
  79. "machine" compatibility of two
  80. bfd_arch_info_type. */
  81. bfd_default_scan, /* Check if a bfd_arch_info_type is a
  82. match. */
  83. bfd_arch_default_fill, /* Default fill. */
  84. &bfd_cris_arch_v32, /* Pointer to next bfd_arch_info_type in
  85. the same family. */
  86. 0 /* Maximum offset of a reloc from the start of an insn. */
  87. };
  88. /*
  89. * Local variables:
  90. * eval: (c-set-style "gnu")
  91. * indent-tabs-mode: t
  92. * End:
  93. */