]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - bfd/cpu-nios2.c
PR31692, objdump fails .debug_info size check
[thirdparty/binutils-gdb.git] / bfd / cpu-nios2.c
1 /* BFD support for the Altera Nios II processor.
2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
3 Contributed by Nigel Gray (ngray@altera.com).
4 Contributed by Mentor Graphics, Inc.
5
6 This file is part of BFD, the Binary File Descriptor library.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
22
23 #include "sysdep.h"
24 #include "bfd.h"
25 #include "libbfd.h"
26
27 static const bfd_arch_info_type *
28 nios2_compatible (const bfd_arch_info_type *a,
29 const bfd_arch_info_type *b)
30 {
31 if (a->arch != b->arch)
32 return NULL;
33
34 if (a->bits_per_word != b->bits_per_word)
35 return NULL;
36
37 if (a->mach == bfd_mach_nios2)
38 return a;
39 else if (b->mach == bfd_mach_nios2)
40 return b;
41 else if (a->mach != b->mach)
42 return NULL;
43
44 return a;
45 }
46
47 #define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \
48 { \
49 BITS_WORD, /* bits in a word */ \
50 BITS_ADDR, /* bits in an address */ \
51 8, /* 8 bits in a byte */ \
52 bfd_arch_nios2, \
53 NUMBER, \
54 "nios2", \
55 PRINT, \
56 3, \
57 DEFAULT, \
58 nios2_compatible, \
59 bfd_default_scan, \
60 bfd_arch_default_fill, \
61 NEXT \
62 }
63
64 #define NIOS2R1_NEXT &arch_info_struct[0]
65 #define NIOS2R2_NEXT &arch_info_struct[1]
66
67 static const bfd_arch_info_type arch_info_struct[] =
68 {
69 N (32, 32, bfd_mach_nios2r1, "nios2:r1", FALSE, NIOS2R2_NEXT),
70 N (32, 32, bfd_mach_nios2r2, "nios2:r2", FALSE, NULL),
71 };
72
73 const bfd_arch_info_type bfd_nios2_arch =
74 N (32, 32, 0, "nios2", TRUE, NIOS2R1_NEXT);