54012359e2757d48799e509f7c3703a1c0c79431
[platform/upstream/binutils.git] / bfd / cpu-powerpc.c
1 /* BFD PowerPC CPU definition
2    Copyright 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2005, 2007, 2008,
3    2010, 2012 Free Software Foundation, Inc.
4    Contributed by Ian Lance Taylor, Cygnus Support.
5
6    This file is part of BFD, the Binary File Descriptor library.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21    MA 02110-1301, USA.  */
22
23 #include "sysdep.h"
24 #include "bfd.h"
25 #include "libbfd.h"
26
27 /* The common PowerPC architecture is compatible with the RS/6000.  */
28
29 static const bfd_arch_info_type *powerpc_compatible
30   PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
31
32 static const bfd_arch_info_type *
33 powerpc_compatible (a,b)
34      const bfd_arch_info_type *a;
35      const bfd_arch_info_type *b;
36 {
37   BFD_ASSERT (a->arch == bfd_arch_powerpc);
38   switch (b->arch)
39     {
40     default:
41       return NULL;
42     case bfd_arch_powerpc:
43       return bfd_default_compatible (a, b);
44     case bfd_arch_rs6000:
45       if (b->mach == bfd_mach_rs6k)
46         return a;
47       return NULL;
48     }
49   /*NOTREACHED*/
50 }
51
52 const bfd_arch_info_type bfd_powerpc_archs[] =
53 {
54 #if BFD_DEFAULT_TARGET_SIZE == 64
55   /* Default arch must come first.  */
56   {
57     64, /* 64 bits in a word */
58     64, /* 64 bits in an address */
59     8,  /* 8 bits in a byte */
60     bfd_arch_powerpc,
61     bfd_mach_ppc64,
62     "powerpc",
63     "powerpc:common64",
64     3,
65     TRUE, /* default for 64 bit target */
66     powerpc_compatible,
67     bfd_default_scan,
68     bfd_arch_default_fill,
69     &bfd_powerpc_archs[1]
70   },
71   /* elf32-ppc:ppc_elf_object_p relies on the default 32 bit arch
72      being immediately after the 64 bit default.  */
73   {
74     32, /* 32 bits in a word */
75     32, /* 32 bits in an address */
76     8,  /* 8 bits in a byte */
77     bfd_arch_powerpc,
78     bfd_mach_ppc, /* for the POWER/PowerPC common architecture */
79     "powerpc",
80     "powerpc:common",
81     3,
82     FALSE,
83     powerpc_compatible,
84     bfd_default_scan,
85     bfd_arch_default_fill,
86     &bfd_powerpc_archs[2],
87   },
88 #else
89   /* Default arch must come first.  */
90   {
91     32, /* 32 bits in a word */
92     32, /* 32 bits in an address */
93     8,  /* 8 bits in a byte */
94     bfd_arch_powerpc,
95     bfd_mach_ppc, /* for the POWER/PowerPC common architecture */
96     "powerpc",
97     "powerpc:common",
98     3,
99     TRUE, /* default for 32 bit target */
100     powerpc_compatible,
101     bfd_default_scan,
102     bfd_arch_default_fill,
103     &bfd_powerpc_archs[1],
104   },
105   /* elf64-ppc:ppc64_elf_object_p relies on the default 64 bit arch
106      being immediately after the 32 bit default.  */
107   {
108     64, /* 64 bits in a word */
109     64, /* 64 bits in an address */
110     8,  /* 8 bits in a byte */
111     bfd_arch_powerpc,
112     bfd_mach_ppc64,
113     "powerpc",
114     "powerpc:common64",
115     3,
116     FALSE,
117     powerpc_compatible,
118     bfd_default_scan,
119     bfd_arch_default_fill,
120     &bfd_powerpc_archs[2]
121   },
122 #endif
123   {
124     32, /* 32 bits in a word */
125     32, /* 32 bits in an address */
126     8,  /* 8 bits in a byte */
127     bfd_arch_powerpc,
128     bfd_mach_ppc_603,
129     "powerpc",
130     "powerpc:603",
131     3,
132     FALSE, /* not the default */
133     powerpc_compatible,
134     bfd_default_scan,
135     bfd_arch_default_fill,
136     &bfd_powerpc_archs[3]
137   },
138   {
139     32, /* 32 bits in a word */
140     32, /* 32 bits in an address */
141     8,  /* 8 bits in a byte */
142     bfd_arch_powerpc,
143     bfd_mach_ppc_ec603e,
144     "powerpc",
145     "powerpc:EC603e",
146     3,
147     FALSE, /* not the default */
148     powerpc_compatible,
149     bfd_default_scan,
150     bfd_arch_default_fill,
151     &bfd_powerpc_archs[4]
152   },
153   {
154     32, /* 32 bits in a word */
155     32, /* 32 bits in an address */
156     8,  /* 8 bits in a byte */
157     bfd_arch_powerpc,
158     bfd_mach_ppc_604,
159     "powerpc",
160     "powerpc:604",
161     3,
162     FALSE, /* not the default */
163     powerpc_compatible,
164     bfd_default_scan,
165     bfd_arch_default_fill,
166     &bfd_powerpc_archs[5]
167   },
168   {
169     32, /* 32 bits in a word */
170     32, /* 32 bits in an address */
171     8,  /* 8 bits in a byte */
172     bfd_arch_powerpc,
173     bfd_mach_ppc_403,
174     "powerpc",
175     "powerpc:403",
176     3,
177     FALSE, /* not the default */
178     powerpc_compatible,
179     bfd_default_scan,
180     bfd_arch_default_fill,
181     &bfd_powerpc_archs[6]
182   },
183   {
184     32, /* 32 bits in a word */
185     32, /* 32 bits in an address */
186     8,  /* 8 bits in a byte */
187     bfd_arch_powerpc,
188     bfd_mach_ppc_601,
189     "powerpc",
190     "powerpc:601",
191     3,
192     FALSE, /* not the default */
193     powerpc_compatible,
194     bfd_default_scan,
195     bfd_arch_default_fill,
196     &bfd_powerpc_archs[7]
197   },
198   {
199     64, /* 64 bits in a word */
200     64, /* 64 bits in an address */
201     8,  /* 8 bits in a byte */
202     bfd_arch_powerpc,
203     bfd_mach_ppc_620,
204     "powerpc",
205     "powerpc:620",
206     3,
207     FALSE, /* not the default */
208     powerpc_compatible,
209     bfd_default_scan,
210     bfd_arch_default_fill,
211     &bfd_powerpc_archs[8]
212   },
213   {
214     64, /* 64 bits in a word */
215     64, /* 64 bits in an address */
216     8,  /* 8 bits in a byte */
217     bfd_arch_powerpc,
218     bfd_mach_ppc_630,
219     "powerpc",
220     "powerpc:630",
221     3,
222     FALSE, /* not the default */
223     powerpc_compatible,
224     bfd_default_scan,
225     bfd_arch_default_fill,
226     &bfd_powerpc_archs[9]
227   },
228   {
229     64, /* 64 bits in a word */
230     64, /* 64 bits in an address */
231     8,  /* 8 bits in a byte */
232     bfd_arch_powerpc,
233     bfd_mach_ppc_a35,
234     "powerpc",
235     "powerpc:a35",
236     3,
237     FALSE, /* not the default */
238     powerpc_compatible,
239     bfd_default_scan,
240     bfd_arch_default_fill,
241     &bfd_powerpc_archs[10]
242   },
243   {
244     64, /* 64 bits in a word */
245     64, /* 64 bits in an address */
246     8,  /* 8 bits in a byte */
247     bfd_arch_powerpc,
248     bfd_mach_ppc_rs64ii,
249     "powerpc",
250     "powerpc:rs64ii",
251     3,
252     FALSE, /* not the default */
253     powerpc_compatible,
254     bfd_default_scan,
255     bfd_arch_default_fill,
256     &bfd_powerpc_archs[11]
257   },
258   {
259     64, /* 64 bits in a word */
260     64, /* 64 bits in an address */
261     8,  /* 8 bits in a byte */
262     bfd_arch_powerpc,
263     bfd_mach_ppc_rs64iii,
264     "powerpc",
265     "powerpc:rs64iii",
266     3,
267     FALSE, /* not the default */
268     powerpc_compatible,
269     bfd_default_scan,
270     bfd_arch_default_fill,
271     &bfd_powerpc_archs[12]
272   },
273   {
274     32, /* 32 bits in a word */
275     32, /* 32 bits in an address */
276     8,  /* 8 bits in a byte */
277     bfd_arch_powerpc,
278     bfd_mach_ppc_7400,
279     "powerpc",
280     "powerpc:7400",
281     3,
282     FALSE, /* not the default */
283     powerpc_compatible,
284     bfd_default_scan,
285     bfd_arch_default_fill,
286     &bfd_powerpc_archs[13]
287   },
288   {
289     32, /* 32 bits in a word */
290     32, /* 32 bits in an address */
291     8,  /* 8 bits in a byte */
292     bfd_arch_powerpc,
293     bfd_mach_ppc_e500,
294     "powerpc",
295     "powerpc:e500",
296     3,
297     FALSE,
298     powerpc_compatible,
299     bfd_default_scan,
300     bfd_arch_default_fill,
301     &bfd_powerpc_archs[14]
302   },
303   {
304     32,        /* 32 bits in a word */
305     32,        /* 32 bits in an address */
306     8, /* 8 bits in a byte */
307     bfd_arch_powerpc,
308     bfd_mach_ppc_e500mc,
309     "powerpc",
310     "powerpc:e500mc",
311     3,
312     FALSE, /* not the default */
313     powerpc_compatible,
314     bfd_default_scan,
315     bfd_arch_default_fill,
316     &bfd_powerpc_archs[15]
317   },
318   {
319     64, /* 64 bits in a word */
320     64, /* 64 bits in an address */
321     8,  /* 8 bits in a byte */
322     bfd_arch_powerpc,
323     bfd_mach_ppc_e500mc64,
324     "powerpc",
325     "powerpc:e500mc64",
326     3,
327     FALSE, /* not the default */
328     powerpc_compatible,
329     bfd_default_scan,
330     bfd_arch_default_fill,
331     &bfd_powerpc_archs[16]
332   },
333   {
334     32,       /* 32 bits in a word */
335     32,       /* 32 bits in an address */
336     8,        /* 8 bits in a byte */
337     bfd_arch_powerpc,
338     bfd_mach_ppc_860,
339     "powerpc",
340     "powerpc:MPC8XX",
341     3,
342     FALSE, /* not the default */
343     powerpc_compatible,
344     bfd_default_scan,
345     bfd_arch_default_fill,
346     &bfd_powerpc_archs[17]
347   },
348   {
349     32, /* 32 bits in a word */
350     32, /* 32 bits in an address */
351     8,  /* 8 bits in a byte */
352     bfd_arch_powerpc,
353     bfd_mach_ppc_750,
354     "powerpc",
355     "powerpc:750",
356     3,
357     FALSE, /* not the default */
358     powerpc_compatible,
359     bfd_default_scan,
360     bfd_arch_default_fill,
361     &bfd_powerpc_archs[18]
362   },
363   {
364     32, /* 32 bits in a word */
365     32, /* 32 bits in an address */
366     8,  /* 8 bits in a byte */
367     bfd_arch_powerpc,
368     bfd_mach_ppc_titan,
369     "powerpc",
370     "powerpc:titan",
371     3,
372     FALSE, /* not the default */
373     powerpc_compatible,
374     bfd_default_scan,
375     bfd_arch_default_fill,
376     &bfd_powerpc_archs[19]
377   },
378   {
379     16, /* 16 or 32 bits in a word */
380     32, /* 32 bits in an address */
381     8,  /* 8 bits in a byte */
382     bfd_arch_powerpc,
383     bfd_mach_ppc_vle,
384     "powerpc",
385     "powerpc:vle",
386     3,
387     FALSE, /* not the default */
388     powerpc_compatible,
389     bfd_default_scan,
390     bfd_arch_default_fill,
391     &bfd_powerpc_archs[20]
392   },
393   {
394     64, /* 64 bits in a word */
395     64, /* 64 bits in an address */
396     8,  /* 8 bits in a byte */
397     bfd_arch_powerpc,
398     bfd_mach_ppc_e5500,
399     "powerpc",
400     "powerpc:e5500",
401     3,
402     FALSE, /* not the default */
403     powerpc_compatible,
404     bfd_default_scan,
405     bfd_arch_default_fill,
406     &bfd_powerpc_archs[21]
407   },
408   {
409     64, /* 64 bits in a word */
410     64, /* 64 bits in an address */
411     8,  /* 8 bits in a byte */
412     bfd_arch_powerpc,
413     bfd_mach_ppc_e6500,
414     "powerpc",
415     "powerpc:e6500",
416     3,
417     FALSE, /* not the default */
418     powerpc_compatible,
419     bfd_default_scan,
420     bfd_arch_default_fill,
421     0
422   }
423 };