if (bfd_ardata (abfd) == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
{
if (!bfd_has_map (abfd))
{
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return BFD_NO_MORE_SYMBOLS;
}
nbfd = _bfd_new_bfd_contained_in (obfd);
if (nbfd == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
return nbfd;
if (new_cache == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
index = strtol (name + 1, NULL, 10);
if (errno != 0)
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
return NULL;
}
if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)
!= sizeof (struct ar_hdr))
{
- bfd_error = no_more_archived_files;
+ bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
}
if (strncmp (hdr.ar_fmag, ARFMAG, 2))
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
return NULL;
}
parsed_size = strtol (hdr.ar_size, NULL, 10);
if (errno != 0)
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
return NULL;
}
filename = get_extended_arelt_filename (abfd, hdr.ar_name);
if (filename == NULL)
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
return NULL;
}
}
allocptr = bfd_zalloc (abfd, allocsize);
if (allocptr == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
filename = (allocptr
+ sizeof (struct ar_hdr));
if (bfd_read (filename, 1, namelen, abfd) != namelen)
{
- bfd_error = no_more_archived_files;
+ bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
}
filename[namelen] = '\0';
allocptr = bfd_zalloc (abfd, allocsize);
if (allocptr == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
}
return n_nfd;
if (0 > bfd_seek (archive, filepos, SEEK_SET))
- {
- bfd_error = system_call_error;
- return NULL;
- }
+ return NULL;
if ((new_areldata = _bfd_snarf_ar_hdr (archive)) == NULL)
return NULL;
if ((bfd_get_format (archive) != bfd_archive) ||
(archive->direction == write_direction))
{
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return NULL;
}
if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
{
- bfd_error = wrong_format;
+ bfd_set_error (bfd_error_wrong_format);
return NULL;
}
if (bfd_ardata (abfd) == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
if (raw_armap == (bfd_byte *) NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
byebye:
bfd_release (abfd, (PTR) raw_armap);
return false;
parsed_size - BSD_SYMDEF_COUNT_SIZE)
{
/* Probably we're using the wrong byte ordering. */
- bfd_error = wrong_format;
+ bfd_set_error (bfd_error_wrong_format);
goto byebye;
}
* sizeof (carsym)));
if (!ardata->symdefs)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
return false;
}
/* It seems that all numeric information in a coff archive is always
ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
if (ardata->symdefs == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
carsyms = ardata->symdefs;
raw_armap = (int *) bfd_alloc (abfd, ptrsize);
if (raw_armap == NULL)
{
- bfd_error = no_memory;
+ 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)
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
goto release_raw_armap;
}
raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
if (raw_armap == NULL)
{
- bfd_error = no_memory;
+ 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)
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
byebyebye:
bfd_release (abfd, (PTR) raw_armap);
goto byebye;
> mapdata->parsed_size - HPUX_SYMDEF_COUNT_SIZE)
{
/* Probably we're using the wrong byte ordering. */
- bfd_error = wrong_format;
+ bfd_set_error (bfd_error_wrong_format);
goto byebyebye;
}
* BSD_SYMDEF_SIZE));
if (!ardata->symdefs)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_zalloc (abfd, namedata->parsed_size);
if (bfd_ardata (abfd)->extended_names == NULL)
{
- bfd_error = no_memory;
+ 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)
{
- bfd_error = malformed_archive;
+ bfd_set_error (bfd_error_malformed_archive);
bfd_release (abfd, (PTR) (bfd_ardata (abfd)->extended_names));
bfd_ardata (abfd)->extended_names = NULL;
goto byebye;
if (!normal)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
thislen = strlen (normal);
*tabloc = bfd_zalloc (abfd, total_namelen);
if (*tabloc == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
if (!normal)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
thislen = strlen (normal);
struct ar_hdr *hdr = arch_hdr (current);
strcpy (strptr, normal);
strptr[thislen] = '\012';
- hdr->ar_name[0] = ' ';
+ hdr->ar_name[0] = ar_padchar (current);
/* We know there will always be enough room (one of the few
cases where you may safely use sprintf). */
sprintf ((hdr->ar_name) + 1, "%-d", (unsigned) (strptr - *tabloc));
if (stat (filename, &status) != 0)
{
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return NULL;
}
sizeof (struct areltdata));
if (ared == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
/* ar headers are space padded, not null padded! */
- memset (hdr, ' ', sizeof (struct ar_hdr));
+ memset ((PTR) hdr, ' ', sizeof (struct ar_hdr));
strncpy (hdr->ar_fmag, ARFMAG, 2);
if (abfd->arelt_data == NULL)
{
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return -1;
}
{
if (bfd_write_p (current))
{
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return false;
}
if (!current->arelt_data)
struct ar_hdr hdr;
memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
- sprintf (&(hdr.ar_name[0]), "ARFILENAMES/");
+ if (ar_padchar (arch) == '/')
+ sprintf (&(hdr.ar_name[0]), "//");
+ else
+ sprintf (&(hdr.ar_name[0]), "ARFILENAMES/");
sprintf (&(hdr.ar_size[0]), "%-10d", (int) elength);
hdr.ar_fmag[0] = '`';
hdr.ar_fmag[1] = '\012';
/* write ar header */
if (bfd_write ((char *) hdr, 1, sizeof (*hdr), arch) != sizeof (*hdr))
- {
- syserr:
- bfd_error = system_call_error;
- return false;
- }
+ return false;
if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
- goto syserr;
+ return false;
while (remaining)
{
unsigned int amt = DEFAULT_BUFFERSIZE;
errno = 0;
if (bfd_read (buffer, amt, 1, current) != amt)
{
- if (errno)
- goto syserr;
- /* Looks like a truncated archive. */
- bfd_error = malformed_archive;
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
return false;
}
if (bfd_write (buffer, amt, 1, arch) != amt)
- goto syserr;
+ return false;
remaining -= amt;
}
if ((arelt_size (current) % 2) == 1)
map = (struct orl *) malloc (orl_max * sizeof (struct orl));
if (map == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
if (first_name == NULL)
{
free (map);
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
{
free (map);
bfd_release (arch, first_name);
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
}
free (syms);
free (map);
bfd_release (arch, first_name);
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}