Timestamp:
Aug 16, 2003, 11:33:53 PM (22 years ago)
Author:
bird
Message:

Joined the port of 2.11.2 with 2.14.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/binutils/bfd/archive.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r617 r618  
    11/* BFD back-end for archive files (libraries).
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000
     3   2000
    44   Free Software Foundation, Inc.
    55   Written by Cygnus Support.  Mostly Gumby Henkel-Wallace's fault.
     
    133133#include "aout/ar.h"
    134134#include "aout/ranlib.h"
    135 #include <ctype.h>
     135#include
    136136
    137137#ifndef errno
     
    141141#ifdef GNU960
    142142#define BFD_GNU960_ARMAG(abfd)  (BFD_COFF_FILE_P((abfd)) ? ARMAG : ARMAGB)
    143 #endif
    144 
    145 /* Define offsetof for those systems which lack it */
    146 
    147 #ifndef offsetof
    148 #define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
    149143#endif
    150144
     
    167161#define arch_hdr(bfd) ((struct ar_hdr *)arch_eltdata(bfd)->arch_header)
    168162
    169 static char *get_extended_arelt_filename PARAMS ((bfd *arch,
    170                                                   const char *name));
    171 static boolean do_slurp_bsd_armap PARAMS ((bfd *abfd));
    172 static boolean do_slurp_coff_armap PARAMS ((bfd *abfd));
    173 static const char *normalize PARAMS ((bfd *, const char *file));
    174 static struct areltdata *bfd_ar_hdr_from_filesystem PARAMS ((bfd *abfd,
    175                                                              const char *,
    176                                                              bfd *member));
    177 
    178 
    179 boolean
     163static char *get_extended_arelt_filename
     164  PARAMS ((bfd *arch, const char *name));
     165static bfd_boolean do_slurp_bsd_armap
     166  PARAMS ((bfd *abfd));
     167static bfd_boolean do_slurp_coff_armap
     168  PARAMS ((bfd *abfd));
     169bfd_boolean bfd_elf64_archive_slurp_armap
     170  PARAMS ((bfd *abfd));
     171static const char *normalize
     172  PARAMS ((bfd *, const char *file));
     173static struct areltdata *bfd_ar_hdr_from_filesystem
     174  PARAMS ((bfd *abfd, const char *, bfd *member));
     175
     176
     177bfd_boolean
    180178_bfd_generic_mkarchive (abfd)
    181179     bfd *abfd;
    182180{
    183   abfd->tdata.aout_ar_data = ((struct artdata *)
    184                               bfd_zalloc (abfd, sizeof (struct artdata)));
    185 
     181 
     182
     183  abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);
    186184  if (bfd_ardata (abfd) == NULL)
    187     return false;
     185    return ;
    188186
    189187  bfd_ardata (abfd)->cache = NULL;
     
    193191  bfd_ardata (abfd)->tdata = NULL;
    194192
    195   return true;
     193  return ;
    196194}
    197195
     
    254252
    255253SYNOPSIS
    256         boolean bfd_set_archive_head(bfd *output, bfd *new_head);
     254        boolean bfd_set_archive_head(bfd *output, bfd *new_head);
    257255
    258256DESCRIPTION
     
    261259*/
    262260
    263 boolean
     261boolean
    264262bfd_set_archive_head (output_archive, new_head)
    265263     bfd *output_archive;
     
    268266
    269267  output_archive->archive_head = new_head;
    270   return true;
     268  return ;
    271269}
    272270
     
    287285
    288286/* Kind of stupid to call cons for each one, but we don't do too many */
    289 boolean
     287boolean
    290288_bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt)
    291289     bfd *arch_bfd, *new_elt;
    292290     file_ptr filepos;
    293291{
    294   struct ar_cache *new_cache = ((struct ar_cache *)
    295                                 bfd_zalloc (arch_bfd,
    296                                             sizeof (struct ar_cache)));
    297 
     292  bfd_size_type amt = sizeof (struct ar_cache);
     293
     294  struct ar_cache *new_cache = (struct ar_cache *) bfd_zalloc (arch_bfd, amt);
    298295  if (new_cache == NULL)
    299     return false;
     296    return ;
    300297
    301298  new_cache->ptr = filepos;
     
    313310    }
    314311
    315   return true;
     312  return ;
    316313}
    317314
     
    367364  struct ar_hdr hdr;
    368365  char *hdrp = (char *) &hdr;
    369   unsigned int parsed_size;
     366  t parsed_size;
    370367  struct areltdata *ared;
    371368  char *filename = NULL;
    372   unsigned int namelen = 0;
    373   unsigned int allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);
     369  namelen = 0;
     370  allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);
    374371  char *allocptr = 0;
    375372
    376   if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)
     373  if (bfd_ sizeof (struct ar_hdr), abfd)
    377374      != sizeof (struct ar_hdr))
    378375    {
     
    417414           && hdr.ar_name[1] == '1'
    418415           && hdr.ar_name[2] == '/'
    419            && isdigit ((unsigned char) hdr.ar_name[3]))
     416           && hdr.ar_name[3]))
    420417    {
    421418      /* BSD-4.4 extended name */
     
    430427                  + sizeof (struct areltdata)
    431428                  + sizeof (struct ar_hdr));
    432       if (bfd_read (filename, 1, namelen, abfd) != namelen)
     429      if (bfd_, namelen, abfd) != namelen)
    433430        {
    434431          if (bfd_get_error () != bfd_error_system_call)
     
    445442
    446443      char *e;
    447       e = memchr (hdr.ar_name, '\0', ar_maxnamelen (abfd));
     444      e = memchr (hdr.ar_name, '\0', ar_maxnamelen (abfd));
    448445      if (e == NULL)
    449446        {
    450           e = memchr (hdr.ar_name, '/', ar_maxnamelen (abfd));
     447          e = memchr (hdr.ar_name, '/', ar_maxnamelen (abfd));
    451448          if (e == NULL)
    452             e = memchr (hdr.ar_name, ' ', ar_maxnamelen (abfd));
     449            e = memchr (hdr.ar_name, ' ', ar_maxnamelen (abfd));
    453450        }
    454451
     
    485482                                   sizeof (struct ar_hdr));
    486483      if (namelen)
    487         memcpy (ared->filename, hdr.ar_name, namelen);
     484        memcpy (ared->filename, hdr.ar_name, namelen);
    488485      ared->filename[namelen] = '\0';
    489486    }
     
    611608  struct artdata *tdata_hold;
    612609  char armag[SARMAG + 1];
    613 
    614   tdata_hold = abfd->tdata.aout_ar_data;
    615 
    616   if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
     610  bfd_size_type amt;
     611
     612  if (bfd_bread ((PTR) armag, (bfd_size_type) SARMAG, abfd) != SARMAG)
    617613    {
    618614      if (bfd_get_error () != bfd_error_system_call)
     
    630626#endif
    631627
    632   /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
    633      involves a cast, we can't do it as the left operand of assignment.  */
    634   abfd->tdata.aout_ar_data = ((struct artdata *)
    635                               bfd_zalloc (abfd, sizeof (struct artdata)));
    636 
     628  tdata_hold = bfd_ardata (abfd);
     629
     630  amt = sizeof (struct artdata);
     631  bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt);
    637632  if (bfd_ardata (abfd) == NULL)
    638     return NULL;
     633    {
     634      bfd_ardata (abfd) = tdata_hold;
     635      return NULL;
     636    }
    639637
    640638  bfd_ardata (abfd)->first_file_filepos = SARMAG;
     
    645643  bfd_ardata (abfd)->tdata = NULL;
    646644
    647   if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))
    648     {
    649       bfd_release (abfd, bfd_ardata (abfd));
    650       abfd->tdata.aout_ar_data = tdata_hold;
     645  if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd))
     646      || !BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
     647    {
    651648      if (bfd_get_error () != bfd_error_system_call)
    652649        bfd_set_error (bfd_error_wrong_format);
    653       return NULL;
    654     }
    655 
    656   if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
    657     {
    658650      bfd_release (abfd, bfd_ardata (abfd));
    659       abfd->tdata.aout_ar_data = tdata_hold;
    660       if (bfd_get_error () != bfd_error_system_call)
    661         bfd_set_error (bfd_error_wrong_format);
     651      bfd_ardata (abfd) = tdata_hold;
    662652      return NULL;
    663653    }
     
    681671      if (first != NULL)
    682672        {
    683           boolean fail;
    684 
    685           first->target_defaulted = false;
    686           fail = false;
     673          boolean fail;
     674
     675          first->target_defaulted = ;
     676          fail = ;
    687677          if (bfd_check_format (first, bfd_object)
    688678              && first->xvec != abfd->xvec)
    689679            {
     680
     681
     682
     683
     684
    690685              (void) bfd_close (first);
    691686              bfd_release (abfd, bfd_ardata (abfd));
    692               abfd->tdata.aout_ar_data = tdata_hold;
    693               bfd_set_error (bfd_error_wrong_format);
     687#endif
     688              bfd_set_error (bfd_error_wrong_object_format);
     689              bfd_ardata (abfd) = tdata_hold;
    694690              return NULL;
    695691            }
    696 
    697           /* We ought to close first here, but we can't, because we
    698              have no way to remove it from the archive cache.  FIXME.  */
     692          /* And we ought to close `first' here too.  */
    699693        }
    700694    }
     
    706700   support 64 bit archives presently; so far as I know, none actually
    707701   exist.  Supporting them would require changing these constants, and
    708    changing some bfd_h_get_32 to bfd_h_get_64.  */
     702   changing some _64.  */
    709703
    710704/* The size of an external symdef structure.  */
     
    720714#define BSD_STRING_COUNT_SIZE 4
    721715
    722 /* Returns false on error, true otherwise */
    723 
    724 static boolean
     716/* Returns otherwise */
     717
     718static boolean
    725719do_slurp_bsd_armap (abfd)
    726720     bfd *abfd;
     
    731725  struct artdata *ardata = bfd_ardata (abfd);
    732726  char *stringbase;
    733   unsigned int parsed_size;
     727  ;
    734728  carsym *set;
    735729
    736730  mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
    737731  if (mapdata == NULL)
    738     return false;
     732    return ;
    739733  parsed_size = mapdata->parsed_size;
    740734  bfd_release (abfd, (PTR) mapdata);    /* Don't need it any more.  */
     
    742736  raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
    743737  if (raw_armap == (bfd_byte *) NULL)
    744     return false;
    745 
    746   if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
     738    return ;
     739
     740  if (bfd_, parsed_size, abfd) != parsed_size)
    747741    {
    748742      if (bfd_get_error () != bfd_error_system_call)
     
    750744    byebye:
    751745      bfd_release (abfd, (PTR) raw_armap);
    752       return false;
    753     }
    754 
    755   ardata->symdef_count = bfd_h_get_32 (abfd, raw_armap) / BSD_SYMDEF_SIZE;
     746      return ;
     747    }
     748
     749  ardata->symdef_count = _32 (abfd, raw_armap) / BSD_SYMDEF_SIZE;
    756750
    757751  if (ardata->symdef_count * BSD_SYMDEF_SIZE >
     
    768762                + ardata->symdef_count * BSD_SYMDEF_SIZE
    769763                + BSD_STRING_COUNT_SIZE);
    770   ardata->symdefs = (carsym *) bfd_alloc (abfd,
    771                                           (ardata->symdef_count
    772                                            * sizeof (carsym)));
     764  amt = (bfd_size_type) ardata->symdef_count * sizeof (carsym);
     765  ardata->symdefs = (carsym *) bfd_alloc (abfd, amt);
    773766  if (!ardata->symdefs)
    774     return false;
     767    return ;
    775768
    776769  for (counter = 0, set = ardata->symdefs;
     
    778771       counter++, set++, rbase += BSD_SYMDEF_SIZE)
    779772    {
    780       set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
    781       set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
     773      set->name = _32 (abfd, rbase) + stringbase;
     774      set->file_offset = _32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
    782775    }
    783776
     
    788781     we are done using the strings from it.  For now, it seems
    789782     to be allocated on an objalloc anyway...  */
    790   bfd_has_map (abfd) = true;
    791   return true;
    792 }
    793 
    794 /* Returns false on error, true otherwise.  */
    795 
    796 static boolean
     783  bfd_has_map (abfd) = ;
     784  return ;
     785}
     786
     787/* Returns otherwise.  */
     788
     789static boolean
    797790do_slurp_coff_armap (abfd)
    798791     bfd *abfd;
     
    802795  struct artdata *ardata = bfd_ardata (abfd);
    803796  char *stringbase;
    804   unsigned int stringsize;
     797  stringsize;
    805798  unsigned int parsed_size;
    806799  carsym *carsyms;
    807   unsigned int nsymz;           /* Number of symbols in armap.  */
     800  nsymz;          /* Number of symbols in armap.  */
    808801  bfd_vma (*swap) PARAMS ((const bfd_byte *));
    809802  char int_buf[sizeof (long)];
    810   unsigned int carsym_size, ptrsize, i;
     803  bfd_size_type carsym_size, ptrsize;
     804  unsigned int i;
    811805
    812806  mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
    813807  if (mapdata == NULL)
    814     return false;
     808    return ;
    815809  parsed_size = mapdata->parsed_size;
    816810  bfd_release (abfd, (PTR) mapdata);    /* Don't need it any more.  */
    817811
    818   if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)
     812  if (bfd_ 4, abfd) != 4)
    819813    {
    820814      if (bfd_get_error () != bfd_error_system_call)
    821815        bfd_set_error (bfd_error_malformed_archive);
    822       return false;
     816      return ;
    823817    }
    824818  /* It seems that all numeric information in a coff archive is always
     
    853847  ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
    854848  if (ardata->symdefs == NULL)
    855     return false;
     849    return ;
    856850  carsyms = ardata->symdefs;
    857851  stringbase = ((char *) ardata->symdefs) + carsym_size;
     
    861855  if (raw_armap == NULL)
    862856    goto release_symdefs;
    863   if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
    864       || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
     857  if (bfd_, ptrsize, abfd) != ptrsize
     858      || )
    865859    {
    866860      if (bfd_get_error () != bfd_error_system_call)
     
    885879  ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
    886880
    887   bfd_has_map (abfd) = true;
     881  bfd_has_map (abfd) = ;
    888882  bfd_release (abfd, (PTR) raw_armap);
    889883
     
    892886    struct areltdata *tmp;
    893887
    894     bfd_seek (abfd,   ardata->first_file_filepos, SEEK_SET);
     888    bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET);
    895889    tmp = (struct areltdata *) _bfd_read_ar_hdr (abfd);
    896890    if (tmp != NULL)
     
    900894          {
    901895            ardata->first_file_filepos +=
    902               (tmp->parsed_size + sizeof (struct ar_hdr) + 1) & ~1;
     896              (tmp->parsed_size + sizeof (struct ar_hdr) + 1) & ~1;
    903897          }
    904898        bfd_release (abfd, tmp);
     
    906900  }
    907901
    908   return true;
     902  return ;
    909903
    910904release_raw_armap:
     
    912906release_symdefs:
    913907  bfd_release (abfd, (PTR) (ardata)->symdefs);
    914   return false;
     908  return ;
    915909}
    916910
    917911/* This routine can handle either coff-style or bsd-style armaps.
    918    Returns false on error, true otherwise */
    919 
    920 boolean
     912   Returns otherwise */
     913
     914boolean
    921915bfd_slurp_armap (abfd)
    922916     bfd *abfd;
    923917{
    924918  char nextname[17];
    925   int i = bfd_read ((PTR) nextname, 1, 16, abfd);
     919  int i = bfd_ 16, abfd);
    926920
    927921  if (i == 0)
    928     return true;
     922    return ;
    929923  if (i != 16)
    930     return false;
    931 
    932   if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
    933     return false;
     924    return ;
     925
     926  if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
     927    return ;
    934928
    935929  if (!strncmp (nextname, "__.SYMDEF       ", 16)
     
    940934  else if (!strncmp (nextname, "/SYM64/         ", 16))
    941935    {
    942       /* Irix 6 archive--must be recognized by code in elf64-mips.c.  */
     936      /* 64bit ELF (Irix 6) archive.  */
     937#ifdef BFD64
     938      return bfd_elf64_archive_slurp_armap (abfd);
     939#else
    943940      bfd_set_error (bfd_error_wrong_format);
    944       return false;
    945     }
    946 
    947   bfd_has_map (abfd) = false;
    948   return true;
    949 }
    950 
    951 
    952 /* Returns false on error, true otherwise */
     941      return FALSE;
     942#endif
     943    }
     944
     945  bfd_has_map (abfd) = FALSE;
     946  return TRUE;
     947}
     948
     949
     950/* Returns FALSE on error, TRUE otherwise */
    953951/* flavor 2 of a bsd armap, similar to bfd_slurp_bsd_armap except the
    954952   header is in a slightly different order and the map name is '/'.
     
    957955#define HPUX_SYMDEF_COUNT_SIZE 2
    958956
    959 boolean
     957boolean
    960958bfd_slurp_bsd_armap_f2 (abfd)
    961959     bfd *abfd;
     
    968966  char *stringbase;
    969967  unsigned int stringsize;
     968
    970969  carsym *set;
    971   int i = bfd_read ((PTR) nextname, 1, 16, abfd);
     970  int i = bfd_ 16, abfd);
    972971
    973972  if (i == 0)
    974     return true;
     973    return ;
    975974  if (i != 16)
    976     return false;
     975    return ;
    977976
    978977  /* The archive has at least 16 bytes in it.  */
    979   if (bfd_seek (abfd, -16L, SEEK_CUR) != 0)
    980     return false;
     978  if (bfd_seek (abfd, , SEEK_CUR) != 0)
     979    return ;
    981980
    982981  if (!strncmp (nextname, "__.SYMDEF       ", 16)
     
    986985  if (strncmp (nextname, "/               ", 16))
    987986    {
    988       bfd_has_map (abfd) = false;
    989       return true;
     987      bfd_has_map (abfd) = ;
     988      return ;
    990989    }
    991990
    992991  mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
    993992  if (mapdata == NULL)
    994     return false;
    995 
    996   raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
     993    return FALSE;
     994
     995  amt = mapdata->parsed_size;
     996  raw_armap = (bfd_byte *) bfd_zalloc (abfd, amt);
    997997  if (raw_armap == NULL)
    998998    {
    999999    byebye:
    10001000      bfd_release (abfd, (PTR) mapdata);
    1001       return false;
    1002     }
    1003 
    1004   if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) !=
    1005       mapdata->parsed_size)
     1001      return FALSE;
     1002    }
     1003
     1004  if (bfd_bread ((PTR) raw_armap, amt, abfd) != amt)
    10061005    {
    10071006      if (bfd_get_error () != bfd_error_system_call)
     
    10121011    }
    10131012
    1014   ardata->symdef_count = bfd_h_get_16 (abfd, (PTR) raw_armap);
     1013  ardata->symdef_count = _16 (abfd, (PTR) raw_armap);
    10151014
    10161015  if (ardata->symdef_count * BSD_SYMDEF_SIZE
     
    10241023  ardata->cache = 0;
    10251024
    1026   stringsize = bfd_h_get_32 (abfd, raw_armap + HPUX_SYMDEF_COUNT_SIZE);
     1025  stringsize = _32 (abfd, raw_armap + HPUX_SYMDEF_COUNT_SIZE);
    10271026  /* Skip sym count and string sz.  */
    10281027  stringbase = ((char *) raw_armap
     
    10301029                + BSD_STRING_COUNT_SIZE);
    10311030  rbase = (bfd_byte *) stringbase + stringsize;
    1032   ardata->symdefs = (carsym *) bfd_alloc (abfd,
    1033                                           (ardata->symdef_count
    1034                                            * BSD_SYMDEF_SIZE));
     1031  amt = (bfd_size_type) ardata->symdef_count * BSD_SYMDEF_SIZE;
     1032  ardata->symdefs = (carsym *) bfd_alloc (abfd, amt);
    10351033  if (!ardata->symdefs)
    1036     return false;
     1034    return ;
    10371035
    10381036  for (counter = 0, set = ardata->symdefs;
     
    10401038       counter++, set++, rbase += BSD_SYMDEF_SIZE)
    10411039    {
    1042       set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
    1043       set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
     1040      set->name = _32 (abfd, rbase) + stringbase;
     1041      set->file_offset = _32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
    10441042    }
    10451043
     
    10501048     we are done using the strings from it.  For now, it seems
    10511049     to be allocated on an objalloc anyway...  */
    1052   bfd_has_map (abfd) = true;
    1053   return true;
     1050  bfd_has_map (abfd) = ;
     1051  return ;
    10541052}
    10551053
     
    10651063  extended the format by using the prefix // for the special element.  */
    10661064
    1067 /* Returns false on error, true otherwise.  */
    1068 
    1069 boolean
     1065/* Returns otherwise.  */
     1066
     1067boolean
    10701068_bfd_slurp_extended_name_table (abfd)
    10711069     bfd *abfd;
     
    10731071  char nextname[17];
    10741072  struct areltdata *namedata;
     1073
    10751074
    10761075  /* FIXME:  Formatting sucks here, and in case of failure of BFD_READ,
    1077      we probably don't want to return true.  */
     1076     we probably don't want to return .  */
    10781077  bfd_seek (abfd, bfd_ardata (abfd)->first_file_filepos, SEEK_SET);
    1079   if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16)
    1080     {
    1081       if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
    1082         return false;
     1078  if (bfd_ 16, abfd) == 16)
     1079    {
     1080      if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
     1081        return ;
    10831082
    10841083      if (strncmp (nextname, "ARFILENAMES/    ", 16) != 0 &&
     
    10861085        {
    10871086          bfd_ardata (abfd)->extended_names = NULL;
    1088           return true;
     1087          return ;
    10891088        }
    10901089
    10911090      namedata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
    10921091      if (namedata == NULL)
    1093         return false;
    1094 
    1095       bfd_ardata (abfd)->extended_names =
    1096         bfd_zalloc (abfd, namedata->parsed_size);
     1092        return ;
     1093
     1094     
     1095);
    10971096      if (bfd_ardata (abfd)->extended_names == NULL)
    10981097        {
    10991098        byebye:
    11001099          bfd_release (abfd, (PTR) namedata);
    1101           return false;
     1100          return ;
    11021101        }
    11031102
    1104       if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1,
    1105                     namedata->parsed_size, abfd) != namedata->parsed_size)
     1103      if (bfd_bread ((PTR) bfd_ardata (abfd)->extended_names, amt, abfd) != amt)
    11061104        {
    11071105          if (bfd_get_error () != bfd_error_system_call)
     
    11401138#endif
    11411139    }
    1142   return true;
     1140  return ;
    11431141}
    11441142
     
    11531151     const char *file;
    11541152{
    1155   CONST char *first;
    1156   CONST char *last;
     1153  char *first;
     1154  char *last;
    11571155  char *copy;
    11581156
     
    11721170    }
    11731171
    1174   copy = (char *) bfd_alloc (abfd, last - first + 1);
     1172  copy = (char *) bfd_alloc (abfd, );
    11751173  if (copy == NULL)
    11761174    return NULL;
     
    12101208/* Build a BFD style extended name table.  */
    12111209
    1212 boolean
     1210boolean
    12131211_bfd_archive_bsd_construct_extended_name_table (abfd, tabloc, tablen, name)
    12141212     bfd *abfd;
     
    12181216{
    12191217  *name = "ARFILENAMES/";
    1220   return _bfd_construct_extended_name_table (abfd, false, tabloc, tablen);
     1218  return _bfd_construct_extended_name_table (abfd, , tabloc, tablen);
    12211219}
    12221220
    12231221/* Build an SVR4 style extended name table.  */
    12241222
    1225 boolean
     1223boolean
    12261224_bfd_archive_coff_construct_extended_name_table (abfd, tabloc, tablen, name)
    12271225     bfd *abfd;
     
    12311229{
    12321230  *name = "//";
    1233   return _bfd_construct_extended_name_table (abfd, true, tabloc, tablen);
     1231  return _bfd_construct_extended_name_table (abfd, , tabloc, tablen);
    12341232}
    12351233
     
    12381236   table, and in tablen the length of the table.  If it makes an entry
    12391237   it clobbers the filename so that the element may be written without
    1240    further massage.  Returns true if it ran successfully, false if
     1238   further massage.  Returns if
    12411239   something went wrong.  A successful return may still involve a
    12421240   zero-length tablen!  */
    12431241
    1244 boolean
     1242boolean
    12451243_bfd_construct_extended_name_table (abfd, trailing_slash, tabloc, tablen)
    12461244     bfd *abfd;
    1247      boolean trailing_slash;
     1245     boolean trailing_slash;
    12481246     char **tabloc;
    12491247     bfd_size_type *tablen;
    12501248{
    12511249  unsigned int maxname = abfd->xvec->ar_max_namelen;
    1252   unsigned int total_namelen = 0;
     1250  total_namelen = 0;
    12531251  bfd *current;
    12541252  char *strptr;
     
    12641262      normal = normalize (current, current->filename);
    12651263      if (normal == NULL)
    1266         return false;
     1264        return ;
    12671265
    12681266      thislen = strlen (normal);
     
    13001298
    13011299  if (total_namelen == 0)
    1302     return true;
     1300    return ;
    13031301
    13041302  *tabloc = bfd_zalloc (abfd, total_namelen);
    13051303  if (*tabloc == NULL)
    1306     return false;
     1304    return ;
    13071305
    13081306  *tablen = total_namelen;
     
    13171315      normal = normalize (current, current->filename);
    13181316      if (normal == NULL)
    1319         return false;
     1317        return ;
    13201318
    13211319      thislen = strlen (normal);
     
    13521350    }
    13531351
    1354   return true;
     1352  return ;
    13551353}
    13561354
     
    13991397  struct ar_hdr *hdr;
    14001398  char *temp, *temp1;
     1399
    14011400
    14021401  if (member && (member->flags & BFD_IN_MEMORY) != 0)
     
    14161415    }
    14171416
    1418   ared = (struct areltdata *) bfd_zalloc (abfd, sizeof (struct ar_hdr) +
    1419                                           sizeof (struct areltdata));
     1417  a
     1418);
    14201419  if (ared == NULL)
    14211420    return NULL;
     
    14691468   stronger stomach to try to code around such a thing!  */
    14701469
    1471 struct ar_hdr *bfd_special_undocumented_glue PARAMS ((bfd *, const char *));
     1470struct ar_hdr *bfd_special_undocumented_glue
     1471  PARAMS ((bfd *, const char *));
    14721472
    14731473struct ar_hdr *
     
    15441544bfd_dont_truncate_arname (abfd, pathname, arhdr)
    15451545     bfd *abfd;
    1546      CONST char *pathname;
     1546      char *pathname;
    15471547     char *arhdr;
    15481548{
     
    15841584bfd_bsd_truncate_arname (abfd, pathname, arhdr)
    15851585     bfd *abfd;
    1586      CONST char *pathname;
     1586      char *pathname;
    15871587     char *arhdr;
    15881588{
    15891589  struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
    1590   int length;
    1591   CONST char *filename = strrchr (pathname, '/');
    1592   int maxlen = ar_maxnamelen (abfd);
     1590  t length;
     1591  char *filename = strrchr (pathname, '/');
     1592  t maxlen = ar_maxnamelen (abfd);
    15931593
    15941594#ifdef HAVE_DOS_BASED_FILE_SYSTEM
     
    16351635bfd_gnu_truncate_arname (abfd, pathname, arhdr)
    16361636     bfd *abfd;
    1637      CONST char *pathname;
     1637      char *pathname;
    16381638     char *arhdr;
    16391639{
    16401640  struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
    1641   int length;
    1642   CONST char *filename = strrchr (pathname, '/');
    1643   int maxlen = ar_maxnamelen (abfd);
     1641  t length;
     1642  char *filename = strrchr (pathname, '/');
     1643  t maxlen = ar_maxnamelen (abfd);
    16441644
    16451645#ifdef HAVE_DOS_BASED_FILE_SYSTEM
     
    16811681/* The BFD is open for write and has its format set to bfd_archive.  */
    16821682
    1683 boolean
     1683boolean
    16841684_bfd_write_archive_contents (arch)
    16851685     bfd *arch;
     
    16891689  bfd_size_type elength = 0;
    16901690  const char *ename = NULL;
    1691   boolean makemap = bfd_has_map (arch);
    1692   boolean hasobjects = false;   /* If no .o's, don't bother to make a map.  */
     1691  bfd_boolean makemap = bfd_has_map (arch);
     1692  /* If no .o's, don't bother to make a map.  */
     1693  bfd_boolean hasobjects = FALSE;
    16931694  bfd_size_type wrote;
    16941695  unsigned int i;
     
    17081709        {
    17091710          bfd_set_error (bfd_error_invalid_operation);
    1710           return false;
     1711          return ;
    17111712        }
    17121713      if (!current->arelt_data)
     
    17151716            (PTR) bfd_ar_hdr_from_filesystem (arch, current->filename, current);
    17161717          if (!current->arelt_data)
    1717             return false;
     1718            return ;
    17181719
    17191720          /* Put in the file name.  */
     
    17301731#endif
    17311732            )
    1732             hasobjects = true;
     1733            hasobjects = ;
    17331734        }
    17341735    }
     
    17361737  if (!BFD_SEND (arch, _bfd_construct_extended_name_table,
    17371738                 (arch, &etable, &elength, &ename)))
    1738     return false;
     1739    return ;
    17391740
    17401741  if (bfd_seek (arch, (file_ptr) 0, SEEK_SET) != 0)
    1741     return false;
     1742    return ;
    17421743#ifdef GNU960
    1743   wrote = bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch);
     1744  wrote = bfd_ SARMAG, arch);
    17441745#else
    1745   wrote = bfd_write (ARMAG, 1, SARMAG, arch);
     1746  wrote = bfd_ SARMAG, arch);
    17461747#endif
    17471748  if (wrote != SARMAG)
    1748     return false;
     1749    return ;
    17491750
    17501751  if (makemap && hasobjects)
    17511752    {
    1752       if (_bfd_compute_and_write_armap (arch, elength) != true)
    1753         return false;
     1753      if ()
     1754        return ;
    17541755    }
    17551756
     
    17621763      /* Round size up to even number in archive header.  */
    17631764      sprintf (&(hdr.ar_size[0]), "%-10d",
    1764                (int) ((elength + 1) & ~1));
     1765               (int) ((elength + 1) & ~1));
    17651766      strncpy (hdr.ar_fmag, ARFMAG, 2);
    17661767      for (i = 0; i < sizeof (struct ar_hdr); i++)
    17671768        if (((char *) (&hdr))[i] == '\0')
    17681769          (((char *) (&hdr))[i]) = ' ';
    1769       if ((bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
     1770      if ((bfd_ sizeof (struct ar_hdr), arch)
    17701771           != sizeof (struct ar_hdr))
    1771           || bfd_write (etable, 1, elength, arch) != elength)
    1772         return false;
     1772          || bfd_, elength, arch) != elength)
     1773        return ;
    17731774      if ((elength % 2) == 1)
    17741775        {
    1775           if (bfd_write ("\012", 1, 1, arch) != 1)
    1776             return false;
     1776          if (bfd_ 1, arch) != 1)
     1777            return ;
    17771778        }
    17781779    }
     
    17851786
    17861787      /* Write ar header.  */
    1787       if (bfd_write ((char *) hdr, 1, sizeof (*hdr), arch) != sizeof (*hdr))
    1788         return false;
     1788      if (bfd_bwrite ((PTR) hdr, (bfd_size_type) sizeof (*hdr), arch)
     1789          != sizeof (*hdr))
     1790        return FALSE;
    17891791      if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
    1790         return false;
     1792        return ;
    17911793      while (remaining)
    17921794        {
     
    17951797            amt = remaining;
    17961798          errno = 0;
    1797           if (bfd_read (buffer, amt, 1, current) != amt)
     1799          if (bfd_, current) != amt)
    17981800            {
    17991801              if (bfd_get_error () != bfd_error_system_call)
    18001802                bfd_set_error (bfd_error_malformed_archive);
    1801               return false;
     1803              return ;
    18021804            }
    1803           if (bfd_write (buffer, amt, 1, arch) != amt)
    1804             return false;
     1805          if (bfd_, arch) != amt)
     1806            return ;
    18051807          remaining -= amt;
    18061808        }
    18071809      if ((arelt_size (current) % 2) == 1)
    18081810        {
    1809           if (bfd_write ("\012", 1, 1, arch) != 1)
    1810             return false;
     1811          if (bfd_ 1, arch) != 1)
     1812            return ;
    18111813        }
    18121814    }
     
    18311833    }
    18321834
    1833   return true;
     1835  return ;
    18341836}
    18351837
     
    18371839/* Note that the namidx for the first symbol is 0.  */
    18381840
    1839 boolean
     1841boolean
    18401842_bfd_compute_and_write_armap (arch, elength)
    18411843     bfd *arch;
     
    18461848  file_ptr elt_no = 0;
    18471849  struct orl *map = NULL;
    1848   int orl_max = 1024;           /* fine initial default */
    1849   int orl_count = 0;
     1850  int orl_max = 1024;          /* fine initial default */
     1851  int orl_count = 0;
    18501852  int stridx = 0;               /* string index */
    18511853  asymbol **syms = NULL;
    18521854  long syms_max = 0;
    1853   boolean ret;
     1855  bfd_boolean ret;
     1856  bfd_size_type amt;
    18541857
    18551858  /* Dunno if this is the best place for this info...  */
     
    18581861  elength += elength % 2;
    18591862
    1860   map = (struct orl *) bfd_malloc (orl_max * sizeof (struct orl));
     1863  amt = (bfd_size_type) orl_max * sizeof (struct orl);
     1864  map = (struct orl *) bfd_malloc (amt);
    18611865  if (map == NULL)
    18621866    goto error_return;
     
    18641868  /* We put the symbol names on the arch objalloc, and then discard
    18651869     them when done.  */
    1866   first_name = bfd_alloc (arch, 1);
     1870  first_name = bfd_alloc (arch, 1);
    18671871  if (first_name == NULL)
    18681872    goto error_return;
     
    18781882       current = current->next, elt_no++)
    18791883    {
    1880       if ((bfd_check_format (current, bfd_object) == true)
    1881           && ((bfd_get_file_flags (current) & HAS_SYMS)))
     1884      if ()
     1885          && ()
    18821886        {
    18831887          long storage;
     
    18961900                    free (syms);
    18971901                  syms_max = storage;
    1898                   syms = (asymbol **) bfd_malloc ((size_t) syms_max);
     1902                  syms = (asymbol **) bfd_malloc (() syms_max);
    18991903                  if (syms == NULL)
    19001904                    goto error_return;
     
    19201924                      && ! bfd_is_und_section (sec))
    19211925                    {
    1922                       size_t namelen;
     1926                      namelen;
    19231927                      struct orl *new_map;
    19241928
     
    19271931                        {
    19281932                          orl_max *= 2;
    1929                           new_map =
    1930                             ((struct orl *)
    1931                              bfd_realloc (map, orl_max * sizeof (struct orl)));
     1933                          amt = (bfd_size_type) orl_max * sizeof (struct orl);
     1934                          new_map = (struct orl *) bfd_realloc (map, amt);
    19321935                          if (new_map == (struct orl *) NULL)
    19331936                            goto error_return;
     
    19371940
    19381941                      namelen = strlen (syms[src_count]->name);
    1939                       map[orl_count].name = ((char **)
    1940                                              bfd_alloc (arch,
    1941                                                         sizeof (char *)));
     1942                      amt = sizeof (char *);
     1943                      map[orl_count].name = (char **) bfd_alloc (arch, amt);
    19421944                      if (map[orl_count].name == NULL)
    19431945                        goto error_return;
     
    19461948                        goto error_return;
    19471949                      strcpy (*(map[orl_count].name), syms[src_count]->name);
    1948                       (map[orl_count]).pos = (file_ptr) current;
    1949                       (map[orl_count]).namidx = stridx;
     1950                      current;
     1951                      .namidx = stridx;
    19501952
    19511953                      stridx += namelen + 1;
     
    19831985    bfd_release (arch, first_name);
    19841986
    1985   return false;
    1986 }
    1987 
    1988 boolean
     1987  return ;
     1988}
     1989
     1990boolean
    19891991bsd_write_armap (arch, elength, map, orl_count, stridx)
    19901992     bfd *arch;
     
    20252027    if (((char *) (&hdr))[i] == '\0')
    20262028      (((char *) (&hdr))[i]) = ' ';
    2027   if (bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
     2029  if (bfd_ sizeof (struct ar_hdr), arch)
    20282030      != sizeof (struct ar_hdr))
    2029     return false;
    2030   bfd_h_put_32 (arch, (bfd_vma) ranlibsize, temp);
    2031   if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
    2032     return false;
     2031    return ;
     2032  ranlibsize, temp);
     2033  if (bfd_ sizeof (temp), arch) != sizeof (temp))
     2034    return ;
    20332035
    20342036  for (count = 0; count < orl_count; count++)
     
    20362038      bfd_byte buf[BSD_SYMDEF_SIZE];
    20372039
    2038       if (((bfd *) (map[count]).pos) != last_elt)
     2040      if ( != last_elt)
    20392041        {
    20402042          do
     
    20442046              current = current->next;
    20452047            }
    2046           while (current != (bfd *) (map[count]).pos);
     2048          while (current != );
    20472049        }                       /* if new archive element */
    20482050
    20492051      last_elt = current;
    2050       bfd_h_put_32 (arch, map[count].namidx, buf);
    2051       bfd_h_put_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
    2052       if (bfd_write (buf, BSD_SYMDEF_SIZE, 1, arch) != BSD_SYMDEF_SIZE)
    2053         return false;
     2052      H_PUT_32 (arch, map[count].namidx, buf);
     2053      H_PUT_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
     2054      if (bfd_bwrite (buf, (bfd_size_type) BSD_SYMDEF_SIZE, arch)
     2055          != BSD_SYMDEF_SIZE)
     2056        return FALSE;
    20542057    }
    20552058
    20562059  /* Now write the strings themselves.  */
    2057   bfd_h_put_32 (arch, stringsize, temp);
    2058   if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
    2059     return false;
     2060  _32 (arch, stringsize, temp);
     2061  if (bfd_ sizeof (temp), arch) != sizeof (temp))
     2062    return ;
    20602063  for (count = 0; count < orl_count; count++)
    20612064    {
    20622065      size_t len = strlen (*map[count].name) + 1;
    20632066
    2064       if (bfd_write (*map[count].name, 1, len, arch) != len)
    2065         return false;
     2067      if (bfd_ len, arch) != len)
     2068        return ;
    20662069    }
    20672070
     
    20702073  if (padit)
    20712074    {
    2072       if (bfd_write ("", 1, 1, arch) != 1)
    2073         return false;
    2074     }
    2075 
    2076   return true;
     2075      if (bfd_ 1, arch) != 1)
     2076        return ;
     2077    }
     2078
     2079  return ;
    20772080}
    20782081
     
    20802083   file, so the linker will accept it.
    20812084
    2082    Return true if the timestamp was OK, or an unusual problem happened.
    2083    Return false if we updated the timestamp.  */
    2084 
    2085 boolean
     2085   Return if the timestamp was OK, or an unusual problem happened.
     2086   Return if we updated the timestamp.  */
     2087
     2088boolean
    20862089_bfd_archive_bsd_update_armap_timestamp (arch)
    20872090     bfd *arch;
     
    20962099  if (bfd_stat (arch, &archstat) == -1)
    20972100    {
    2098       perror (_("Reading archive file mod timestamp"));
     2101      perror (_("Reading archive file mod timestamp"));
    20992102
    21002103      /* Can't read mod time for some reason.  */
    2101       return true;
     2104      return ;
    21022105    }
    21032106  if (archstat.st_mtime <= bfd_ardata (arch)->armap_timestamp)
    21042107    /* OK by the linker's rules.  */
    2105     return true;
     2108    return ;
    21062109
    21072110  /* Update the timestamp.  */
     
    21192122                                      + offsetof (struct ar_hdr, ar_date[0]));
    21202123  if (bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET) != 0
    2121       || (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch)
     2124      || (bfd_, arch)
    21222125          != sizeof (hdr.ar_date)))
    21232126    {
    2124       /* FIXME: bfd can't call perror.  */
    2125       perror (_("Writing updated armap timestamp"));
     2127      bfd_perror (_("Writing updated armap timestamp"));
    21262128
    21272129      /* Some error while writing.  */
    2128       return true;
     2130      return ;
    21292131    }
    21302132
    21312133  /* We updated the timestamp successfully.  */
    2132   return false;
     2134  return ;
    21332135}
    21342136
     
    21482150*/
    21492151
    2150 boolean
     2152boolean
    21512153coff_write_armap (arch, elength, map, symbol_count, stridx)
    21522154     bfd *arch;
     
    21572159{
    21582160  /* The size of the ranlib is the number of exported symbols in the
    2159      archive * the number of bytes in a int, + an int for the count.  */
     2161     archive * the number of bytes in a int, + an int for the count.  */
    21602162  unsigned int ranlibsize = (symbol_count * 4) + 4;
    21612163  unsigned int stringsize = stridx;
    21622164  unsigned int mapsize = stringsize + ranlibsize;
    2163   file_ptr archive_member_file_ptr;
     2165  archive_member_file_ptr;
    21642166  bfd *current = arch->archive_head;
    21652167  unsigned int count;
     
    21932195  /* Write the ar header for this item and the number of symbols.  */
    21942196
    2195   if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch)
     2197  if (bfd_ sizeof (struct ar_hdr), arch)
    21962198      != sizeof (struct ar_hdr))
    2197     return false;
    2198 
    2199   bfd_write_bigendian_4byte_int (arch, symbol_count);
     2199    return FALSE;
     2200
     2201  if (!bfd_write_bigendian_4byte_int (arch, symbol_count))
     2202    return FALSE;
    22002203
    22012204  /* Two passes, first write the file offsets for each symbol -
     
    22122215         out the object file's address in the archive.  */
    22132216
    2214       while (count < symbol_count && ((bfd *) (map[count]).pos) == current)
     2217      while (count < symbol_count && == current)
    22152218        {
    2216           bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr);
     2219          if (!bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr))
     2220            return FALSE;
    22172221          count++;
    22182222        }
     
    22302234      size_t len = strlen (*map[count].name) + 1;
    22312235
    2232       if (bfd_write (*map[count].name, 1, len, arch) != len)
    2233         return false;
     2236      if (bfd_ len, arch) != len)
     2237        return ;
    22342238    }
    22352239
     
    22382242  if (padit)
    22392243    {
    2240       if (bfd_write ("", 1, 1, arch) != 1)
    2241         return false;
    2242     }
    2243 
    2244   return true;
    2245 }
     2244      if (bfd_ 1, arch) != 1)
     2245        return ;
     2246    }
     2247
     2248  return ;
     2249}
Note: See TracChangeset for help on using the changeset viewer.