+Sun Feb 6 20:04:10 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * elfcode.h (prep_headers, swap_out_syms): Check for NULL return
+ from bfd_new_strtab.
+ (elf_compute_section_file_positions): Check for false return from
+ swap_out_syms.
+
+ * linker.c (default_indirect_link_order): Check for NULL return
+ from bfd_get_relocated_section_contents.
+
+ * syms.c: Make example application in doc call xmalloc, not
+ bfd_xmalloc.
+
+ * aoutx.h (NAME(aout,slurp_symbol_table),
+ aout_link_get_symbols, NAME(aout,link_hash_table_create)):
+ * bout.c (b_out_slurp_reloc_table, b_out_squirt_out_relocs):
+ * ecoff.c (ecoff_bfd_link_hash_table_create):
+ * ecofflink.c (bfd_ecoff_debug_init):
+ * format.c (bfd_check_format_matches):
+ * linker.c (_bfd_generic_link_hash_table_create):
+ (_bfd_generic_final_link):
+ * reloc16.c (bfd_coff_reloc16_relax_section):
+ (bfd_coff_reloc16_get_relocated_section_contents):
+ * elf32-hppa.c (hppa_elf_build_arg_reloc_stub):
+ * elf32-mips.c (mips_elf_final_link):
+ * elfcode.h (bfd_new_strtab):
+ (bfd_add_2_to_strtab):
+ (elf_slurp_symbol_table):
+ (elf_corefile_note):
+ * libbfd.c (bfd_zmalloc):
+ Use malloc and check the result, instead of bfd_xmalloc.
+
Sat Feb 5 12:39:28 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
* config.bfd: Put m68*-*-sysv* line after m68*-*-sysv4*.
/* ELF executable support for BFD.
- Copyright 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
in "UNIX System V Release 4, Programmers Guide: ANSI C and
struct symbol_cache_entry **));
static void elf_map_symbols PARAMS ((bfd *));
-static void swap_out_syms PARAMS ((bfd *));
+static boolean swap_out_syms PARAMS ((bfd *));
#ifdef DEBUG
static void elf_debug_section PARAMS ((char *, int, Elf_Internal_Shdr *));
{
struct strtab *ss;
- ss = (struct strtab *) bfd_xmalloc (sizeof (struct strtab));
- ss->tab = bfd_xmalloc (1);
- BFD_ASSERT (ss->tab != 0);
+ ss = (struct strtab *) malloc (sizeof (struct strtab));
+ if (!ss)
+ {
+ bfd_error = no_memory;
+ return NULL;
+ }
+ ss->tab = malloc (1);
+ if (!ss->tab)
+ {
+ bfd_error = no_memory;
+ return NULL;
+ }
*ss->tab = 0;
ss->nentries = 0;
ss->length = 1;
if (ss->length)
ss->tab = realloc (ss->tab, ss->length + ln);
else
- ss->tab = bfd_xmalloc (ln);
+ ss->tab = malloc (ln);
BFD_ASSERT (ss->tab != 0);
strcpy (ss->tab + ss->length, str);
bfd_map_over_sections (abfd, fix_up_strtabs, 0); /* .stab/.stabstr &c */
- swap_out_syms (abfd);
+ if (swap_out_syms (abfd) == false)
+ return false;
assign_file_positions_except_relocs (abfd);
i_shdrp = elf_elfsections (abfd);
shstrtab = bfd_new_strtab (abfd);
+ if (!shstrtab)
+ return false;
+
elf_shstrtab (abfd) = shstrtab;
i_ehdrp->e_ident[EI_MAG0] = ELFMAG0;
return true;
}
-static void
+static boolean
swap_out_syms (abfd)
bfd *abfd;
{
Elf_External_Sym *outbound_syms;
int idx;
+ if (!stt)
+ return false;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
symtab_hdr->sh_type = SHT_SYMTAB;
symtab_hdr->sh_entsize = sizeof (Elf_External_Sym);
this_hdr->sh_addralign = 1;
this_hdr->size = 0;
}
+ return true;
}
static boolean
sym = symbase;
/* Temporarily allocate room for the raw ELF symbols. */
- x_symp = (Elf_External_Sym *) bfd_xmalloc (symcount * sizeof (Elf_External_Sym));
+ x_symp = (Elf_External_Sym *) malloc (symcount * sizeof (Elf_External_Sym));
+ if (!x_symp)
+ {
+ bfd_error = no_memory;
+ return false;
+ }
if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd)
!= symcount * sizeof (Elf_External_Sym))
asection *newsect;
if (hdr->p_filesz > 0
- && (buf = (char *) bfd_xmalloc (hdr->p_filesz)) != NULL
+ && (buf = (char *) malloc (hdr->p_filesz)) != NULL
&& bfd_seek (abfd, hdr->p_offset, SEEK_SET) != -1
&& bfd_read ((PTR) buf, hdr->p_filesz, 1, abfd) == hdr->p_filesz)
{
{
free (buf);
}
+ else if (hdr->p_filesz > 0)
+ {
+ bfd_error = no_memory;
+ return false;
+ }
return true;
}