+2002-06-07 Alan Modra <amodra@bigpond.net.au>
+
+ * aoutx.h (NAME(aout,slurp_symbol_table)): Use bfd_zmalloc.
+ (NAME(aout,slurp_reloc_table)): Likewise.
+ * coff-mips.c (mips_relax_section): Use bfd_zalloc.
+ * coff-rs6000.c (xcoff_write_armap_big): Use bfd_zmalloc.
+ (xcoff_write_archive_contents_big): Likewise.
+ (xcoff_generate_rtinit): Likewise.
+ (xcoff_generate_rtinit): Likewise, and check error return.
+ * coff64-rs6000.c (xcoff64_generate_rtinit): Likewise.
+ * coffgen.c (coff_section_symbol): Use bfd_zalloc.
+ (coff_get_normalized_symtab): Likewise.
+ (coff_make_empty_symbol): Likewise.
+ (bfd_coff_set_symbol_class): Likewise.
+ * cofflink.c (coff_link_add_symbols): Likewise.
+ * ecoff.c (_bfd_ecoff_make_empty_symbol): Likewise.
+ * ecofflink.c (ecoff_write_shuffle): Use bfd_zmalloc.
+ (bfd_ecoff_write_accumulated_debug): Likewise.
+ * elf64-alpha.c (get_got_entry): Use bfd_zalloc.
+ * i386linux.c (bfd_i386linux_size_dynamic_sections): Likewise.
+ * i386lynx.c (NAME(lynx,slurp_reloc_table)): Use bfd_zmalloc.
+ * ieee.c (do_with_relocs): Use bfd_zalloc.
+ * m68klinux.c (bfd_m68klinux_size_dynamic_sections): Likewise.
+ * pdp11.c (NAME(aout,slurp_symbol_table)): Use bfd_zmalloc.
+ (NAME(aout,slurp_reloc_table)): Likewise.
+ (NAME(aout,squirt_out_relocs)): Don't memset when zalloc'd.
+ * reloc16.c (bfd_coff_reloc16_relax_section): Use bfd_zmalloc.
+ * som.c (som_build_and_write_symbol_table): Likewise.
+ (som_slurp_string_table): Likewise.
+ (som_slurp_symbol_table): Likewise.
+ (som_bfd_ar_write_symbol_stuff): Likewise.
+ * sparclinux.c (bfd_sparclinux_size_dynamic_sections): Use bfd_zalloc.
+ * sunos.c (bfd_sunos_size_dynamic_sections): Likewise.
+ * tekhex.c (find_chunk): Likewise. Get rid of unused "sname".
+ * vms-gsd.c (_bfd_vms_slurp_gsd): Use bfd_zmalloc.
+ * xcofflink.c (xcoff_link_add_symbols): Use bfd_zalloc/bfd_zmalloc.
+
2002-06-07 Alan Modra <amodra@bigpond.net.au>
* elf-bfd.h (struct bfd_elf_section_data <group_name>): Replace with
* elf32-arm.h (bfd_elf32_arm_get_bfd_for_interworking): Don't add glue
sections only record bfd.
- (bfd_elf32_arm_add_glue_sections_to_bfd): New function.
+ (bfd_elf32_arm_add_glue_sections_to_bfd): New function.
* bfd-in.h (bfd_elf32_arm_add_glue_sections_to_bfd): Declare it.
- * bfd-in2.h: Regenerate.
+ * bfd-in2.h: Regenerate.
2002-05-28 Nick Clifton <nickc@cambridge.redhat.com>
cached_size = obj_aout_external_sym_count (abfd);
cached_size *= sizeof (aout_symbol_type);
- cached = (aout_symbol_type *) bfd_malloc (cached_size);
+ cached = (aout_symbol_type *) bfd_zmalloc (cached_size);
if (cached == NULL && cached_size != 0)
return false;
- if (cached_size != 0)
- memset (cached, 0, (size_t) cached_size);
/* Convert from external symbol information to internal. */
if (! (NAME(aout,translate_symbol_table)
count = reloc_size / each_size;
amt = count * sizeof (arelent);
- reloc_cache = (arelent *) bfd_malloc (amt);
+ reloc_cache = (arelent *) bfd_zmalloc (amt);
if (reloc_cache == NULL && count != 0)
return false;
- memset (reloc_cache, 0, (size_t) amt);
relocs = bfd_malloc (reloc_size);
if (relocs == NULL && reloc_size != 0)
bfd_size_type size;
size = (bfd_size_type) sec->reloc_count * sizeof (long);
- offsets = (long *) bfd_alloc (abfd, size);
+ offsets = (long *) bfd_zalloc (abfd, size);
if (offsets == (long *) NULL)
goto error_return;
- memset (offsets, 0, (size_t) size);
section_tdata->offsets = offsets;
}
+ str_32 + (str_32 & 1);
symbol_table = NULL;
- symbol_table = (bfd_byte *) bfd_malloc (symbol_table_size);
+ symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size);
if (symbol_table == NULL)
return false;
- memset (symbol_table, 0, symbol_table_size);
hdr = (struct xcoff_ar_hdr_big *) symbol_table;
+ str_64 + (str_64 & 1);
symbol_table = NULL;
- symbol_table = (bfd_byte *) bfd_malloc (symbol_table_size);
+ symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size);
if (symbol_table == NULL)
return false;
- memset (symbol_table, 0, symbol_table_size);
hdr = (struct xcoff_ar_hdr_big *) symbol_table;
member_table_size += member_table_size & 1;
member_table = NULL;
- member_table = (bfd_byte *) bfd_malloc (member_table_size);
+ member_table = (bfd_byte *) bfd_zmalloc (member_table_size);
if (member_table == NULL)
return false;
- memset (member_table, 0, member_table_size);
hdr = (struct xcoff_ar_hdr_big *) member_table;
data_buffer_size = 0x0040 + initsz + finisz;
data_buffer_size += (data_buffer_size & 7) ? 8 - (data_buffer_size & 7) : 0;
data_buffer = NULL;
- data_buffer = (bfd_byte *) bfd_malloc (data_buffer_size);
+ data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size);
if (data_buffer == NULL)
return false;
-
- memset (data_buffer, 0, data_buffer_size);
if (initsz)
{
if (string_table_size)
{
string_table_size += 4;
- string_table = (bfd_byte *)bfd_malloc (string_table_size);
- memset (string_table, 0, string_table_size);
+ string_table = (bfd_byte *) bfd_zmalloc (string_table_size);
+ if (string_table_size == NULL)
+ return false;
+
val = string_table_size;
bfd_h_put_32 (abfd, val, &string_table[0]);
st_tmp = string_table + 4;
data_buffer_size = 0x0058 + initsz + finisz;
data_buffer_size += (data_buffer_size & 7) ? 8 - (data_buffer_size & 7) : 0;
data_buffer = NULL;
- data_buffer = (bfd_byte *)bfd_malloc (data_buffer_size);
+ data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size);
if (data_buffer == NULL)
return false;
- memset (data_buffer, 0, data_buffer_size);
-
if (initsz)
{
val = 0x18;
if (true == rtld)
string_table_size += strlen (rtld_name) + 1;
- string_table = (bfd_byte *)bfd_malloc (string_table_size);
- memset (string_table, 0, string_table_size);
+ string_table = (bfd_byte *) bfd_zmalloc (string_table_size);
+ if (string_table == NULL)
+ return false;
+
val = string_table_size;
bfd_put_32 (abfd, val, &string_table[0]);
st_tmp = string_table + 4;
/* Support for the generic parts of COFF, for BFD.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001
+ 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Cygnus Support.
combined_entry_type e[10];
};
struct foo *f;
- f = (struct foo *) bfd_alloc (abfd, (bfd_size_type) sizeof (*f));
+
+ f = (struct foo *) bfd_zalloc (abfd, (bfd_size_type) sizeof (*f));
if (!f)
{
bfd_set_error (bfd_error_no_error);
return NULL;
}
- memset ((char *) f, 0, sizeof (*f));
coff_symbol_from (abfd, sym)->native = csym = f->e;
}
csym[0].u.syment.n_sclass = C_STAT;
if (internal_ptr->u.syment._n._n_name[i] == '\0')
break;
- newstring = (PTR) bfd_alloc (abfd, (bfd_size_type) (i + 1));
+ newstring = (PTR) bfd_zalloc (abfd, (bfd_size_type) (i + 1));
if (newstring == NULL)
return (NULL);
- memset (newstring, 0, i + 1);
strncpy (newstring, internal_ptr->u.syment._n._n_name, i);
internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
internal_ptr->u.syment._n._n_n._n_zeroes = 0;
bfd *abfd;
{
bfd_size_type amt = sizeof (coff_symbol_type);
- coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, amt);
+ coff_symbol_type *new = (coff_symbol_type *) bfd_zalloc (abfd, amt);
if (new == NULL)
return (NULL);
- memset (new, 0, sizeof *new);
new->symbol.section = 0;
new->native = 0;
new->lineno = (alent *) NULL;
combined_entry_type * native;
bfd_size_type amt = sizeof (* native);
- native = (combined_entry_type *) bfd_alloc (abfd, amt);
+ native = (combined_entry_type *) bfd_zalloc (abfd, amt);
if (native == NULL)
return false;
- memset (native, 0, sizeof (* native));
-
native->u.syment.n_type = T_NULL;
native->u.syment.n_sclass = class;
/* We keep a list of the linker hash table entries that correspond
to particular symbols. */
amt = symcount * sizeof (struct coff_link_hash_entry *);
- sym_hash = (struct coff_link_hash_entry **) bfd_alloc (abfd, amt);
+ sym_hash = (struct coff_link_hash_entry **) bfd_zalloc (abfd, amt);
if (sym_hash == NULL && symcount != 0)
goto error_return;
obj_coff_sym_hashes (abfd) = sym_hash;
- memset (sym_hash, 0,
- (size_t) symcount * sizeof (struct coff_link_hash_entry *));
symesz = bfd_coff_symesz (abfd);
BFD_ASSERT (symesz == bfd_coff_auxesz (abfd));
ecoff_symbol_type *new;
bfd_size_type amt = sizeof (ecoff_symbol_type);
- new = (ecoff_symbol_type *) bfd_alloc (abfd, amt);
+ new = (ecoff_symbol_type *) bfd_zalloc (abfd, amt);
if (new == (ecoff_symbol_type *) NULL)
return (asymbol *) NULL;
- memset ((PTR) new, 0, sizeof *new);
new->symbol.section = (asection *) NULL;
new->fdr = (FDR *) NULL;
new->local = false;
/* Routines to link ECOFF debugging information.
- Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001
+ Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>.
bfd_byte *s;
i = swap->debug_align - (total & (swap->debug_align - 1));
- s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
+ s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i);
if (s == NULL && i != 0)
return false;
- memset ((PTR) s, 0, i);
if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
{
free (s);
bfd_byte *s;
i = swap->debug_align - (total & (swap->debug_align - 1));
- s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
+ s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i);
if (s == NULL && i != 0)
goto error_return;
- memset ((PTR) s, 0, i);
+
if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
{
free (s);
i = (swap->debug_align
- (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
- s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
+ s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i);
if (s == NULL && i != 0)
goto error_return;
- memset ((PTR) s, 0, i);
+
if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
{
free (s);
size *= sizeof (struct alpha_elf_got_entry *);
local_got_entries
- = (struct alpha_elf_got_entry **) bfd_alloc (abfd, size);
+ = (struct alpha_elf_got_entry **) bfd_zalloc (abfd, size);
if (!local_got_entries)
return NULL;
- memset (local_got_entries, 0, (size_t) size);
alpha_elf_tdata (abfd)->local_got_entries = local_got_entries;
}
{
s->_raw_size = linux_hash_table (info)->fixup_count + 1;
s->_raw_size *= 8;
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
return false;
- memset (s->contents, 0, (size_t) s->_raw_size);
}
return true;
/* BFD back-end for i386 a.out binaries under LynxOS.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2001
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
count = reloc_size / each_size;
- reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
+ reloc_cache = (arelent *) bfd_zmalloc (count * sizeof (arelent));
if (!reloc_cache && count != 0)
return false;
- memset (reloc_cache, 0, (size_t) count * sizeof (arelent));
relocs = (PTR) bfd_alloc (abfd, reloc_size);
if (!relocs && reloc_size != 0)
if ((PTR) stream == (PTR) NULL)
{
/* Outputting a section without data, fill it up */
- stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
+ stream = (unsigned char *) bfd_zalloc (abfd, s->_raw_size);
if (!stream)
return false;
- memset ((PTR) stream, 0, (size_t) s->_raw_size);
}
while (current_byte_index < s->_raw_size)
{
{
s->_raw_size = linux_hash_table (info)->fixup_count + 1;
s->_raw_size *= 8;
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
- memset (s->contents, 0, (size_t) s->_raw_size);
}
return true;
cached_size = obj_aout_external_sym_count (abfd);
cached_size *= sizeof (aout_symbol_type);
- cached = (aout_symbol_type *) bfd_malloc (cached_size);
+ cached = (aout_symbol_type *) bfd_zmalloc (cached_size);
if (cached == NULL && cached_size != 0)
return false;
- if (cached_size != 0)
- memset (cached, 0, (size_t) cached_size);
/* Convert from external symbol information to internal. */
if (! (NAME(aout,translate_symbol_table)
count = real_count;
}
- reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
+ reloc_cache = (arelent *) bfd_zmalloc (count * sizeof (arelent));
if (reloc_cache == NULL && count != 0)
return false;
- memset (reloc_cache, 0, (size_t) count * sizeof (arelent));
cache_ptr = reloc_cache;
if (!native)
return false;
- memset ((PTR)native, 0, (size_t) natsize);
-
generic = section->orelocation;
if (generic != NULL)
{
The last element is used as an accumlator of shrinks. */
amt = reloc_count + 1;
amt *= sizeof (unsigned);
- shrinks = (unsigned *) bfd_malloc (amt);
- memset (shrinks, 0, (size_t) amt);
+ shrinks = (unsigned *) bfd_zmalloc (amt);
/* Loop until nothing changes in this section. */
do {
to hold the symbol table as we build it. */
symtab_size = num_syms;
symtab_size *= sizeof (struct symbol_dictionary_record);
- som_symtab = (struct symbol_dictionary_record *) bfd_malloc (symtab_size);
+ som_symtab = (struct symbol_dictionary_record *) bfd_zmalloc (symtab_size);
if (som_symtab == NULL && symtab_size != 0)
goto error_return;
- memset (som_symtab, 0, (size_t) symtab_size);
/* Walk over each symbol. */
for (i = 0; i < num_syms; i++)
/* Allocate and read in the string table. */
amt = obj_som_stringtab_size (abfd);
- stringtab = bfd_malloc (amt);
+ stringtab = bfd_zmalloc (amt);
if (stringtab == NULL)
return false;
- memset (stringtab, 0, obj_som_stringtab_size (abfd));
if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) != 0)
return false;
amt = symbol_count;
amt *= sizeof (som_symbol_type);
- symbase = (som_symbol_type *) bfd_malloc (amt);
+ symbase = (som_symbol_type *) bfd_zmalloc (amt);
if (symbase == NULL)
goto error_return;
- memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
/* Read in the external SOM representation. */
amt = symbol_count;
amt = lst.hash_size;
amt *= sizeof (unsigned int);
- hash_table = (unsigned int *) bfd_malloc (amt);
+ hash_table = (unsigned int *) bfd_zmalloc (amt);
if (hash_table == NULL && lst.hash_size != 0)
goto error_return;
amt = lst.module_count;
amt *= sizeof (struct som_entry);
- som_dict = (struct som_entry *) bfd_malloc (amt);
+ som_dict = (struct som_entry *) bfd_zmalloc (amt);
if (som_dict == NULL && lst.module_count != 0)
goto error_return;
amt = lst.hash_size;
amt *= sizeof (struct lst_symbol_record *);
- last_hash_entry = ((struct lst_symbol_record **) bfd_malloc (amt));
+ last_hash_entry = ((struct lst_symbol_record **) bfd_zmalloc (amt));
if (last_hash_entry == NULL && lst.hash_size != 0)
goto error_return;
of the lst record. So save its location. */
lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
- /* Some initialization. */
- memset (hash_table, 0, 4 * lst.hash_size);
- memset (som_dict, 0, lst.module_count * sizeof (struct som_entry));
- memset (last_hash_entry, 0,
- lst.hash_size * sizeof (struct lst_symbol_record *));
-
/* Symbols have som_index fields, so we have to keep track of the
index of each SOM in the archive.
{
s->_raw_size = linux_hash_table (info)->fixup_count + 1;
s->_raw_size *= 8;
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+ s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
return false;
- memset (s->contents, 0, (size_t) s->_raw_size);
}
return true;
s = bfd_get_section_by_name (dynobj, ".hash");
BFD_ASSERT (s != NULL);
hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
- s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, hashalloc);
if (s->contents == NULL && dynsymcount > 0)
return false;
- memset (s->contents, 0, (size_t) hashalloc);
for (i = 0; i < bucketcount; i++)
PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
s->_raw_size = bucketcount * HASH_ENTRY_SIZE;
}
if (!d)
{
- char *sname = bfd_alloc (abfd, (bfd_size_type) 12);
-
/* No chunk for this address, so make one up */
d = ((struct data_struct *)
- bfd_alloc (abfd, (bfd_size_type) sizeof (struct data_struct)));
+ bfd_zalloc (abfd, (bfd_size_type) sizeof (struct data_struct)));
- if (!sname || !d)
+ if (!d)
return NULL;
- memset (d->chunk_init, 0, CHUNK_MASK + 1);
- memset (d->chunk_data, 0, CHUNK_MASK + 1);
d->next = abfd->tdata.tekhex_data->data;
d->vma = vma;
abfd->tdata.tekhex_data->data = d;
else
{
section->contents = ((unsigned char *)
- bfd_malloc (section->_raw_size));
+ bfd_zmalloc (section->_raw_size));
if (section->contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
return -1;
}
- memset (section->contents, 0, (size_t) section->_raw_size);
}
section->_cooked_size = section->_raw_size;
#if VMS_DEBUG
section->vma = (bfd_vma)base_addr;
base_addr += section->_raw_size;
section->contents = ((unsigned char *)
- bfd_malloc (section->_raw_size));
+ bfd_zmalloc (section->_raw_size));
if (section->contents == NULL)
return -1;
- memset (section->contents, 0, (size_t) section->_raw_size);
section->_cooked_size = section->_raw_size;
#if VMS_DEBUG
vms_debug(4, "egsd psc %d (%s, flags %04x=%s) ",
/* We keep a list of the linker hash table entries that correspond
to each external symbol. */
amt = symcount * sizeof (struct xcoff_link_hash_entry *);
- sym_hash = (struct xcoff_link_hash_entry **) bfd_alloc (abfd, amt);
+ sym_hash = (struct xcoff_link_hash_entry **) bfd_zalloc (abfd, amt);
if (sym_hash == NULL && symcount != 0)
goto error_return;
coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
- memset (sym_hash, 0, (size_t) amt);
/* Because of the weird stuff we are doing with XCOFF csects, we can
not easily determine which section a symbol is in, so we store
the information in the tdata for the input file. */
amt = symcount * sizeof (asection *);
- csect_cache = (asection **) bfd_alloc (abfd, amt);
+ csect_cache = (asection **) bfd_zalloc (abfd, amt);
if (csect_cache == NULL && symcount != 0)
goto error_return;
xcoff_data (abfd)->csects = csect_cache;
- memset (csect_cache, 0, (size_t) amt);
/* While splitting sections into csects, we need to assign the
relocs correctly. The relocs and the csects must both be in
into reloc_info using the section target_index. */
amt = abfd->section_count + 1;
amt *= sizeof (struct reloc_info_struct);
- reloc_info = (struct reloc_info_struct *) bfd_malloc (amt);
+ reloc_info = (struct reloc_info_struct *) bfd_zmalloc (amt);
if (reloc_info == NULL)
goto error_return;
- memset ((PTR) reloc_info, 0, (size_t) amt);
/* Read in the relocs and line numbers for each section. */
linesz = bfd_coff_linesz (abfd);
false, (struct internal_reloc *) NULL);
amt = o->reloc_count;
amt *= sizeof (asection *);
- reloc_info[o->target_index].csects = (asection **) bfd_malloc (amt);
+ reloc_info[o->target_index].csects = (asection **) bfd_zmalloc (amt);
if (reloc_info[o->target_index].csects == NULL)
goto error_return;
- memset (reloc_info[o->target_index].csects, 0, (size_t) amt);
-
}
if ((info->strip == strip_none || info->strip == strip_some)