ss = (struct strtab *) malloc (sizeof (struct strtab));
if (!ss)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
ss->tab = malloc (1);
if (!ss->tab)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
*ss->tab = 0;
sdata = (struct bfd_elf_section_data *) bfd_alloc (abfd, sizeof (*sdata));
if (!sdata)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
sec->used_by_bfd = (PTR) sdata;
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
strcpy (name, namebuf);
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
strcpy (name, namebuf);
/* Read in the ELF header in external format. */
if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
- goto got_system_call_error;
+ goto got_system_call;
/* Now check to see if we have a valid ELF file, and one that BFD can
make use of. The magic number must match, the address size ('class')
if (!i_shdrp || !elf_elfsections(abfd))
goto got_no_memory_error;
if (bfd_seek (abfd, i_ehdrp->e_shoff, SEEK_SET) == -1)
- goto got_system_call_error;
+ goto got_system_call;
for (shindex = 0; shindex < i_ehdrp->e_shnum; shindex++)
{
if (bfd_read ((PTR) & x_shdr, sizeof x_shdr, 1, abfd) != sizeof (x_shdr))
- goto got_system_call_error;
+ goto got_system_call;
elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
elf_elfsections(abfd)[shindex] = i_shdrp + shindex;
/* If we are going to use goto's to avoid duplicating error setting
and return(NULL) code, then this at least makes it more maintainable. */
- got_system_call_error:
- bfd_error = system_call_error;
+ got_system_call:
+ bfd_set_error (bfd_error_system_call);
goto got_no_match;
got_wrong_format_error:
- bfd_error = wrong_format;
+ bfd_set_error (bfd_error_wrong_format);
goto got_no_match;
got_no_memory_error:
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
goto got_no_match;
got_no_match:
elf_tdata (abfd) = preserved_tdata;
rela_hdr->contents = (void *) bfd_alloc (abfd, rela_hdr->sh_size);
if (!rela_hdr->contents)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
abort(); /* FIXME */
}
if (sect_syms == 0)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
asymbol *sym = bfd_make_empty_symbol (abfd);
if (!sym)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
sym->the_bfd = abfd;
(num_sections + 1) * sizeof (asymbol *));
if (!syms)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
= (Elf_Sym_Extra *) bfd_alloc (abfd, symcount * sizeof (Elf_Sym_Extra));
if (!sym_extra)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_alloc (abfd, section_number * sizeof (Elf_Internal_Shdr *));
if (!i_shdrp)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
elf_elfsections(abfd) = i_shdrp;
s = (struct seg_info *) bfd_alloc (abfd, sizeof (struct seg_info));
if (!s)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
s->next = seg;
n_segs * sizeof (Elf_Internal_Phdr));
if (!phdr)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
abort(); /* FIXME */
}
elf_tdata (abfd)->phdr = phdr;
bfd_alloc (abfd, (1 + symcount) * sizeof (Elf_External_Sym));
if (!outbound_syms)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
/* now generate the data (for "contents") */
bfd_alloc (abfd, sizeof (*x_shdrp) * (i_ehdrp->e_shnum));
if (!x_shdrp)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
if ((abfd->flags & DYNAMIC) != 0)
{
fprintf (stderr, "Writing ELF dynamic objects is not supported\n");
- bfd_error = wrong_format;
+ bfd_set_error (bfd_error_wrong_format);
return false;
}
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
{
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return false;
}
x_symp = (Elf_External_Sym *) malloc (symcount * sizeof (Elf_External_Sym));
if (!symbase || !x_symp)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
!= symcount * sizeof (Elf_External_Sym))
{
free ((PTR) x_symp);
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return false;
}
/* Skip first symbol, which is a null dummy. */
if (!native_relocs)
if (!reloc_cache)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_read ((PTR) native_relocs,
if (!reloc_cache)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_alloc (abfd, asect->reloc_count * sizeof (Elf_External_Rel));
if (!native_relocs)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_read ((PTR) native_relocs,
if (!reloc_cache)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof (elf_symbol_type));
if (!newsym)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
else
if (core_bfd->xvec != exec_bfd->xvec)
{
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return false;
}
}
else if (hdr->p_filesz > 0)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return false;
}
return true;
if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
{
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return NULL;
}
if (elf_file_p (&x_ehdr) == false)
{
wrong:
- bfd_error = wrong_format;
+ bfd_set_error (bfd_error_wrong_format);
return NULL;
}
(struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
if (elf_tdata (abfd) == NULL)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
if (!i_phdrp)
{
- bfd_error = no_memory;
+ bfd_set_error (bfd_error_no_memory);
return NULL;
}
if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) == -1)
{
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return NULL;
}
for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
if (bfd_read ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd)
!= sizeof (x_phdr))
{
- bfd_error = system_call_error;
+ bfd_set_error (bfd_error_system_call);
return NULL;
}
elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex);