1 /* BFD support for KVX.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 Contributed by Kalray SA.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING3. If not,
19 see <http://www.gnu.org/licenses/>. */
25 /* This routine is provided two arch_infos and returns if machines
29 static const bfd_arch_info_type
*
30 kvx_compatible (const bfd_arch_info_type
*a
, const bfd_arch_info_type
*b
)
32 long amach
= a
->mach
, bmach
= b
->mach
;
33 /* If a & b are for different architecture we can do nothing. */
34 if (a
->arch
!= b
->arch
)
37 if ((amach
== bfd_mach_kv3_1_64
&& bmach
== bfd_mach_kv3_1_usr
)
38 || (amach
== bfd_mach_kv3_2_64
&& bmach
== bfd_mach_kv3_2_usr
))
41 if ((bmach
== bfd_mach_kv3_1_64
&& amach
== bfd_mach_kv3_1_usr
)
42 || (bmach
== bfd_mach_kv3_2_64
&& amach
== bfd_mach_kv3_2_usr
))
45 /* Otherwise if either a or b is the 'default' machine
46 * then it can be polymorphed into the other.
47 * This will enable to execute merge_private_bfd_data
55 /* We do not want to transmute some machine into another one */
59 /* If a & b are for the same machine then all is well. */
67 scan (const struct bfd_arch_info
*info
, const char *string
)
69 /* First test for an exact match. */
70 if (strcasecmp (string
, info
->printable_name
) == 0)
73 /* Finally check for the default architecture. */
74 if (strcasecmp (string
, "kvx") == 0)
75 return info
->the_default
;
80 #define N(addr_bits, machine, print, default, next) \
82 32, /* 32 bits in a word. */ \
83 addr_bits, /* bits in an address. */ \
84 8, /* 8 bits in a byte. */ \
86 machine, /* Machine number. */ \
87 "kvx", /* Architecture name. */ \
88 print, /* Printable name. */ \
89 4, /* Section align power. */ \
90 default, /* Is this the default ? */ \
93 bfd_arch_default_fill, \
99 const bfd_arch_info_type bfd_kv4_1_usr_arch
=
100 N (64 , bfd_mach_kv4_1_usr
, "kvx:kv4-1:usr" , false , NULL
);
102 const bfd_arch_info_type bfd_kv3_2_usr_arch
=
103 N (64 , bfd_mach_kv3_2_usr
, "kvx:kv3-2:usr" , false , &bfd_kv4_1_usr_arch
);
105 const bfd_arch_info_type bfd_kv3_1_usr_arch
=
106 N (64 , bfd_mach_kv3_1_usr
, "kvx:kv3-1:usr" , false , &bfd_kv3_2_usr_arch
);
108 const bfd_arch_info_type bfd_kv4_1_64_arch
=
109 N (64 , bfd_mach_kv4_1_64
, "kvx:kv4-1:64" , false , &bfd_kv3_1_usr_arch
);
111 const bfd_arch_info_type bfd_kv3_2_64_arch
=
112 N (64 , bfd_mach_kv3_2_64
, "kvx:kv3-2:64" , false , &bfd_kv4_1_64_arch
);
114 const bfd_arch_info_type bfd_kv3_1_64_arch
=
115 N (64 , bfd_mach_kv3_1_64
, "kvx:kv3-1:64" , false , &bfd_kv3_2_64_arch
);
117 const bfd_arch_info_type bfd_kv4_1_arch
=
118 N (32 , bfd_mach_kv4_1
, "kvx:kv4-1" , false , &bfd_kv3_1_64_arch
);
120 const bfd_arch_info_type bfd_kv3_2_arch
=
121 N (32 , bfd_mach_kv3_2
, "kvx:kv3-2" , false , &bfd_kv4_1_arch
);
123 const bfd_arch_info_type bfd_kvx_arch
=
124 N (32 , bfd_mach_kv3_1
, "kvx:kv3-1" , true , &bfd_kv3_2_arch
);