cpu-nios2.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* BFD support for the Altera Nios II processor.
  2. Copyright (C) 2012-2022 Free Software Foundation, Inc.
  3. Contributed by Nigel Gray (ngray@altera.com).
  4. Contributed by Mentor Graphics, Inc.
  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. static const bfd_arch_info_type *
  22. nios2_compatible (const bfd_arch_info_type *a,
  23. const bfd_arch_info_type *b)
  24. {
  25. if (a->arch != b->arch)
  26. return NULL;
  27. if (a->bits_per_word != b->bits_per_word)
  28. return NULL;
  29. if (a->mach == bfd_mach_nios2)
  30. return a;
  31. else if (b->mach == bfd_mach_nios2)
  32. return b;
  33. else if (a->mach != b->mach)
  34. return NULL;
  35. return a;
  36. }
  37. #define N(NUMBER, PRINT, DEFAULT, NEXT) \
  38. { \
  39. 32, /* Bits in a word. */ \
  40. 32, /* Bits in an address. */ \
  41. 8, /* Bits in a byte. */ \
  42. bfd_arch_nios2, \
  43. NUMBER, \
  44. "nios2", \
  45. PRINT, \
  46. 3, \
  47. DEFAULT, \
  48. nios2_compatible, \
  49. bfd_default_scan, \
  50. bfd_arch_default_fill, \
  51. NEXT, \
  52. 0 /* Maximum offset of a reloc from the start of an insn. */ \
  53. }
  54. #define NIOS2R1_NEXT &arch_info_struct[0]
  55. #define NIOS2R2_NEXT &arch_info_struct[1]
  56. static const bfd_arch_info_type arch_info_struct[2] =
  57. {
  58. N (bfd_mach_nios2r1, "nios2:r1", false, NIOS2R2_NEXT),
  59. N (bfd_mach_nios2r2, "nios2:r2", false, NULL),
  60. };
  61. const bfd_arch_info_type bfd_nios2_arch =
  62. N (bfd_mach_nios2, "nios2", true, NIOS2R1_NEXT);