Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/aout-tic30.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for TMS320C30 a.out binaries.
    2    Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
     2   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    33   Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
    44
     
    2222#define TARGET_IS_BIG_ENDIAN_P
    2323#define N_HEADER_IN_TEXT(x) 1
    24 #define BYTES_IN_WORD 4
    2524#define TEXT_START_ADDR 1024
    2625#define TARGET_PAGE_SIZE 128
     
    2928#define ARCH_SIZE 32
    3029
    31 #define MY(OP) CAT(tic30_aout_,OP)
     30/* Do not "beautify" the CONCAT* macro args.  Traditional C will not
     31   remove whitespace added here, and thus will fail to concatenate
     32   the tokens.  */
     33#define MY(OP) CONCAT2 (tic30_aout_,OP)
    3234#define TARGETNAME "a.out-tic30"
    33 #define NAME(x,y) CAT3(tic30_aout,_32_,y)
     35#define NAME(x,y) CONCAT3 (tic30_aout,_32_,y)
    3436
    3537#include "bfd.h"
     
    5456  PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma,
    5557           bfd_vma, bfd_vma));
    56 static const bfd_target *tic30_aout_object_p PARAMS ((bfd *));
    57 static boolean tic30_aout_write_object_contents PARAMS ((bfd *));
    58 static boolean tic30_aout_set_sizes PARAMS ((bfd *));
    59 
    60 #define MY_reloc_howto(BFD,REL,IN,EX,PC) tic30_aout_reloc_howto(BFD,REL,&IN,&EX,&PC)
     58static const bfd_target *tic30_aout_object_p
     59  PARAMS ((bfd *));
     60static bfd_boolean tic30_aout_write_object_contents
     61  PARAMS ((bfd *));
     62static bfd_boolean tic30_aout_set_sizes
     63  PARAMS ((bfd *));
     64static const bfd_target * tic30_aout_callback
     65  PARAMS ((bfd *));
     66static bfd_boolean MY_bfd_copy_private_section_data
     67  PARAMS ((bfd *, asection *, bfd *, asection *));
     68static bfd_boolean MY_bfd_final_link
     69  PARAMS ((bfd *, struct bfd_link_info *));
     70reloc_howto_type * tic30_aout_reloc_type_lookup
     71  PARAMS ((bfd *, bfd_reloc_code_real_type));
     72enum machine_type tic30_aout_machine_type
     73  PARAMS ((enum bfd_architecture, unsigned long, bfd_boolean *));
     74bfd_boolean tic30_aout_set_arch_mach
     75  PARAMS ((bfd *, enum bfd_architecture, unsigned long));
     76
     77#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
     78  tic30_aout_reloc_howto(BFD, REL, &IN, &EX, &PC)
    6179#define MY_final_link_relocate tic30_aout_final_link_relocate
    6280#define MY_object_p tic30_aout_object_p
     
    102120#endif
    103121
    104 static CONST struct aout_backend_data tic30_aout_backend_data =
     122static const struct aout_backend_data tic30_aout_backend_data =
    105123{
    106124  MY_zmagic_contiguous,
     
    131149   it.  */
    132150reloc_howto_type tic30_aout_howto_table[] =
    133 {
    134   EMPTY_HOWTO (-1),
    135   HOWTO (1, 2, 1, 16, false, 0, 0, tic30_aout_fix_16,
    136          "16", false, 0x0000FFFF, 0x0000FFFF, false),
    137   HOWTO (2, 2, 2, 24, false, 0, complain_overflow_bitfield, NULL,
    138          "24", false, 0x00FFFFFF, 0x00FFFFFF, false),
    139   HOWTO (3, 18, 3, 24, false, 0, complain_overflow_bitfield, NULL,
    140          "LDP", false, 0x00FF0000, 0x000000FF, false),
    141   HOWTO (4, 2, 4, 32, false, 0, complain_overflow_bitfield, tic30_aout_fix_32,
    142          "32", false, 0xFFFFFFFF, 0xFFFFFFFF, false),
    143   HOWTO (5, 2, 1, 16, true, 0, complain_overflow_signed,
    144          tic30_aout_fix_pcrel_16, "PCREL", true, 0x0000FFFF, 0x0000FFFF, true),
    145   EMPTY_HOWTO (-1),
    146   EMPTY_HOWTO (-1),
    147   EMPTY_HOWTO (-1),
    148   EMPTY_HOWTO (-1),
    149   EMPTY_HOWTO (-1)
    150 };
    151 
    152 extern reloc_howto_type *NAME (aout, reloc_type_lookup) ();
     151  {
     152    EMPTY_HOWTO (-1),
     153    HOWTO (1, 2, 1, 16, FALSE, 0, 0, tic30_aout_fix_16,
     154           "16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
     155    HOWTO (2, 2, 2, 24, FALSE, 0, complain_overflow_bitfield, NULL,
     156           "24", FALSE, 0x00FFFFFF, 0x00FFFFFF, FALSE),
     157    HOWTO (3, 18, 3, 24, FALSE, 0, complain_overflow_bitfield, NULL,
     158           "LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE),
     159    HOWTO (4, 2, 4, 32, FALSE, 0, complain_overflow_bitfield, tic30_aout_fix_32,
     160           "32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE),
     161    HOWTO (5, 2, 1, 16, TRUE, 0, complain_overflow_signed,
     162           tic30_aout_fix_pcrel_16, "PCREL", TRUE, 0x0000FFFF, 0x0000FFFF, TRUE),
     163    EMPTY_HOWTO (-1),
     164    EMPTY_HOWTO (-1),
     165    EMPTY_HOWTO (-1),
     166    EMPTY_HOWTO (-1),
     167    EMPTY_HOWTO (-1)
     168  };
     169
     170extern reloc_howto_type *NAME (aout, reloc_type_lookup)
     171  PARAMS ((bfd *, bfd_reloc_code_real_type));
    153172
    154173reloc_howto_type *
     
    318337  unsigned long arch_align;
    319338
    320   /* Calculate the file positions of the parts of a newly read aout header */
     339  /* Calculate the file positions of the parts of a newly read aout header. */
    321340  obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp);
    322341
    323   /* The virtual memory addresses of the sections */
     342  /* The virtual memory addresses of the sections. */
    324343  obj_textsec (abfd)->vma = N_TXTADDR (*execp);
    325344  obj_datasec (abfd)->vma = N_DATADDR (*execp);
     
    330349  obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
    331350
    332   /* The file offsets of the sections */
     351  /* The file offsets of the sections. */
    333352  obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
    334353  obj_datasec (abfd)->filepos = N_DATOFF (*execp);
    335354
    336   /* The file offsets of the relocation info */
     355  /* The file offsets of the relocation info. */
    337356  obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
    338357  obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
     
    346365  SET_ARCH_MACH (abfd, *execp);
    347366#else
    348   bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
     367  bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0L);
    349368#endif
    350369
     
    406425{
    407426  bfd_vma x;
    408   boolean overflow;
     427  bfd_boolean overflow;
    409428
    410429  if (howto->size < 0)
     
    430449      break;
    431450    }
    432   overflow = false;
     451
     452  overflow = FALSE;
     453
    433454  if (howto->complain_on_overflow != complain_overflow_dont)
    434455    {
     
    475496            bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
    476497            if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
    477               overflow = true;
     498              overflow = TRUE;
    478499          }
    479500          break;
     
    482503            bfd_vma reloc_unsigned_max = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
    483504            if (check > reloc_unsigned_max)
    484               overflow = true;
     505              overflow = TRUE;
    485506          }
    486507          break;
     
    488509          {
    489510            bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
    490             if ((check & ~reloc_bits) != 0 && (((bfd_vma) signed_check & ~reloc_bits) != (-1 & ~reloc_bits)))
    491               overflow = true;
     511            if ((check & ~reloc_bits) != 0
     512                && (((bfd_vma) signed_check & ~reloc_bits)
     513                    != ((bfd_vma) -1 & ~reloc_bits)))
     514              overflow = TRUE;
    492515          }
    493516          break;
     
    521544}
    522545
    523 /* Finish up the reading of an a.out file header */
     546/* Finish up the reading of an a.out file header. */
    524547
    525548static const bfd_target *
     
    527550     bfd *abfd;
    528551{
    529   struct external_exec exec_bytes;      /* Raw exec header from file */
    530   struct internal_exec exec;    /* Cleaned-up exec header */
     552  struct external_exec exec_bytes;      /* Raw exec header from file. */
     553  struct internal_exec exec;    /* Cleaned-up exec header. */
    531554  const bfd_target *target;
    532 
    533   if (bfd_read ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
    534       != EXEC_BYTES_SIZE)
     555  bfd_size_type amt = EXEC_BYTES_SIZE;
     556
     557  if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
    535558    {
    536559      if (bfd_get_error () != bfd_error_system_call)
     
    542565  exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
    543566#else
    544   exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
     567  exec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
    545568#endif /* SWAP_MAGIC */
    546569
     
    563586#ifdef ENTRY_CAN_BE_ZERO
    564587  /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
    565    * means that it isn't obvious if EXEC_P should be set.
    566    * All of the following must be true for an executable:
    567    * There must be no relocations, the bfd can be neither an
    568    * archive nor an archive element, and the file must be executable.  */
     588     means that it isn't obvious if EXEC_P should be set.
     589     All of the following must be true for an executable:
     590     There must be no relocations, the bfd can be neither an
     591     archive nor an archive element, and the file must be executable.  */
    569592
    570593  if (exec.a_trsize + exec.a_drsize == 0
     
    589612   after the section contents have been set.  */
    590613
    591 static boolean
     614static bfd_boolean
    592615MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
    593616     bfd *ibfd;
     
    598621  if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
    599622    obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
    600   return true;
     623  return TRUE;
    601624}
    602625
     
    605628   file header, symbols, and relocation.  */
    606629
    607 static boolean
     630static bfd_boolean
    608631tic30_aout_write_object_contents (abfd)
    609632     bfd *abfd;
     
    615638
    616639  {
    617     bfd_size_type text_size;    /* dummy vars */
     640    bfd_size_type text_size;    /* Dummy vars. */
    618641    file_ptr text_end;
     642
    619643    if (adata (abfd).magic == undecided_magic)
    620644      NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
     
    629653    if (adata (abfd).exec_bytes_size > 0)
    630654      {
     655        bfd_size_type amt;
    631656        if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
    632           return false;
    633         if (bfd_write ((PTR) & exec_bytes, 1, adata (abfd).exec_bytes_size, abfd) != adata (abfd).exec_bytes_size)
    634           return false;
     657          return FALSE;
     658        amt = adata (abfd).exec_bytes_size;
     659        if (bfd_bwrite ((PTR) &exec_bytes, amt, abfd) != amt)
     660          return FALSE;
    635661      }
    636     /* Now write out reloc info, followed by syms and strings */
    637 
     662
     663    /* Now write out reloc info, followed by syms and strings.  */
    638664    if (bfd_get_outsymbols (abfd) != (asymbol **) NULL
    639665        && bfd_get_symcount (abfd) != 0)
    640666      {
    641667        if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*execp)), SEEK_SET) != 0)
    642           return false;
     668          return FALSE;
    643669
    644670        if (!NAME (aout, write_syms) (abfd))
    645           return false;
     671          return FALSE;
    646672      }
    647673
    648674    if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0)
    649       return false;
     675      return FALSE;
    650676    if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
    651       return false;
     677      return FALSE;
    652678
    653679    if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0)
    654       return false;
     680      return FALSE;
    655681    if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
    656       return false;
     682      return FALSE;
    657683  }
    658684
    659   return true;
    660 }
    661 
    662 static boolean
     685  return TRUE;
     686}
     687
     688static bfd_boolean
    663689tic30_aout_set_sizes (abfd)
    664690     bfd *abfd;
     
    680706  adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
    681707
    682   return true;
     708  return TRUE;
    683709}
    684710
     
    711737   offsets in the output file.  */
    712738
    713 static boolean
     739static bfd_boolean
    714740MY_bfd_final_link (abfd, info)
    715741     bfd *abfd;
     
    746772      obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
    747773    }
     774
    748775  if (obj_datasec (abfd)->vma < vma)
    749     {
    750       obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
    751     }
     776    obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
     777
    752778  obj_datasec (abfd)->user_set_vma = 1;
    753779  vma = obj_datasec (abfd)->vma;
     
    779805     enum bfd_architecture arch;
    780806     unsigned long machine ATTRIBUTE_UNUSED;
    781      boolean *unknown;
     807     bfd_boolean *unknown;
    782808{
    783809  enum machine_type arch_flags;
    784810
    785811  arch_flags = M_UNKNOWN;
    786   *unknown = true;
     812  *unknown = TRUE;
    787813
    788814  switch (arch)
    789815    {
    790816    case bfd_arch_tic30:
    791       *unknown = false;
     817      *unknown = FALSE;
    792818      break;
    793819    default:
     
    795821    }
    796822  if (arch_flags != M_UNKNOWN)
    797     *unknown = false;
     823    *unknown = FALSE;
    798824  return arch_flags;
    799825}
    800826
    801 boolean
     827bfd_boolean
    802828tic30_aout_set_arch_mach (abfd, arch, machine)
    803829     bfd *abfd;
     
    806832{
    807833  if (!bfd_default_set_arch_mach (abfd, arch, machine))
    808     return false;
     834    return FALSE;
    809835  if (arch != bfd_arch_unknown)
    810836    {
    811       boolean unknown;
     837      bfd_boolean unknown;
    812838      tic30_aout_machine_type (arch, machine, &unknown);
    813839      if (unknown)
    814         return false;
     840        return FALSE;
    815841    }
    816842  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
     
    941967#define MY_bfd_gc_sections bfd_generic_gc_sections
    942968#endif
     969#ifndef MY_bfd_merge_sections
     970#define MY_bfd_merge_sections bfd_generic_merge_sections
     971#endif
     972#ifndef MY_bfd_discard_group
     973#define MY_bfd_discard_group bfd_generic_discard_group
     974#endif
    943975#ifndef MY_bfd_reloc_type_lookup
    944976#define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup
     
    956988#define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
    957989#endif
     990#ifndef MY_bfd_link_hash_table_free
     991#define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
     992#endif
    958993#ifndef MY_bfd_link_add_symbols
    959994#define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
     995#endif
     996#ifndef MY_bfd_link_just_syms
     997#define MY_bfd_link_just_syms _bfd_generic_link_just_syms
    960998#endif
    961999#ifndef MY_bfd_link_split_section
Note: See TracChangeset for help on using the changeset viewer.