175fd0b74Schristos /* bfd back-end for TMS320C[34]x support
2*e992f068Schristos Copyright (C) 1996-2022 Free Software Foundation, Inc.
375fd0b74Schristos
475fd0b74Schristos Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
575fd0b74Schristos
675fd0b74Schristos This file is part of BFD, the Binary File Descriptor library.
775fd0b74Schristos
875fd0b74Schristos This program is free software; you can redistribute it and/or modify
975fd0b74Schristos it under the terms of the GNU General Public License as published by
1075fd0b74Schristos the Free Software Foundation; either version 3 of the License, or
1175fd0b74Schristos (at your option) any later version.
1275fd0b74Schristos
1375fd0b74Schristos This program is distributed in the hope that it will be useful,
1475fd0b74Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
1575fd0b74Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1675fd0b74Schristos GNU General Public License for more details.
1775fd0b74Schristos
1875fd0b74Schristos You should have received a copy of the GNU General Public License
1975fd0b74Schristos along with this program; if not, write to the Free Software
2075fd0b74Schristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
2175fd0b74Schristos MA 02110-1301, USA. */
2275fd0b74Schristos
2375fd0b74Schristos #include "sysdep.h"
2475fd0b74Schristos #include "bfd.h"
2575fd0b74Schristos #include "libbfd.h"
2675fd0b74Schristos
27*e992f068Schristos static bool
tic4x_scan(const struct bfd_arch_info * info,const char * string)2875fd0b74Schristos tic4x_scan (const struct bfd_arch_info *info,
2975fd0b74Schristos const char *string)
3075fd0b74Schristos {
3175fd0b74Schristos /* Allow strings of form [ti][Cc][34][0-9], let's not be too picky
3275fd0b74Schristos about strange numbered machines in C3x or C4x series. */
3375fd0b74Schristos if (string[0] == 't' && string[1] == 'i')
3475fd0b74Schristos string += 2;
3575fd0b74Schristos if (*string == 'C' || *string == 'c')
3675fd0b74Schristos string++;
3775fd0b74Schristos if (string[1] < '0' && string[1] > '9')
38*e992f068Schristos return false;
3975fd0b74Schristos
4075fd0b74Schristos if (*string == '3')
4175fd0b74Schristos return (info->mach == bfd_mach_tic3x);
4275fd0b74Schristos else if (*string == '4')
4375fd0b74Schristos return info->mach == bfd_mach_tic4x;
4475fd0b74Schristos
45*e992f068Schristos return false;
4675fd0b74Schristos }
4775fd0b74Schristos
48012573ebSchristos #define N(NUMBER, NAME, PRINT, DEFAULT, NEXT) \
49012573ebSchristos { \
50012573ebSchristos 32, /* Bits in a word. */ \
51012573ebSchristos 32, /* Bits in an address. */ \
52012573ebSchristos 32, /* Bits in a byte. */ \
53012573ebSchristos bfd_arch_tic4x, \
54012573ebSchristos NUMBER, \
55012573ebSchristos NAME, \
56012573ebSchristos PRINT, \
57012573ebSchristos 0, /* Section alignment power. */ \
58012573ebSchristos DEFAULT, \
59012573ebSchristos bfd_default_compatible, \
60012573ebSchristos tic4x_scan, \
61012573ebSchristos bfd_arch_default_fill, \
62012573ebSchristos NEXT, \
63012573ebSchristos 0 /* Maximum offset of a reloc from the start of an insn. */ \
64012573ebSchristos }
6575fd0b74Schristos
6675fd0b74Schristos const bfd_arch_info_type bfd_tic3x_arch =
67*e992f068Schristos N (bfd_mach_tic3x, "tic3x", "tms320c3x", false, NULL);
6875fd0b74Schristos
6975fd0b74Schristos const bfd_arch_info_type bfd_tic4x_arch =
70*e992f068Schristos N (bfd_mach_tic4x, "tic4x", "tms320c4x", true, &bfd_tic3x_arch);
71