summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog41
-rw-r--r--bfd/aoutx.h7
-rw-r--r--bfd/coff-mips.c3
-rw-r--r--bfd/coff-rs6000.c19
-rw-r--r--bfd/coff64-rs6000.c10
-rw-r--r--bfd/coffgen.c16
-rw-r--r--bfd/cofflink.c4
-rw-r--r--bfd/ecoff.c3
-rw-r--r--bfd/ecofflink.c13
-rw-r--r--bfd/elf64-alpha.c3
-rw-r--r--bfd/i386linux.c3
-rw-r--r--bfd/i386lynx.c5
-rw-r--r--bfd/ieee.c3
-rw-r--r--bfd/m68klinux.c3
-rw-r--r--bfd/pdp11.c9
-rw-r--r--bfd/reloc16.c3
-rw-r--r--bfd/som.c21
-rw-r--r--bfd/sparclinux.c3
-rw-r--r--bfd/sunos.c3
-rw-r--r--bfd/tekhex.c8
-rw-r--r--bfd/vms-gsd.c6
-rw-r--r--bfd/xcofflink.c13
22 files changed, 94 insertions, 105 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 148731404f..a98068e859 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,42 @@
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
"group" union.
(elf_group_name): Update.
@@ -476,9 +513,9 @@
* 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>
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 3c9cd4fafc..c2448f4a57 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -1837,11 +1837,9 @@ NAME(aout,slurp_symbol_table) (abfd)
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)
@@ -2411,10 +2409,9 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
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)
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index 1e4ead4c3f..edccd5cbbe 100644
--- a/bfd/coff-mips.c
+++ b/bfd/coff-mips.c
@@ -2116,10 +2116,9 @@ mips_relax_section (abfd, sec, info, again)
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;
}
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index fdf3162bb7..7cd26b88ff 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -1839,10 +1839,9 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx)
+ 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;
@@ -1943,10 +1942,9 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx)
+ 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;
@@ -2457,10 +2455,9 @@ xcoff_write_archive_contents_big (abfd)
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;
@@ -3719,11 +3716,9 @@ xcoff_generate_rtinit (abfd, init, fini, rtld)
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)
{
@@ -3757,8 +3752,10 @@ xcoff_generate_rtinit (abfd, init, fini, rtld)
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;
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 16b63d4f8a..c7fe5ac5e7 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -2264,12 +2264,10 @@ xcoff64_generate_rtinit (abfd, init, fini, rtld)
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;
@@ -2302,8 +2300,10 @@ xcoff64_generate_rtinit (abfd, init, fini, rtld)
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;
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 88591f1499..71179fbb55 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -1,6 +1,6 @@
/* 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.
@@ -1438,13 +1438,13 @@ coff_section_symbol (abfd, name)
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;
@@ -1835,10 +1835,9 @@ coff_get_normalized_symtab (abfd)
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;
@@ -1897,10 +1896,9 @@ coff_make_empty_symbol (abfd)
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;
@@ -2453,12 +2451,10 @@ bfd_coff_set_symbol_class (abfd, symbol, class)
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;
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 1eac3c58ce..32200a83a6 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -342,12 +342,10 @@ coff_link_add_symbols (abfd, info)
/* 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));
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index c7230f6aaf..56165a48cf 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -661,10 +661,9 @@ _bfd_ecoff_make_empty_symbol (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;
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c
index 53d65441db..8044f3ab6e 100644
--- a/bfd/ecofflink.c
+++ b/bfd/ecofflink.c
@@ -1,5 +1,5 @@
/* 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>.
@@ -1650,11 +1650,10 @@ ecoff_write_shuffle (abfd, swap, shuffle, space)
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);
@@ -1736,10 +1735,10 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
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);
@@ -1761,10 +1760,10 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
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);
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 67ada729bb..a491ecad8c 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -2974,11 +2974,10 @@ get_got_entry (abfd, h, r_type, r_symndx, r_addend)
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;
}
diff --git a/bfd/i386linux.c b/bfd/i386linux.c
index 755b456cfc..c144822ac2 100644
--- a/bfd/i386linux.c
+++ b/bfd/i386linux.c
@@ -597,10 +597,9 @@ bfd_i386linux_size_dynamic_sections (output_bfd, info)
{
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;
diff --git a/bfd/i386lynx.c b/bfd/i386lynx.c
index f74854334b..fc58767a97 100644
--- a/bfd/i386lynx.c
+++ b/bfd/i386lynx.c
@@ -1,5 +1,5 @@
/* 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.
@@ -429,10 +429,9 @@ doit:
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)
diff --git a/bfd/ieee.c b/bfd/ieee.c
index 4e7f3a3ed7..2433cc432d 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -2398,10 +2398,9 @@ do_with_relocs (abfd, s)
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)
{
diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c
index 7dd0428947..863a61d68f 100644
--- a/bfd/m68klinux.c
+++ b/bfd/m68klinux.c
@@ -601,13 +601,12 @@ bfd_m68klinux_size_dynamic_sections (output_bfd, info)
{
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;
diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index d4fe79eba6..90db56b987 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -1841,11 +1841,9 @@ NAME(aout,slurp_symbol_table) (abfd)
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)
@@ -2255,10 +2253,9 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
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;
@@ -2319,8 +2316,6 @@ NAME(aout,squirt_out_relocs) (abfd, section)
if (!native)
return false;
- memset ((PTR)native, 0, (size_t) natsize);
-
generic = section->orelocation;
if (generic != NULL)
{
diff --git a/bfd/reloc16.c b/bfd/reloc16.c
index 1d69a7f25d..1db8daf2aa 100644
--- a/bfd/reloc16.c
+++ b/bfd/reloc16.c
@@ -196,8 +196,7 @@ bfd_coff_reloc16_relax_section (abfd, input_section, link_info, again)
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 {
diff --git a/bfd/som.c b/bfd/som.c
index 6bb27f7a22..68c561c9b3 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -4141,10 +4141,9 @@ som_build_and_write_symbol_table (abfd)
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++)
@@ -4230,10 +4229,9 @@ som_slurp_string_table (abfd)
/* 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;
@@ -4336,10 +4334,9 @@ som_slurp_symbol_table (abfd)
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;
@@ -5899,19 +5896,19 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength)
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;
@@ -5919,12 +5916,6 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength)
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.
diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c
index 7f1d270ea3..e55a4ffc2b 100644
--- a/bfd/sparclinux.c
+++ b/bfd/sparclinux.c
@@ -599,10 +599,9 @@ bfd_sparclinux_size_dynamic_sections (output_bfd, info)
{
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;
diff --git a/bfd/sunos.c b/bfd/sunos.c
index 7825a821a0..5fec6f91d7 100644
--- a/bfd/sunos.c
+++ b/bfd/sunos.c
@@ -1434,10 +1434,9 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
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;
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 8efd401dbd..034ef28b86 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -354,17 +354,13 @@ find_chunk (abfd, vma)
}
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;
diff --git a/bfd/vms-gsd.c b/bfd/vms-gsd.c
index d9dcd78578..002412232d 100644
--- a/bfd/vms-gsd.c
+++ b/bfd/vms-gsd.c
@@ -426,13 +426,12 @@ _bfd_vms_slurp_gsd (abfd, objtype)
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
@@ -618,10 +617,9 @@ _bfd_vms_slurp_gsd (abfd, objtype)
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) ",
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 9d66243478..7215b1bc64 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -1086,21 +1086,19 @@ xcoff_link_add_symbols (abfd, info)
/* 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
@@ -1109,10 +1107,9 @@ xcoff_link_add_symbols (abfd, info)
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);
@@ -1129,11 +1126,9 @@ xcoff_link_add_symbols (abfd, info)
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)
OpenPOWER on IntegriCloud