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/versados.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for VERSAdos-E objects.
    2    Copyright 1995, 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
     2   Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002
     3   Free Software Foundation, Inc.
    34   Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
    45
     
    4445#include "libiberty.h"
    4546
    46 static boolean versados_mkobject PARAMS ((bfd *));
    47 static boolean versados_scan PARAMS ((bfd *));
     47static bfd_boolean versados_mkobject PARAMS ((bfd *));
     48static bfd_boolean versados_scan PARAMS ((bfd *));
    4849static const bfd_target *versados_object_p PARAMS ((bfd *));
     50static asymbol *versados_new_symbol
     51  PARAMS ((bfd *, int, const char *, bfd_vma, asection *));
     52static char *new_symbol_string PARAMS ((bfd *, const char *));
     53static const bfd_target *versados_object_p PARAMS ((bfd *));
     54static bfd_boolean versados_pass_2 PARAMS ((bfd *));
     55static bfd_boolean versados_get_section_contents
     56  PARAMS ((bfd *, asection *, void *, file_ptr, bfd_size_type));
     57static bfd_boolean versados_set_section_contents
     58  PARAMS ((bfd *, sec_ptr, void *, file_ptr, bfd_size_type));
     59static int versados_sizeof_headers PARAMS ((bfd *, bfd_boolean));
     60static long int versados_get_symtab_upper_bound PARAMS ((bfd *));
     61static long int versados_get_symtab PARAMS ((bfd *, asymbol **));
     62static void versados_get_symbol_info
     63  PARAMS ((bfd *, asymbol *, symbol_info *));
     64static void versados_print_symbol
     65  PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
     66static long versados_get_reloc_upper_bound
     67  PARAMS ((bfd *, sec_ptr));
     68static long versados_canonicalize_reloc
     69  PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
    4970
    5071#define VHEADER '1'
     
    142163  };
    143164
     165static int get_record PARAMS ((bfd *, union ext_any *));
     166static int get_4 PARAMS ((unsigned char **));
     167static void get_10 PARAMS ((unsigned char **, char *));
     168static void process_esd PARAMS ((bfd *, struct ext_esd *, int));
     169static int get_offset PARAMS ((int, unsigned char *));
     170static void process_otr PARAMS ((bfd *, struct ext_otr *, int));
     171
    144172/* Initialize by filling in the hex conversion array.  */
    145173
    146174/* Set up the tdata information.  */
    147175
    148 static boolean
     176static bfd_boolean
    149177versados_mkobject (abfd)
    150178     bfd *abfd;
     
    152180  if (abfd->tdata.versados_data == NULL)
    153181    {
    154       tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
     182      bfd_size_type amt = sizeof (tdata_type);
     183      tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, amt);
    155184      if (tdata == NULL)
    156         return false;
     185        return FALSE;
    157186      abfd->tdata.versados_data = tdata;
    158187      tdata->symbols = NULL;
     
    161190
    162191  bfd_default_set_arch_mach (abfd, bfd_arch_m68k, 0);
    163   return true;
     192  return TRUE;
    164193}
    165194
     
    190219     union ext_any *ptr;
    191220{
    192   bfd_read (&ptr->size, 1, 1, abfd);
    193   if (bfd_read ((char *) ptr + 1, 1, ptr->size, abfd) != ptr->size)
     221  if (bfd_bread (&ptr->size, (bfd_size_type) 1, abfd) != 1
     222      || (bfd_bread ((char *) ptr + 1, (bfd_size_type) ptr->size, abfd)
     223          != ptr->size))
    194224    return 0;
    195225  return 1;
    196226}
    197227
    198 int
     228static int
    199229get_4 (pp)
    200230     unsigned char **pp;
     
    205235}
    206236
    207 void
     237static void
    208238get_10 (pp, name)
    209239     unsigned char **pp;
     
    225255new_symbol_string (abfd, name)
    226256     bfd *abfd;
    227      char *name;
     257     const char *name;
    228258{
    229259  char *n = VDATA (abfd)->strings;
     
    276306                asymbol *s;
    277307                char *n = new_symbol_string (abfd, name);
    278                 s = versados_new_symbol (abfd, snum, n, 0,
    279                                          &bfd_und_section, scn);
     308                s = versados_new_symbol (abfd, snum, n, (bfd_vma) 0,
     309                                         bfd_und_section_ptr);
    280310                esidx = VDATA (abfd)->es_done++;
    281311                RDATA (abfd, esidx - ES_BASE) = s;
     
    300330          {
    301331            int snum = VDATA (abfd)->def_idx++;
    302             long val;
     332            bfd_vma val;
    303333            get_10 (&ptr, name);
    304334            val = get_4 (&ptr);
     
    312342                asymbol *s;
    313343                char *n = new_symbol_string (abfd, name);
    314                 s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n, val, sec, scn);
     344                s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n,
     345                                         val, sec);
    315346                s->flags |= BSF_GLOBAL;
    316347              }
     
    328359reloc_howto_type versados_howto_table[] =
    329360{
    330   HOWTO (R_RELWORD, 0, 1, 16, false,
     361  HOWTO (R_RELWORD, 0, 1, 16, FALSE,
    331362         0, complain_overflow_dont, 0,
    332          "+v16", true, 0x0000ffff, 0x0000ffff, false),
    333   HOWTO (R_RELLONG, 0, 2, 32, false,
     363         "+v16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
     364  HOWTO (R_RELLONG, 0, 2, 32, FALSE,
    334365         0, complain_overflow_dont, 0,
    335          "+v32", true, 0xffffffff, 0xffffffff, false),
    336 
    337   HOWTO (R_RELWORD_NEG, 0, -1, 16, false,
     366         "+v32", TRUE, 0xffffffff, 0xffffffff, FALSE),
     367
     368  HOWTO (R_RELWORD_NEG, 0, -1, 16, FALSE,
    338369         0, complain_overflow_dont, 0,
    339          "-v16", true, 0x0000ffff, 0x0000ffff, false),
    340   HOWTO (R_RELLONG_NEG, 0, -2, 32, false,
     370         "-v16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
     371  HOWTO (R_RELLONG_NEG, 0, -2, 32, FALSE,
    341372         0, complain_overflow_dont, 0,
    342          "-v32", true, 0xffffffff, 0xffffffff, false),
     373         "-v32", TRUE, 0xffffffff, 0xffffffff, FALSE),
    343374};
    344375
     
    381412  unsigned int dst_idx = esdid->pc;
    382413
    383   for (shift = (1 << 31); shift && srcp < endp; shift >>= 1)
     414  for (shift = ((unsigned long) 1 << 31); shift && srcp < endp; shift >>= 1)
    384415    {
    385416      if (bits & shift)
     
    454485
    455486  if (!contents && need_contents)
    456     esdid->contents = (unsigned char *) bfd_alloc (abfd, esdid->section->_raw_size);
    457 
    458 }
    459 
    460 static boolean
     487    {
     488      bfd_size_type size = esdid->section->_raw_size;
     489      esdid->contents = (unsigned char *) bfd_alloc (abfd, size);
     490    }
     491}
     492
     493static bfd_boolean
    461494versados_scan (abfd)
    462495     bfd *abfd;
     
    466499  int j;
    467500  int nsecs = 0;
     501  bfd_size_type amt;
    468502
    469503  VDATA (abfd)->stringlen = 0;
     
    478512      union ext_any any;
    479513      if (!get_record (abfd, &any))
    480         return true;
     514        return TRUE;
    481515      switch (any.header.type)
    482516        {
     
    509543      if (esdid->section)
    510544        {
    511           esdid->section->relocation
    512             = (arelent *) bfd_alloc (abfd, sizeof (arelent) * esdid->relocs);
     545          amt = (bfd_size_type) esdid->relocs * sizeof (arelent);
     546          esdid->section->relocation = (arelent *) bfd_alloc (abfd, amt);
    513547
    514548          esdid->pc = 0;
     
    531565  abfd->symcount += nsecs;
    532566
    533   VDATA (abfd)->symbols = (asymbol *) bfd_alloc (abfd,
    534                                        sizeof (asymbol) * (abfd->symcount));
    535 
    536   VDATA (abfd)->strings = bfd_alloc (abfd, VDATA (abfd)->stringlen);
     567  amt = abfd->symcount;
     568  amt *= sizeof (asymbol);
     569  VDATA (abfd)->symbols = (asymbol *) bfd_alloc (abfd, amt);
     570
     571  amt = VDATA (abfd)->stringlen;
     572  VDATA (abfd)->strings = bfd_alloc (abfd, amt);
    537573
    538574  if ((VDATA (abfd)->symbols == NULL && abfd->symcount > 0)
    539575      || (VDATA (abfd)->strings == NULL && VDATA (abfd)->stringlen > 0))
    540     return false;
     576    return FALSE;
    541577
    542578  /* Actually fill in the section symbols,
     
    578614  struct ext_vheader ext;
    579615  unsigned char len;
     616  tdata_type *tdata_save;
    580617
    581618  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
    582619    return NULL;
    583620
    584   if (bfd_read (&len, 1, 1, abfd) != 1)
     621  if (bfd_bread (&len, (bfd_size_type) 1, abfd) != 1)
    585622    {
    586623      if (bfd_get_error () != bfd_error_system_call)
     
    589626    }
    590627
    591   if (bfd_read (&ext.type, 1, len, abfd) != len)
     628  if (bfd_bread (&ext.type, (bfd_size_type) len, abfd) != len)
    592629    {
    593630      if (bfd_get_error () != bfd_error_system_call)
     
    608645  /* OK, looks like a record, build the tdata and read in.  */
    609646
    610   if (!versados_mkobject (abfd)
    611       || !versados_scan (abfd))
    612     return NULL;
     647  tdata_save = abfd->tdata.versados_data;
     648  if (!versados_mkobject (abfd) || !versados_scan (abfd))
     649    {
     650      abfd->tdata.versados_data = tdata_save;
     651      return NULL;
     652    }
    613653
    614654  return abfd->xvec;
    615655}
    616656
    617 static boolean
     657static bfd_boolean
    618658versados_pass_2 (abfd)
    619659     bfd *abfd;
     
    624664    return 1;
    625665
    626   if (bfd_seek (abfd, 0, SEEK_SET) != 0)
     666  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
    627667    return 0;
    628668
     
    649689}
    650690
    651 static boolean
     691static bfd_boolean
    652692versados_get_section_contents (abfd, section, location, offset, count)
    653693     bfd *abfd;
     
    658698{
    659699  if (!versados_pass_2 (abfd))
    660     return false;
     700    return FALSE;
    661701
    662702  memcpy (location,
     
    664704          (size_t) count);
    665705
    666   return true;
     706  return TRUE;
    667707}
    668708
     
    670710  _bfd_generic_get_section_contents_in_window
    671711
    672 static boolean
     712static bfd_boolean
    673713versados_set_section_contents (abfd, section, location, offset, bytes_to_do)
    674714     bfd *abfd ATTRIBUTE_UNUSED;
     
    678718     bfd_size_type bytes_to_do ATTRIBUTE_UNUSED;
    679719{
    680   return false;
     720  return FALSE;
    681721}
    682722
     
    684724versados_sizeof_headers (abfd, exec)
    685725     bfd *abfd ATTRIBUTE_UNUSED;
    686      boolean exec ATTRIBUTE_UNUSED;
     726     bfd_boolean exec ATTRIBUTE_UNUSED;
    687727{
    688728  return 0;
    689 }
    690 
    691 static asymbol *
    692 versados_make_empty_symbol (abfd)
    693      bfd *abfd;
    694 {
    695   asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
    696   if (new)
    697     new->the_bfd = abfd;
    698   return new;
    699729}
    700730
     
    733763}
    734764
    735 void
     765static void
    736766versados_get_symbol_info (ignore_abfd, symbol, ret)
    737767     bfd *ignore_abfd ATTRIBUTE_UNUSED;
     
    742772}
    743773
    744 void
    745 versados_print_symbol (ignore_abfd, afile, symbol, how)
    746      bfd *ignore_abfd ATTRIBUTE_UNUSED;
     774static void
     775versados_print_symbol (abfd, afile, symbol, how)
     776     bfd *abfd;
    747777     PTR afile;
    748778     asymbol *symbol;
     
    756786      break;
    757787    default:
    758       bfd_print_symbol_vandf ((PTR) file, symbol);
     788      bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
    759789      fprintf (file, " %-5s %s",
    760790               symbol->section->name,
     
    764794}
    765795
    766 long
     796static long
    767797versados_get_reloc_upper_bound (abfd, asect)
    768798     bfd *abfd ATTRIBUTE_UNUSED;
     
    772802}
    773803
    774 long
     804static long
    775805versados_canonicalize_reloc (abfd, section, relptr, symbols)
    776806     bfd *abfd;
     
    829859#define versados_get_lineno _bfd_nosymbols_get_lineno
    830860#define versados_find_nearest_line _bfd_nosymbols_find_nearest_line
     861#define versados_make_empty_symbol _bfd_generic_make_empty_symbol
    831862#define versados_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
    832863#define versados_read_minisymbols _bfd_generic_read_minisymbols
     
    841872#define versados_bfd_relax_section bfd_generic_relax_section
    842873#define versados_bfd_gc_sections bfd_generic_gc_sections
     874#define versados_bfd_merge_sections bfd_generic_merge_sections
     875#define versados_bfd_discard_group bfd_generic_discard_group
    843876#define versados_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
     877#define versados_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
    844878#define versados_bfd_link_add_symbols _bfd_generic_link_add_symbols
     879#define versados_bfd_link_just_syms _bfd_generic_link_just_syms
    845880#define versados_bfd_final_link _bfd_generic_final_link
    846881#define versados_bfd_link_split_section _bfd_generic_link_split_section
Note: See TracChangeset for help on using the changeset viewer.