bfd_set_error (bfd_error_no_memory);
static const char *normalize PARAMS ((bfd *, const char *file));static struct areltdata *bfd_ar_hdr_from_filesystem PARAMS ((bfd *abfd,							     const char *));boolean_bfd_generic_mkarchive (abfd)     bfd *abfd;{  abfd->tdata.aout_ar_data = ((struct artdata *)			      bfd_zalloc (abfd, sizeof (struct artdata)));  if (bfd_ardata (abfd) == NULL)    {      bfd_set_error (bfd_error_no_memory);      return false;    }  bfd_ardata (abfd)->cache = NULL;  bfd_ardata (abfd)->archive_head = NULL;  bfd_ardata (abfd)->symdefs = NULL;  bfd_ardata (abfd)->extended_names = NULL;  bfd_ardata (abfd)->tdata = NULL;  return true;}/*FUNCTION	bfd_get_next_mapentSYNOPSIS	symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym);DESCRIPTION	Step through archive @var{abfd}'s symbol table (if it	has one).  Successively update @var{sym} with the next symbol's	information, returning that symbol's (internal) index into the	symbol table.	Supply <<BFD_NO_MORE_SYMBOLS>> as the @var{previous} entry to get	the first one; returns <<BFD_NO_MORE_SYMBOLS>> when you've already	got the last one.	A <<carsym>> is a canonical archive symbol.  The only	user-visible element is its name, a null-terminated string.*/symindexbfd_get_next_mapent (abfd, prev, entry)     bfd *abfd;     symindex prev;     carsym **entry;{  if (!bfd_has_map (abfd))    {      bfd_set_error (bfd_error_invalid_operation);      return BFD_NO_MORE_SYMBOLS;    }  if (prev == BFD_NO_MORE_SYMBOLS)    prev = 0;  else    ++prev;  if (prev >= bfd_ardata (abfd)->symdef_count)    return BFD_NO_MORE_SYMBOLS;  *entry = (bfd_ardata (abfd)->symdefs + prev);  return prev;}/* To be called by backends only */bfd *_bfd_create_empty_archive_element_shell (obfd)     bfd *obfd;{  bfd *nbfd;  nbfd = _bfd_new_bfd_contained_in (obfd);  if (nbfd == NULL)    {      bfd_set_error (bfd_error_no_memory);      return NULL;    }  return nbfd;}/*FUNCTION	bfd_set_archive_headSYNOPSIS	boolean bfd_set_archive_head(bfd *output, bfd *new_head);DESCRIPTION	Set the head of the chain of	BFDs contained in the archive @var{output} to @var{new_head}.*/booleanbfd_set_archive_head (output_archive, new_head)     bfd *output_archive;     bfd *new_head;{  output_archive->archive_head = new_head;  return true;}bfd *_bfd_look_for_bfd_in_cache (arch_bfd, filepos)     bfd *arch_bfd;     file_ptr filepos;{  struct ar_cache *current;  for (current = bfd_ardata (arch_bfd)->cache; current != NULL;       current = current->next)    if (current->ptr == filepos)      return current->arelt;  return NULL;}/* Kind of stupid to call cons for each one, but we don't do too many */boolean_bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt)     bfd *arch_bfd, *new_elt;     file_ptr filepos;{  struct ar_cache *new_cache = ((struct ar_cache *)				bfd_zalloc (arch_bfd,					    sizeof (struct ar_cache)));  if (new_cache == NULL)    {      bfd_set_error (bfd_error_no_memory);      return false;    }  new_cache->ptr = filepos;  new_cache->arelt = new_elt;  new_cache->next = (struct ar_cache *) NULL;  if (bfd_ardata (arch_bfd)->cache == NULL)    bfd_ardata (arch_bfd)->cache = new_cache;  else    {      struct ar_cache *current = bfd_ardata (arch_bfd)->cache;      while (current->next != NULL)	current = current->next;      current->next = new_cache;    }  return true;}/* The name begins with space.  Hence the rest of the name is an index into   the string table. */static char *get_extended_arelt_filename (arch, name)     bfd *arch;     const char *name;{  unsigned long index = 0;  /* Should extract string so that I can guarantee not to overflow into     the next region, but I'm too lazy. */  errno = 0;  /* Skip first char, which is '/' in SVR4 or ' ' in some other variants. */  index = strtol (name + 1, NULL, 10);  if (errno != 0)    {      bfd_set_error (bfd_error_malformed_archive);      return NULL;    }  return bfd_ardata (arch)->extended_names + index;}/* This functions reads an arch header and returns an areltdata pointer, or   NULL on error.   Presumes the file pointer is already in the right place (ie pointing   to the ar_hdr in the file).   Moves the file pointer; on success it   should be pointing to the front of the file contents; on failure it   could have been moved arbitrarily.*/PTR_bfd_generic_read_ar_hdr (abfd)     bfd *abfd;{#ifndef errno  extern int errno;#endif  struct ar_hdr hdr;  char *hdrp = (char *) &hdr;  unsigned int parsed_size;  struct areltdata *ared;  char *filename = NULL;  unsigned int namelen = 0;  unsigned int allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);  char *allocptr = 0;  if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)      != sizeof (struct ar_hdr))    {      if (bfd_get_error () != bfd_error_system_call)	bfd_set_error (bfd_error_no_more_archived_files);      return NULL;    }  if (strncmp (hdr.ar_fmag, ARFMAG, 2))    {      bfd_set_error (bfd_error_malformed_archive);      return NULL;    }  errno = 0;  parsed_size = strtol (hdr.ar_size, NULL, 10);  if (errno != 0)    {      bfd_set_error (bfd_error_malformed_archive);      return NULL;    }  /* Extract the filename from the archive - there are two ways to     specify an extendend name table, either the first char of the     name is a space, or it's a slash.  */  if ((hdr.ar_name[0] == '/'       || (hdr.ar_name[0] == ' '	   && memchr (hdr.ar_name, '/', ar_maxnamelen (abfd)) == NULL))      && bfd_ardata (abfd)->extended_names != NULL)    {      filename = get_extended_arelt_filename (abfd, hdr.ar_name);      if (filename == NULL)	{	  bfd_set_error (bfd_error_malformed_archive);	  return NULL;	}    }  /* BSD4.4-style long filename.     Only implemented for reading, so far! */  else if (hdr.ar_name[0] == '#' && hdr.ar_name[1] == '1'	   && hdr.ar_name[2] == '/' && isdigit (hdr.ar_name[3]))    {      /* BSD-4.4 extended name */      namelen = atoi (&hdr.ar_name[3]);      allocsize += namelen + 1;      parsed_size -= namelen;      allocptr = bfd_zalloc (abfd, allocsize);      if (allocptr == NULL)	{	  bfd_set_error (bfd_error_no_memory);	  return NULL;	}      filename = (allocptr		  + sizeof (struct areltdata)		  + sizeof (struct ar_hdr));      if (bfd_read (filename, 1, namelen, abfd) != namelen)	{	  if (bfd_get_error () != bfd_error_system_call)	    bfd_set_error (bfd_error_no_more_archived_files);	  return NULL;	}      filename[namelen] = '\0';    }  else    {      /* We judge the end of the name by looking for '/' or ' '.	 Note:  The SYSV format (terminated by '/') allows embedded	 spaces, so only look for ' ' if we don't find '/'. */      namelen = 0;      while (hdr.ar_name[namelen] != '\0' &&	     hdr.ar_name[namelen] != '/')	{	  namelen++;	  if (namelen == (unsigned) ar_maxnamelen (abfd))	    {	      namelen = 0;	      while (hdr.ar_name[namelen] != ' '		     && namelen < (unsigned) ar_maxnamelen (abfd))		namelen++;	      break;	    }	}      allocsize += namelen + 1;    }  if (!allocptr)    {      allocptr = bfd_zalloc (abfd, allocsize);      if (allocptr == NULL)	{	  bfd_set_error (bfd_error_no_memory);	  return NULL;	}    }  ared = (struct areltdata *) allocptr;  ared->arch_header = allocptr + sizeof (struct areltdata);  memcpy ((char *) ared->arch_header, (char *) &hdr, sizeof (struct ar_hdr));  ared->parsed_size = parsed_size;  if (filename != NULL)    ared->filename = filename;  else    {      ared->filename = allocptr + (sizeof (struct areltdata) +				   sizeof (struct ar_hdr));      if (namelen)	memcpy (ared->filename, hdr.ar_name, namelen);      ared->filename[namelen] = '\0';    }  return (PTR) ared;}/* This is an internal function; it's mainly used when indexing   through the archive symbol table, but also used to get the next   element, since it handles the bookkeeping so nicely for us.  */bfd *_bfd_get_elt_at_filepos (archive, filepos)     bfd *archive;     file_ptr filepos;{  struct areltdata *new_areldata;  bfd *n_nfd;  n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);  if (n_nfd)    return n_nfd;  if (0 > bfd_seek (archive, filepos, SEEK_SET))    return NULL;  if ((new_areldata = (struct areltdata *) _bfd_read_ar_hdr (archive)) == NULL)    return NULL;  n_nfd = _bfd_create_empty_archive_element_shell (archive);  if (n_nfd == NULL)    {      bfd_release (archive, (PTR) new_areldata);      return NULL;    }  n_nfd->origin = bfd_tell (archive);  n_nfd->arelt_data = (PTR) new_areldata;  n_nfd->filename = new_areldata->filename;  if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd))    return n_nfd;  /* huh? */  bfd_release (archive, (PTR) n_nfd);  bfd_release (archive, (PTR) new_areldata);  return NULL;}/*FUNCTION	bfd_get_elt_at_indexSYNOPSIS	bfd *bfd_get_elt_at_index(bfd *archive, int index);DESCRIPTION	Return the BFD which is referenced by the symbol in @var{archive}	indexed by @var{index}.  @var{index} should have been returned by	<<bfd_get_next_mapent>> (q.v.).*/bfd *bfd_get_elt_at_index (abfd, index)     bfd *abfd;     int index;{  carsym *entry;  entry = bfd_ardata (abfd)->symdefs + index;  return _bfd_get_elt_at_filepos (abfd, entry->file_offset);}/*FUNCTION	bfd_openr_next_archived_fileSYNOPSIS	bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous);DESCRIPTION	Provided a BFD, @var{archive}, containing an archive and NULL, open	an input BFD on the first contained element and returns that.	Subsequent calls should pass	the archive and the previous return value to return a created	BFD to the next contained element. NULL is returned when there	are no more.*/bfd *bfd_openr_next_archived_file (archive, last_file)     bfd *archive;     bfd *last_file;{  if ((bfd_get_format (archive) != bfd_archive) ||      (archive->direction == write_direction))    {      bfd_set_error (bfd_error_invalid_operation);      return NULL;    }  return BFD_SEND (archive,		   openr_next_archived_file,		   (archive,		    last_file));}bfd *bfd_generic_openr_next_archived_file (archive, last_file)     bfd *archive;     bfd *last_file;{  file_ptr filestart;  if (!last_file)    filestart = bfd_ardata (archive)->first_file_filepos;  else    {      unsigned int size = arelt_size (last_file);      /* Pad to an even boundary...	 Note that last_file->origin can be odd in the case of	 BSD-4.4-style element with a long odd size. */      filestart = last_file->origin + size;      filestart += filestart % 2;    }  return _bfd_get_elt_at_filepos (archive, filestart);}const bfd_target *bfd_generic_archive_p (abfd)     bfd *abfd;{  struct artdata *tdata_hold;  char armag[SARMAG + 1];  tdata_hold = abfd->tdata.aout_ar_data;  if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)    {      if (bfd_get_error () != bfd_error_system_call)	bfd_set_error (bfd_error_wrong_format);      return NULL;    }#ifdef GNU960  if (strncmp (armag, BFD_GNU960_ARMAG (abfd), SARMAG) != 0)    return 0;#else  if (strncmp (armag, ARMAG, SARMAG) != 0 &&      strncmp (armag, ARMAGB, SARMAG) != 0)    return 0;#endif  /* We are setting bfd_ardata(abfd) here, but since bfd_ardata     involves a cast, we can't do it as the left operand of assignment. */  abfd->tdata.aout_ar_data = ((struct artdata *)			      bfd_zalloc (abfd, sizeof (struct artdata)));  if (bfd_ardata (abfd) == NULL)    {      bfd_set_error (bfd_error_no_memory);      return NULL;    }  bfd_ardata (abfd)->first_file_filepos = SARMAG;  bfd_ardata (abfd)->cache = NULL;  bfd_ardata (abfd)->archive_head = NULL;  bfd_ardata (abfd)->symdefs = NULL;  bfd_ardata (abfd)->extended_names = NULL;  bfd_ardata (abfd)->tdata = NULL;  if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))    {      bfd_release (abfd, bfd_ardata (abfd));      abfd->tdata.aout_ar_data = tdata_hold;      return NULL;    }  if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))    {      bfd_release (abfd, bfd_ardata (abfd));      abfd->tdata.aout_ar_data = tdata_hold;      return NULL;    }  if (bfd_has_map (abfd))    {      bfd *first;      /* This archive has a map, so we may presume that the contents	 are object files.  Make sure that the first file in the	 archive can be recognized as an object file for this target.	 If not, assume that this is the wrong format.	 This is done because any normal format will recognize any	 normal archive, regardless of the format of the object files.	 We do accept an empty archive.  */      first = bfd_openr_next_archived_file (abfd, (bfd *) NULL);      if (first != NULL)	{	  boolean fail;	  first->target_defaulted = false;	  fail = false;	  if (! bfd_check_format (first, bfd_object))	    fail = true;	  else if (first->xvec != abfd->xvec)	    {	      bfd_set_error (bfd_error_wrong_format);	      fail = true;	    }	  if (fail)	    {	      bfd_error_type err;	      err = bfd_get_error ();	      (void) bfd_close (first);	      bfd_release (abfd, bfd_ardata (abfd));	      abfd->tdata.aout_ar_data = tdata_hold;	      bfd_set_error (err);	      return NULL;	    }	  /* We ought to close first here, but we can't, because we             have no way to remove it from the archive cache.  FIXME.  */	}    }  return abfd->xvec;}/* Some constants for a 32 bit BSD archive structure.  We do not   support 64 bit archives presently; so far as I know, none actually   exist.  Supporting them would require changing these constants, and   changing some bfd_h_get_32 to bfd_h_get_64.  *//* The size of an external symdef structure.  */#define BSD_SYMDEF_SIZE 8/* The offset from the start of a symdef structure to the file offset.  */#define BSD_SYMDEF_OFFSET_SIZE 4/* The size of the symdef count.  */#define BSD_SYMDEF_COUNT_SIZE 4/* The size of the string count.  */#define BSD_STRING_COUNT_SIZE 4/* Returns false on error, true otherwise */static booleando_slurp_bsd_armap (abfd)     bfd *abfd;{  struct areltdata *mapdata;  unsigned int counter;  bfd_byte *raw_armap, *rbase;  struct artdata *ardata = bfd_ardata (abfd);  char *stringbase;  unsigned int parsed_size;  carsym *set;  mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);  if (mapdata == NULL)    return false;  parsed_size = mapdata->parsed_size;  bfd_release (abfd, (PTR) mapdata);	/* Don't need it any more. */  raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);  if (raw_armap == (bfd_byte *) NULL)    {      bfd_set_error (bfd_error_no_memory);      return false;    }  if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)    {      if (bfd_get_error () != bfd_error_system_call)	bfd_set_error (bfd_error_malformed_archive);    byebye:      bfd_release (abfd, (PTR) raw_armap);      return false;    }  ardata->symdef_count = bfd_h_get_32 (abfd, raw_armap) / BSD_SYMDEF_SIZE;  if (ardata->symdef_count * BSD_SYMDEF_SIZE >      parsed_size - BSD_SYMDEF_COUNT_SIZE)    {      /* Probably we're using the wrong byte ordering.  */      bfd_set_error (bfd_error_wrong_format);      goto byebye;    }  ardata->cache = 0;  rbase = raw_armap + BSD_SYMDEF_COUNT_SIZE;  stringbase = ((char *) rbase		+ ardata->symdef_count * BSD_SYMDEF_SIZE		+ BSD_STRING_COUNT_SIZE);  ardata->symdefs = (carsym *) bfd_alloc (abfd,					  (ardata->symdef_count					   * sizeof (carsym)));  if (!ardata->symdefs)    {      bfd_set_error (bfd_error_no_memory);      return false;    }  for (counter = 0, set = ardata->symdefs;       counter < ardata->symdef_count;       counter++, set++, rbase += BSD_SYMDEF_SIZE)    {      set->name = bfd_h_get_32 (abfd, rbase) + stringbase;      set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);    }  ardata->first_file_filepos = bfd_tell (abfd);  /* Pad to an even boundary if you have to */  ardata->first_file_filepos += (ardata->first_file_filepos) % 2;  /* FIXME, we should provide some way to free raw_ardata when     we are done using the strings from it.  For now, it seems     to be allocated on an obstack anyway... */  bfd_has_map (abfd) = true;  return true;}/* Returns false on error, true otherwise */static booleando_slurp_coff_armap (abfd)     bfd *abfd;{  struct areltdata *mapdata;  int *raw_armap, *rawptr;  struct artdata *ardata = bfd_ardata (abfd);  char *stringbase;  unsigned int stringsize;  unsigned int parsed_size;  carsym *carsyms;  unsigned int nsymz;		/* Number of symbols in armap. */  bfd_vma (*swap) PARAMS ((const bfd_byte *));  char int_buf[sizeof (long)];  unsigned int carsym_size, ptrsize, i;  mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);  if (mapdata == NULL)    return false;  parsed_size = mapdata->parsed_size;  bfd_release (abfd, (PTR) mapdata);	/* Don't need it any more. */  if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)    {      if (bfd_get_error () != bfd_error_system_call)	bfd_set_error (bfd_error_malformed_archive);      return false;    }  /* It seems that all numeric information in a coff archive is always     in big endian format, nomatter the host or target. */  swap = bfd_getb32;  nsymz = bfd_getb32 ((PTR) int_buf);  stringsize = parsed_size - (4 * nsymz) - 4;#if 1  /* ... except that some archive formats are broken, and it may be our     fault - the i960 little endian coff sometimes has big and sometimes     little, because our tools changed.  Here's a horrible hack to clean     up the crap.  */  if (stringsize > 0xfffff)    {      /* This looks dangerous, let's do it the other way around */      nsymz = bfd_getl32 ((PTR) int_buf);      stringsize = parsed_size - (4 * nsymz) - 4;      swap = bfd_getl32;    }#endif  /* The coff armap must be read sequentially.  So we construct a     bsd-style one in core all at once, for simplicity. */  carsym_size = (nsymz * sizeof (carsym));  ptrsize = (4 * nsymz);  ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);  if (ardata->symdefs == NULL)    {      bfd_set_error (bfd_error_no_memory);      return false;    }  carsyms = ardata->symdefs;  stringbase = ((char *) ardata->symdefs) + carsym_size;  /* Allocate and read in the raw offsets. */  raw_armap = (int *) bfd_alloc (abfd, ptrsize);  if (raw_armap == NULL)    {      bfd_set_error (bfd_error_no_memory);      goto release_symdefs;    }  if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize      || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)    {      if (bfd_get_error () != bfd_error_system_call)	bfd_set_error (bfd_error_malformed_archive);      goto release_raw_armap;    }  /* OK, build the carsyms */  for (i = 0; i < nsymz; i++)    {      rawptr = raw_armap + i;      carsyms->file_offset = swap ((PTR) rawptr);      carsyms->name = stringbase;      stringbase += strlen (stringbase) + 1;      carsyms++;    }  *stringbase = 0;  ardata->symdef_count = nsymz;  ardata->first_file_filepos = bfd_tell (abfd);  /* Pad to an even boundary if you have to */  ardata->first_file_filepos += (ardata->first_file_filepos) % 2;  bfd_has_map (abfd) = true;  bfd_release (abfd, (PTR) raw_armap);  /* Check for a second archive header (as used by PE) */  {    struct areltdata *tmp;    bfd_seek (abfd,   ardata->first_file_filepos, SEEK_SET);    tmp = (struct areltdata *) _bfd_read_ar_hdr (abfd);    if (tmp != NULL)       {	if (tmp->arch_header[0] == '/'	    && tmp->arch_header[1] == ' ') 	  {	    ardata->first_file_filepos +=	      (tmp->parsed_size + sizeof(struct ar_hdr) + 1) & ~1;	  }	bfd_release (abfd, tmp);      }  }  return true;release_raw_armap:  bfd_release (abfd, (PTR) raw_armap);release_symdefs:  bfd_release (abfd, (PTR) (ardata)->symdefs);  return false;}/* This routine can handle either coff-style or bsd-style armaps.   Returns false on error, true otherwise */booleanbfd_slurp_armap (abfd)     bfd *abfd;{  char nextname[17];  int i = bfd_read ((PTR) nextname, 1, 16, abfd);  if (i == 0)    return true;  if (i != 16)    return false;  if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)    return false;  if (!strncmp (nextname, "__.SYMDEF       ", 16)      || !strncmp (nextname, "__.SYMDEF/      ", 16)) /* old Linux archives */    return do_slurp_bsd_armap (abfd);  else if (!strncmp (nextname, "/               ", 16))    return do_slurp_coff_armap (abfd);  bfd_has_map (abfd) = false;  return true;}/* Returns false on error, true otherwise *//* flavor 2 of a bsd armap, similar to bfd_slurp_bsd_armap except the   header is in a slightly different order and the map name is '/'.   This flavour is used by hp300hpux. */#define HPUX_SYMDEF_COUNT_SIZE 2booleanbfd_slurp_bsd_armap_f2 (abfd)     bfd *abfd;{  struct areltdata *mapdata;  char nextname[17];  unsigned int counter;  bfd_byte *raw_armap, *rbase;  struct artdata *ardata = bfd_ardata (abfd);  char *stringbase;  unsigned int stringsize;  carsym *set;  int i = bfd_read ((PTR) nextname, 1, 16, abfd);  if (i == 0)    return true;  if (i != 16)    return false;  /* The archive has at least 16 bytes in it */  if (bfd_seek (abfd, -16L, SEEK_CUR) != 0)    return false;  if (!strncmp (nextname, "__.SYMDEF       ", 16)      || !strncmp (nextname, "__.SYMDEF/      ", 16)) /* old Linux archives */    return do_slurp_bsd_armap (abfd);  if (strncmp (nextname, "/               ", 16))    {      bfd_has_map (abfd) = false;      return true;    }  mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);  if (mapdata == NULL)    return false;  raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);  if (raw_armap == NULL)    {      bfd_set_error (bfd_error_no_memory);    byebye:      bfd_release (abfd, (PTR) mapdata);      return false;    }  if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) !=      mapdata->parsed_size)    {      if (bfd_get_error () != bfd_error_system_call)	bfd_set_error (bfd_error_malformed_archive);    byebyebye:      bfd_release (abfd, (PTR) raw_armap);      goto byebye;    }  ardata->symdef_count = bfd_h_get_16 (abfd, (PTR) raw_armap);  if (ardata->symdef_count * BSD_SYMDEF_SIZE      > mapdata->parsed_size - HPUX_SYMDEF_COUNT_SIZE)    {      /* Probably we're using the wrong byte ordering.  */      bfd_set_error (bfd_error_wrong_format);      goto byebyebye;    }  ardata->cache = 0;  stringsize = bfd_h_get_32 (abfd, raw_armap + HPUX_SYMDEF_COUNT_SIZE);  /* skip sym count and string sz */  stringbase = ((char *) raw_armap		+ HPUX_SYMDEF_COUNT_SIZE		+ BSD_STRING_COUNT_SIZE);  rbase = (bfd_byte *) stringbase + stringsize;  ardata->symdefs = (carsym *) bfd_alloc (abfd,					  (ardata->symdef_count					   * BSD_SYMDEF_SIZE));  if (!ardata->symdefs)    {      bfd_set_error (bfd_error_no_memory);      return false;    }  for (counter = 0, set = ardata->symdefs;       counter < ardata->symdef_count;       counter++, set++, rbase += BSD_SYMDEF_SIZE)    {      set->name = bfd_h_get_32 (abfd, rbase) + stringbase;      set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);    }  ardata->first_file_filepos = bfd_tell (abfd);  /* Pad to an even boundary if you have to */  ardata->first_file_filepos += (ardata->first_file_filepos) % 2;  /* FIXME, we should provide some way to free raw_ardata when     we are done using the strings from it.  For now, it seems     to be allocated on an obstack anyway... */  bfd_has_map (abfd) = true;  return true;}/** Extended name table.  Normally archives support only 14-character filenames.  Intel has extended the format: longer names are stored in a special  element (the first in the archive, or second if there is an armap);  the name in the ar_hdr is replaced by <space><index into filename  element>.  Index is the P.R. of an int (decimal).  Data General have  extended the format by using the prefix // for the special element *//* Returns false on error, true otherwise */boolean_bfd_slurp_extended_name_table (abfd)     bfd *abfd;{  char nextname[17];  struct areltdata *namedata;  /* FIXME:  Formatting sucks here, and in case of failure of BFD_READ,     we probably don't want to return true.  */  bfd_seek (abfd, bfd_ardata (abfd)->first_file_filepos, SEEK_SET);  if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16)    {      if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)	return false;      if (strncmp (nextname, "ARFILENAMES/    ", 16) != 0 &&	  strncmp (nextname, "//              ", 16) != 0)	{	  bfd_ardata (abfd)->extended_names = NULL;	  return true;	}      namedata = (struct areltdata *) _bfd_read_ar_hdr (abfd);      if (namedata == NULL)	return false;      bfd_ardata (abfd)->extended_names =	bfd_zalloc (abfd, namedata->parsed_size);      if (bfd_ardata (abfd)->extended_names == NULL)	{	  bfd_set_error (bfd_error_no_memory);	byebye:	  bfd_release (abfd, (PTR) namedata);	  return false;	}      if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1,		    namedata->parsed_size, abfd) != namedata->parsed_size)	{	  if (bfd_get_error () != bfd_error_system_call)	    bfd_set_error (bfd_error_malformed_archive);	  bfd_release (abfd, (PTR) (bfd_ardata (abfd)->extended_names));	  bfd_ardata (abfd)->extended_names = NULL;	  goto byebye;	}      /* Since the archive is supposed to be printable if it contains	 text, the entries in the list are newline-padded, not null	 padded. In SVR4-style archives, the names also have a	 trailing '/'.  DOS/NT created archive often have \ in them	 We'll fix all problems here..  */      {	char *temp = bfd_ardata (abfd)->extended_names;	char *limit = temp + namedata->parsed_size;	for (; temp < limit; ++temp) {	  if (*temp == '\012')	    temp[temp[-1] == '/' ? -1 : 0] = '\0';	  if (*temp == '\\')	    *temp = '/';	}      }      /* Pad to an even boundary if you have to */      bfd_ardata (abfd)->first_file_filepos = bfd_tell (abfd);      bfd_ardata (abfd)->first_file_filepos +=	(bfd_ardata (abfd)->first_file_filepos) % 2;      /* FIXME, we can't release namedata here because it was allocated	 below extended_names on the obstack... */      /* bfd_release (abfd, namedata); */    }  return true;}#ifdef VMS/* Return a copy of the stuff in the filename between any :]> and a   semicolon */static const char *normalize (abfd, file)     bfd *abfd;     const char *file;{  CONST char *first;  CONST char *last;  char *copy;  first = file + strlen (file) - 1;  last = first + 1;  while (first != file)    {      if (*first == ';')	last = first;      if (*first == ':' || *first == ']' || *first == '>')	{	  first++;	  break;	}      first--;    }  copy = (char *) bfd_alloc (abfd, last - first + 1);  if (copy == NULL)    {      bfd_set_error (bfd_error_no_memory);      return NULL;    }  memcpy (copy, first, last - first);  copy[last - first] = 0;  return copy;}#elsestatic const char *normalize (abfd, file)     bfd *abfd;     const char *file;{  const char *filename = strrchr (file, '/');  if (filename != (char *) NULL)    filename++;  else    filename = file;  return filename;}