12a6b7db3Sskrll /* bfd back-end for mips support
2*dd7241dfSchristos Copyright (C) 1990-2024 Free Software Foundation, Inc.
32a6b7db3Sskrll Written by Steve Chamberlain of Cygnus Support.
42a6b7db3Sskrll
52a6b7db3Sskrll This file is part of BFD, the Binary File Descriptor library.
62a6b7db3Sskrll
72a6b7db3Sskrll This program is free software; you can redistribute it and/or modify
82a6b7db3Sskrll it under the terms of the GNU General Public License as published by
92a6b7db3Sskrll the Free Software Foundation; either version 3 of the License, or
102a6b7db3Sskrll (at your option) any later version.
112a6b7db3Sskrll
122a6b7db3Sskrll This program is distributed in the hope that it will be useful,
132a6b7db3Sskrll but WITHOUT ANY WARRANTY; without even the implied warranty of
142a6b7db3Sskrll MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
152a6b7db3Sskrll GNU General Public License for more details.
162a6b7db3Sskrll
172a6b7db3Sskrll You should have received a copy of the GNU General Public License
182a6b7db3Sskrll along with this program; if not, write to the Free Software
192a6b7db3Sskrll Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
202a6b7db3Sskrll MA 02110-1301, USA. */
212a6b7db3Sskrll
222a6b7db3Sskrll #include "sysdep.h"
232a6b7db3Sskrll #include "bfd.h"
242a6b7db3Sskrll #include "libbfd.h"
252a6b7db3Sskrll
262a6b7db3Sskrll static const bfd_arch_info_type *mips_compatible
272a6b7db3Sskrll (const bfd_arch_info_type *, const bfd_arch_info_type *);
282a6b7db3Sskrll
292a6b7db3Sskrll /* The default routine tests bits_per_word, which is wrong on mips as
302a6b7db3Sskrll mips word size doesn't correlate with reloc size. */
312a6b7db3Sskrll
322a6b7db3Sskrll static const bfd_arch_info_type *
mips_compatible(const bfd_arch_info_type * a,const bfd_arch_info_type * b)332a6b7db3Sskrll mips_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
342a6b7db3Sskrll {
352a6b7db3Sskrll if (a->arch != b->arch)
362a6b7db3Sskrll return NULL;
372a6b7db3Sskrll
382a6b7db3Sskrll /* Machine compatibility is checked in
392a6b7db3Sskrll _bfd_mips_elf_merge_private_bfd_data. */
402a6b7db3Sskrll
412a6b7db3Sskrll return a;
422a6b7db3Sskrll }
432a6b7db3Sskrll
442a6b7db3Sskrll #define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \
452a6b7db3Sskrll { \
46106c59e5Schristos BITS_WORD, /* Bits in a word. */ \
47106c59e5Schristos BITS_ADDR, /* Bits in an address. */ \
48106c59e5Schristos 8, /* Bits in a byte. */ \
492a6b7db3Sskrll bfd_arch_mips, \
502a6b7db3Sskrll NUMBER, \
512a6b7db3Sskrll "mips", \
522a6b7db3Sskrll PRINT, \
532a6b7db3Sskrll 3, \
542a6b7db3Sskrll DEFAULT, \
552a6b7db3Sskrll mips_compatible, \
562a6b7db3Sskrll bfd_default_scan, \
57b410d692Schristos bfd_arch_default_fill, \
582a6b7db3Sskrll NEXT, \
59106c59e5Schristos 0 /* Maximum offset of a reloc from the start of an insn. */ \
602a6b7db3Sskrll }
612a6b7db3Sskrll
622a6b7db3Sskrll enum
632a6b7db3Sskrll {
642a6b7db3Sskrll I_mips3000,
652a6b7db3Sskrll I_mips3900,
662a6b7db3Sskrll I_mips4000,
672a6b7db3Sskrll I_mips4010,
682a6b7db3Sskrll I_mips4100,
692a6b7db3Sskrll I_mips4111,
702a6b7db3Sskrll I_mips4120,
712a6b7db3Sskrll I_mips4300,
722a6b7db3Sskrll I_mips4400,
732a6b7db3Sskrll I_mips4600,
742a6b7db3Sskrll I_mips4650,
752a6b7db3Sskrll I_mips5000,
762a6b7db3Sskrll I_mips5400,
772a6b7db3Sskrll I_mips5500,
785f4eaf39Schristos I_mips5900,
792a6b7db3Sskrll I_mips6000,
802a6b7db3Sskrll I_mips7000,
812a6b7db3Sskrll I_mips8000,
822a6b7db3Sskrll I_mips9000,
832a6b7db3Sskrll I_mips10000,
842a6b7db3Sskrll I_mips12000,
8532998b1cSchristos I_mips14000,
8632998b1cSchristos I_mips16000,
872a6b7db3Sskrll I_mips16,
882a6b7db3Sskrll I_mips5,
892a6b7db3Sskrll I_mipsisa32,
902a6b7db3Sskrll I_mipsisa32r2,
915f4eaf39Schristos I_mipsisa32r3,
925f4eaf39Schristos I_mipsisa32r5,
935f4eaf39Schristos I_mipsisa32r6,
942a6b7db3Sskrll I_mipsisa64,
952a6b7db3Sskrll I_mipsisa64r2,
965f4eaf39Schristos I_mipsisa64r3,
975f4eaf39Schristos I_mipsisa64r5,
985f4eaf39Schristos I_mipsisa64r6,
992a6b7db3Sskrll I_sb1,
1002a6b7db3Sskrll I_loongson_2e,
1012a6b7db3Sskrll I_loongson_2f,
102106c59e5Schristos I_gs464,
103106c59e5Schristos I_gs464e,
104106c59e5Schristos I_gs264e,
10591f4e65aSmatt I_mipsocteon,
106b410d692Schristos I_mipsocteonp,
107b410d692Schristos I_mipsocteon2,
1085f4eaf39Schristos I_mipsocteon3,
109b410d692Schristos I_xlr,
1106f226886Schristos I_interaptiv_mr2,
111*dd7241dfSchristos I_allegrex,
112b410d692Schristos I_micromips
1132a6b7db3Sskrll };
1142a6b7db3Sskrll
1152a6b7db3Sskrll #define NN(index) (&arch_info_struct[(index) + 1])
1162a6b7db3Sskrll
1172a6b7db3Sskrll static const bfd_arch_info_type arch_info_struct[] =
1182a6b7db3Sskrll {
11903f5171aSchristos N (32, 32, bfd_mach_mips3000, "mips:3000", false, NN(I_mips3000)),
12003f5171aSchristos N (32, 32, bfd_mach_mips3900, "mips:3900", false, NN(I_mips3900)),
12103f5171aSchristos N (64, 64, bfd_mach_mips4000, "mips:4000", false, NN(I_mips4000)),
12203f5171aSchristos N (32, 32, bfd_mach_mips4010, "mips:4010", false, NN(I_mips4010)),
12303f5171aSchristos N (64, 64, bfd_mach_mips4100, "mips:4100", false, NN(I_mips4100)),
12403f5171aSchristos N (64, 64, bfd_mach_mips4111, "mips:4111", false, NN(I_mips4111)),
12503f5171aSchristos N (64, 64, bfd_mach_mips4120, "mips:4120", false, NN(I_mips4120)),
12603f5171aSchristos N (64, 64, bfd_mach_mips4300, "mips:4300", false, NN(I_mips4300)),
12703f5171aSchristos N (64, 64, bfd_mach_mips4400, "mips:4400", false, NN(I_mips4400)),
12803f5171aSchristos N (64, 64, bfd_mach_mips4600, "mips:4600", false, NN(I_mips4600)),
12903f5171aSchristos N (64, 64, bfd_mach_mips4650, "mips:4650", false, NN(I_mips4650)),
13003f5171aSchristos N (64, 64, bfd_mach_mips5000, "mips:5000", false, NN(I_mips5000)),
13103f5171aSchristos N (64, 64, bfd_mach_mips5400, "mips:5400", false, NN(I_mips5400)),
13203f5171aSchristos N (64, 64, bfd_mach_mips5500, "mips:5500", false, NN(I_mips5500)),
13303f5171aSchristos N (64, 32, bfd_mach_mips5900, "mips:5900", false, NN(I_mips5900)),
13403f5171aSchristos N (32, 32, bfd_mach_mips6000, "mips:6000", false, NN(I_mips6000)),
13503f5171aSchristos N (64, 64, bfd_mach_mips7000, "mips:7000", false, NN(I_mips7000)),
13603f5171aSchristos N (64, 64, bfd_mach_mips8000, "mips:8000", false, NN(I_mips8000)),
13703f5171aSchristos N (64, 64, bfd_mach_mips9000, "mips:9000", false, NN(I_mips9000)),
13803f5171aSchristos N (64, 64, bfd_mach_mips10000,"mips:10000", false, NN(I_mips10000)),
13903f5171aSchristos N (64, 64, bfd_mach_mips12000,"mips:12000", false, NN(I_mips12000)),
14003f5171aSchristos N (64, 64, bfd_mach_mips14000,"mips:14000", false, NN(I_mips14000)),
14103f5171aSchristos N (64, 64, bfd_mach_mips16000,"mips:16000", false, NN(I_mips16000)),
14203f5171aSchristos N (64, 64, bfd_mach_mips16, "mips:16", false, NN(I_mips16)),
14303f5171aSchristos N (64, 64, bfd_mach_mips5, "mips:mips5", false, NN(I_mips5)),
14403f5171aSchristos N (32, 32, bfd_mach_mipsisa32, "mips:isa32", false, NN(I_mipsisa32)),
14503f5171aSchristos N (32, 32, bfd_mach_mipsisa32r2,"mips:isa32r2", false, NN(I_mipsisa32r2)),
14603f5171aSchristos N (32, 32, bfd_mach_mipsisa32r3,"mips:isa32r3", false, NN(I_mipsisa32r3)),
14703f5171aSchristos N (32, 32, bfd_mach_mipsisa32r5,"mips:isa32r5", false, NN(I_mipsisa32r5)),
14803f5171aSchristos N (32, 32, bfd_mach_mipsisa32r6,"mips:isa32r6", false, NN(I_mipsisa32r6)),
14903f5171aSchristos N (64, 64, bfd_mach_mipsisa64, "mips:isa64", false, NN(I_mipsisa64)),
15003f5171aSchristos N (64, 64, bfd_mach_mipsisa64r2,"mips:isa64r2", false, NN(I_mipsisa64r2)),
15103f5171aSchristos N (64, 64, bfd_mach_mipsisa64r3,"mips:isa64r3", false, NN(I_mipsisa64r3)),
15203f5171aSchristos N (64, 64, bfd_mach_mipsisa64r5,"mips:isa64r5", false, NN(I_mipsisa64r5)),
15303f5171aSchristos N (64, 64, bfd_mach_mipsisa64r6,"mips:isa64r6", false, NN(I_mipsisa64r6)),
15403f5171aSchristos N (64, 64, bfd_mach_mips_sb1, "mips:sb1", false, NN(I_sb1)),
15503f5171aSchristos N (64, 64, bfd_mach_mips_loongson_2e, "mips:loongson_2e", false, NN(I_loongson_2e)),
15603f5171aSchristos N (64, 64, bfd_mach_mips_loongson_2f, "mips:loongson_2f", false, NN(I_loongson_2f)),
15703f5171aSchristos N (64, 64, bfd_mach_mips_gs464, "mips:gs464", false, NN(I_gs464)),
15803f5171aSchristos N (64, 64, bfd_mach_mips_gs464e, "mips:gs464e", false, NN(I_gs464e)),
15903f5171aSchristos N (64, 64, bfd_mach_mips_gs264e, "mips:gs264e", false, NN(I_gs264e)),
16003f5171aSchristos N (64, 64, bfd_mach_mips_octeon,"mips:octeon", false, NN(I_mipsocteon)),
16103f5171aSchristos N (64, 64, bfd_mach_mips_octeonp,"mips:octeon+", false, NN(I_mipsocteonp)),
16203f5171aSchristos N (64, 64, bfd_mach_mips_octeon2,"mips:octeon2", false, NN(I_mipsocteon2)),
16303f5171aSchristos N (64, 64, bfd_mach_mips_octeon3, "mips:octeon3", false, NN(I_mipsocteon3)),
16403f5171aSchristos N (64, 64, bfd_mach_mips_xlr, "mips:xlr", false, NN(I_xlr)),
16503f5171aSchristos N (32, 32, bfd_mach_mips_interaptiv_mr2, "mips:interaptiv-mr2", false,
1666f226886Schristos NN(I_interaptiv_mr2)),
167*dd7241dfSchristos N (32, 32, bfd_mach_mips_allegrex, "mips:allegrex", false, NN(I_allegrex)),
16803f5171aSchristos N (64, 64, bfd_mach_mips_micromips, "mips:micromips", false, NULL)
1692a6b7db3Sskrll };
1702a6b7db3Sskrll
1712a6b7db3Sskrll /* The default architecture is mips:3000, but with a machine number of
1722a6b7db3Sskrll zero. This lets the linker distinguish between a default setting
1732a6b7db3Sskrll of mips, and an explicit setting of mips:3000. */
1742a6b7db3Sskrll
1752a6b7db3Sskrll const bfd_arch_info_type bfd_mips_arch =
17603f5171aSchristos N (32, 32, 0, "mips", true, &arch_info_struct[0]);
177