Commit | Line | Data |
---|---|---|
8988d935 | 1 | /* BFD support for the NEC V850 processor |
7dac939c | 2 | Copyright 1996, 1997 Free Software Foundation, Inc. |
8988d935 NC |
3 | |
4 | This file is part of BFD, the Binary File Descriptor library. | |
5 | ||
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 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | #include "bfd.h" | |
21 | #include "sysdep.h" | |
22 | #include "libbfd.h" | |
23 | ||
24 | static boolean | |
25 | scan (info, string) | |
26 | const struct bfd_arch_info * info; | |
27 | const char * string; | |
28 | { | |
29 | const char *ptr_src; | |
30 | const char *ptr_tst; | |
31 | unsigned long number; | |
32 | enum bfd_architecture arch; | |
33 | ||
34 | /* First test for an exact match */ | |
f40d28bf | 35 | if (strcasecmp (string, info->printable_name) == 0) |
8988d935 NC |
36 | return true; |
37 | ||
38 | /* See how much of the supplied string matches with the | |
39 | architecture, eg the string m68k:68020 would match the m68k entry | |
40 | up to the :, then we get left with the machine number */ | |
41 | ||
42 | for (ptr_src = string, ptr_tst = info->arch_name; | |
43 | *ptr_src && *ptr_tst; | |
44 | ptr_src++, ptr_tst++) | |
45 | { | |
46 | if (*ptr_src != *ptr_tst) break; | |
47 | } | |
48 | ||
49 | /* Chewed up as much of the architecture as will match, skip any | |
50 | colons */ | |
51 | if (*ptr_src == ':') | |
52 | ptr_src++; | |
53 | ||
54 | if (*ptr_src == 0) | |
55 | { | |
56 | /* nothing more, then only keep this one if it is the default | |
57 | machine for this architecture */ | |
58 | return info->the_default; | |
59 | } | |
60 | ||
61 | number = 0; | |
62 | while (isdigit (*ptr_src)) | |
63 | { | |
64 | number = number * 10 + * ptr_src - '0'; | |
65 | ptr_src++; | |
66 | } | |
67 | ||
68 | switch (number) | |
69 | { | |
7dac939c | 70 | /* start-sanitize-v850e */ |
8988d935 | 71 | case bfd_mach_v850e: arch = bfd_arch_v850; break; |
7dac939c ILT |
72 | /* end-sanitize-v850e */ |
73 | /* start-sanitize-v850eq */ | |
8988d935 | 74 | case bfd_mach_v850eq: arch = bfd_arch_v850; break; |
7dac939c | 75 | /* end-sanitize-v850eq */ |
8988d935 NC |
76 | |
77 | default: | |
78 | return false; | |
79 | } | |
80 | ||
81 | if (arch != info->arch) | |
82 | return false; | |
83 | ||
84 | if (number != info->mach) | |
85 | return false; | |
86 | ||
87 | return true; | |
88 | } | |
89 | ||
def31039 NC |
90 | #define N(number, print, default, next) \ |
91 | { 32, 32, 8, bfd_arch_v850, number, "v850", print, 2, default, bfd_default_compatible, scan, next } | |
8988d935 NC |
92 | |
93 | static const bfd_arch_info_type arch_info_struct[2] = | |
94 | { | |
95 | /* start-sanitize-v850e */ | |
def31039 | 96 | N( bfd_mach_v850e, "v850e", false, & arch_info_struct[1] ), |
8988d935 NC |
97 | /* end-sanitize-v850e */ |
98 | /* start-sanitize-v850eq */ | |
def31039 | 99 | N( bfd_mach_v850eq, "v850eq", false, NULL ), |
8988d935 NC |
100 | /* end-sanitize-v850eq */ |
101 | }; | |
102 | ||
103 | const bfd_arch_info_type bfd_v850_arch = | |
def31039 | 104 | N( bfd_mach_v850, "v850", true, & arch_info_struct[0] ); |