/* BFD back-end for archive files (libraries).
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001
+ 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault.
spaces, so only look for ' ' if we don't find '/'. */
char *e;
- e = memchr (hdr.ar_name, '\0', ar_maxnamelen (abfd));
+ e = (char *) memchr (hdr.ar_name, '\0', ar_maxnamelen (abfd));
if (e == NULL)
{
- e = memchr (hdr.ar_name, '/', ar_maxnamelen (abfd));
+ e = (char *) memchr (hdr.ar_name, '/', ar_maxnamelen (abfd));
if (e == NULL)
- e = memchr (hdr.ar_name, ' ', ar_maxnamelen (abfd));
+ e = (char *) memchr (hdr.ar_name, ' ', ar_maxnamelen (abfd));
}
if (e != NULL)
char armag[SARMAG + 1];
bfd_size_type amt;
- tdata_hold = abfd->tdata.aout_ar_data;
-
if (bfd_bread ((PTR) armag, (bfd_size_type) SARMAG, abfd) != SARMAG)
{
if (bfd_get_error () != bfd_error_system_call)
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. */
- amt = sizeof (struct artdata);
- abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);
+ tdata_hold = bfd_ardata (abfd);
+ amt = sizeof (struct artdata);
+ bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd) == NULL)
- return NULL;
+ {
+ bfd_ardata (abfd) = tdata_hold;
+ return NULL;
+ }
bfd_ardata (abfd)->first_file_filepos = SARMAG;
bfd_ardata (abfd)->cache = NULL;
bfd_ardata (abfd)->extended_names = NULL;
bfd_ardata (abfd)->tdata = NULL;
- if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))
+ if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd))
+ || !BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
{
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = tdata_hold;
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
- 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;
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
+ bfd_ardata (abfd) = tdata_hold;
return NULL;
}
release bfd_ardata. FIXME. */
(void) bfd_close (first);
bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = tdata_hold;
#endif
bfd_set_error (bfd_error_wrong_object_format);
+ bfd_ardata (abfd) = tdata_hold;
return NULL;
}
/* And we ought to close `first' here too. */
if (makemap && hasobjects)
{
- if (_bfd_compute_and_write_armap (arch, (unsigned int) elength) != true)
+ if (! _bfd_compute_and_write_armap (arch, (unsigned int) elength))
return false;
}
current != (bfd *) NULL;
current = current->next, elt_no++)
{
- if ((bfd_check_format (current, bfd_object) == true)
- && ((bfd_get_file_flags (current) & HAS_SYMS)))
+ if (bfd_check_format (current, bfd_object)
+ && (bfd_get_file_flags (current) & HAS_SYMS) != 0)
{
long storage;
long symcount;
bfd_flush (arch);
if (bfd_stat (arch, &archstat) == -1)
{
- perror (_("Reading archive file mod timestamp"));
+ bfd_perror (_("Reading archive file mod timestamp"));
/* Can't read mod time for some reason. */
return true;
|| (bfd_bwrite (hdr.ar_date, (bfd_size_type) sizeof (hdr.ar_date), arch)
!= sizeof (hdr.ar_date)))
{
- /* FIXME: bfd can't call perror. */
- perror (_("Writing updated armap timestamp"));
+ bfd_perror (_("Writing updated armap timestamp"));
/* Some error while writing. */
return true;
!= sizeof (struct ar_hdr))
return false;
- bfd_write_bigendian_4byte_int (arch, symbol_count);
+ if (!bfd_write_bigendian_4byte_int (arch, symbol_count))
+ return false;
/* Two passes, first write the file offsets for each symbol -
remembering that each offset is on a two byte boundary. */
while (count < symbol_count && map[count].u.abfd == current)
{
- bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr);
+ if (!bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr))
+ return false;
count++;
}
/* Add size of this archive entry. */