/* Assorted wastage to null-terminate the name, thanks AT&T! */
name = bfd_alloc(abfd, sizeof (hdr->s_name)+1);
if (name == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
strncpy(name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
external_sections = (char *)bfd_alloc(abfd, readsize);
if (!external_sections)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
goto fail;
}
return (bfd_target *)NULL;
}
-/* Turn a COFF file into a BFD, but fail with wrong_format if it is
+/* Turn a COFF file into a BFD, but fail with bfd_error_wrong_format if it is
not a COFF file. This is also used by ECOFF. */
bfd_target *
struct internal_filehdr internal_f;
struct internal_aouthdr internal_a;
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
/* figure out how much to read */
filhsz = bfd_coff_filhsz (abfd);
bfd_release (abfd, filehdr);
if (bfd_coff_bad_format_hook (abfd, &internal_f) == false) {
- bfd_error = wrong_format;
+ bfd_set_error (bfd_error_wrong_format);
return 0;
}
nscns =internal_f.f_nscns;
* (symbol_count + 1));
if (!newsyms)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_ptr->outsymbols = newsyms;
buf = bfd_alloc (abfd, symesz);
if (!buf)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
abort(); /* FIXME */
}
bfd_coff_swap_sym_out(abfd, &native->u.syment, buf);
buf = bfd_alloc (abfd, auxesz);
if (!buf)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
abort(); /* FIXME */
}
for (j = 0; j < native->u.syment.n_numaux; j++)
buff = bfd_alloc (abfd, linesz);
if (!buff)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return;
}
for (s = abfd->sections; s != (asection *) NULL; s = s->next) {
f = (struct foo *) bfd_alloc_by_size_t (abfd, sizeof (*f));
if (!f)
{
- bfd_error = no_error;
+ bfd_set_error (bfd_error_no_error);
return NULL;
}
memset ((char *) f, 0, sizeof (*f));
if (bfd_read((char *) string_table_size_buffer,
sizeof(string_table_size_buffer),
1, abfd) != sizeof(string_table_size)) {
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return (NULL);
} /* on error */
string_table_size = bfd_h_get_32(abfd, (bfd_byte *) string_table_size_buffer);
if ((string_table = (PTR) bfd_alloc(abfd, string_table_size -= 4)) == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (NULL);
} /* on mallocation error */
if (bfd_read(string_table, string_table_size, 1, abfd) != string_table_size) {
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return (NULL);
}
return string_table;
asection *sect = bfd_get_section_by_name (abfd, ".debug");
if (!sect) {
- bfd_error = no_debug_section;
+ bfd_set_error (bfd_error_no_debug_section);
return NULL;
}
debug_section = (PTR) bfd_alloc (abfd,
bfd_get_section_size_before_reloc (sect));
if (debug_section == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
if (bfd_read (debug_section,
bfd_get_section_size_before_reloc (sect), 1, abfd)
!= bfd_get_section_size_before_reloc(sect)) {
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return NULL;
}
bfd_seek (abfd, position, SEEK_SET);
}
if ((newname = (PTR) bfd_alloc(abfd, len+1)) == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (NULL);
}
strncpy(newname, name, len);
return obj_raw_syments(abfd);
}
if ((size = bfd_get_symcount(abfd) * sizeof(combined_entry_type)) == 0) {
- bfd_error = no_symbols;
+ bfd_set_error (bfd_error_no_symbols);
return (NULL);
}
internal = (combined_entry_type *)bfd_alloc(abfd, size);
if (!internal)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
internal_end = internal + bfd_get_symcount(abfd);
raw = bfd_alloc(abfd,raw_size);
if (!raw)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1
|| bfd_read(raw, raw_size, 1, abfd) != raw_size) {
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return (NULL);
}
/* mark the end of the symbols */
} /* possible lengths of this string. */
if ((newstring = (PTR) bfd_alloc(abfd, ++i)) == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (NULL);
} /* on error */
memset(newstring, 0, i);
sec_ptr asect)
{
if (bfd_get_format(abfd) != bfd_object) {
- bfd_error = invalid_operation;
+ bfd_set_error (bfd_error_invalid_operation);
return 0;
}
return (asect->reloc_count + 1) * sizeof(arelent *);
{
coff_symbol_type *new = (coff_symbol_type *) bfd_alloc(abfd, sizeof(coff_symbol_type));
if (new == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (NULL);
} /* on error */
memset (new, 0, sizeof *new);
{
coff_symbol_type *new = (coff_symbol_type *) bfd_alloc(abfd, sizeof(coff_symbol_type));
if (new == NULL) {
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (NULL);
} /* on error */
/* @@ This shouldn't be using a constant multiplier. */
new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
if (!new->native)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return (NULL);
} /* on error */
new->symbol.section = &bfd_debug_section;