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