Home | History | Annotate | Line # | Download | only in bfd
coff-tic54x.c revision 1.1.1.7
      1 /* BFD back-end for TMS320C54X coff binaries.
      2    Copyright (C) 1999-2024 Free Software Foundation, Inc.
      3    Contributed by Timothy Wall (twall (at) 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
     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
     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
     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 static void
     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 static int
     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 static bfd_reloc_status_type
    113 tic54x_relocation (bfd *abfd ATTRIBUTE_UNUSED,
    114 		   arelent *reloc_entry,
    115 		   asymbol *symbol ATTRIBUTE_UNUSED,
    116 		   void * data ATTRIBUTE_UNUSED,
    117 		   asection *input_section,
    118 		   bfd *output_bfd,
    119 		   char **error_message ATTRIBUTE_UNUSED)
    120 {
    121   if (output_bfd != (bfd *) NULL)
    122     {
    123       /* This is a partial relocation, and we want to apply the
    124 	 relocation to the reloc entry rather than the raw data.
    125 	 Modify the reloc inplace to reflect what we now know.  */
    126       reloc_entry->address += input_section->output_offset;
    127       return bfd_reloc_ok;
    128     }
    129   return bfd_reloc_continue;
    130 }
    131 
    132 reloc_howto_type tic54x_howto_table[] =
    133   {
    134     /* type,rightshift,size,
    135        bit size, pc_relative, bitpos, dont complain_on_overflow,
    136        special_function, name, partial_inplace, src_mask, dst_mask, pcrel_offset.  */
    137 
    138     /* NORMAL BANK */
    139     /* 16-bit direct reference to symbol's address.  */
    140     HOWTO (R_RELWORD,0,2,16,false,0,complain_overflow_dont,
    141 	   tic54x_relocation,"REL16",false,0xFFFF,0xFFFF,false),
    142 
    143     /* 7 LSBs of an address */
    144     HOWTO (R_PARTLS7,0,2,7,false,0,complain_overflow_dont,
    145 	   tic54x_relocation,"LS7",false,0x007F,0x007F,false),
    146 
    147     /* 9 MSBs of an address */
    148     /* TI assembler doesn't shift its encoding, and is thus incompatible */
    149     HOWTO (R_PARTMS9,7,2,9,false,0,complain_overflow_dont,
    150 	   tic54x_relocation,"MS9",false,0x01FF,0x01FF,false),
    151 
    152     /* 23-bit relocation */
    153     HOWTO (R_EXTWORD,0,4,23,false,0,complain_overflow_dont,
    154 	   tic54x_relocation,"RELEXT",false,0x7FFFFF,0x7FFFFF,false),
    155 
    156     /* 16 bits of 23-bit extended address */
    157     HOWTO (R_EXTWORD16,0,2,16,false,0,complain_overflow_dont,
    158 	   tic54x_relocation,"RELEXT16",false,0x7FFFFF,0x7FFFFF,false),
    159 
    160     /* upper 7 bits of 23-bit extended address */
    161     HOWTO (R_EXTWORDMS7,16,2,7,false,0,complain_overflow_dont,
    162 	   tic54x_relocation,"RELEXTMS7",false,0x7F,0x7F,false),
    163 
    164     /* ABSOLUTE BANK */
    165     /* 16-bit direct reference to symbol's address, absolute */
    166     HOWTO (R_RELWORD,0,2,16,false,0,complain_overflow_dont,
    167 	   tic54x_relocation,"AREL16",false,0xFFFF,0xFFFF,false),
    168 
    169     /* 7 LSBs of an address, absolute */
    170     HOWTO (R_PARTLS7,0,2,7,false,0,complain_overflow_dont,
    171 	   tic54x_relocation,"ALS7",false,0x007F,0x007F,false),
    172 
    173     /* 9 MSBs of an address, absolute */
    174     /* TI assembler doesn't shift its encoding, and is thus incompatible */
    175     HOWTO (R_PARTMS9,7,2,9,false,0,complain_overflow_dont,
    176 	   tic54x_relocation,"AMS9",false,0x01FF,0x01FF,false),
    177 
    178     /* 23-bit direct reference, absolute */
    179     HOWTO (R_EXTWORD,0,4,23,false,0,complain_overflow_dont,
    180 	   tic54x_relocation,"ARELEXT",false,0x7FFFFF,0x7FFFFF,false),
    181 
    182     /* 16 bits of 23-bit extended address, absolute */
    183     HOWTO (R_EXTWORD16,0,2,16,false,0,complain_overflow_dont,
    184 	   tic54x_relocation,"ARELEXT16",false,0x7FFFFF,0x7FFFFF,false),
    185 
    186     /* upper 7 bits of 23-bit extended address, absolute */
    187     HOWTO (R_EXTWORDMS7,16,2,7,false,0,complain_overflow_dont,
    188 	   tic54x_relocation,"ARELEXTMS7",false,0x7F,0x7F,false),
    189 
    190     /* 32-bit relocation exclusively for stabs */
    191     HOWTO (R_RELLONG,0,4,32,false,0,complain_overflow_dont,
    192 	   tic54x_relocation,"STAB",false,0xFFFFFFFF,0xFFFFFFFF,false),
    193   };
    194 
    195 #define coff_bfd_reloc_type_lookup tic54x_coff_reloc_type_lookup
    196 #define coff_bfd_reloc_name_lookup tic54x_coff_reloc_name_lookup
    197 
    198 /* For the case statement use the code values used tc_gen_reloc (defined in
    199    bfd/reloc.c) to map to the howto table entries.  */
    200 
    201 static reloc_howto_type *
    202 tic54x_coff_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
    203 			       bfd_reloc_code_real_type code)
    204 {
    205   switch (code)
    206     {
    207     case BFD_RELOC_16:
    208       return &tic54x_howto_table[0];
    209     case BFD_RELOC_TIC54X_PARTLS7:
    210       return &tic54x_howto_table[1];
    211     case BFD_RELOC_TIC54X_PARTMS9:
    212       return &tic54x_howto_table[2];
    213     case BFD_RELOC_TIC54X_23:
    214       return &tic54x_howto_table[3];
    215     case BFD_RELOC_TIC54X_16_OF_23:
    216       return &tic54x_howto_table[4];
    217     case BFD_RELOC_TIC54X_MS7_OF_23:
    218       return &tic54x_howto_table[5];
    219     case BFD_RELOC_32:
    220       return &tic54x_howto_table[12];
    221     default:
    222       return (reloc_howto_type *) NULL;
    223     }
    224 }
    225 
    226 static reloc_howto_type *
    227 tic54x_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
    228 			       const char *r_name)
    229 {
    230   unsigned int i;
    231 
    232   for (i = 0;
    233        i < sizeof (tic54x_howto_table) / sizeof (tic54x_howto_table[0]);
    234        i++)
    235     if (tic54x_howto_table[i].name != NULL
    236 	&& strcasecmp (tic54x_howto_table[i].name, r_name) == 0)
    237       return &tic54x_howto_table[i];
    238 
    239   return NULL;
    240 }
    241 
    242 /* Code to turn a r_type into a howto ptr, uses the above howto table.
    243    Called after some initial checking by the tic54x_rtype_to_howto fn below.  */
    244 
    245 static void
    246 tic54x_lookup_howto (bfd *abfd,
    247 		     arelent *internal,
    248 		     struct internal_reloc *dst)
    249 {
    250   unsigned i;
    251   int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0;
    252 
    253   for (i = 0; i < sizeof tic54x_howto_table/sizeof tic54x_howto_table[0]; i++)
    254     {
    255       if (tic54x_howto_table[i].type == dst->r_type)
    256 	{
    257 	  internal->howto = tic54x_howto_table + i + bank;
    258 	  return;
    259 	}
    260     }
    261 
    262   _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
    263 		      abfd, (unsigned int) dst->r_type);
    264   internal->howto = NULL;
    265 }
    266 
    267 #define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\
    268  tic54x_reloc_processing(RELENT,RELOC,SYMS,ABFD,SECT)
    269 
    270 #define coff_rtype_to_howto coff_tic54x_rtype_to_howto
    271 
    272 static reloc_howto_type *
    273 coff_tic54x_rtype_to_howto (bfd *abfd,
    274 			    asection *sec,
    275 			    struct internal_reloc *rel,
    276 			    struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
    277 			    struct internal_syment *sym ATTRIBUTE_UNUSED,
    278 			    bfd_vma *addendp)
    279 {
    280   arelent genrel;
    281 
    282   if (rel->r_symndx == -1 && addendp != NULL)
    283     {
    284       /* This is a TI "internal relocation", which means that the relocation
    285 	 amount is the amount by which the current section is being relocated
    286 	 in the output section.  */
    287       *addendp = (sec->output_section->vma + sec->output_offset) - sec->vma;
    288     }
    289 
    290   tic54x_lookup_howto (abfd, &genrel, rel);
    291 
    292   return genrel.howto;
    293 }
    294 
    295 /* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local
    296    labels.  */
    297 
    298 static bool
    299 ticoff_bfd_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
    300 				const char *name)
    301 {
    302   if (TICOFF_LOCAL_LABEL_P(name))
    303     return true;
    304   return false;
    305 }
    306 
    307 #define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name
    308 
    309 /* Customize coffcode.h; the default coff_ functions are set up to use COFF2;
    310    coff_bad_format_hook uses BADMAG, so set that for COFF2.  The COFF1
    311    and COFF0 vectors use custom _bad_format_hook procs instead of setting
    312    BADMAG.  */
    313 #define BADMAG(x) COFF2_BADMAG(x)
    314 
    315 #ifndef bfd_pe_print_pdata
    316 #define bfd_pe_print_pdata	NULL
    317 #endif
    318 
    319 #include "coffcode.h"
    320 
    321 static void
    322 tic54x_reloc_processing (arelent *relent,
    323 			 struct internal_reloc *reloc,
    324 			 asymbol **symbols,
    325 			 bfd *abfd,
    326 			 asection *section)
    327 {
    328   asymbol *ptr;
    329 
    330   relent->address = reloc->r_vaddr;
    331 
    332   if (reloc->r_symndx != -1 && symbols != NULL)
    333     {
    334       if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd))
    335 	{
    336 	  _bfd_error_handler
    337 	    /* xgettext: c-format */
    338 	    (_("%pB: warning: illegal symbol index %ld in relocs"),
    339 	     abfd, reloc->r_symndx);
    340 	  relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
    341 	  ptr = NULL;
    342 	}
    343       else
    344 	{
    345 	  relent->sym_ptr_ptr = (symbols
    346 				 + obj_convert (abfd)[reloc->r_symndx]);
    347 	  ptr = *(relent->sym_ptr_ptr);
    348 	}
    349     }
    350   else
    351     {
    352       relent->sym_ptr_ptr = section->symbol_ptr_ptr;
    353       ptr = *(relent->sym_ptr_ptr);
    354     }
    355 
    356   /* The symbols definitions that we have read in have been
    357      relocated as if their sections started at 0. But the offsets
    358      refering to the symbols in the raw data have not been
    359      modified, so we have to have a negative addend to compensate.
    360 
    361      Note that symbols which used to be common must be left alone.  */
    362 
    363   /* Calculate any reloc addend by looking at the symbol.  */
    364   CALC_ADDEND (abfd, ptr, *reloc, relent);
    365 
    366   relent->address -= section->vma;
    367   /* !!     relent->section = (asection *) NULL;*/
    368 
    369   /* Fill in the relent->howto field from reloc->r_type.  */
    370   tic54x_lookup_howto (abfd, relent, reloc);
    371 }
    372 
    373 /* TI COFF v0, DOS tools (little-endian headers).  */
    374 const bfd_target tic54x_coff0_vec =
    375   {
    376     "coff0-c54x",		/* name */
    377     bfd_target_coff_flavour,
    378     BFD_ENDIAN_LITTLE,		/* data byte order is little */
    379     BFD_ENDIAN_LITTLE,		/* header byte order is little (DOS tools) */
    380 
    381     (HAS_RELOC | EXEC_P		/* object flags */
    382      | HAS_LINENO | HAS_DEBUG
    383      | HAS_SYMS | HAS_LOCALS | WP_TEXT ),
    384 
    385     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
    386     '_',			/* leading symbol underscore */
    387     '/',			/* ar_pad_char */
    388     15,				/* ar_max_namelen */
    389     0,				/* match priority.  */
    390     TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
    391     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    392     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
    393     bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* data */
    394     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    395     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
    396     bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* hdrs */
    397 
    398     {				/* bfd_check_format */
    399       _bfd_dummy_target,
    400       coff_object_p,
    401       bfd_generic_archive_p,
    402       _bfd_dummy_target
    403     },
    404     {				/* bfd_set_format */
    405       _bfd_bool_bfd_false_error,
    406       coff_mkobject,
    407       _bfd_generic_mkarchive,
    408       _bfd_bool_bfd_false_error
    409     },
    410     {				/* bfd_write_contents */
    411       _bfd_bool_bfd_false_error,
    412       coff_write_object_contents,
    413       _bfd_write_archive_contents,
    414       _bfd_bool_bfd_false_error
    415     },
    416 
    417     BFD_JUMP_TABLE_GENERIC (coff),
    418     BFD_JUMP_TABLE_COPY (coff),
    419     BFD_JUMP_TABLE_CORE (_bfd_nocore),
    420     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
    421     BFD_JUMP_TABLE_SYMBOLS (coff),
    422     BFD_JUMP_TABLE_RELOCS (coff),
    423     BFD_JUMP_TABLE_WRITE (coff),
    424     BFD_JUMP_TABLE_LINK (coff),
    425     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
    426     NULL,
    427 
    428     &ticoff0_swap_table
    429   };
    430 
    431 /* TI COFF v0, SPARC tools (big-endian headers).  */
    432 const bfd_target tic54x_coff0_beh_vec =
    433   {
    434     "coff0-beh-c54x",		/* name */
    435     bfd_target_coff_flavour,
    436     BFD_ENDIAN_LITTLE,		/* data byte order is little */
    437     BFD_ENDIAN_BIG,		/* header byte order is big */
    438 
    439     (HAS_RELOC | EXEC_P		/* object flags */
    440      | HAS_LINENO | HAS_DEBUG
    441      | HAS_SYMS | HAS_LOCALS | WP_TEXT ),
    442 
    443     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
    444     '_',			/* leading symbol underscore */
    445     '/',			/* ar_pad_char */
    446     15,				/* ar_max_namelen */
    447     0,				/* match priority.  */
    448 #ifdef TARGET_KEEP_UNUSED_SECTION_SYMBOLS
    449     true,			/* keep unused section symbols.  */
    450 #else
    451     false,			/* keep unused section symbols.  */
    452 #endif
    453     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    454     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
    455     bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* data */
    456     bfd_getb64, bfd_getb_signed_64, bfd_putb64,
    457     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
    458     bfd_getb16, bfd_getb_signed_16, bfd_putb16,	/* hdrs */
    459 
    460     {				/* bfd_check_format */
    461       _bfd_dummy_target,
    462       coff_object_p,
    463       bfd_generic_archive_p,
    464       _bfd_dummy_target
    465     },
    466     {				/* bfd_set_format */
    467       _bfd_bool_bfd_false_error,
    468       coff_mkobject,
    469       _bfd_generic_mkarchive,
    470       _bfd_bool_bfd_false_error
    471     },
    472     {				/* bfd_write_contents */
    473       _bfd_bool_bfd_false_error,
    474       coff_write_object_contents,
    475       _bfd_write_archive_contents,
    476       _bfd_bool_bfd_false_error
    477     },
    478 
    479     BFD_JUMP_TABLE_GENERIC (coff),
    480     BFD_JUMP_TABLE_COPY (coff),
    481     BFD_JUMP_TABLE_CORE (_bfd_nocore),
    482     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
    483     BFD_JUMP_TABLE_SYMBOLS (coff),
    484     BFD_JUMP_TABLE_RELOCS (coff),
    485     BFD_JUMP_TABLE_WRITE (coff),
    486     BFD_JUMP_TABLE_LINK (coff),
    487     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
    488 
    489     &tic54x_coff0_vec,
    490 
    491     &ticoff0_swap_table
    492   };
    493 
    494 /* TI COFF v1, DOS tools (little-endian headers).  */
    495 const bfd_target tic54x_coff1_vec =
    496   {
    497     "coff1-c54x",		/* name */
    498     bfd_target_coff_flavour,
    499     BFD_ENDIAN_LITTLE,		/* data byte order is little */
    500     BFD_ENDIAN_LITTLE,		/* header byte order is little (DOS tools) */
    501 
    502     (HAS_RELOC | EXEC_P		/* object flags */
    503      | HAS_LINENO | HAS_DEBUG
    504      | HAS_SYMS | HAS_LOCALS | WP_TEXT ),
    505 
    506     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
    507     '_',			/* leading symbol underscore */
    508     '/',			/* ar_pad_char */
    509     15,				/* ar_max_namelen */
    510     0,				/* match priority.  */
    511 #ifdef TARGET_KEEP_UNUSED_SECTION_SYMBOLS
    512     true,			/* keep unused section symbols.  */
    513 #else
    514     false,			/* keep unused section symbols.  */
    515 #endif
    516     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    517     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
    518     bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* data */
    519     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    520     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
    521     bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* hdrs */
    522 
    523     {				/* bfd_check_format */
    524       _bfd_dummy_target,
    525       coff_object_p,
    526       bfd_generic_archive_p,
    527       _bfd_dummy_target
    528     },
    529     {				/* bfd_set_format */
    530       _bfd_bool_bfd_false_error,
    531       coff_mkobject,
    532       _bfd_generic_mkarchive,
    533       _bfd_bool_bfd_false_error
    534     },
    535     {				/* bfd_write_contents */
    536       _bfd_bool_bfd_false_error,
    537       coff_write_object_contents,
    538       _bfd_write_archive_contents,
    539       _bfd_bool_bfd_false_error
    540     },
    541 
    542     BFD_JUMP_TABLE_GENERIC (coff),
    543     BFD_JUMP_TABLE_COPY (coff),
    544     BFD_JUMP_TABLE_CORE (_bfd_nocore),
    545     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
    546     BFD_JUMP_TABLE_SYMBOLS (coff),
    547     BFD_JUMP_TABLE_RELOCS (coff),
    548     BFD_JUMP_TABLE_WRITE (coff),
    549     BFD_JUMP_TABLE_LINK (coff),
    550     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
    551 
    552     &tic54x_coff0_beh_vec,
    553 
    554     &ticoff1_swap_table
    555 };
    556 
    557 /* TI COFF v1, SPARC tools (big-endian headers).  */
    558 const bfd_target tic54x_coff1_beh_vec =
    559   {
    560     "coff1-beh-c54x",		/* name */
    561     bfd_target_coff_flavour,
    562     BFD_ENDIAN_LITTLE,		/* data byte order is little */
    563     BFD_ENDIAN_BIG,		/* header byte order is big */
    564 
    565     (HAS_RELOC | EXEC_P		/* object flags */
    566      | HAS_LINENO | HAS_DEBUG
    567      | HAS_SYMS | HAS_LOCALS | WP_TEXT ),
    568 
    569     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
    570     '_',			/* leading symbol underscore */
    571     '/',			/* ar_pad_char */
    572     15,				/* ar_max_namelen */
    573     0,				/* match priority.  */
    574 #ifdef TARGET_KEEP_UNUSED_SECTION_SYMBOLS
    575     true,			/* keep unused section symbols.  */
    576 #else
    577     false,			/* keep unused section symbols.  */
    578 #endif
    579     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    580     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
    581     bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* data */
    582     bfd_getb64, bfd_getb_signed_64, bfd_putb64,
    583     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
    584     bfd_getb16, bfd_getb_signed_16, bfd_putb16,	/* hdrs */
    585 
    586     {				/* bfd_check_format */
    587       _bfd_dummy_target,
    588       coff_object_p,
    589       bfd_generic_archive_p,
    590       _bfd_dummy_target
    591     },
    592     {				/* bfd_set_format */
    593       _bfd_bool_bfd_false_error,
    594       coff_mkobject,
    595       _bfd_generic_mkarchive,
    596       _bfd_bool_bfd_false_error
    597     },
    598     {				/* bfd_write_contents */
    599       _bfd_bool_bfd_false_error,
    600       coff_write_object_contents,
    601       _bfd_write_archive_contents,
    602       _bfd_bool_bfd_false_error
    603     },
    604 
    605     BFD_JUMP_TABLE_GENERIC (coff),
    606     BFD_JUMP_TABLE_COPY (coff),
    607     BFD_JUMP_TABLE_CORE (_bfd_nocore),
    608     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
    609     BFD_JUMP_TABLE_SYMBOLS (coff),
    610     BFD_JUMP_TABLE_RELOCS (coff),
    611     BFD_JUMP_TABLE_WRITE (coff),
    612     BFD_JUMP_TABLE_LINK (coff),
    613     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
    614 
    615     &tic54x_coff1_vec,
    616 
    617     &ticoff1_swap_table
    618   };
    619 
    620 /* TI COFF v2, TI DOS tools output (little-endian headers).  */
    621 const bfd_target tic54x_coff2_vec =
    622   {
    623     "coff2-c54x",		/* name */
    624     bfd_target_coff_flavour,
    625     BFD_ENDIAN_LITTLE,		/* data byte order is little */
    626     BFD_ENDIAN_LITTLE,		/* header byte order is little (DOS tools) */
    627 
    628     (HAS_RELOC | EXEC_P		/* object flags */
    629      | HAS_LINENO | HAS_DEBUG
    630      | HAS_SYMS | HAS_LOCALS | WP_TEXT ),
    631 
    632     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
    633     '_',			/* leading symbol underscore */
    634     '/',			/* ar_pad_char */
    635     15,				/* ar_max_namelen */
    636     0,				/* match priority.  */
    637 #ifdef TARGET_KEEP_UNUSED_SECTION_SYMBOLS
    638     true,			/* keep unused section symbols.  */
    639 #else
    640     false,			/* keep unused section symbols.  */
    641 #endif
    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_getl64, bfd_getl_signed_64, bfd_putl64,
    646     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
    647     bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* hdrs */
    648 
    649     {				/* bfd_check_format */
    650       _bfd_dummy_target,
    651       coff_object_p,
    652       bfd_generic_archive_p,
    653       _bfd_dummy_target
    654     },
    655     {				/* bfd_set_format */
    656       _bfd_bool_bfd_false_error,
    657       coff_mkobject,
    658       _bfd_generic_mkarchive,
    659       _bfd_bool_bfd_false_error
    660     },
    661     {				/* bfd_write_contents */
    662       _bfd_bool_bfd_false_error,
    663       coff_write_object_contents,
    664       _bfd_write_archive_contents,
    665       _bfd_bool_bfd_false_error
    666     },
    667 
    668     BFD_JUMP_TABLE_GENERIC (coff),
    669     BFD_JUMP_TABLE_COPY (coff),
    670     BFD_JUMP_TABLE_CORE (_bfd_nocore),
    671     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
    672     BFD_JUMP_TABLE_SYMBOLS (coff),
    673     BFD_JUMP_TABLE_RELOCS (coff),
    674     BFD_JUMP_TABLE_WRITE (coff),
    675     BFD_JUMP_TABLE_LINK (coff),
    676     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
    677 
    678     &tic54x_coff1_beh_vec,
    679 
    680     COFF_SWAP_TABLE
    681   };
    682 
    683 /* TI COFF v2, TI SPARC tools output (big-endian headers).  */
    684 const bfd_target tic54x_coff2_beh_vec =
    685   {
    686     "coff2-beh-c54x",		/* name */
    687     bfd_target_coff_flavour,
    688     BFD_ENDIAN_LITTLE,		/* data byte order is little */
    689     BFD_ENDIAN_BIG,		/* header byte order is big */
    690 
    691     (HAS_RELOC | EXEC_P		/* object flags */
    692      | HAS_LINENO | HAS_DEBUG
    693      | HAS_SYMS | HAS_LOCALS | WP_TEXT ),
    694 
    695     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
    696     '_',			/* leading symbol underscore */
    697     '/',			/* ar_pad_char */
    698     15,				/* ar_max_namelen */
    699     0,				/* match priority.  */
    700 #ifdef TARGET_KEEP_UNUSED_SECTION_SYMBOLS
    701     true,			/* keep unused section symbols.  */
    702 #else
    703     false,			/* keep unused section symbols.  */
    704 #endif
    705     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    706     tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32,
    707     bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* data */
    708     bfd_getb64, bfd_getb_signed_64, bfd_putb64,
    709     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
    710     bfd_getb16, bfd_getb_signed_16, bfd_putb16,	/* hdrs */
    711 
    712     {				/* bfd_check_format */
    713       _bfd_dummy_target,
    714       coff_object_p,
    715       bfd_generic_archive_p,
    716       _bfd_dummy_target
    717     },
    718     {				/* bfd_set_format */
    719       _bfd_bool_bfd_false_error,
    720       coff_mkobject,
    721       _bfd_generic_mkarchive,
    722       _bfd_bool_bfd_false_error
    723     },
    724     {				/* bfd_write_contents */
    725       _bfd_bool_bfd_false_error,
    726       coff_write_object_contents,
    727       _bfd_write_archive_contents,
    728       _bfd_bool_bfd_false_error
    729     },
    730 
    731     BFD_JUMP_TABLE_GENERIC (coff),
    732     BFD_JUMP_TABLE_COPY (coff),
    733     BFD_JUMP_TABLE_CORE (_bfd_nocore),
    734     BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
    735     BFD_JUMP_TABLE_SYMBOLS (coff),
    736     BFD_JUMP_TABLE_RELOCS (coff),
    737     BFD_JUMP_TABLE_WRITE (coff),
    738     BFD_JUMP_TABLE_LINK (coff),
    739     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
    740 
    741     &tic54x_coff2_vec,
    742 
    743     COFF_SWAP_TABLE
    744   };
    745