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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Support for the generic parts of COFF, for BFD.
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000, 2001
     3   2000, 2001, 2002
    44   Free Software Foundation, Inc.
    55   Written by Cygnus Support.
     
    4747  PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_size_type *,
    4848           asection **, bfd_size_type *));
    49 static boolean coff_write_symbol
    50   PARAMS ((bfd *, asymbol *, combined_entry_type *, unsigned int *,
     49static bfd_boolean coff_write_symbol
     50  PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_vma *,
    5151           bfd_size_type *, asection **, bfd_size_type *));
    52 static boolean coff_write_alien_symbol
    53   PARAMS ((bfd *, asymbol *, unsigned int *, bfd_size_type *,
     52static bfd_boolean coff_write_alien_symbol
     53  PARAMS ((bfd *, asymbol *, bfd_vma *, bfd_size_type *,
    5454           asection **, bfd_size_type *));
    55 static boolean coff_write_native_symbol
    56   PARAMS ((bfd *, coff_symbol_type *, unsigned int *, bfd_size_type *,
     55static bfd_boolean coff_write_native_symbol
     56  PARAMS ((bfd *, coff_symbol_type *, bfd_vma *, bfd_size_type *,
    5757           asection **, bfd_size_type *));
    5858static void coff_pointerize_aux
    5959  PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
    6060           unsigned int, combined_entry_type *));
    61 static boolean make_a_section_from_file
     61static bfd_boolean make_a_section_from_file
    6262  PARAMS ((bfd *, struct internal_scnhdr *, unsigned int));
    6363static const bfd_target *coff_real_object_p
     
    6969  PARAMS ((bfd *));
    7070static char *copy_name
    71   PARAMS ((bfd *, char *, int));
     71  PARAMS ((bfd *, char *, size_t));
    7272
    7373#define STRING_SIZE_SIZE (4)
     
    7575/* Take a section header read from a coff file (in HOST byte order),
    7676   and make a BFD "section" out of it.  This is used by ECOFF.  */
    77 static boolean
     77static bfd_boolean
    7878make_a_section_from_file (abfd, hdr, target_index)
    7979     bfd *abfd;
     
    8383  asection *return_section;
    8484  char *name;
     85  bfd_boolean result = TRUE;
     86  flagword flags;
    8587
    8688  name = NULL;
     
    102104          strings = _bfd_coff_read_string_table (abfd);
    103105          if (strings == NULL)
    104             return false;
     106            return FALSE;
    105107          /* FIXME: For extra safety, we should make sure that
    106108             strindex does not run us past the end, but right now we
    107109             don't know the length of the string table.  */
    108110          strings += strindex;
    109           name = bfd_alloc (abfd, strlen (strings) + 1);
     111          name = bfd_alloc (abfd, (bfd_size_type) strlen (strings) + 1);
    110112          if (name == NULL)
    111             return false;
     113            return FALSE;
    112114          strcpy (name, strings);
    113115        }
     
    117119    {
    118120      /* Assorted wastage to null-terminate the name, thanks AT&T! */
    119       name = bfd_alloc (abfd, sizeof (hdr->s_name) + 1);
     121      name = bfd_alloc (abfd, (bfd_size_type) sizeof (hdr->s_name) + 1);
    120122      if (name == NULL)
    121         return false;
     123        return FALSE;
    122124      strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
    123125      name[sizeof (hdr->s_name)] = 0;
     
    126128  return_section = bfd_make_section_anyway (abfd, name);
    127129  if (return_section == NULL)
    128     return false;
     130    return FALSE;
    129131
    130132  return_section->vma = hdr->s_vaddr;
     
    143145  return_section->next = (asection *) NULL;
    144146  return_section->target_index = target_index;
    145   return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name,
    146                                                            return_section);
     147
     148  if (! bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name, return_section,
     149                                         & flags))
     150    result = FALSE;
     151
     152  return_section->flags = flags;
    147153
    148154  /* At least on i386-coff, the line number count for a shared library
     
    156162  if (hdr->s_scnptr != 0)
    157163    return_section->flags |= SEC_HAS_CONTENTS;
    158   return true;
     164
     165  return result;
    159166}
    160167
     
    172179  bfd_vma ostart = bfd_get_start_address (abfd);
    173180  PTR tdata;
    174   size_t readsize;              /* length of file_info */
     181  PTR tdata_save;
     182  bfd_size_type readsize;       /* length of file_info */
    175183  unsigned int scnhsz;
    176184  char *external_sections;
     
    200208  /* Set up the tdata area.  ECOFF uses its own routine, and overrides
    201209     abfd->flags.  */
     210  tdata_save = abfd->tdata.any;
    202211  tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a);
    203212  if (tdata == NULL)
    204     return 0;
     213    goto fail2;
    205214
    206215  scnhsz = bfd_coff_scnhsz (abfd);
    207   readsize = nscns * scnhsz;
     216  readsize = (bfd_size_type) nscns * scnhsz;
    208217  external_sections = (char *) bfd_alloc (abfd, readsize);
    209218  if (!external_sections)
    210219    goto fail;
    211220
    212   if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
     221  if (bfd_bread ((PTR) external_sections, readsize, abfd) != readsize)
    213222    goto fail;
    214223
    215224  /* Set the arch/mach *before* swapping in sections; section header swapping
    216225     may depend on arch/mach info.  */
    217   if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false)
     226  if (! bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f))
    218227    goto fail;
    219228
    220   /* Now copy data as required; construct all asections etc */
     229  /* Now copy data as required; construct all asections etc. */
    221230  if (nscns != 0)
    222231    {
     
    233242    }
    234243
    235   /*  make_abs_section (abfd); */
    236 
    237244  return abfd->xvec;
    238245
    239246 fail:
    240247  bfd_release (abfd, tdata);
     248 fail2:
     249  abfd->tdata.any = tdata_save;
    241250  abfd->flags = oflags;
    242251  bfd_get_start_address (abfd) = ostart;
     
    251260     bfd *abfd;
    252261{
    253   unsigned int filhsz;
    254   unsigned int aoutsz;
    255   int nscns;
     262  bfd_size_type filhsz;
     263  bfd_size_type aoutsz;
     264  unsigned int nscns;
    256265  PTR filehdr;
    257266  struct internal_filehdr internal_f;
     
    264273  filehdr = bfd_alloc (abfd, filhsz);
    265274  if (filehdr == NULL)
    266     return 0;
    267   if (bfd_read (filehdr, 1, filhsz, abfd) != filhsz)
     275    return NULL;
     276  if (bfd_bread (filehdr, filhsz, abfd) != filhsz)
    268277    {
    269278      if (bfd_get_error () != bfd_error_system_call)
    270279        bfd_set_error (bfd_error_wrong_format);
    271       return 0;
     280      bfd_release (abfd, filehdr);
     281      return NULL;
    272282    }
    273283  bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f);
    274284  bfd_release (abfd, filehdr);
    275285
    276   if (bfd_coff_bad_format_hook (abfd, &internal_f) == false)
     286  /* The XCOFF format has two sizes for the f_opthdr.  SMALL_AOUTSZ
     287     (less than aoutsz) used in object files and AOUTSZ (equal to
     288     aoutsz) in executables.  The bfd_coff_swap_aouthdr_in function
     289     expects this header to be aoutsz bytes in length, so we use that
     290     value in the call to bfd_alloc below.  But we must be careful to
     291     only read in f_opthdr bytes in the call to bfd_bread.  We should
     292     also attempt to catch corrupt or non-COFF binaries with a strange
     293     value for f_opthdr.  */
     294  if (! bfd_coff_bad_format_hook (abfd, &internal_f)
     295      || internal_f.f_opthdr > aoutsz)
    277296    {
    278297      bfd_set_error (bfd_error_wrong_format);
    279       return 0;
     298      return NULL;
    280299    }
    281300  nscns = internal_f.f_nscns;
     
    287306      opthdr = bfd_alloc (abfd, aoutsz);
    288307      if (opthdr == NULL)
    289         return 0;;
    290       if (bfd_read (opthdr, 1, internal_f.f_opthdr, abfd)
     308        return NULL;
     309      if (bfd_bread (opthdr, (bfd_size_type) internal_f.f_opthdr, abfd)
    291310          != internal_f.f_opthdr)
    292311        {
    293           return 0;
     312          bfd_release (abfd, opthdr);
     313          return NULL;
    294314        }
    295315      bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) &internal_a);
     316      bfd_release (abfd, opthdr);
    296317    }
    297318
     
    401422
    402423/* Read in and swap the relocs.  This returns a buffer holding the
    403    relocs for section SEC in file ABFD.  If CACHE is true and
     424   relocs for section SEC in file ABFD.  If CACHE is TRUE and
    404425   INTERNAL_RELOCS is NULL, the relocs read in will be saved in case
    405426   the function is called again.  If EXTERNAL_RELOCS is not NULL, it
    406427   is a buffer large enough to hold the unswapped relocs.  If
    407428   INTERNAL_RELOCS is not NULL, it is a buffer large enough to hold
    408    the swapped relocs.  If REQUIRE_INTERNAL is true, then the return
     429   the swapped relocs.  If REQUIRE_INTERNAL is TRUE, then the return
    409430   value must be INTERNAL_RELOCS.  The function returns NULL on error.  */
    410431
     
    414435     bfd *abfd;
    415436     asection *sec;
    416      boolean cache;
     437     bfd_boolean cache;
    417438     bfd_byte *external_relocs;
    418      boolean require_internal;
     439     bfd_boolean require_internal;
    419440     struct internal_reloc *internal_relocs;
    420441{
     
    425446  bfd_byte *erel_end;
    426447  struct internal_reloc *irel;
     448  bfd_size_type amt;
    427449
    428450  if (coff_section_data (abfd, sec) != NULL
     
    438460  relsz = bfd_coff_relsz (abfd);
    439461
     462  amt = sec->reloc_count * relsz;
    440463  if (external_relocs == NULL)
    441464    {
    442       free_external = (bfd_byte *) bfd_malloc (sec->reloc_count * relsz);
     465      free_external = (bfd_byte *) bfd_malloc (amt);
    443466      if (free_external == NULL && sec->reloc_count > 0)
    444467        goto error_return;
     
    447470
    448471  if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
    449       || (bfd_read (external_relocs, relsz, sec->reloc_count, abfd)
    450           != relsz * sec->reloc_count))
     472      || bfd_bread (external_relocs, amt, abfd) != amt)
    451473    goto error_return;
    452474
    453475  if (internal_relocs == NULL)
    454476    {
    455       free_internal = ((struct internal_reloc *)
    456                        bfd_malloc (sec->reloc_count
    457                                    * sizeof (struct internal_reloc)));
     477      amt = sec->reloc_count;
     478      amt *= sizeof (struct internal_reloc);
     479      free_internal = (struct internal_reloc *) bfd_malloc (amt);
    458480      if (free_internal == NULL && sec->reloc_count > 0)
    459481        goto error_return;
     
    478500      if (coff_section_data (abfd, sec) == NULL)
    479501        {
    480           sec->used_by_bfd =
    481             (PTR) bfd_zalloc (abfd,
    482                               sizeof (struct coff_section_tdata));
     502          amt = sizeof (struct coff_section_tdata);
     503          sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
    483504          if (sec->used_by_bfd == NULL)
    484505            goto error_return;
     
    540561              alent *l = q->lineno;
    541562
    542               ++q->symbol.section->output_section->lineno_count;
    543               ++total;
    544               ++l;
    545               while (l->line_number != 0)
     563              do
    546564                {
     565                  asection * sec = q->symbol.section->output_section;
     566
     567                  /* Do not try to update fields in read-only sections.  */
     568                  if (! bfd_is_const_section (sec))
     569                    sec->lineno_count ++;
     570
    547571                  ++total;
    548                   ++q->symbol.section->output_section->lineno_count;
    549572                  ++l;
    550573                }
     574              while (l->line_number != 0);
    551575            }
    552576        }
     
    631655   do that here too.  */
    632656
    633 boolean
     657bfd_boolean
    634658coff_renumber_symbols (bfd_ptr, first_undef)
    635659     bfd *bfd_ptr;
     
    655679    asymbol **newsyms;
    656680    unsigned int i;
    657 
    658     newsyms = (asymbol **) bfd_alloc (bfd_ptr,
    659                                       sizeof (asymbol *) * (symbol_count + 1));
     681    bfd_size_type amt;
     682
     683    amt = sizeof (asymbol *) * ((bfd_size_type) symbol_count + 1);
     684    newsyms = (asymbol **) bfd_alloc (bfd_ptr, amt);
    660685    if (!newsyms)
    661       return false;
     686      return FALSE;
    662687    bfd_ptr->outsymbols = newsyms;
    663688    for (i = 0; i < symbol_count; i++)
     
    722747  obj_conv_table_size (bfd_ptr) = native_index;
    723748
    724   return true;
     749  return TRUE;
    725750}
    726751
     
    751776              /* FIXME: We should use a union here.  */
    752777              s->u.syment.n_value =
    753                 ((combined_entry_type *) s->u.syment.n_value)->offset;
     778                (bfd_vma)((combined_entry_type *)
     779                          ((unsigned long) s->u.syment.n_value))->offset;
    754780              s->fix_value = 0;
    755781            }
     
    869895      else
    870896        {
    871           long filepos;
     897          file_ptr filepos;
    872898          bfd_byte buf[4];
    873899          int prefix_len = bfd_coff_debug_string_prefix_length (abfd);
     
    882908          filepos = bfd_tell (abfd);
    883909          if (prefix_len == 4)
    884             bfd_put_32 (abfd, name_length + 1, buf);
     910            bfd_put_32 (abfd, (bfd_vma) (name_length + 1), buf);
    885911          else
    886             bfd_put_16 (abfd, name_length + 1, buf);
     912            bfd_put_16 (abfd, (bfd_vma) (name_length + 1), buf);
    887913
    888914          if (!bfd_set_section_contents (abfd,
     
    894920                                            *debug_string_section_p,
    895921                                            (PTR) symbol->name,
    896                                             ((file_ptr) *debug_string_size_p
    897                                              + prefix_len),
     922                                            (file_ptr) (*debug_string_size_p
     923                                                        + prefix_len),
    898924                                            (bfd_size_type) name_length + 1))
    899925            abort ();
     
    916942/* Write a symbol out to a COFF file.  */
    917943
    918 static boolean
     944static bfd_boolean
    919945coff_write_symbol (abfd, symbol, native, written, string_size_p,
    920946                   debug_string_section_p, debug_string_size_p)
     
    922948     asymbol *symbol;
    923949     combined_entry_type *native;
    924      unsigned int *written;
     950     bfd_vma *written;
    925951     bfd_size_type *string_size_p;
    926952     asection **debug_string_section_p;
     
    961987  buf = bfd_alloc (abfd, symesz);
    962988  if (!buf)
    963     return false;
     989    return FALSE;
    964990  bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
    965   if (bfd_write (buf, 1, symesz, abfd) != symesz)
    966     return false;
     991  if (bfd_bwrite (buf, symesz, abfd) != symesz)
     992    return FALSE;
    967993  bfd_release (abfd, buf);
    968994
     
    9751001      buf = bfd_alloc (abfd, auxesz);
    9761002      if (!buf)
    977         return false;
     1003        return FALSE;
    9781004      for (j = 0; j < native->u.syment.n_numaux; j++)
    9791005        {
     
    9821008                                 type,
    9831009                                 class,
    984                                  j,
     1010                                 (int) j,
    9851011                                 native->u.syment.n_numaux,
    9861012                                 buf);
    987           if (bfd_write (buf, 1, auxesz, abfd) != auxesz)
    988             return false;
     1013          if (bfd_bwrite (buf, auxesz, abfd) != auxesz)
     1014            return FALSE;
    9891015        }
    9901016      bfd_release (abfd, buf);
     
    9951021
    9961022  *written += numaux + 1;
    997   return true;
     1023  return TRUE;
    9981024}
    9991025
     
    10021028   or we may be linking a non COFF file to a COFF file.  */
    10031029
    1004 static boolean
     1030static bfd_boolean
    10051031coff_write_alien_symbol (abfd, symbol, written, string_size_p,
    10061032                         debug_string_section_p, debug_string_size_p)
    10071033     bfd *abfd;
    10081034     asymbol *symbol;
    1009      unsigned int *written;
     1035     bfd_vma *written;
    10101036     bfd_size_type *string_size_p;
    10111037     asection **debug_string_section_p;
     
    10351061         name to keep it from being put in the string table.  */
    10361062      symbol->name = "";
    1037       return true;
     1063      return TRUE;
    10381064    }
    10391065  else
     
    10461072        native->u.syment.n_value += symbol->section->output_section->vma;
    10471073
    1048       /* Copy the any flags from the the file header into the symbol.
     1074      /* Copy the any flags from the file header into the symbol.
    10491075         FIXME: Why?  */
    10501076      {
     
    10701096/* Write a native symbol to a COFF file.  */
    10711097
    1072 static boolean
     1098static bfd_boolean
    10731099coff_write_native_symbol (abfd, symbol, written, string_size_p,
    10741100                          debug_string_section_p, debug_string_size_p)
    10751101     bfd *abfd;
    10761102     coff_symbol_type *symbol;
    1077      unsigned int *written;
     1103     bfd_vma *written;
    10781104     bfd_size_type *string_size_p;
    10791105     asection **debug_string_section_p;
     
    11261152          count++;
    11271153        }
    1128       symbol->done_lineno = true;
    1129 
    1130       symbol->symbol.section->output_section->moving_line_filepos +=
    1131         count * bfd_coff_linesz (abfd);
     1154      symbol->done_lineno = TRUE;
     1155
     1156      if (! bfd_is_const_section (symbol->symbol.section->output_section))
     1157        symbol->symbol.section->output_section->moving_line_filepos +=
     1158          count * bfd_coff_linesz (abfd);
    11321159    }
    11331160
     
    11391166/* Write out the COFF symbols.  */
    11401167
    1141 boolean
     1168bfd_boolean
    11421169coff_write_symbols (abfd)
    11431170     bfd *abfd;
     
    11481175  unsigned int i;
    11491176  unsigned int limit = bfd_get_symcount (abfd);
    1150   unsigned int written = 0;
     1177  bfd_signed_vma written = 0;
    11511178  asymbol **p;
    11521179
     
    11751202  /* Seek to the right place */
    11761203  if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
    1177     return false;
     1204    return FALSE;
    11781205
    11791206  /* Output all the symbols we have */
     
    11911218                                        &debug_string_section,
    11921219                                        &debug_string_size))
    1193             return false;
     1220            return FALSE;
    11941221        }
    11951222      else
     
    11981225                                         &string_size, &debug_string_section,
    11991226                                         &debug_string_size))
    1200             return false;
     1227            return FALSE;
    12011228        }
    12021229    }
     
    12121239
    12131240#if STRING_SIZE_SIZE == 4
    1214       bfd_h_put_32 (abfd, size, buffer);
     1241      H_PUT_32 (abfd, size, buffer);
    12151242#else
    1216  #error Change bfd_h_put_32
     1243 #error Change H_PUT_32
    12171244#endif
    1218       if (bfd_write ((PTR) buffer, 1, sizeof (buffer), abfd) != sizeof (buffer))
    1219         return false;
     1245      if (bfd_bwrite ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd)
     1246          != sizeof (buffer))
     1247        return FALSE;
    12201248
    12211249      /* Handle long section names.  This code must handle section
     
    12321260              if (len > SCNNMLEN)
    12331261                {
    1234                   if (bfd_write (o->name, 1, len + 1, abfd) != len + 1)
    1235                     return false;
     1262                  if (bfd_bwrite (o->name, (bfd_size_type) (len + 1), abfd)
     1263                      != len + 1)
     1264                    return FALSE;
    12361265                }
    12371266            }
     
    12721301            {
    12731302              if (bfd_coff_force_symnames_in_strings (abfd))
    1274                 bfd_write (".file", 1, 6, abfd);
     1303                {
     1304                  if (bfd_bwrite (".file", (bfd_size_type) 6, abfd) != 6)
     1305                    return FALSE;
     1306                }
    12751307              maxlen = bfd_coff_filnmlen (abfd);
    12761308            }
     
    12801312          if (name_length > maxlen)
    12811313            {
    1282               if (bfd_write ((PTR) (q->name), 1, name_length + 1, abfd)
    1283                   != name_length + 1)
    1284                 return false;
     1314              if (bfd_bwrite ((PTR) (q->name), (bfd_size_type) name_length + 1,
     1315                             abfd) != name_length + 1)
     1316                return FALSE;
    12851317            }
    12861318        }
     
    12951327
    12961328#if STRING_SIZE_SIZE == 4
    1297       bfd_h_put_32 (abfd, size, buffer);
     1329      H_PUT_32 (abfd, size, buffer);
    12981330#else
    1299  #error Change bfd_h_put_32
     1331 #error Change H_PUT_32
    13001332#endif
    1301       if (bfd_write ((PTR) buffer, 1, STRING_SIZE_SIZE, abfd)
     1333      if (bfd_bwrite ((PTR) buffer, (bfd_size_type) STRING_SIZE_SIZE, abfd)
    13021334          != STRING_SIZE_SIZE)
    1303         return false;
     1335        return FALSE;
    13041336    }
    13051337
     
    13151347                      == bfd_section_size (abfd, debug_string_section))));
    13161348
    1317   return true;
    1318 }
    1319 
    1320 boolean
     1349  return TRUE;
     1350}
     1351
     1352bfd_boolean
    13211353coff_write_linenumbers (abfd)
    13221354     bfd *abfd;
     
    13291361  buff = bfd_alloc (abfd, linesz);
    13301362  if (!buff)
    1331     return false;
     1363    return FALSE;
    13321364  for (s = abfd->sections; s != (asection *) NULL; s = s->next)
    13331365    {
     
    13361368          asymbol **q = abfd->outsymbols;
    13371369          if (bfd_seek (abfd, s->line_filepos, SEEK_SET) != 0)
    1338             return false;
     1370            return FALSE;
    13391371          /* Find all the linenumbers in this section */
    13401372          while (*q)
     
    13541386                      out.l_addr.l_symndx = l->u.offset;
    13551387                      bfd_coff_swap_lineno_out (abfd, &out, buff);
    1356                       if (bfd_write (buff, 1, linesz, abfd) != linesz)
    1357                         return false;
     1388                      if (bfd_bwrite (buff, (bfd_size_type) linesz, abfd)
     1389                          != linesz)
     1390                        return FALSE;
    13581391                      l++;
    13591392                      while (l->line_number)
     
    13621395                          out.l_addr.l_symndx = l->u.offset;
    13631396                          bfd_coff_swap_lineno_out (abfd, &out, buff);
    1364                           if (bfd_write (buff, 1, linesz, abfd) != linesz)
    1365                             return false;
     1397                          if (bfd_bwrite (buff, (bfd_size_type) linesz, abfd)
     1398                              != linesz)
     1399                            return FALSE;
    13661400                          l++;
    13671401                        }
     
    13731407    }
    13741408  bfd_release (abfd, buff);
    1375   return true;
     1409  return TRUE;
    13761410}
    13771411
     
    14101444        };
    14111445      struct foo *f;
    1412       f = (struct foo *) bfd_alloc (abfd, sizeof (*f));
     1446
     1447      f = (struct foo *) bfd_zalloc (abfd, (bfd_size_type) sizeof (*f));
    14131448      if (!f)
    14141449        {
     
    14161451          return NULL;
    14171452        }
    1418       memset ((char *) f, 0, sizeof (*f));
    14191453      coff_symbol_from (abfd, sym)->native = csym = f->e;
    14201454    }
     
    14931527{
    14941528  char *debug_section;
    1495   long position;
     1529  file_ptr position;
     1530  bfd_size_type sec_size;
    14961531
    14971532  asection *sect = bfd_get_section_by_name (abfd, ".debug");
     
    15031538    }
    15041539
    1505   debug_section = (PTR) bfd_alloc (abfd,
    1506                                    bfd_get_section_size_before_reloc (sect));
     1540  sec_size = bfd_get_section_size_before_reloc (sect);
     1541  debug_section = (PTR) bfd_alloc (abfd, sec_size);
    15071542  if (debug_section == NULL)
    15081543    return NULL;
     
    15141549  position = bfd_tell (abfd);
    15151550  if (bfd_seek (abfd, sect->filepos, SEEK_SET) != 0
    1516       || (bfd_read (debug_section,
    1517                     bfd_get_section_size_before_reloc (sect), 1, abfd)
    1518           != bfd_get_section_size_before_reloc (sect))
     1551      || bfd_bread (debug_section, sec_size, abfd) != sec_size
    15191552      || bfd_seek (abfd, position, SEEK_SET) != 0)
    15201553    return NULL;
     
    15291562     bfd *abfd;
    15301563     char *name;
    1531      int maxlen;
    1532 {
    1533   int len;
     1564     size_t maxlen;
     1565{
     1566  size_t len;
    15341567  char *newname;
    15351568
     
    15421575    }
    15431576
    1544   if ((newname = (PTR) bfd_alloc (abfd, len + 1)) == NULL)
     1577  if ((newname = (PTR) bfd_alloc (abfd, (bfd_size_type) len + 1)) == NULL)
    15451578    return (NULL);
    15461579  strncpy (newname, name, len);
     
    15511584/* Read in the external symbols.  */
    15521585
    1553 boolean
     1586bfd_boolean
    15541587_bfd_coff_get_external_symbols (abfd)
    15551588     bfd *abfd;
    15561589{
    15571590  bfd_size_type symesz;
    1558   size_t size;
     1591  bfd_size_type size;
    15591592  PTR syms;
    15601593
    15611594  if (obj_coff_external_syms (abfd) != NULL)
    1562     return true;
     1595    return TRUE;
    15631596
    15641597  symesz = bfd_coff_symesz (abfd);
     
    15681601  syms = (PTR) bfd_malloc (size);
    15691602  if (syms == NULL && size != 0)
    1570     return false;
     1603    return FALSE;
    15711604
    15721605  if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
    1573       || bfd_read (syms, size, 1, abfd) != size)
     1606      || bfd_bread (syms, size, abfd) != size)
    15741607    {
    15751608      if (syms != NULL)
    15761609        free (syms);
    1577       return false;
     1610      return FALSE;
    15781611    }
    15791612
    15801613  obj_coff_external_syms (abfd) = syms;
    15811614
    1582   return true;
     1615  return TRUE;
    15831616}
    15841617
     
    15921625{
    15931626  char extstrsize[STRING_SIZE_SIZE];
    1594   size_t strsize;
     1627  bfd_size_type strsize;
    15951628  char *strings;
     1629  file_ptr pos;
    15961630
    15971631  if (obj_coff_strings (abfd) != NULL)
     
    16041638    }
    16051639
    1606   if (bfd_seek (abfd,
    1607                 (obj_sym_filepos (abfd)
    1608                  + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd)),
    1609                 SEEK_SET) != 0)
     1640  pos = obj_sym_filepos (abfd);
     1641  pos += obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
     1642  if (bfd_seek (abfd, pos, SEEK_SET) != 0)
    16101643    return NULL;
    16111644
    1612   if (bfd_read (extstrsize, sizeof extstrsize, 1, abfd) != sizeof extstrsize)
     1645  if (bfd_bread (extstrsize, (bfd_size_type) sizeof extstrsize, abfd)
     1646      != sizeof extstrsize)
    16131647    {
    16141648      if (bfd_get_error () != bfd_error_file_truncated)
     
    16211655    {
    16221656#if STRING_SIZE_SIZE == 4
    1623       strsize = bfd_h_get_32 (abfd, (bfd_byte *) extstrsize);
     1657      strsize = H_GET_32 (abfd, extstrsize);
    16241658#else
    1625  #error Change bfd_h_get_32
     1659 #error Change H_GET_32
    16261660#endif
    16271661    }
     
    16301664    {
    16311665      (*_bfd_error_handler)
    1632         (_("%s: bad string table size %lu"), bfd_get_filename (abfd),
     1666        (_("%s: bad string table size %lu"), bfd_archive_filename (abfd),
    16331667         (unsigned long) strsize);
    16341668      bfd_set_error (bfd_error_bad_value);
     
    16401674    return NULL;
    16411675
    1642   if (bfd_read (strings + STRING_SIZE_SIZE,
    1643                 strsize - STRING_SIZE_SIZE, 1, abfd)
     1676  if (bfd_bread (strings + STRING_SIZE_SIZE, strsize - STRING_SIZE_SIZE, abfd)
    16441677      != strsize - STRING_SIZE_SIZE)
    16451678    {
     
    16551688/* Free up the external symbols and strings read from a COFF file.  */
    16561689
    1657 boolean
     1690bfd_boolean
    16581691_bfd_coff_free_symbols (abfd)
    16591692     bfd *abfd;
     
    16711704      obj_coff_strings (abfd) = NULL;
    16721705    }
    1673   return true;
     1706  return TRUE;
    16741707}
    16751708
     
    16871720  combined_entry_type *symbol_ptr;
    16881721  combined_entry_type *internal_end;
    1689   bfd_size_type symesz;
     1722  size_t symesz;
    16901723  char *raw_src;
    16911724  char *raw_end;
    16921725  const char *string_table = NULL;
    16931726  char *debug_section = NULL;
    1694   unsigned long size;
     1727  bfd_size_type size;
    16951728
    16961729  if (obj_raw_syments (abfd) != NULL)
     
    17351768                                symbol_ptr->u.syment.n_type,
    17361769                                symbol_ptr->u.syment.n_sclass,
    1737                                 i, symbol_ptr->u.syment.n_numaux,
     1770                                (int) i, symbol_ptr->u.syment.n_numaux,
    17381771                                &(internal_ptr->u.auxent));
    17391772          coff_pointerize_aux (abfd, internal, symbol_ptr, i,
     
    17431776
    17441777  /* Free the raw symbols, but not the strings (if we have them).  */
    1745   obj_coff_keep_strings (abfd) = true;
     1778  obj_coff_keep_strings (abfd) = TRUE;
    17461779  if (! _bfd_coff_free_symbols (abfd))
    17471780    return NULL;
     
    17901823                     copy_name (abfd,
    17911824                                (internal_ptr + 1)->u.auxent.x_file.x_fname,
    1792                                 bfd_coff_filnmlen (abfd)));
     1825                                (size_t) bfd_coff_filnmlen (abfd)));
    17931826                }
    17941827            }
     
    17991832            {
    18001833              /* This is a "short" name.  Make it long.  */
    1801               unsigned long i = 0;
    1802               char *newstring = NULL;
     1834              size_t i;
     1835              char *newstring;
    18031836
    18041837              /* find the length of this string without walking into memory
    18051838                 that isn't ours.  */
    18061839              for (i = 0; i < 8; ++i)
    1807                 {
    1808                   if (internal_ptr->u.syment._n._n_name[i] == '\0')
    1809                     {
    1810                       break;
    1811                     }           /* if end of string */
    1812                 }               /* possible lengths of this string.  */
    1813 
    1814               if ((newstring = (PTR) bfd_alloc (abfd, ++i)) == NULL)
     1840                if (internal_ptr->u.syment._n._n_name[i] == '\0')
     1841                  break;
     1842
     1843              newstring = (PTR) bfd_zalloc (abfd, (bfd_size_type) (i + 1));
     1844              if (newstring == NULL)
    18151845                return (NULL);
    1816               memset (newstring, 0, i);
    1817               strncpy (newstring, internal_ptr->u.syment._n._n_name, i - 1);
     1846              strncpy (newstring, internal_ptr->u.syment._n._n_name, i);
    18181847              internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
    18191848              internal_ptr->u.syment._n._n_n._n_zeroes = 0;
     
    18721901     bfd *abfd;
    18731902{
    1874   coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
     1903  bfd_size_type amt = sizeof (coff_symbol_type);
     1904  coff_symbol_type *new = (coff_symbol_type *) bfd_zalloc (abfd, amt);
    18751905  if (new == NULL)
    18761906    return (NULL);
    1877   memset (new, 0, sizeof *new);
    18781907  new->symbol.section = 0;
    18791908  new->native = 0;
    18801909  new->lineno = (alent *) NULL;
    1881   new->done_lineno = false;
     1910  new->done_lineno = FALSE;
    18821911  new->symbol.the_bfd = abfd;
    18831912  return &new->symbol;
     
    18921921     unsigned long sz ATTRIBUTE_UNUSED;
    18931922{
    1894   coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
     1923  bfd_size_type amt = sizeof (coff_symbol_type);
     1924  coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, amt);
    18951925  if (new == NULL)
    18961926    return (NULL);
    18971927  /* @@ The 10 is a guess at a plausible maximum number of aux entries
    18981928     (but shouldn't be a constant).  */
    1899   new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
     1929  amt = sizeof (combined_entry_type) * 10;
     1930  new->native = (combined_entry_type *) bfd_zalloc (abfd, amt);
    19001931  if (!new->native)
    19011932    return (NULL);
     
    19031934  new->symbol.flags = BSF_DEBUGGING;
    19041935  new->lineno = (alent *) NULL;
    1905   new->done_lineno = false;
     1936  new->done_lineno = FALSE;
    19061937  new->symbol.the_bfd = abfd;
    19071938  return &new->symbol;
     
    19181949      && coffsymbol (symbol)->native->fix_value)
    19191950    {
    1920       combined_entry_type *psym;
    1921 
    1922       psym = ((combined_entry_type *)
    1923               coffsymbol (symbol)->native->u.syment.n_value);
    1924       ret->value = (bfd_vma) (psym - obj_raw_syments (abfd));
     1951      ret->value = coffsymbol (symbol)->native->u.syment.n_value -
     1952        (unsigned long) obj_raw_syments (abfd);
    19251953    }
    19261954}
     
    19281956/* Return the COFF syment for a symbol.  */
    19291957
    1930 boolean
     1958bfd_boolean
    19311959bfd_coff_get_syment (abfd, symbol, psyment)
    19321960     bfd *abfd;
     
    19401968    {
    19411969      bfd_set_error (bfd_error_invalid_operation);
    1942       return false;
     1970      return FALSE;
    19431971    }
    19441972
     
    19461974
    19471975  if (csym->native->fix_value)
    1948     psyment->n_value = ((combined_entry_type *) psyment->n_value
    1949                         - obj_raw_syments (abfd));
     1976    psyment->n_value = psyment->n_value -
     1977      (unsigned long) obj_raw_syments (abfd);
    19501978
    19511979  /* FIXME: We should handle fix_line here.  */
    19521980
    1953   return true;
     1981  return TRUE;
    19541982}
    19551983
    19561984/* Return the COFF auxent for a symbol.  */
    19571985
    1958 boolean
     1986bfd_boolean
    19591987bfd_coff_get_auxent (abfd, symbol, indx, pauxent)
    19601988     bfd *abfd;
     
    19732001    {
    19742002      bfd_set_error (bfd_error_invalid_operation);
    1975       return false;
     2003      return FALSE;
    19762004    }
    19772005
     
    19952023       - obj_raw_syments (abfd));
    19962024
    1997   return true;
     2025  return TRUE;
    19982026}
    19992027
     
    20242052      if (coffsymbol (symbol)->native)
    20252053        {
    2026           unsigned long val;
     2054          bfd_vma val;
    20272055          unsigned int aux;
    20282056          combined_entry_type *combined = coffsymbol (symbol)->native;
     
    20332061
    20342062          if (! combined->fix_value)
    2035             val = (unsigned long) combined->u.syment.n_value;
     2063            val = (bfd_vma) combined->u.syment.n_value;
    20362064          else
    2037             val = ((unsigned long)
    2038                    ((combined_entry_type *) combined->u.syment.n_value
    2039                     - root));
    2040 
     2065            val = combined->u.syment.n_value - (unsigned long) root;
     2066
     2067#ifndef XCOFF64
    20412068          fprintf (file,
    20422069                   "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%08lx %s",
     
    20462073                   combined->u.syment.n_sclass,
    20472074                   combined->u.syment.n_numaux,
     2075                   (unsigned long) val,
     2076                   symbol->name);
     2077#else
     2078          /* Print out the wide, 64 bit, symbol value */
     2079          fprintf (file,
     2080                   "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%016llx %s",
     2081                   combined->u.syment.n_scnum,
     2082                   combined->u.syment.n_flags,
     2083                   combined->u.syment.n_type,
     2084                   combined->u.syment.n_sclass,
     2085                   combined->u.syment.n_numaux,
    20482086                   val,
    20492087                   symbol->name);
     2088#endif
    20502089
    20512090          for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
     
    20912130                  if (ISFCN (combined->u.syment.n_type))
    20922131                    {
     2132                      long next, llnos;
     2133
     2134                      if (auxp->fix_end)
     2135                        next = (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
     2136                               - root);
     2137                      else
     2138                        next = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l;
     2139                      llnos = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr;
    20932140                      fprintf (file,
    2094                                _("AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld"),
    2095                                tagndx,
    2096                                auxp->u.auxent.x_sym.x_misc.x_fsize,
    2097                                auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr,
    2098                                (auxp->fix_end
    2099                                 ? ((long)
    2100                                    (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p
    2101                                     - root))
    2102                                 : auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l));
     2141                               "AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld",
     2142                               tagndx, auxp->u.auxent.x_sym.x_misc.x_fsize,
     2143                               llnos, next);
    21032144                      break;
    21042145                    }
     
    21342175      else
    21352176        {
    2136           bfd_print_symbol_vandf ((PTR) file, symbol);
     2177          bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
    21372178          fprintf (file, " %-5s %s %s %s",
    21382179                   symbol->section->name,
     
    21492190   override it.  */
    21502191
    2151 boolean
     2192bfd_boolean
    21522193_bfd_coff_is_local_label_name (abfd, name)
    21532194     bfd *abfd ATTRIBUTE_UNUSED;
     
    21612202   nearest to the wanted location.  */
    21622203
    2163 boolean
     2204bfd_boolean
    21642205coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
    21652206                        functionname_ptr, line_ptr)
     
    21682209     asymbol **symbols;
    21692210     bfd_vma offset;
    2170      CONST char **filename_ptr;
    2171      CONST char **functionname_ptr;
     2211     const char **filename_ptr;
     2212     const char **functionname_ptr;
    21722213     unsigned int *line_ptr;
    21732214{
    2174   boolean found;
     2215  bfd_boolean found;
    21752216  unsigned int i;
    21762217  unsigned int line_base;
     
    21812222  alent *l;
    21822223  struct coff_section_tdata *sec_data;
     2224  bfd_size_type amt;
    21832225
    21842226  /* Before looking through the symbol table, try to use a .stab
     
    21882230                                             functionname_ptr, line_ptr,
    21892231                                             &coff_data(abfd)->line_info))
    2190     return false;
     2232    return FALSE;
    21912233
    21922234  if (found)
    2193     return true;
     2235    return TRUE;
    21942236
    21952237  /* Also try examining DWARF2 debugging information.  */
     
    21982240                                     line_ptr, 0,
    21992241                                     &coff_data(abfd)->dwarf2_find_line_info))
    2200     return true;
     2242    return TRUE;
    22012243
    22022244  *filename_ptr = 0;
     
    22062248  /* Don't try and find line numbers in a non coff file */
    22072249  if (!bfd_family_coff (abfd))
    2208     return false;
     2250    return FALSE;
    22092251
    22102252  if (cof == NULL)
    2211     return false;
     2253    return FALSE;
    22122254
    22132255  /* Find the first C_FILE symbol.  */
    22142256  p = cof->raw_syments;
    22152257  if (!p)
    2216     return false;
     2258    return FALSE;
    22172259
    22182260  pend = p + cof->raw_syment_count;
     
    22652307          /* Avoid endless loops on erroneous files by ensuring that
    22662308             we always move forward in the file.  */
    2267           if (p - cof->raw_syments >= p->u.syment.n_value)
     2309          if (p >= cof->raw_syments + p->u.syment.n_value)
    22682310            break;
    22692311
     
    23552397  if (sec_data == NULL && section->owner == abfd)
    23562398    {
    2357       section->used_by_bfd =
    2358         ((PTR) bfd_zalloc (abfd,
    2359                            sizeof (struct coff_section_tdata)));
     2399      amt = sizeof (struct coff_section_tdata);
     2400      section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
    23602401      sec_data = (struct coff_section_tdata *) section->used_by_bfd;
    23612402    }
     
    23682409    }
    23692410
    2370   return true;
     2411  return TRUE;
    23712412}
    23722413
     
    23742415coff_sizeof_headers (abfd, reloc)
    23752416     bfd *abfd;
    2376      boolean reloc;
     2417     bfd_boolean reloc;
    23772418{
    23782419  size_t size;
    23792420
    2380   if (reloc == false)
     2421  if (! reloc)
    23812422    {
    23822423      size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
     
    23922433
    23932434/* Change the class of a coff symbol held by BFD.  */
    2394 boolean
     2435bfd_boolean
    23952436bfd_coff_set_symbol_class (abfd, symbol, class)
    23962437     bfd *         abfd;
     
    24042445    {
    24052446      bfd_set_error (bfd_error_invalid_operation);
    2406       return false;
     2447      return FALSE;
    24072448    }
    24082449  else if (csym->native == NULL)
     
    24142455
    24152456      combined_entry_type * native;
    2416 
    2417       native = (combined_entry_type *) bfd_alloc (abfd, sizeof (* native));
     2457      bfd_size_type amt = sizeof (* native);
     2458
     2459      native = (combined_entry_type *) bfd_zalloc (abfd, amt);
    24182460      if (native == NULL)
    2419         return false;
    2420 
    2421       memset (native, 0, sizeof (* native));
     2461        return FALSE;
    24222462
    24232463      native->u.syment.n_type   = T_NULL;
     
    24432483            native->u.syment.n_value += symbol->section->output_section->vma;
    24442484
    2445           /* Copy the any flags from the the file header into the symbol.
     2485          /* Copy the any flags from the file header into the symbol.
    24462486             FIXME: Why?  */
    24472487          native->u.syment.n_flags = bfd_asymbol_bfd (& csym->symbol)->flags;
     
    24552495    }
    24562496
    2457   return true;
    2458 }
     2497  return TRUE;
     2498}
Note: See TracChangeset for help on using the changeset viewer.