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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for oasys objects.
    2    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999
    3    Free Software Foundation, Inc.
     2   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001,
     3   2002, 2003 Free Software Foundation, Inc.
    44   Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
    55
    6 This file is part of BFD, the Binary File Descriptor library.
    7 
    8 This program is free software; you can redistribute it and/or modify
    9 it under the terms of the GNU General Public License as published by
    10 the Free Software Foundation; either version 2 of the License, or
    11 (at your option) any later version.
    12 
    13 This program is distributed in the hope that it will be useful,
    14 but WITHOUT ANY WARRANTY; without even the implied warranty of
    15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 GNU General Public License for more details.
    17 
    18 You should have received a copy of the GNU General Public License
    19 along with this program; if not, write to the Free Software
    20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     6   This file is part of BFD, the Binary File Descriptor library.
     7
     8   This program is free software; you can redistribute it and/or modify
     9   it under the terms of the GNU General Public License as published by
     10   the Free Software Foundation; either version 2 of the License, or
     11   (at your option) any later version.
     12
     13   This program is distributed in the hope that it will be useful,
     14   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16   GNU General Public License for more details.
     17
     18   You should have received a copy of the GNU General Public License
     19   along with this program; if not, write to the Free Software
     20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2121
    2222#define UNDERSCORE_HACK 1
    2323#include "bfd.h"
    2424#include "sysdep.h"
    25 #include <ctype.h>
     25#include "safe-ctype.h"
    2626#include "libbfd.h"
    2727#include "oasys.h"
    2828#include "liboasys.h"
    2929
    30 /* XXX - FIXME.  offsetof belongs in the system-specific files in
    31    ../include/sys. */
    32 /* Define offsetof for those systems which lack it */
    33 
    34 #ifndef offsetof
    35 #define offsetof(type, identifier) (size_t) &(((type *) 0)->identifier)
    36 #endif
    37 
    38 static boolean oasys_read_record PARAMS ((bfd *,
    39                                           oasys_record_union_type *));
    40 static boolean oasys_write_sections PARAMS ((bfd *));
    41 static boolean oasys_write_record PARAMS ((bfd *,
    42                                            oasys_record_enum_type,
    43                                            oasys_record_union_type *,
    44                                            size_t));
    45 static boolean oasys_write_syms PARAMS ((bfd *));
    46 static boolean oasys_write_header PARAMS ((bfd *));
    47 static boolean oasys_write_end PARAMS ((bfd *));
    48 static boolean oasys_write_data PARAMS ((bfd *));
    49 
    50 /* Read in all the section data and relocation stuff too */
    51 PROTO (static boolean, oasys_slurp_section_data, (bfd * CONST abfd));
    52 
    53 static boolean
     30static bfd_boolean oasys_slurp_section_data
     31  PARAMS ((bfd * const));
     32static bfd_boolean oasys_read_record
     33  PARAMS ((bfd *, oasys_record_union_type *));
     34static bfd_boolean oasys_write_sections
     35  PARAMS ((bfd *));
     36static bfd_boolean oasys_write_record
     37  PARAMS ((bfd *, oasys_record_enum_type, oasys_record_union_type *, size_t));
     38static bfd_boolean oasys_write_syms
     39  PARAMS ((bfd *));
     40static bfd_boolean oasys_write_header
     41  PARAMS ((bfd *));
     42static bfd_boolean oasys_write_end
     43  PARAMS ((bfd *));
     44static bfd_boolean oasys_write_data
     45  PARAMS ((bfd *));
     46static size_t oasys_string_length
     47  PARAMS ((oasys_record_union_type *));
     48static bfd_boolean oasys_slurp_symbol_table
     49  PARAMS ((bfd *const));
     50static long int oasys_get_symtab_upper_bound
     51  PARAMS ((bfd *const));
     52static const bfd_target *oasys_archive_p
     53  PARAMS ((bfd *));
     54static bfd_boolean oasys_mkobject
     55  PARAMS ((bfd *));
     56static const bfd_target *oasys_object_p
     57  PARAMS ((bfd *));
     58static void oasys_get_symbol_info
     59  PARAMS ((bfd *, asymbol *, symbol_info *));
     60static void oasys_print_symbol
     61  PARAMS ((bfd *, void *, asymbol *, bfd_print_symbol_type));
     62static bfd_boolean oasys_new_section_hook
     63  PARAMS ((bfd *, asection *));
     64static long int oasys_get_reloc_upper_bound
     65  PARAMS ((bfd *, sec_ptr));
     66static bfd_boolean oasys_get_section_contents
     67  PARAMS ((bfd *, sec_ptr, void *, file_ptr, bfd_size_type));
     68static int comp
     69  PARAMS ((const void *, const void *));
     70static bfd_boolean oasys_write_object_contents
     71  PARAMS ((bfd *));
     72static bfd_boolean oasys_set_section_contents
     73  PARAMS ((bfd *, sec_ptr, void *, file_ptr, bfd_size_type));
     74static asymbol *oasys_make_empty_symbol
     75  PARAMS ((bfd *));
     76static bfd *oasys_openr_next_archived_file
     77  PARAMS ((bfd *, bfd *));
     78static bfd_boolean oasys_find_nearest_line
     79  PARAMS ((bfd *, asection *, asymbol **, bfd_vma,
     80           const char **, const char **, unsigned int *));
     81static int oasys_generic_stat_arch_elt
     82  PARAMS ((bfd *, struct stat *));
     83static int oasys_sizeof_headers
     84  PARAMS ((bfd *, bfd_boolean));
     85
     86long oasys_get_symtab
     87  PARAMS ((bfd *, asymbol **));
     88long oasys_canonicalize_reloc
     89  PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
     90
     91/* Read in all the section data and relocation stuff too.  */
     92
     93static bfd_boolean
    5494oasys_read_record (abfd, record)
    5595     bfd *abfd;
    5696     oasys_record_union_type *record;
    5797{
    58   if (bfd_read ((PTR) record, 1, sizeof (record->header), abfd)
    59       != sizeof (record->header))
    60     return false;
    61 
    62   if ((size_t) record->header.length <= (size_t) sizeof (record->header))
    63     return true;
    64   if (bfd_read ((PTR) (((char *) record) + sizeof (record->header)),
    65                 1, record->header.length - sizeof (record->header),
    66                 abfd)
    67       != record->header.length - sizeof (record->header))
    68     return false;
    69   return true;
    70 }
     98  bfd_size_type amt = sizeof (record->header);
     99  if (bfd_bread ((PTR) record, amt, abfd) != amt)
     100    return FALSE;
     101
     102  amt = record->header.length - sizeof (record->header);
     103  if ((long) amt <= 0)
     104    return TRUE;
     105  if (bfd_bread ((PTR) ((char *) record + sizeof (record->header)), amt, abfd)
     106      != amt)
     107    return FALSE;
     108  return TRUE;
     109}
     110
    71111static size_t
    72112oasys_string_length (record)
     
    93133*/
    94134
    95 static boolean
     135static bfd_boolean
    96136oasys_slurp_symbol_table (abfd)
    97      bfd *CONST abfd;
     137     bfd *const abfd;
    98138{
    99139  oasys_record_union_type record;
    100140  oasys_data_type *data = OASYS_DATA (abfd);
    101   boolean loop = true;
     141  bfd_boolean loop = TRUE;
    102142  asymbol *dest_defined;
    103143  asymbol *dest;
    104144  char *string_ptr;
    105 
     145  bfd_size_type amt;
    106146
    107147  if (data->symbols != (asymbol *) NULL)
    108148    {
    109       return true;
     149      return TRUE;
    110150    }
    111151  /* Buy enough memory for all the symbols and all the names */
    112   data->symbols =
    113     (asymbol *) bfd_alloc (abfd, sizeof (asymbol) * abfd->symcount);
     152  amt = abfd->symcount;
     153  amt *= sizeof (asymbol);
     154  data->symbols = (asymbol *) bfd_alloc (abfd, amt);
     155
     156  amt = data->symbol_string_length;
    114157#ifdef UNDERSCORE_HACK
    115158  /* buy 1 more char for each symbol to keep the underscore in*/
    116   data->strings = bfd_alloc (abfd, data->symbol_string_length +
    117                              abfd->symcount);
    118 #else
    119   data->strings = bfd_alloc (abfd, data->symbol_string_length);
     159  amt += abfd->symcount;
    120160#endif
     161  data->strings = bfd_alloc (abfd, amt);
     162
    121163  if (!data->symbols || !data->strings)
    122     return false;
     164    return FALSE;
    123165
    124166  dest_defined = data->symbols + abfd->symcount - 1;
     
    126168  string_ptr = data->strings;
    127169  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
    128     return false;
     170    return FALSE;
    129171  while (loop)
    130172    {
    131173
    132174      if (! oasys_read_record (abfd, &record))
    133         return false;
     175        return FALSE;
    134176      switch (record.header.type)
    135177        {
     
    175217                break;
    176218              case RELOCATION_TYPE_UND:
    177                 dest = data->symbols + bfd_h_get_16 (abfd, record.symbol.refno);
     219                dest = data->symbols + H_GET_16 (abfd, record.symbol.refno);
    178220                dest->section = bfd_und_section_ptr;
    179221                break;
     
    194236            dest->the_bfd = abfd;
    195237            dest->udata.p = (PTR) NULL;
    196             dest->value = bfd_h_get_32 (abfd, record.symbol.value);
     238            dest->value = H_GET_32 (abfd, record.symbol.value);
    197239
    198240#ifdef UNDERSCORE_HACK
     
    211253          break;
    212254        default:
    213           loop = false;
     255          loop = FALSE;
    214256        }
    215257    }
    216   return true;
     258  return TRUE;
    217259}
    218260
    219261static long
    220262oasys_get_symtab_upper_bound (abfd)
    221      bfd *CONST abfd;
     263     bfd *const abfd;
    222264{
    223265  if (! oasys_slurp_symbol_table (abfd))
     
    227269}
    228270
    229 /*
    230 */
    231 
    232271extern const bfd_target oasys_vec;
    233272
     
    239278  asymbol *symbase;
    240279  unsigned int counter;
    241   if (oasys_slurp_symbol_table (abfd) == false)
     280  if (! oasys_slurp_symbol_table (abfd))
    242281    {
    243282      return -1;
     
    264303  unsigned int i;
    265304  file_ptr filepos;
    266 
    267   if (bfd_seek (abfd, (file_ptr) 0, false) != 0
    268       || (bfd_read ((PTR) & header_ext, 1, sizeof (header_ext), abfd)
    269           != sizeof (header_ext)))
     305  bfd_size_type amt;
     306
     307  amt = sizeof (header_ext);
     308  if (bfd_seek (abfd, (file_ptr) 0, 0) != 0
     309      || bfd_bread ((PTR) &header_ext, amt, abfd) != amt)
    270310    {
    271311      if (bfd_get_error () != bfd_error_system_call)
     
    274314    }
    275315
    276   header.version = bfd_h_get_32 (abfd, header_ext.version);
    277   header.mod_count = bfd_h_get_32 (abfd, header_ext.mod_count);
    278   header.mod_tbl_offset = bfd_h_get_32 (abfd, header_ext.mod_tbl_offset);
    279   header.sym_tbl_size = bfd_h_get_32 (abfd, header_ext.sym_tbl_size);
    280   header.sym_count = bfd_h_get_32 (abfd, header_ext.sym_count);
    281   header.sym_tbl_offset = bfd_h_get_32 (abfd, header_ext.sym_tbl_offset);
    282   header.xref_count = bfd_h_get_32 (abfd, header_ext.xref_count);
    283   header.xref_lst_offset = bfd_h_get_32 (abfd, header_ext.xref_lst_offset);
     316  header.version = H_GET_32 (abfd, header_ext.version);
     317  header.mod_count = H_GET_32 (abfd, header_ext.mod_count);
     318  header.mod_tbl_offset = H_GET_32 (abfd, header_ext.mod_tbl_offset);
     319  header.sym_tbl_size = H_GET_32 (abfd, header_ext.sym_tbl_size);
     320  header.sym_count = H_GET_32 (abfd, header_ext.sym_count);
     321  header.sym_tbl_offset = H_GET_32 (abfd, header_ext.sym_tbl_offset);
     322  header.xref_count = H_GET_32 (abfd, header_ext.xref_count);
     323  header.xref_lst_offset = H_GET_32 (abfd, header_ext.xref_lst_offset);
    284324
    285325  /*
     
    300340    */
    301341  {
    302     oasys_ar_data_type *ar =
    303     (oasys_ar_data_type *) bfd_alloc (abfd, sizeof (oasys_ar_data_type));
    304 
    305     oasys_module_info_type *module =
    306     (oasys_module_info_type *)
    307     bfd_alloc (abfd, sizeof (oasys_module_info_type) * header.mod_count);
     342    oasys_ar_data_type *ar;
     343    oasys_module_info_type *module;
    308344    oasys_module_table_type record;
     345
     346    amt = sizeof (oasys_ar_data_type);
     347    ar = (oasys_ar_data_type *) bfd_alloc (abfd, amt);
     348
     349    amt = header.mod_count;
     350    amt *= sizeof (oasys_module_info_type);
     351    module = (oasys_module_info_type *) bfd_alloc (abfd, amt);
    309352
    310353    if (!ar || !module)
     
    326369          {
    327370            oasys_extmodule_table_type_a_type record_ext;
    328             if (bfd_read ((PTR) & record_ext, 1, sizeof (record_ext), abfd)
    329                 != sizeof (record_ext))
     371
     372            amt = sizeof (record_ext);
     373            if (bfd_bread ((PTR) &record_ext, amt, abfd) != amt)
    330374              return NULL;
    331375
    332             record.mod_size = bfd_h_get_32 (abfd, record_ext.mod_size);
    333             record.file_offset = bfd_h_get_32 (abfd, record_ext.file_offset);
    334 
    335             record.dep_count = bfd_h_get_32 (abfd, record_ext.dep_count);
    336             record.depee_count = bfd_h_get_32 (abfd, record_ext.depee_count);
    337             record.sect_count = bfd_h_get_32 (abfd, record_ext.sect_count);
    338 
    339             module[i].name = bfd_alloc (abfd, 33);
     376            record.mod_size = H_GET_32 (abfd, record_ext.mod_size);
     377            record.file_offset = H_GET_32 (abfd, record_ext.file_offset);
     378
     379            record.dep_count = H_GET_32 (abfd, record_ext.dep_count);
     380            record.depee_count = H_GET_32 (abfd, record_ext.depee_count);
     381            record.sect_count = H_GET_32 (abfd, record_ext.sect_count);
     382
     383            module[i].name = bfd_alloc (abfd, (bfd_size_type) 33);
    340384            if (!module[i].name)
    341385              return NULL;
     
    351395          {
    352396            oasys_extmodule_table_type_b_type record_ext;
    353             if (bfd_read ((PTR) & record_ext, 1, sizeof (record_ext), abfd)
    354                 != sizeof (record_ext))
     397
     398            amt = sizeof (record_ext);
     399            if (bfd_bread ((PTR) &record_ext, amt, abfd) != amt)
    355400              return NULL;
    356401
    357             record.mod_size = bfd_h_get_32 (abfd, record_ext.mod_size);
    358             record.file_offset = bfd_h_get_32 (abfd, record_ext.file_offset);
    359 
    360             record.dep_count = bfd_h_get_32 (abfd, record_ext.dep_count);
    361             record.depee_count = bfd_h_get_32 (abfd, record_ext.depee_count);
    362             record.sect_count = bfd_h_get_32 (abfd, record_ext.sect_count);
    363             record.module_name_size = bfd_h_get_32 (abfd, record_ext.mod_name_length);
    364 
    365             module[i].name = bfd_alloc (abfd, record.module_name_size + 1);
     402            record.mod_size = H_GET_32 (abfd, record_ext.mod_size);
     403            record.file_offset = H_GET_32 (abfd, record_ext.file_offset);
     404
     405            record.dep_count = H_GET_32 (abfd, record_ext.dep_count);
     406            record.depee_count = H_GET_32 (abfd, record_ext.depee_count);
     407            record.sect_count = H_GET_32 (abfd, record_ext.sect_count);
     408            record.module_name_size = H_GET_32 (abfd,
     409                                                record_ext.mod_name_length);
     410
     411            amt = record.module_name_size;
     412            module[i].name = bfd_alloc (abfd, amt + 1);
    366413            if (!module[i].name)
    367414              return NULL;
    368             if (bfd_read ((PTR) module[i].name, 1, record.module_name_size,
    369                           abfd)
    370                 != record.module_name_size)
     415            if (bfd_bread ((PTR) module[i].name, amt, abfd) != amt)
    371416              return NULL;
    372417            module[i].name[record.module_name_size] = 0;
    373             filepos +=
    374               sizeof (record_ext) +
    375               record.dep_count * 4 +
    376               record.module_name_size + 1;
    377 
     418            filepos += (sizeof (record_ext)
     419                        + record.dep_count * 4
     420                        + record.module_name_size + 1);
    378421          }
    379 
    380422
    381423        module[i].size = record.mod_size;
     
    383425        module[i].abfd = 0;
    384426      }
    385 
    386427  }
    387428  return abfd->xvec;
    388429}
    389430
    390 static boolean
     431static bfd_boolean
    391432oasys_mkobject (abfd)
    392433     bfd *abfd;
    393434{
    394 
    395   abfd->tdata.oasys_obj_data = (oasys_data_type *) bfd_alloc (abfd, sizeof (oasys_data_type));
    396   return abfd->tdata.oasys_obj_data ? true : false;
     435  bfd_size_type amt = sizeof (oasys_data_type);
     436  abfd->tdata.oasys_obj_data = (oasys_data_type *) bfd_alloc (abfd, amt);
     437  return abfd->tdata.oasys_obj_data != NULL;
    397438}
    398439
     
    404445  oasys_data_type *oasys;
    405446  oasys_data_type *save = OASYS_DATA (abfd);
    406   boolean loop = true;
    407   boolean had_usefull = false;
     447  bfd_boolean loop = TRUE;
     448  bfd_boolean had_usefull = FALSE;
    408449
    409450  abfd->tdata.oasys_obj_data = 0;
     
    432473        {
    433474        case oasys_record_is_header_enum:
    434           had_usefull = true;
     475          had_usefull = TRUE;
    435476          break;
    436477        case oasys_record_is_symbol_enum:
     
    439480          abfd->symcount++;
    440481          oasys->symbol_string_length += 1 + oasys_string_length (&record);
    441           had_usefull = true;
     482          had_usefull = TRUE;
    442483          break;
    443484        case oasys_record_is_section_enum:
     
    450491                goto fail;
    451492              }
    452             buffer = bfd_alloc (abfd, 3);
     493            buffer = bfd_alloc (abfd, (bfd_size_type) 3);
    453494            if (!buffer)
    454495              goto fail;
     
    467508              }
    468509
    469             s->_raw_size = bfd_h_get_32 (abfd, record.section.value);
    470             s->vma = bfd_h_get_32 (abfd, record.section.vma);
     510            s->_raw_size = H_GET_32 (abfd, record.section.value);
     511            s->vma = H_GET_32 (abfd, record.section.vma);
    471512            s->flags = 0;
    472             had_usefull = true;
     513            had_usefull = TRUE;
    473514          }
    474515          break;
     
    479520        case oasys_record_is_named_section_enum:
    480521        case oasys_record_is_end_enum:
    481           if (had_usefull == false)
     522          if (! had_usefull)
    482523            goto fail;
    483           loop = false;
     524          loop = FALSE;
    484525          break;
    485526        default:
     
    526567
    527568static void
    528 oasys_print_symbol (ignore_abfd, afile, symbol, how)
    529      bfd *ignore_abfd ATTRIBUTE_UNUSED;
     569oasys_print_symbol (abfd, afile, symbol, how)
     570     bfd *abfd;
    530571     PTR afile;
    531572     asymbol *symbol;
     
    542583    case bfd_print_symbol_all:
    543584      {
    544         CONST char *section_name = symbol->section == (asection *) NULL ?
    545         (CONST char *) "*abs" : symbol->section->name;
    546 
    547         bfd_print_symbol_vandf ((PTR) file, symbol);
     585        const char *section_name = symbol->section == (asection *) NULL ?
     586        (const char *) "*abs" : symbol->section->name;
     587
     588        bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
    548589
    549590        fprintf (file, " %-5s %s",
     
    561602{
    562603
    563   HOWTO (0, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false),
    564   HOWTO (0, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs32", true, 0xffffffff, 0xffffffff, false),
    565   HOWTO (0, 0, 1, 16, true, 0, complain_overflow_signed, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, false),
    566   HOWTO (0, 0, 2, 32, true, 0, complain_overflow_signed, 0, "pcrel32", true, 0xffffffff, 0xffffffff, false)
     604  HOWTO (0, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "abs16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
     605  HOWTO (0, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "abs32", TRUE, 0xffffffff, 0xffffffff, FALSE),
     606  HOWTO (0, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "pcrel16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
     607  HOWTO (0, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "pcrel32", TRUE, 0xffffffff, 0xffffffff, FALSE)
    567608};
    568609
    569610/* Read in all the section data and relocation stuff too */
    570 static boolean
     611static bfd_boolean
    571612oasys_slurp_section_data (abfd)
    572      bfd *CONST abfd;
     613     bfd *const abfd;
    573614{
    574615  oasys_record_union_type record;
    575616  oasys_data_type *data = OASYS_DATA (abfd);
    576   boolean loop = true;
    577 
     617  bfd_boolean loop = TRUE;
    578618  oasys_per_section_type *per;
    579 
    580619  asection *s;
     620  bfd_size_type amt;
    581621
    582622  /* See if the data has been slurped already .. */
     
    584624    {
    585625      per = oasys_per_section (s);
    586       if (per->initialized == true)
    587         return true;
     626      if (per->initialized)
     627        return TRUE;
    588628    }
    589629
    590630  if (data->first_data_record == 0)
    591     return true;
     631    return TRUE;
    592632
    593633  if (bfd_seek (abfd, data->first_data_record, SEEK_SET) != 0)
    594     return false;
     634    return FALSE;
    595635  while (loop)
    596636    {
    597637      if (! oasys_read_record (abfd, &record))
    598         return false;
     638        return FALSE;
    599639      switch (record.header.type)
    600640        {
     
    616656            per = oasys_per_section (section);
    617657
    618             if (per->initialized == false)
     658            if (! per->initialized)
    619659              {
    620660                per->data = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size);
    621661                if (!per->data)
    622                   return false;
    623                 per->reloc_tail_ptr = (oasys_reloc_type **) & (section->relocation);
    624                 per->had_vma = false;
    625                 per->initialized = true;
     662                  return FALSE;
     663                per->reloc_tail_ptr
     664                  = (oasys_reloc_type **) &section->relocation;
     665                per->had_vma = FALSE;
     666                per->initialized = TRUE;
    626667                section->reloc_count = 0;
    627668                section->flags = SEC_ALLOC;
    628669              }
    629670
    630             dst_offset = bfd_h_get_32 (abfd, record.data.addr);
    631             if (per->had_vma == false)
     671            dst_offset = H_GET_32 (abfd, record.data.addr);
     672            if (! per->had_vma)
    632673              {
    633674                /* Take the first vma we see as the base */
    634675                section->vma = dst_offset;
    635                 per->had_vma = true;
     676                per->had_vma = TRUE;
    636677              }
    637678
     
    682723                                {
    683724                                  /* Relocate the item relative to the section */
    684                                   oasys_reloc_type *r =
    685                                   (oasys_reloc_type *)
    686                                   bfd_alloc (abfd,
    687                                              sizeof (oasys_reloc_type));
     725                                  oasys_reloc_type *r;
     726
     727                                  amt = sizeof (oasys_reloc_type);
     728                                  r = (oasys_reloc_type *) bfd_alloc (abfd,
     729                                                                      amt);
    688730                                  if (!r)
    689                                     return false;
     731                                    return FALSE;
    690732                                  *(per->reloc_tail_ptr) = r;
    691733                                  per->reloc_tail_ptr = &r->next;
     
    710752                                  section->reloc_count++;
    711753
    712                                   /* Fake up the data to look like it's got the -ve pc in it, this makes
    713                                        it much easier to convert into other formats. This is done by
    714                                        hitting the addend.
    715                                        */
    716                                   if (r->relent.howto->pc_relative == true)
    717                                     {
    718                                       r->relent.addend -= dst_ptr - dst_base_ptr;
    719                                     }
    720 
    721 
     754                                  /* Fake up the data to look like
     755                                     it's got the -ve pc in it, this
     756                                     makes it much easier to convert
     757                                     into other formats.  This is done
     758                                     by hitting the addend.  */
     759                                  if (r->relent.howto->pc_relative)
     760                                    r->relent.addend -= dst_ptr - dst_base_ptr;
    722761                                }
    723762                                break;
     
    726765                              case RELOCATION_TYPE_UND:
    727766                                {
    728                                   oasys_reloc_type *r =
    729                                   (oasys_reloc_type *)
    730                                   bfd_alloc (abfd,
    731                                              sizeof (oasys_reloc_type));
     767                                  oasys_reloc_type *r;
     768
     769                                  amt = sizeof (oasys_reloc_type);
     770                                  r = (oasys_reloc_type *) bfd_alloc (abfd,
     771                                                                      amt);
    732772                                  if (!r)
    733                                     return false;
     773                                    return FALSE;
    734774                                  *(per->reloc_tail_ptr) = r;
    735775                                  per->reloc_tail_ptr = &r->next;
     
    753793
    754794                                  src += 2;
    755                                   /* Fake up the data to look like it's got the -ve pc in it, this makes
    756                                        it much easier to convert into other formats. This is done by
    757                                        hitting the addend.
    758                                        */
    759                                   if (r->relent.howto->pc_relative == true)
    760                                     {
    761                                       r->relent.addend -= dst_ptr - dst_base_ptr;
    762                                     }
    763 
    764 
    765 
     795                                  /* Fake up the data to look like
     796                                     it's got the -ve pc in it, this
     797                                     makes it much easier to convert
     798                                     into other formats.  This is done
     799                                     by hitting the addend.  */
     800                                  if (r->relent.howto->pc_relative)
     801                                    r->relent.addend -= dst_ptr - dst_base_ptr;
    766802                                }
    767803                                break;
     
    781817          break;
    782818        default:
    783           loop = false;
     819          loop = FALSE;
    784820        }
    785821    }
    786822
    787   return true;
    788 
    789 }
    790 
    791 static boolean
     823  return TRUE;
     824
     825}
     826
     827static bfd_boolean
    792828oasys_new_section_hook (abfd, newsect)
    793829     bfd *abfd;
     
    795831{
    796832  newsect->used_by_bfd = (PTR)
    797     bfd_alloc (abfd, sizeof (oasys_per_section_type));
     833    bfd_alloc (abfd, (bfd_size_type) sizeof (oasys_per_section_type));
    798834  if (!newsect->used_by_bfd)
    799     return false;
     835    return FALSE;
    800836  oasys_per_section (newsect)->data = (bfd_byte *) NULL;
    801837  oasys_per_section (newsect)->section = newsect;
    802838  oasys_per_section (newsect)->offset = 0;
    803   oasys_per_section (newsect)->initialized = false;
     839  oasys_per_section (newsect)->initialized = FALSE;
    804840  newsect->alignment_power = 1;
    805841  /* Turn the section string into an index */
     
    807843  sscanf (newsect->name, "%u", &newsect->target_index);
    808844
    809   return true;
     845  return TRUE;
    810846}
    811847
     
    821857}
    822858
    823 static boolean
     859static bfd_boolean
    824860oasys_get_section_contents (abfd, section, location, offset, count)
    825861     bfd *abfd;
     
    829865     bfd_size_type count;
    830866{
    831   oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd;
     867  oasys_per_section_type *p = oasys_per_section (section);
    832868  oasys_slurp_section_data (abfd);
    833   if (p->initialized == false)
    834     {
    835       (void) memset (location, 0, (int) count);
     869  if (! p->initialized)
     870    {
     871      (void) memset (location, 0, (size_t) count);
    836872    }
    837873  else
    838874    {
    839       (void) memcpy (location, (PTR) (p->data + offset), (int) count);
    840     }
    841   return true;
     875      (void) memcpy (location, (PTR) (p->data + offset), (size_t) count);
     876    }
     877  return TRUE;
    842878}
    843879
     
    878914
    879915/* Calculate the checksum and write one record */
    880 static boolean
     916static bfd_boolean
    881917oasys_write_record (abfd, type, record, size)
    882918     bfd *abfd;
     
    900936    }
    901937  record->header.check_sum = 0xff & (-checksum);
    902   if (bfd_write ((PTR) record, 1, size, abfd) != size)
    903     return false;
    904   return true;
     938  if (bfd_bwrite ((PTR) record, (bfd_size_type) size, abfd) != size)
     939    return FALSE;
     940  return TRUE;
    905941}
    906942
    907943
    908944/* Write out all the symbols */
    909 static boolean
     945static bfd_boolean
    910946oasys_write_syms (abfd)
    911947     bfd *abfd;
     
    918954
    919955      oasys_symbol_record_type symbol;
    920       asymbol *CONST g = generic[count];
    921 
    922       CONST char *src = g->name;
     956      asymbol *const g = generic[count];
     957
     958      const char *src = g->name;
    923959      char *dst = symbol.name;
    924960      unsigned int l = 0;
     
    927963        {
    928964          symbol.relb = RELOCATION_TYPE_COM;
    929           bfd_h_put_16 (abfd, index, symbol.refno);
     965          H_PUT_16 (abfd, index, symbol.refno);
    930966          index++;
    931967        }
     
    933969        {
    934970          symbol.relb = RELOCATION_TYPE_ABS;
    935           bfd_h_put_16 (abfd, 0, symbol.refno);
     971          H_PUT_16 (abfd, 0, symbol.refno);
    936972
    937973        }
     
    939975        {
    940976          symbol.relb = RELOCATION_TYPE_UND;
    941           bfd_h_put_16 (abfd, index, symbol.refno);
     977          H_PUT_16 (abfd, index, symbol.refno);
    942978          /* Overload the value field with the output index number */
    943979          index++;
     
    961997              symbol.relb = RELOCATION_TYPE_REL | g->section->output_section->target_index;
    962998            }
    963           bfd_h_put_16 (abfd, 0, symbol.refno);
     999          H_PUT_16 (abfd, 0, symbol.refno);
    9641000        }
    9651001#ifdef UNDERSCORE_HACK
     
    9731009        }
    9741010
    975       bfd_h_put_32 (abfd, g->value, symbol.value);
     1011      H_PUT_32 (abfd, g->value, symbol.value);
    9761012
    9771013
     
    9831019                                    offsetof (oasys_symbol_record_type,
    9841020                                              name[0]) + l))
    985             return false;
     1021            return FALSE;
    9861022        }
    9871023      else
     
    9921028                                    offsetof (oasys_symbol_record_type,
    9931029                                              name[0]) + l))
    994             return false;
     1030            return FALSE;
    9951031        }
    9961032      g->value = index - 1;
    9971033    }
    9981034
    999   return true;
     1035  return TRUE;
    10001036}
    10011037
    10021038
    10031039 /* Write a section header for each section */
    1004 static boolean
     1040static bfd_boolean
    10051041oasys_write_sections (abfd)
    10061042     bfd *abfd;
     
    10111047  for (s = abfd->sections; s != (asection *) NULL; s = s->next)
    10121048    {
    1013       if (!isdigit ((unsigned char) s->name[0]))
     1049      if (!ISDIGIT (s->name[0]))
    10141050        {
    10151051          (*_bfd_error_handler)
     
    10171053             bfd_get_filename (abfd), s->name);
    10181054          bfd_set_error (bfd_error_nonrepresentable_section);
    1019           return false;
     1055          return FALSE;
    10201056        }
    10211057      out.relb = RELOCATION_TYPE_REL | s->target_index;
    1022       bfd_h_put_32 (abfd, s->_cooked_size, out.value);
    1023       bfd_h_put_32 (abfd, s->vma, out.vma);
     1058      H_PUT_32 (abfd, s->_cooked_size, out.value);
     1059      H_PUT_32 (abfd, s->vma, out.vma);
    10241060
    10251061      if (! oasys_write_record (abfd,
     
    10271063                                (oasys_record_union_type *) & out,
    10281064                                sizeof (out)))
    1029         return false;
    1030     }
    1031   return true;
    1032 }
    1033 
    1034 static boolean
     1065        return FALSE;
     1066    }
     1067  return TRUE;
     1068}
     1069
     1070static bfd_boolean
    10351071oasys_write_header (abfd)
    10361072     bfd *abfd;
     
    10581094                            offsetof (oasys_header_record_type,
    10591095                                      description[0])))
    1060     return false;
    1061 
    1062   return true;
    1063 }
    1064 
    1065 static boolean
     1096    return FALSE;
     1097
     1098  return TRUE;
     1099}
     1100
     1101static bfd_boolean
    10661102oasys_write_end (abfd)
    10671103     bfd *abfd;
     
    10701106  unsigned char null = 0;
    10711107  end.relb = RELOCATION_TYPE_ABS;
    1072   bfd_h_put_32 (abfd, abfd->start_address, end.entry);
    1073   bfd_h_put_16 (abfd, 0, end.fill);
     1108  H_PUT_32 (abfd, abfd->start_address, end.entry);
     1109  H_PUT_16 (abfd, 0, end.fill);
    10741110  end.zero = 0;
    10751111  if (! oasys_write_record (abfd,
     
    10771113                            (oasys_record_union_type *) & end,
    10781114                            sizeof (end)))
    1079     return false;
    1080   if (bfd_write ((PTR) & null, 1, 1, abfd) != 1)
    1081     return false;
    1082   return true;
     1115    return FALSE;
     1116  if (bfd_bwrite ((PTR) &null, (bfd_size_type) 1, abfd) != 1)
     1117    return FALSE;
     1118  return TRUE;
    10831119}
    10841120
    10851121static int
    10861122comp (ap, bp)
    1087      CONST PTR ap;
    1088      CONST PTR bp;
     1123     const PTR ap;
     1124     const PTR bp;
    10891125{
    10901126  arelent *a = *((arelent **) ap);
     
    10971133
    10981134*/
    1099 static boolean
     1135static bfd_boolean
    11001136oasys_write_data (abfd)
    11011137     bfd *abfd;
     
    11351171
    11361172
    1137               bfd_h_put_32 (abfd, s->vma + current_byte_index,
    1138                             processed_data.addr);
     1173              H_PUT_32 (abfd, s->vma + current_byte_index,
     1174                        processed_data.addr);
    11391175
    11401176              /* Don't start a relocation unless you're sure you can finish it
     
    12081244#endif
    12091245                            {
    1210                               asymbol *p = *(r->sym_ptr_ptr);
     1246                              asymbol *sym = *(r->sym_ptr_ptr);
    12111247
    12121248                              /* If this symbol has a section attached, then it
    12131249                             has already been resolved.  Change from a symbol
    12141250                             ref to a section ref */
    1215                               if (p->section != (asection *) NULL)
     1251                              if (sym->section != (asection *) NULL)
    12161252                                {
    12171253                                  rel_byte |= RELOCATION_TYPE_REL;
    12181254                                  rel_byte |=
    1219                                     p->section->output_section->target_index;
     1255                                    sym->section->output_section->target_index;
    12201256                                  *dst++ = rel_byte;
    12211257                                }
     
    12291265                               symbol table was written
    12301266                               */
    1231                                   *dst++ = p->value >> 8;
    1232                                   *dst++ = p->value;
     1267                                  *dst++ = sym->value >> 8;
     1268                                  *dst++ = sym->value;
    12331269                                }
    12341270                            }
     
    12701306                }
    12711307
    1272               if (! oasys_write_record (abfd,
    1273                                         oasys_record_is_data_enum,
    1274                                         ((oasys_record_union_type *)
    1275                                          & processed_data),
    1276                                         dst - (bfd_byte *) & processed_data))
    1277                 return false;
     1308              if (! (oasys_write_record
     1309                     (abfd, oasys_record_is_data_enum,
     1310                      ((oasys_record_union_type *) &processed_data),
     1311                      (size_t) (dst - (bfd_byte *) &processed_data))))
     1312                return FALSE;
    12781313            }
    12791314        }
    12801315    }
    12811316
    1282   return true;
    1283 }
    1284 
    1285 static boolean
     1317  return TRUE;
     1318}
     1319
     1320static bfd_boolean
    12861321oasys_write_object_contents (abfd)
    12871322     bfd *abfd;
    12881323{
    12891324  if (! oasys_write_header (abfd))
    1290     return false;
     1325    return FALSE;
    12911326  if (! oasys_write_syms (abfd))
    1292     return false;
     1327    return FALSE;
    12931328  if (! oasys_write_sections (abfd))
    1294     return false;
     1329    return FALSE;
    12951330  if (! oasys_write_data (abfd))
    1296     return false;
     1331    return FALSE;
    12971332  if (! oasys_write_end (abfd))
    1298     return false;
    1299   return true;
     1333    return FALSE;
     1334  return TRUE;
    13001335}
    13011336
     
    13081343* not a byte image, but a record stream.
    13091344*/
    1310 static boolean
     1345static bfd_boolean
    13111346oasys_set_section_contents (abfd, section, location, offset, count)
    13121347     bfd *abfd;
     
    13231358            (bfd_byte *) (bfd_alloc (abfd, section->_cooked_size));
    13241359          if (!oasys_per_section (section)->data)
    1325             return false;
     1360            return FALSE;
    13261361        }
    13271362      (void) memcpy ((PTR) (oasys_per_section (section)->data + offset),
     
    13291364                     (size_t) count);
    13301365    }
    1331   return true;
     1366  return TRUE;
    13321367}
    13331368
     
    13441379     bfd *abfd;
    13451380{
    1346 
    1347   oasys_symbol_type *new =
    1348   (oasys_symbol_type *) bfd_zalloc (abfd, sizeof (oasys_symbol_type));
     1381  bfd_size_type amt = sizeof (oasys_symbol_type);
     1382  oasys_symbol_type *new = (oasys_symbol_type *) bfd_zalloc (abfd, amt);
    13491383  if (!new)
    13501384    return NULL;
     
    13971431}
    13981432
    1399 static boolean
    1400 oasys_find_nearest_line (abfd,
    1401                          section,
    1402                          symbols,
    1403                          offset,
    1404                          filename_ptr,
    1405                          functionname_ptr,
    1406                          line_ptr)
     1433static bfd_boolean
     1434oasys_find_nearest_line (abfd, section, symbols, offset,
     1435                         filename_ptr, functionname_ptr, line_ptr)
    14071436     bfd *abfd ATTRIBUTE_UNUSED;
    14081437     asection *section ATTRIBUTE_UNUSED;
    14091438     asymbol **symbols ATTRIBUTE_UNUSED;
    14101439     bfd_vma offset ATTRIBUTE_UNUSED;
    1411      char **filename_ptr ATTRIBUTE_UNUSED;
    1412      char **functionname_ptr ATTRIBUTE_UNUSED;
     1440     const char **filename_ptr ATTRIBUTE_UNUSED;
     1441     const char **functionname_ptr ATTRIBUTE_UNUSED;
    14131442     unsigned int *line_ptr ATTRIBUTE_UNUSED;
    14141443{
    1415   return false;
     1444  return FALSE;
    14161445
    14171446}
     
    14391468oasys_sizeof_headers (abfd, exec)
    14401469     bfd *abfd ATTRIBUTE_UNUSED;
    1441      boolean exec ATTRIBUTE_UNUSED;
     1470     bfd_boolean exec ATTRIBUTE_UNUSED;
    14421471{
    14431472  return 0;
     
    14501479#define oasys_slurp_extended_name_table bfd_true
    14511480#define oasys_construct_extended_name_table \
    1452   ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
     1481  ((bfd_boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
    14531482   bfd_true)
    14541483#define oasys_truncate_arname bfd_dont_truncate_arname
    14551484#define oasys_write_armap \
    1456   ((boolean (*) \
     1485  ((bfd_boolean (*) \
    14571486    PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
    14581487   bfd_true)
     
    14781507#define oasys_bfd_relax_section bfd_generic_relax_section
    14791508#define oasys_bfd_gc_sections bfd_generic_gc_sections
     1509#define oasys_bfd_merge_sections bfd_generic_merge_sections
     1510#define oasys_bfd_discard_group bfd_generic_discard_group
    14801511#define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
     1512#define oasys_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
    14811513#define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols
     1514#define oasys_bfd_link_just_syms _bfd_generic_link_just_syms
    14821515#define oasys_bfd_final_link _bfd_generic_final_link
    14831516#define oasys_bfd_link_split_section _bfd_generic_link_split_section
     
    15341567
    15351568  NULL,
    1536  
     1569
    15371570  (PTR) 0
    15381571};
Note: See TracChangeset for help on using the changeset viewer.