bfd/
[external/binutils.git] / bfd / coff-tic54x.c
1 /* BFD back-end for TMS320C54X coff binaries.
2    Copyright 1999, 2000, 2001, 2002, 2003, 2004
3    Free Software Foundation, Inc.
4    Contributed by Timothy Wall (twall@cygnus.com)
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 2 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., 59 Temple Place - Suite 330, Boston, MA
21    02111-1307, USA.  */
22
23 #include "bfd.h"
24 #include "sysdep.h"
25 #include "libbfd.h"
26 #include "bfdlink.h"
27 #include "coff/tic54x.h"
28 #include "coff/internal.h"
29 #include "libcoff.h"
30
31 #undef  F_LSYMS
32 #define F_LSYMS         F_LSYMS_TICOFF
33
34 static void tic54x_reloc_processing
35   PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
36 static bfd_reloc_status_type tic54x_relocation
37   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
38 static bfd_boolean tic54x_set_section_contents
39   PARAMS ((bfd *, sec_ptr, const PTR, file_ptr, bfd_size_type));
40 static reloc_howto_type *coff_tic54x_rtype_to_howto
41   PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *));
42 static bfd_boolean tic54x_set_arch_mach
43   PARAMS ((bfd *, enum bfd_architecture, unsigned long));
44 static reloc_howto_type * tic54x_coff_reloc_type_lookup
45   PARAMS ((bfd *, bfd_reloc_code_real_type));
46 static void tic54x_lookup_howto
47   PARAMS ((arelent *, struct internal_reloc *));
48 static bfd_boolean ticoff_bfd_is_local_label_name
49   PARAMS ((bfd *, const char *));
50
51 /* 32-bit operations
52    The octet order is screwy.  words are LSB first (LS octet, actually), but
53    longwords are MSW first.  For example, 0x12345678 is encoded 0x5678 in the
54    first word and 0x1234 in the second.  When looking at the data as stored in
55    the COFF file, you would see the octets ordered as 0x78, 0x56, 0x34, 0x12.
56    Don't bother with 64-bits, as there aren't any.  */
57
58 static bfd_vma
59 tic54x_getl32 (const void *p)
60 {
61   const bfd_byte *addr = p;
62   unsigned long v;
63
64   v  = (unsigned long) addr[2];
65   v |= (unsigned long) addr[3] << 8;
66   v |= (unsigned long) addr[0] << 16;
67   v |= (unsigned long) addr[1] << 24;
68   return v;
69 }
70
71 static void
72 tic54x_putl32 (bfd_vma data, void *p)
73 {
74   bfd_byte *addr = p;
75   addr[2] = data & 0xff;
76   addr[3] = (data >>  8) & 0xff;
77   addr[0] = (data >> 16) & 0xff;
78   addr[1] = (data >> 24) & 0xff;
79 }
80
81 static bfd_signed_vma
82 tic54x_getl_signed_32 (const void *p)
83 {
84   const bfd_byte *addr = p;
85   unsigned long v;
86
87   v  = (unsigned long) addr[2];
88   v |= (unsigned long) addr[3] << 8;
89   v |= (unsigned long) addr[0] << 16;
90   v |= (unsigned long) addr[1] << 24;
91 #define COERCE32(x) \
92   ((bfd_signed_vma) (long) (((unsigned long) (x) ^ 0x80000000) - 0x80000000))
93   return COERCE32 (v);
94 }
95
96 #define coff_get_section_load_page bfd_ticoff_get_section_load_page
97 #define coff_set_section_load_page bfd_ticoff_set_section_load_page
98
99 void
100 bfd_ticoff_set_section_load_page (sect, page)
101   asection *sect;
102   int page;
103 {
104   sect->lma = (sect->lma & ADDR_MASK) | PG_TO_FLAG(page);
105 }
106
107 int
108 bfd_ticoff_get_section_load_page (sect)
109   asection *sect;
110 {
111   int page;
112
113   /* Provide meaningful defaults for predefined sections.  */
114   if (sect == &bfd_com_section)
115     page = PG_DATA;
116
117   else if (sect == &bfd_und_section
118       || sect == &bfd_abs_section
119       || sect == &bfd_ind_section)
120     page = PG_PROG;
121
122   else
123     page = FLAG_TO_PG (sect->lma);
124
125   return page;
126 }
127
128 /* Set the architecture appropriately.  Allow unkown architectures
129    (e.g. binary).  */
130
131 static bfd_boolean
132 tic54x_set_arch_mach (abfd, arch, machine)
133      bfd *abfd;
134      enum bfd_architecture arch;
135      unsigned long machine;
136 {
137   if (arch == bfd_arch_unknown)
138     arch = bfd_arch_tic54x;
139
140   else if (arch != bfd_arch_tic54x)
141     return FALSE;
142
143   return bfd_default_set_arch_mach (abfd, arch, machine);
144 }
145
146 static bfd_reloc_status_type
147 tic54x_relocation (abfd, reloc_entry, symbol, data, input_section,
148                    output_bfd, error_message)
149   bfd *abfd ATTRIBUTE_UNUSED;
150   arelent *reloc_entry;
151   asymbol *symbol ATTRIBUTE_UNUSED;
152   PTR data ATTRIBUTE_UNUSED;
153   asection *input_section;
154   bfd *output_bfd;
155   char **error_message ATTRIBUTE_UNUSED;
156 {
157   if (output_bfd != (bfd *) NULL)
158     {
159       /* This is a partial relocation, and we want to apply the
160          relocation to the reloc entry rather than the raw data.
161          Modify the reloc inplace to reflect what we now know.  */
162       reloc_entry->address += input_section->output_offset;
163       return bfd_reloc_ok;
164     }
165   return bfd_reloc_continue;
166 }
167
168 reloc_howto_type tic54x_howto_table[] =
169   {
170     /* type,rightshift,size (0=byte, 1=short, 2=long),
171        bit size, pc_relative, bitpos, dont complain_on_overflow,
172        special_function, name, partial_inplace, src_mask, dst_mask, pcrel_offset.  */
173
174     /* NORMAL BANK */
175     /* 16-bit direct reference to symbol's address.  */
176     HOWTO (R_RELWORD,0,1,16,FALSE,0,complain_overflow_dont,
177            tic54x_relocation,"REL16",FALSE,0xFFFF,0xFFFF,FALSE),
178
179     /* 7 LSBs of an address */
180     HOWTO (R_PARTLS7,0,1,7,FALSE,0,complain_overflow_dont,
181            tic54x_relocation,"LS7",FALSE,0x007F,0x007F,FALSE),
182
183     /* 9 MSBs of an address */
184     /* TI assembler doesn't shift its encoding, and is thus incompatible */
185     HOWTO (R_PARTMS9,7,1,9,FALSE,0,complain_overflow_dont,
186            tic54x_relocation,"MS9",FALSE,0x01FF,0x01FF,FALSE),
187
188     /* 23-bit relocation */
189     HOWTO (R_EXTWORD,0,2,23,FALSE,0,complain_overflow_dont,
190            tic54x_relocation,"RELEXT",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
191
192     /* 16 bits of 23-bit extended address */
193     HOWTO (R_EXTWORD16,0,1,16,FALSE,0,complain_overflow_dont,
194            tic54x_relocation,"RELEXT16",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
195
196     /* upper 7 bits of 23-bit extended address */
197     HOWTO (R_EXTWORDMS7,16,1,7,FALSE,0,complain_overflow_dont,
198            tic54x_relocation,"RELEXTMS7",FALSE,0x7F,0x7F,FALSE),
199
200     /* ABSOLUTE BANK */
201     /* 16-bit direct reference to symbol's address, absolute */
202     HOWTO (R_RELWORD,0,1,16,FALSE,0,complain_overflow_dont,
203            tic54x_relocation,"AREL16",FALSE,0xFFFF,0xFFFF,FALSE),
204
205     /* 7 LSBs of an address, absolute */
206     HOWTO (R_PARTLS7,0,1,7,FALSE,0,complain_overflow_dont,
207            tic54x_relocation,"ALS7",FALSE,0x007F,0x007F,FALSE),
208
209     /* 9 MSBs of an address, absolute */
210     /* TI assembler doesn't shift its encoding, and is thus incompatible */
211     HOWTO (R_PARTMS9,7,1,9,FALSE,0,complain_overflow_dont,
212            tic54x_relocation,"AMS9",FALSE,0x01FF,0x01FF,FALSE),
213
214     /* 23-bit direct reference, absolute */
215     HOWTO (R_EXTWORD,0,2,23,FALSE,0,complain_overflow_dont,
216            tic54x_relocation,"ARELEXT",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
217
218     /* 16 bits of 23-bit extended address, absolute */
219     HOWTO (R_EXTWORD16,0,1,16,FALSE,0,complain_overflow_dont,
220            tic54x_relocation,"ARELEXT16",FALSE,0x7FFFFF,0x7FFFFF,FALSE),
221
222     /* upper 7 bits of 23-bit extended address, absolute */
223     HOWTO (R_EXTWORDMS7,16,1,7,FALSE,0,complain_overflow_dont,
224            tic54x_relocation,"ARELEXTMS7",FALSE,0x7F,0x7F,FALSE),
225
226     /* 32-bit relocation exclusively for stabs */
227     HOWTO (R_RELLONG,0,2,32,FALSE,0,complain_overflow_dont,
228            tic54x_relocation,"STAB",FALSE,0xFFFFFFFF,0xFFFFFFFF,FALSE),
229   };
230
231 #define coff_bfd_reloc_type_lookup tic54x_coff_reloc_type_lookup
232
233 /* For the case statement use the code values used tc_gen_reloc (defined in
234    bfd/reloc.c) to map to the howto table entries.  */
235
236 reloc_howto_type *
237 tic54x_coff_reloc_type_lookup (abfd, code)
238      bfd *abfd ATTRIBUTE_UNUSED;
239      bfd_reloc_code_real_type code;
240 {
241   switch (code)
242     {
243     case BFD_RELOC_16:
244       return &tic54x_howto_table[0];
245     case BFD_RELOC_TIC54X_PARTLS7:
246       return &tic54x_howto_table[1];
247     case BFD_RELOC_TIC54X_PARTMS9:
248       return &tic54x_howto_table[2];
249     case BFD_RELOC_TIC54X_23:
250       return &tic54x_howto_table[3];
251     case BFD_RELOC_TIC54X_16_OF_23:
252       return &tic54x_howto_table[4];
253     case BFD_RELOC_TIC54X_MS7_OF_23:
254       return &tic54x_howto_table[5];
255     case BFD_RELOC_32:
256       return &tic54x_howto_table[12];
257     default:
258       return (reloc_howto_type *) NULL;
259     }
260 }
261
262 /* Code to turn a r_type into a howto ptr, uses the above howto table.
263    Called after some initial checking by the tic54x_rtype_to_howto fn below.  */
264
265 static void
266 tic54x_lookup_howto (internal, dst)
267      arelent *internal;
268      struct internal_reloc *dst;
269 {
270   unsigned i;
271   int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0;
272
273   for (i = 0; i < sizeof tic54x_howto_table/sizeof tic54x_howto_table[0]; i++)
274     {
275       if (tic54x_howto_table[i].type == dst->r_type)
276         {
277           internal->howto = tic54x_howto_table + i + bank;
278           return;
279         }
280     }
281
282   (*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"),
283                          (unsigned int) dst->r_type);
284   abort ();
285 }
286
287 #define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\
288  tic54x_reloc_processing(RELENT,RELOC,SYMS,ABFD,SECT)
289
290 #define coff_rtype_to_howto coff_tic54x_rtype_to_howto
291
292 static reloc_howto_type *
293 coff_tic54x_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
294      bfd *abfd ATTRIBUTE_UNUSED;
295      asection *sec;
296      struct internal_reloc *rel;
297      struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
298      struct internal_syment *sym ATTRIBUTE_UNUSED;
299      bfd_vma *addendp;
300 {
301   arelent genrel;
302
303   if (rel->r_symndx == -1 && addendp != NULL)
304     {
305       /* This is a TI "internal relocation", which means that the relocation
306          amount is the amount by which the current section is being relocated
307          in the output section.  */
308       *addendp = (sec->output_section->vma + sec->output_offset) - sec->vma;
309     }
310
311   tic54x_lookup_howto (&genrel, rel);
312
313   return genrel.howto;
314 }
315
316 /* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local
317    labels.  */
318
319 static bfd_boolean
320 ticoff_bfd_is_local_label_name (abfd, name)
321   bfd *abfd ATTRIBUTE_UNUSED;
322   const char *name;
323 {
324   if (TICOFF_LOCAL_LABEL_P(name))
325     return TRUE;
326   return FALSE;
327 }
328
329 #define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name
330
331 /* Customize coffcode.h; the default coff_ functions are set up to use COFF2;
332    coff_bad_format_hook uses BADMAG, so set that for COFF2.  The COFF1
333    and COFF0 vectors use custom _bad_format_hook procs instead of setting
334    BADMAG.  */
335 #define BADMAG(x) COFF2_BADMAG(x)
336 #include "coffcode.h"
337
338 static bfd_boolean
339 tic54x_set_section_contents (abfd, section, location, offset, bytes_to_do)
340      bfd *abfd;
341      sec_ptr section;
342      const PTR location;
343      file_ptr offset;
344      bfd_size_type bytes_to_do;
345 {
346   return coff_set_section_contents (abfd, section, location,
347                                     offset, bytes_to_do);
348 }
349
350 static void
351 tic54x_reloc_processing (relent, reloc, symbols, abfd, section)
352      arelent *relent;
353      struct internal_reloc *reloc;
354      asymbol **symbols;
355      bfd *abfd;
356      asection *section;
357 {
358   asymbol *ptr;
359
360   relent->address = reloc->r_vaddr;
361
362   if (reloc->r_symndx != -1)
363     {
364       if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd))
365         {
366           (*_bfd_error_handler)
367             (_("%B: warning: illegal symbol index %ld in relocs"),
368              abfd, reloc->r_symndx);
369           relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
370           ptr = NULL;
371         }
372       else
373         {
374           relent->sym_ptr_ptr = (symbols
375                                  + obj_convert (abfd)[reloc->r_symndx]);
376           ptr = *(relent->sym_ptr_ptr);
377         }
378     }
379   else
380     {
381       relent->sym_ptr_ptr = section->symbol_ptr_ptr;
382       ptr = *(relent->sym_ptr_ptr);
383     }
384
385   /* The symbols definitions that we have read in have been
386      relocated as if their sections started at 0. But the offsets
387      refering to the symbols in the raw data have not been
388      modified, so we have to have a negative addend to compensate.
389
390      Note that symbols which used to be common must be left alone.  */
391
392   /* Calculate any reloc addend by looking at the symbol.  */
393   CALC_ADDEND (abfd, ptr, *reloc, relent);
394
395   relent->address -= section->vma;
396   /* !!     relent->section = (asection *) NULL;*/
397
398   /* Fill in the relent->howto field from reloc->r_type.  */
399   tic54x_lookup_howto (relent, reloc);
400 }
401
402 /* TI COFF v0, DOS tools (little-endian headers).  */
403 const bfd_target tic54x_coff0_vec =
404   {
405     "coff0-c54x",                       /* name */
406     bfd_target_coff_flavour,
407     BFD_ENDIAN_LITTLE,          /* data byte order is little */
408     BFD_ENDIAN_LITTLE,          /* header byte order is little (DOS tools) */
409
410     (HAS_RELOC | EXEC_P |               /* object flags */
411      HAS_LINENO | HAS_DEBUG |
412      HAS_SYMS | HAS_LOCALS | WP_TEXT ),
413
414     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
415     '_',                                /* leading symbol underscore */
416     '/',                                /* ar_pad_char */
417     15,                         /* ar_max_namelen */
418     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
419     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
420     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
421     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
422     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
423     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
424
425     {_bfd_dummy_target, coff_object_p,  /* bfd_check_format */
426      bfd_generic_archive_p, _bfd_dummy_target},
427     {bfd_false, coff_mkobject, _bfd_generic_mkarchive,  /* bfd_set_format */
428      bfd_false},
429     {bfd_false, coff_write_object_contents,     /* bfd_write_contents */
430      _bfd_write_archive_contents, bfd_false},
431
432     BFD_JUMP_TABLE_GENERIC (coff),
433     BFD_JUMP_TABLE_COPY (coff),
434     BFD_JUMP_TABLE_CORE (_bfd_nocore),
435     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
436     BFD_JUMP_TABLE_SYMBOLS (coff),
437     BFD_JUMP_TABLE_RELOCS (coff),
438     BFD_JUMP_TABLE_WRITE (tic54x),
439     BFD_JUMP_TABLE_LINK (coff),
440     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
441     NULL,
442
443     (PTR) & ticoff0_swap_table
444   };
445
446 /* TI COFF v0, SPARC tools (big-endian headers).  */
447 const bfd_target tic54x_coff0_beh_vec =
448   {
449     "coff0-beh-c54x",                   /* name */
450     bfd_target_coff_flavour,
451     BFD_ENDIAN_LITTLE,          /* data byte order is little */
452     BFD_ENDIAN_BIG,             /* header byte order is big */
453
454     (HAS_RELOC | EXEC_P |               /* object flags */
455      HAS_LINENO | HAS_DEBUG |
456      HAS_SYMS | HAS_LOCALS | WP_TEXT ),
457
458     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
459     '_',                                /* leading symbol underscore */
460     '/',                                /* ar_pad_char */
461     15,                         /* ar_max_namelen */
462     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
463     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
464     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
465     bfd_getb64, bfd_getb_signed_64, bfd_putb64,
466     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
467     bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
468
469     {_bfd_dummy_target, coff_object_p,  /* bfd_check_format */
470      bfd_generic_archive_p, _bfd_dummy_target},
471     {bfd_false, coff_mkobject, _bfd_generic_mkarchive,  /* bfd_set_format */
472      bfd_false},
473     {bfd_false, coff_write_object_contents,     /* bfd_write_contents */
474      _bfd_write_archive_contents, bfd_false},
475
476     BFD_JUMP_TABLE_GENERIC (coff),
477     BFD_JUMP_TABLE_COPY (coff),
478     BFD_JUMP_TABLE_CORE (_bfd_nocore),
479     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
480     BFD_JUMP_TABLE_SYMBOLS (coff),
481     BFD_JUMP_TABLE_RELOCS (coff),
482     BFD_JUMP_TABLE_WRITE (tic54x),
483     BFD_JUMP_TABLE_LINK (coff),
484     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
485
486     & tic54x_coff0_vec,
487
488     (PTR) & ticoff0_swap_table
489   };
490
491 /* TI COFF v1, DOS tools (little-endian headers).  */
492 const bfd_target tic54x_coff1_vec =
493   {
494     "coff1-c54x",                       /* name */
495     bfd_target_coff_flavour,
496     BFD_ENDIAN_LITTLE,          /* data byte order is little */
497     BFD_ENDIAN_LITTLE,          /* header byte order is little (DOS tools) */
498
499     (HAS_RELOC | EXEC_P |               /* object flags */
500      HAS_LINENO | HAS_DEBUG |
501      HAS_SYMS | HAS_LOCALS | WP_TEXT ),
502
503     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
504     '_',                                /* leading symbol underscore */
505     '/',                                /* ar_pad_char */
506     15,                         /* ar_max_namelen */
507     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
508     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
509     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
510     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
511     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
512     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
513
514     {_bfd_dummy_target, coff_object_p,  /* bfd_check_format */
515      bfd_generic_archive_p, _bfd_dummy_target},
516     {bfd_false, coff_mkobject, _bfd_generic_mkarchive,  /* bfd_set_format */
517      bfd_false},
518     {bfd_false, coff_write_object_contents,     /* bfd_write_contents */
519      _bfd_write_archive_contents, bfd_false},
520
521     BFD_JUMP_TABLE_GENERIC (coff),
522     BFD_JUMP_TABLE_COPY (coff),
523     BFD_JUMP_TABLE_CORE (_bfd_nocore),
524     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
525     BFD_JUMP_TABLE_SYMBOLS (coff),
526     BFD_JUMP_TABLE_RELOCS (coff),
527     BFD_JUMP_TABLE_WRITE (tic54x),
528     BFD_JUMP_TABLE_LINK (coff),
529     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
530
531     & tic54x_coff0_beh_vec,
532
533     (PTR) & ticoff1_swap_table
534 };
535
536 /* TI COFF v1, SPARC tools (big-endian headers).  */
537 const bfd_target tic54x_coff1_beh_vec =
538   {
539     "coff1-beh-c54x",                   /* name */
540     bfd_target_coff_flavour,
541     BFD_ENDIAN_LITTLE,          /* data byte order is little */
542     BFD_ENDIAN_BIG,             /* header byte order is big */
543
544     (HAS_RELOC | EXEC_P |               /* object flags */
545      HAS_LINENO | HAS_DEBUG |
546      HAS_SYMS | HAS_LOCALS | WP_TEXT ),
547
548     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
549     '_',                                /* leading symbol underscore */
550     '/',                                /* ar_pad_char */
551     15,                         /* ar_max_namelen */
552     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
553     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
554     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
555     bfd_getb64, bfd_getb_signed_64, bfd_putb64,
556     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
557     bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
558
559     {_bfd_dummy_target, coff_object_p,  /* bfd_check_format */
560      bfd_generic_archive_p, _bfd_dummy_target},
561     {bfd_false, coff_mkobject, _bfd_generic_mkarchive,  /* bfd_set_format */
562      bfd_false},
563     {bfd_false, coff_write_object_contents,     /* bfd_write_contents */
564      _bfd_write_archive_contents, bfd_false},
565
566     BFD_JUMP_TABLE_GENERIC (coff),
567     BFD_JUMP_TABLE_COPY (coff),
568     BFD_JUMP_TABLE_CORE (_bfd_nocore),
569     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
570     BFD_JUMP_TABLE_SYMBOLS (coff),
571     BFD_JUMP_TABLE_RELOCS (coff),
572     BFD_JUMP_TABLE_WRITE (tic54x),
573     BFD_JUMP_TABLE_LINK (coff),
574     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
575
576     & tic54x_coff1_vec,
577
578     (PTR) & ticoff1_swap_table
579   };
580
581 /* TI COFF v2, TI DOS tools output (little-endian headers).  */
582 const bfd_target tic54x_coff2_vec =
583   {
584     "coff2-c54x",                       /* name */
585     bfd_target_coff_flavour,
586     BFD_ENDIAN_LITTLE,          /* data byte order is little */
587     BFD_ENDIAN_LITTLE,          /* header byte order is little (DOS tools) */
588
589     (HAS_RELOC | EXEC_P |               /* object flags */
590      HAS_LINENO | HAS_DEBUG |
591      HAS_SYMS | HAS_LOCALS | WP_TEXT ),
592
593     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
594     '_',                                /* leading symbol underscore */
595     '/',                                /* ar_pad_char */
596     15,                         /* ar_max_namelen */
597     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
598     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
599     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
600     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
601     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
602     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
603
604     {_bfd_dummy_target, coff_object_p,  /* bfd_check_format */
605      bfd_generic_archive_p, _bfd_dummy_target},
606     {bfd_false, coff_mkobject, _bfd_generic_mkarchive,  /* bfd_set_format */
607      bfd_false},
608     {bfd_false, coff_write_object_contents,     /* bfd_write_contents */
609      _bfd_write_archive_contents, bfd_false},
610
611     BFD_JUMP_TABLE_GENERIC (coff),
612     BFD_JUMP_TABLE_COPY (coff),
613     BFD_JUMP_TABLE_CORE (_bfd_nocore),
614     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
615     BFD_JUMP_TABLE_SYMBOLS (coff),
616     BFD_JUMP_TABLE_RELOCS (coff),
617     BFD_JUMP_TABLE_WRITE (tic54x),
618     BFD_JUMP_TABLE_LINK (coff),
619     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
620
621     & tic54x_coff1_beh_vec,
622
623     COFF_SWAP_TABLE
624   };
625
626 /* TI COFF v2, TI SPARC tools output (big-endian headers).  */
627 const bfd_target tic54x_coff2_beh_vec =
628   {
629     "coff2-beh-c54x",                   /* name */
630     bfd_target_coff_flavour,
631     BFD_ENDIAN_LITTLE,          /* data byte order is little */
632     BFD_ENDIAN_BIG,             /* header byte order is big */
633
634     (HAS_RELOC | EXEC_P |               /* object flags */
635      HAS_LINENO | HAS_DEBUG |
636      HAS_SYMS | HAS_LOCALS | WP_TEXT ),
637
638     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
639     '_',                                /* leading symbol underscore */
640     '/',                                /* ar_pad_char */
641     15,                         /* ar_max_namelen */
642     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
643     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
644     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
645     bfd_getb64, bfd_getb_signed_64, bfd_putb64,
646     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
647     bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
648
649     {_bfd_dummy_target, coff_object_p,  /* bfd_check_format */
650      bfd_generic_archive_p, _bfd_dummy_target},
651     {bfd_false, coff_mkobject, _bfd_generic_mkarchive,  /* bfd_set_format */
652      bfd_false},
653     {bfd_false, coff_write_object_contents,     /* bfd_write_contents */
654      _bfd_write_archive_contents, bfd_false},
655
656     BFD_JUMP_TABLE_GENERIC (coff),
657     BFD_JUMP_TABLE_COPY (coff),
658     BFD_JUMP_TABLE_CORE (_bfd_nocore),
659     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
660     BFD_JUMP_TABLE_SYMBOLS (coff),
661     BFD_JUMP_TABLE_RELOCS (coff),
662     BFD_JUMP_TABLE_WRITE (tic54x),
663     BFD_JUMP_TABLE_LINK (coff),
664     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
665
666     & tic54x_coff2_vec,
667
668     COFF_SWAP_TABLE
669   };