* simple.c (bfd_simple_get_relocated_section_contents): Add
[deliverable/binutils-gdb.git] / bfd / cpu-arm.c
CommitLineData
252b5132 1/* BFD support for the ARM processor
e2fd756b 2 Copyright 1994, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
252b5132
RH
3 Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
4
e2fd756b 5 This file is part of BFD, the Binary File Descriptor library.
252b5132 6
e2fd756b
NC
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 2 of the License, or
10 (at your option) any later version.
252b5132 11
e2fd756b
NC
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.
252b5132 16
e2fd756b
NC
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
252b5132
RH
20
21#include "bfd.h"
22#include "sysdep.h"
23#include "libbfd.h"
24
e2fd756b 25static const bfd_arch_info_type * compatible
252b5132 26 PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
b34976b6 27static bfd_boolean scan
e2fd756b 28 PARAMS ((const struct bfd_arch_info *, const char *));
252b5132
RH
29
30/* This routine is provided two arch_infos and works out which ARM
31 machine which would be compatible with both and returns a pointer
e2fd756b 32 to its info structure. */
252b5132
RH
33
34static const bfd_arch_info_type *
35compatible (a,b)
36 const bfd_arch_info_type * a;
37 const bfd_arch_info_type * b;
38{
e2fd756b 39 /* If a & b are for different architecture we can do nothing. */
252b5132
RH
40 if (a->arch != b->arch)
41 return NULL;
42
e2fd756b 43 /* If a & b are for the same machine then all is well. */
252b5132
RH
44 if (a->mach == b->mach)
45 return a;
46
e2fd756b
NC
47 /* Otherwise if either a or b is the 'default' machine
48 then it can be polymorphed into the other. */
252b5132
RH
49 if (a->the_default)
50 return b;
71f6b586 51
252b5132
RH
52 if (b->the_default)
53 return a;
54
e2fd756b
NC
55 /* So far all newer ARM architecture cores are
56 supersets of previous cores. */
252b5132
RH
57 if (a->mach < b->mach)
58 return b;
59 else if (a->mach > b->mach)
60 return a;
61
e2fd756b 62 /* Never reached! */
252b5132
RH
63 return NULL;
64}
65
66static struct
67{
e2fd756b
NC
68 unsigned int mach;
69 char * name;
252b5132
RH
70}
71processors[] =
72{
73 { bfd_mach_arm_2, "arm2" },
74 { bfd_mach_arm_2a, "arm250" },
75 { bfd_mach_arm_2a, "arm3" },
76 { bfd_mach_arm_3, "arm6" },
77 { bfd_mach_arm_3, "arm60" },
78 { bfd_mach_arm_3, "arm600" },
79 { bfd_mach_arm_3, "arm610" },
80 { bfd_mach_arm_3, "arm7" },
81 { bfd_mach_arm_3, "arm710" },
82 { bfd_mach_arm_3, "arm7500" },
83 { bfd_mach_arm_3, "arm7d" },
84 { bfd_mach_arm_3, "arm7di" },
85 { bfd_mach_arm_3M, "arm7dm" },
86 { bfd_mach_arm_3M, "arm7dmi" },
478d07d6 87 { bfd_mach_arm_4T, "arm7tdmi" },
252b5132
RH
88 { bfd_mach_arm_4, "arm8" },
89 { bfd_mach_arm_4, "arm810" },
478d07d6
NC
90 { bfd_mach_arm_4, "arm9" },
91 { bfd_mach_arm_4, "arm920" },
92 { bfd_mach_arm_4T, "arm920t" },
93 { bfd_mach_arm_4T, "arm9tdmi" },
252b5132 94 { bfd_mach_arm_4, "sa1" },
478d07d6
NC
95 { bfd_mach_arm_4, "strongarm"},
96 { bfd_mach_arm_4, "strongarm110" },
97 { bfd_mach_arm_4, "strongarm1100" },
fde78edd 98 { bfd_mach_arm_XScale, "xscale" },
e16bb312
NC
99 { bfd_mach_arm_ep9312, "ep9312" },
100 { bfd_mach_arm_iWMMXt, "iwmmxt" }
252b5132
RH
101};
102
b34976b6 103static bfd_boolean
252b5132
RH
104scan (info, string)
105 const struct bfd_arch_info * info;
106 const char * string;
107{
108 int i;
109
e2fd756b 110 /* First test for an exact match. */
252b5132 111 if (strcasecmp (string, info->printable_name) == 0)
b34976b6 112 return TRUE;
252b5132 113
e2fd756b 114 /* Next check for a processor name instead of an Architecture name. */
252b5132
RH
115 for (i = sizeof (processors) / sizeof (processors[0]); i--;)
116 {
e2fd756b 117 if (strcasecmp (string, processors [i].name) == 0)
252b5132
RH
118 break;
119 }
120
e2fd756b 121 if (i != -1 && info->mach == processors [i].mach)
b34976b6 122 return TRUE;
252b5132 123
e2fd756b 124 /* Finally check for the default architecture. */
252b5132
RH
125 if (strcasecmp (string, "arm") == 0)
126 return info->the_default;
71f6b586 127
b34976b6 128 return FALSE;
252b5132
RH
129}
130
252b5132
RH
131#define N(number, print, default, next) \
132{ 32, 32, 8, bfd_arch_arm, number, "arm", print, 4, default, compatible, scan, next }
133
134static const bfd_arch_info_type arch_info_struct[] =
71f6b586 135{
b34976b6
AM
136 N (bfd_mach_arm_2, "armv2", FALSE, & arch_info_struct[1]),
137 N (bfd_mach_arm_2a, "armv2a", FALSE, & arch_info_struct[2]),
138 N (bfd_mach_arm_3, "armv3", FALSE, & arch_info_struct[3]),
139 N (bfd_mach_arm_3M, "armv3m", FALSE, & arch_info_struct[4]),
140 N (bfd_mach_arm_4, "armv4", FALSE, & arch_info_struct[5]),
141 N (bfd_mach_arm_4T, "armv4t", FALSE, & arch_info_struct[6]),
142 N (bfd_mach_arm_5, "armv5", FALSE, & arch_info_struct[7]),
143 N (bfd_mach_arm_5T, "armv5t", FALSE, & arch_info_struct[8]),
144 N (bfd_mach_arm_5TE, "armv5te", FALSE, & arch_info_struct[9]),
fde78edd 145 N (bfd_mach_arm_XScale, "xscale", FALSE, & arch_info_struct[10]),
e16bb312
NC
146 N (bfd_mach_arm_ep9312, "ep9312", FALSE, & arch_info_struct[11]),
147 N (bfd_mach_arm_iWMMXt,"iwmmxt", FALSE, NULL)
252b5132
RH
148};
149
150const bfd_arch_info_type bfd_arm_arch =
b34976b6 151 N (0, "arm", TRUE, & arch_info_struct[0]);
This page took 0.17287 seconds and 4 git commands to generate.