OSDN Git Service

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