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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD backend for hp-ux 9000/300
    2    Copyright 1990, 1991, 1993, 1994, 1995, 1997, 2000, 2001
     2   Copyright 1990, 1991, 1993, 1994, 1995, 1997, 2000, 2001, 2002
    33   Free Software Foundation, Inc.
    44   Written by Glenn Engel.
     
    2121
    2222/*
    23 
    2423    hpux native  ------------> |               |
    2524                               | hp300hpux bfd | ----------> hpux w/gnu ext
     
    102101
    103102#define TARGETNAME "a.out-hp300hpux"
    104 #define MY(OP) CAT(hp300hpux_,OP)
     103
     104/* Do not "beautify" the CONCAT* macro args.  Traditional C will not
     105   remove whitespace added here, and thus will fail to concatenate
     106   the tokens.  */
     107#define MY(OP) CONCAT2 (hp300hpux_,OP)
    105108
    106109#define external_exec hp300hpux_exec_bytes
     
    125128/***********************************************/
    126129/* these don't use MY because that causes problems within JUMP_TABLE
    127    (CAT winds up being expanded recursively, which ANSI C compilers
     130   (CONCAT2 winds up being expanded recursively, which ANSI C compilers
    128131   will not do).  */
    129132#define MY_get_symtab hp300hpux_get_symtab
     
    183186#define HP_RLENGTH_ALIGN        0x03
    184187
    185 #define NAME(x,y) CAT3(hp300hpux,_32_,y)
     188#define NAME(x,y) CONCAT3 (hp300hpux,_32_,y)
    186189#define ARCH_SIZE 32
    187190
     
    191194
    192195#include "aoutx.h"
     196
     197static const bfd_target * MY (callback)
     198  PARAMS ((bfd *));
     199static bfd_boolean MY (write_object_contents)
     200  PARAMS ((bfd *));
     201static void convert_sym_type
     202  PARAMS ((struct external_nlist *, aout_symbol_type *, bfd *));
     203
     204bfd_boolean MY (slurp_symbol_table)
     205  PARAMS ((bfd *));
     206void MY (swap_std_reloc_in)
     207  PARAMS ((bfd *, struct hp300hpux_reloc *, arelent *, asymbol **,
     208           bfd_size_type));
     209bfd_boolean MY (slurp_reloc_table)
     210  PARAMS ((bfd *, sec_ptr, asymbol **));
     211long MY (get_symtab)
     212  PARAMS ((bfd *, asymbol **));
     213long MY (get_symtab_upper_bound)
     214  PARAMS ((bfd *));
     215long MY (canonicalize_reloc)
     216  PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
    193217
    194218/* Since the hpux symbol table has nlist elements interspersed with
     
    258282}
    259283
    260 extern boolean aout_32_write_syms PARAMS ((bfd * abfd));
    261 
    262 static boolean
     284extern bfd_boolean aout_32_write_syms
     285  PARAMS ((bfd * abfd));
     286
     287static bfd_boolean
    263288MY (write_object_contents) (abfd)
    264289     bfd *abfd;
     
    292317
    293318  /* this is really the sym table size but we store it in drelocs */
    294   bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
    295 
    296   if (bfd_seek (abfd, 0L, false) != 0
    297       || (bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
     319  H_PUT_32 (abfd, (bfd_get_symcount (abfd) * 12), exec_bytes.e_drelocs);
     320
     321  if (bfd_seek (abfd, (file_ptr) 0, FALSE) != 0
     322      || (bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd)
    298323          != EXEC_BYTES_SIZE))
    299     return false;
     324    return FALSE;
    300325
    301326  /* Write out the symbols, and then the relocs.  We must write out
     
    305330    {
    306331      /* Skip the relocs to where we want to put the symbols.  */
    307       if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp) + execp->a_drsize,
     332      if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp) + execp->a_drsize),
    308333                    SEEK_SET) != 0)
    309         return false;
     334        return FALSE;
    310335    }
    311336
    312337  if (!MY (write_syms) (abfd))
    313     return false;
     338    return FALSE;
    314339
    315340  if (bfd_get_symcount (abfd) != 0)
    316341    {
    317       if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0)
    318         return false;
     342      if (bfd_seek (abfd, (file_ptr) N_TRELOFF (*execp), SEEK_CUR) != 0)
     343        return FALSE;
    319344      if (!NAME (aout,squirt_out_relocs) (abfd, obj_textsec (abfd)))
    320         return false;
    321       if (bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false) != 0)
    322         return false;
     345        return FALSE;
     346      if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp), SEEK_CUR) != 0)
     347        return FALSE;
    323348      if (!NAME (aout,squirt_out_relocs) (abfd, obj_datasec (abfd)))
    324         return false;
    325     }
    326 
    327   return true;
     349        return FALSE;
     350    }
     351
     352  return TRUE;
    328353}
    329354
     
    440465  memset (execp, 0, sizeof (struct internal_exec));
    441466  /* Now fill in fields in the execp, from the bytes in the raw data.  */
    442   execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
     467  execp->a_info = H_GET_32 (abfd, bytes->e_info);
    443468  execp->a_text = GET_WORD (abfd, bytes->e_text);
    444469  execp->a_data = GET_WORD (abfd, bytes->e_data);
     
    459484      long syms;
    460485      struct aout_data_struct *rawptr;
    461       if (bfd_h_get_32 (abfd, bytes->e_passize) != 0)
     486      bfd_size_type amt;
     487
     488      if (H_GET_32 (abfd, bytes->e_passize) != 0)
    462489        break;
    463       if (bfd_h_get_32 (abfd, bytes->e_syms) != 0)
     490      if (H_GET_32 (abfd, bytes->e_syms) != 0)
    464491        break;
    465       if (bfd_h_get_32 (abfd, bytes->e_supsize) != 0)
     492      if (H_GET_32 (abfd, bytes->e_supsize) != 0)
    466493        break;
    467494
    468       syms = bfd_h_get_32 (abfd, bytes->e_drelocs);
     495      syms = H_GET_32 (abfd, bytes->e_drelocs);
    469496      if (syms == 0)
    470497        break;
     
    474501
    475502      /* allocate storage for where we will store this result */
    476       rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (*rawptr));
     503      amt = sizeof (*rawptr);
     504      rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
    477505
    478506      if (rawptr == NULL)
     
    507535*/
    508536
    509 boolean
     537bfd_boolean
    510538MY (slurp_symbol_table) (abfd)
    511539     bfd *abfd;
     
    518546  aout_symbol_type *cached;
    519547  unsigned num_syms = 0;
     548  bfd_size_type amt;
    520549
    521550  /* If there's no work to be done, don't do any */
    522551  if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
    523     return true;
     552    return TRUE;
    524553  symbol_bytes = exec_hdr (abfd)->a_syms;
    525554
    526   strings = (char *) bfd_alloc (abfd,
    527                                 symbol_bytes + SYM_EXTRA_BYTES);
     555  amt = symbol_bytes + SYM_EXTRA_BYTES;
     556  strings = (char *) bfd_alloc (abfd, amt);
    528557  if (!strings)
    529     return false;
     558    return FALSE;
    530559  syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
    531560  if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
    532       || bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
     561      || bfd_bread ((PTR) syms, symbol_bytes, abfd) != symbol_bytes)
    533562    {
    534563      bfd_release (abfd, syms);
    535       return false;
     564      return FALSE;
    536565    }
    537566
     
    549578  bfd_get_symcount (abfd) = num_syms;
    550579
    551   cached = ((aout_symbol_type *)
    552             bfd_zalloc (abfd,
    553                         bfd_get_symcount (abfd) * sizeof (aout_symbol_type)));
    554   if (cached == NULL && bfd_get_symcount (abfd) != 0)
    555     return false;
     580  amt = num_syms;
     581  amt *= sizeof (aout_symbol_type);
     582  cached = (aout_symbol_type *) bfd_zalloc (abfd, amt);
     583  if (cached == NULL && num_syms != 0)
     584    return FALSE;
    556585
    557586  /* as we march thru the hp symbol table, convert it into a list of
     
    580609        convert_sym_type (sym_pointer, cache_ptr, abfd);
    581610        if (!translate_from_native_sym_flags (abfd, cache_ptr))
    582           return false;
     611          return FALSE;
    583612
    584613        /********************************************************/
     
    609638  obj_aout_symbols (abfd) = cached;
    610639
    611   return true;
     640  return TRUE;
    612641}
    613642
     
    626655  struct aoutdata *su = &(abfd->tdata.aout_data->a);
    627656
    628   cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
    629   r_index = bfd_h_get_16 (abfd, bytes->r_index);
     657  cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
     658  r_index = H_GET_16 (abfd, bytes->r_index);
    630659
    631660  switch (bytes->r_type[0])
     
    691720}
    692721
    693 boolean
     722bfd_boolean
    694723MY (slurp_reloc_table) (abfd, asect, symbols)
    695724     bfd *abfd;
     
    697726     asymbol **symbols;
    698727{
    699   unsigned int count;
     728  bfd_size_type count;
    700729  bfd_size_type reloc_size;
    701730  PTR relocs;
     
    707736
    708737  if (asect->relocation)
    709     return true;
     738    return TRUE;
    710739
    711740  if (asect->flags & SEC_CONSTRUCTOR)
    712     return true;
     741    return TRUE;
    713742
    714743  if (asect == obj_datasec (abfd))
     
    725754
    726755  bfd_set_error (bfd_error_invalid_operation);
    727   return false;
     756  return FALSE;
    728757
    729758doit:
    730759  if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
    731     return false;
     760    return FALSE;
    732761  each_size = obj_reloc_entry_size (abfd);
    733762
    734763  count = reloc_size / each_size;
    735764
    736   reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t) (count * sizeof
    737                                                         (arelent)));
     765  reloc_cache = (arelent *) bfd_zalloc (abfd, count * sizeof (arelent));
    738766  if (!reloc_cache && count != 0)
    739     return false;
     767    return FALSE;
    740768
    741769  relocs = (PTR) bfd_alloc (abfd, reloc_size);
     
    743771    {
    744772      bfd_release (abfd, reloc_cache);
    745       return false;
    746     }
    747 
    748   if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
     773      return FALSE;
     774    }
     775
     776  if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
    749777    {
    750778      bfd_release (abfd, relocs);
    751779      bfd_release (abfd, reloc_cache);
    752       return false;
     780      return FALSE;
    753781    }
    754782
     
    760788    {
    761789      MY (swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
    762                               bfd_get_symcount (abfd));
     790                              (bfd_size_type) bfd_get_symcount (abfd));
    763791    }
    764792
     
    766794  asect->relocation = reloc_cache;
    767795  asect->reloc_count = count;
    768   return true;
     796  return TRUE;
    769797}
    770798
     
    775803/************************************************************************/
    776804
    777 long aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location));
    778 long aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd));
    779 
    780 long aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section,
    781                                          arelent ** relptr,
    782                                          asymbol ** symbols));
     805long aout_32_get_symtab
     806  PARAMS ((bfd * abfd, asymbol ** location));
     807long aout_32_get_symtab_upper_bound
     808  PARAMS ((bfd * abfd));
     809long aout_32_canonicalize_reloc
     810  PARAMS ((bfd * abfd, sec_ptr section, arelent ** relptr,
     811           asymbol ** symbols));
    783812
    784813long
Note: See TracChangeset for help on using the changeset viewer.