Fix PR15113 by using bfd_zmalloc to allocate hash table
Alan Modra
amodra@gmail.com
Sun Feb 10 04:36:00 GMT 2013
This makes all ELF backends use bfd_zalloc when creating the linker
hash table, which should prevent any future bugs like PR ld/15113 for
ELF. I did the same for a random assortment of non-ELF targets too.
* coff-arm.c (coff_arm_link_hash_table_create): Use bfd_zmalloc.
* coff-h8300.c (h8300_coff_link_hash_table_create): Likewise.
* m68klinux.c (linux_link_hash_table_create): Likewise.
* sparclinux.c (linux_link_hash_table_create): Likewise.
* sunos.c (sunos_link_hash_table_create): Likewise.
* xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create): Likewise.
* elf-m10300.c (elf32_mn10300_link_hash_table_create): Likewise.
* elf32-arm.c (elf32_arm_link_hash_table_create): Likewise.
* elf32-avr.c (elf32_avr_link_hash_table_create): Likewise.
* elf32-cr16.c (elf32_cr16_link_hash_table_create): Likewise.
* elf32-cris.c (elf_cris_link_hash_table_create): Likewise.
* elf32-hppa.c (elf32_hppa_link_hash_table_create): Likewise.
* elf32-i386.c (elf_i386_link_hash_table_create): Likewise.
* elf32-lm32.c (lm32_elf_link_hash_table_create): Likewise.
* elf32-m32r.c (m32r_elf_link_hash_table_create): Likewise.
* elf32-m68hc1x.c (m68hc11_elf_hash_table_create): Likewise.
* elf32-m68k.c (elf_m68k_link_hash_table_create): Likewise.
* elf32-metag.c (elf_metag_link_hash_table_create): Likewise.
* elf32-nios2.c (nios2_elf32_link_hash_table_create): Likewise.
* elf32-s390.c (elf_s390_link_hash_table_create): Likewise.
* elf32-score.c (elf32_score_link_hash_table_create): Likewise.
* elf32-spu.c (spu_elf_link_hash_table_create): Likewise.
* elf32-tic6x.c (elf32_tic6x_link_hash_table_create): Likewise.
* elf32-vax.c (elf_vax_link_hash_table_create): Likewise.
* elf32-xgate.c (xgate_elf_bfd_link_hash_table_create): Likewise.
* elf32-xtensa.c (elf_xtensa_link_hash_table_create): Likewise.
* elf64-aarch64.c (elf64_aarch64_link_hash_table_create): Likewise.
* elf64-s390.c (elf_s390_link_hash_table_create): Likewise.
* elf64-sh64.c (sh64_elf64_link_hash_table_create): Likewise.
* elf64-x86-64.c (elf_x86_64_link_hash_table_create): Likewise.
* elfxx-mips.c (_bfd_mips_elf_link_hash_table_create): Likewise.
* elflink.c (_bfd_elf_link_hash_table_create): Likewise.
(_bfd_elf_link_hash_table_init): Assume zero fill table on entry.
Index: bfd/coff-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-arm.c,v
retrieving revision 1.80
diff -u -p -r1.80 coff-arm.c
--- bfd/coff-arm.c 5 May 2012 03:05:25 -0000 1.80
+++ bfd/coff-arm.c 9 Feb 2013 10:41:11 -0000
@@ -918,7 +918,7 @@ coff_arm_link_hash_table_create (bfd * a
struct coff_arm_link_hash_table * ret;
bfd_size_type amt = sizeof (struct coff_arm_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -931,10 +931,6 @@ coff_arm_link_hash_table_create (bfd * a
return NULL;
}
- ret->thumb_glue_size = 0;
- ret->arm_glue_size = 0;
- ret->bfd_of_glue_owner = NULL;
-
return & ret->root.root;
}
Index: bfd/coff-h8300.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-h8300.c,v
retrieving revision 1.44
diff -u -p -r1.44 coff-h8300.c
--- bfd/coff-h8300.c 13 Jul 2012 14:22:43 -0000 1.44
+++ bfd/coff-h8300.c 9 Feb 2013 10:41:11 -0000
@@ -173,7 +173,7 @@ h8300_coff_link_hash_table_create (bfd *
struct h8300_coff_link_hash_table *ret;
bfd_size_type amt = sizeof (struct h8300_coff_link_hash_table);
- ret = (struct h8300_coff_link_hash_table *) bfd_malloc (amt);
+ ret = (struct h8300_coff_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
if (!_bfd_link_hash_table_init (&ret->root.root, abfd,
@@ -184,11 +184,6 @@ h8300_coff_link_hash_table_create (bfd *
return NULL;
}
- /* Initialize our data. */
- ret->vectors_sec = NULL;
- ret->funcvec_hash_table = NULL;
-
- /* OK. Everything's initialized, return the base pointer. */
return &ret->root.root;
}
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.118
diff -u -p -r1.118 elf-m10300.c
--- bfd/elf-m10300.c 10 Jan 2013 20:03:52 -0000 1.118
+++ bfd/elf-m10300.c 9 Feb 2013 10:41:11 -0000
@@ -4603,7 +4603,7 @@ elf32_mn10300_link_hash_table_create (bf
struct elf32_mn10300_link_hash_table *ret;
bfd_size_type amt = sizeof (* ret);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -4616,14 +4616,10 @@ elf32_mn10300_link_hash_table_create (bf
return NULL;
}
- ret->flags = 0;
- ret->tls_ldm_got.refcount = 0;
ret->tls_ldm_got.offset = -1;
- ret->tls_ldm_got.got_allocated = 0;
- ret->tls_ldm_got.rel_emitted = 0;
amt = sizeof (struct elf_link_hash_table);
- ret->static_hash_table = bfd_malloc (amt);
+ ret->static_hash_table = bfd_zmalloc (amt);
if (ret->static_hash_table == NULL)
{
free (ret);
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.305
diff -u -p -r1.305 elf32-arm.c
--- bfd/elf32-arm.c 5 Feb 2013 23:18:44 -0000 1.305
+++ bfd/elf32-arm.c 9 Feb 2013 10:41:12 -0000
@@ -3417,7 +3417,7 @@ elf32_arm_link_hash_table_create (bfd *a
struct elf32_arm_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table);
- ret = (struct elf32_arm_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf32_arm_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -3430,27 +3430,7 @@ elf32_arm_link_hash_table_create (bfd *a
return NULL;
}
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->srelplt2 = NULL;
- ret->dt_tlsdesc_plt = 0;
- ret->dt_tlsdesc_got = 0;
- ret->tls_trampoline = 0;
- ret->next_tls_desc_index = 0;
- ret->num_tls_desc = 0;
- ret->thumb_glue_size = 0;
- ret->arm_glue_size = 0;
- ret->bx_glue_size = 0;
- memset (ret->bx_glue_offset, 0, sizeof (ret->bx_glue_offset));
ret->vfp11_fix = BFD_ARM_VFP11_FIX_NONE;
- ret->vfp11_erratum_glue_size = 0;
- ret->num_vfp11_fixes = 0;
- ret->fix_cortex_a8 = 0;
- ret->fix_arm1176 = 0;
- ret->bfd_of_glue_owner = NULL;
- ret->byteswap_code = 0;
- ret->target1_is_rel = 0;
- ret->target2_reloc = R_ARM_NONE;
#ifdef FOUR_WORD_PLT
ret->plt_header_size = 16;
ret->plt_entry_size = 16;
@@ -3458,23 +3438,8 @@ elf32_arm_link_hash_table_create (bfd *a
ret->plt_header_size = 20;
ret->plt_entry_size = 12;
#endif
- ret->fix_v4bx = 0;
- ret->use_blx = 0;
- ret->vxworks_p = 0;
- ret->symbian_p = 0;
- ret->nacl_p = 0;
ret->use_rel = 1;
- ret->sym_cache.abfd = NULL;
ret->obfd = abfd;
- ret->tls_ldm_got.refcount = 0;
- ret->stub_bfd = NULL;
- ret->add_stub_section = NULL;
- ret->layout_sections_again = NULL;
- ret->stub_group = NULL;
- ret->top_id = 0;
- ret->bfd_count = 0;
- ret->top_index = 0;
- ret->input_list = NULL;
if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc,
sizeof (struct elf32_arm_stub_hash_entry)))
Index: bfd/elf32-avr.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-avr.c,v
retrieving revision 1.59
diff -u -p -r1.59 elf32-avr.c
--- bfd/elf32-avr.c 10 Jan 2013 20:03:52 -0000 1.59
+++ bfd/elf32-avr.c 9 Feb 2013 10:41:12 -0000
@@ -672,7 +672,7 @@ elf32_avr_link_hash_table_create (bfd *a
struct elf32_avr_link_hash_table *htab;
bfd_size_type amt = sizeof (*htab);
- htab = bfd_malloc (amt);
+ htab = bfd_zmalloc (amt);
if (htab == NULL)
return NULL;
@@ -690,15 +690,6 @@ elf32_avr_link_hash_table_create (bfd *a
sizeof (struct elf32_avr_stub_hash_entry)))
return NULL;
- htab->stub_bfd = NULL;
- htab->stub_sec = NULL;
-
- /* Initialize the address mapping table. */
- htab->amt_stub_offsets = NULL;
- htab->amt_destination_addr = NULL;
- htab->amt_entry_cnt = 0;
- htab->amt_max_entry_cnt = 0;
-
return &htab->etab.root;
}
Index: bfd/elf32-cr16.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cr16.c,v
retrieving revision 1.23
diff -u -p -r1.23 elf32-cr16.c
--- bfd/elf32-cr16.c 10 Jan 2013 20:03:52 -0000 1.23
+++ bfd/elf32-cr16.c 9 Feb 2013 10:41:12 -0000
@@ -1660,7 +1660,7 @@ elf32_cr16_link_hash_table_create (bfd *
struct elf_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_link_hash_table);
- ret = (struct elf_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_link_hash_table *) bfd_zmalloc (amt);
if (ret == (struct elf_link_hash_table *) NULL)
return NULL;
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.127
diff -u -p -r1.127 elf32-cris.c
--- bfd/elf32-cris.c 10 Jan 2013 20:03:52 -0000 1.127
+++ bfd/elf32-cris.c 9 Feb 2013 10:41:12 -0000
@@ -884,7 +884,7 @@ elf_cris_link_hash_table_create (bfd *ab
struct elf_cris_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_cris_link_hash_table);
- ret = ((struct elf_cris_link_hash_table *) bfd_malloc (amt));
+ ret = ((struct elf_cris_link_hash_table *) bfd_zmalloc (amt));
if (ret == (struct elf_cris_link_hash_table *) NULL)
return NULL;
@@ -901,9 +901,6 @@ elf_cris_link_hash_table_create (bfd *ab
are used for run-time symbol evaluation. */
ret->next_gotplt_entry = 12;
- /* We haven't seen any R_CRIS_nn_GOT_TPREL initially. */
- ret->dtpmod_refcount = 0;
-
return &ret->root.root;
}
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.189
diff -u -p -r1.189 elf32-hppa.c
--- bfd/elf32-hppa.c 10 Jan 2013 20:03:52 -0000 1.189
+++ bfd/elf32-hppa.c 9 Feb 2013 10:41:13 -0000
@@ -419,7 +419,7 @@ elf32_hppa_link_hash_table_create (bfd *
struct elf32_hppa_link_hash_table *htab;
bfd_size_type amt = sizeof (*htab);
- htab = bfd_malloc (amt);
+ htab = bfd_zmalloc (amt);
if (htab == NULL)
return NULL;
@@ -436,26 +436,8 @@ elf32_hppa_link_hash_table_create (bfd *
sizeof (struct elf32_hppa_stub_hash_entry)))
return NULL;
- htab->stub_bfd = NULL;
- htab->add_stub_section = NULL;
- htab->layout_sections_again = NULL;
- htab->stub_group = NULL;
- htab->sgot = NULL;
- htab->srelgot = NULL;
- htab->splt = NULL;
- htab->srelplt = NULL;
- htab->sdynbss = NULL;
- htab->srelbss = NULL;
htab->text_segment_base = (bfd_vma) -1;
htab->data_segment_base = (bfd_vma) -1;
- htab->multi_subspace = 0;
- htab->has_12bit_branch = 0;
- htab->has_17bit_branch = 0;
- htab->has_22bit_branch = 0;
- htab->need_plt_stub = 0;
- htab->sym_cache.abfd = NULL;
- htab->tls_ldm_got.refcount = 0;
-
return &htab->etab.root;
}
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.299
diff -u -p -r1.299 elf32-i386.c
--- bfd/elf32-i386.c 7 Feb 2013 02:15:29 -0000 1.299
+++ bfd/elf32-i386.c 9 Feb 2013 10:41:13 -0000
@@ -937,7 +937,7 @@ elf_i386_link_hash_table_create (bfd *ab
struct elf_i386_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_i386_link_hash_table);
- ret = (struct elf_i386_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_i386_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -950,18 +950,6 @@ elf_i386_link_hash_table_create (bfd *ab
return NULL;
}
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->plt_eh_frame = NULL;
- ret->tls_ldm_got.refcount = 0;
- ret->next_tls_desc_index = 0;
- ret->sgotplt_jump_table_size = 0;
- ret->sym_cache.abfd = NULL;
- ret->srelplt2 = NULL;
- ret->tls_module_base = NULL;
- ret->next_jump_slot_index = 0;
- ret->next_irelative_index = 0;
-
ret->loc_hash_table = htab_try_create (1024,
elf_i386_local_htab_hash,
elf_i386_local_htab_eq,
Index: bfd/elf32-lm32.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-lm32.c,v
retrieving revision 1.17
diff -u -p -r1.17 elf32-lm32.c
--- bfd/elf32-lm32.c 23 Oct 2012 09:33:54 -0000 1.17
+++ bfd/elf32-lm32.c 9 Feb 2013 10:41:13 -0000
@@ -159,7 +159,7 @@ lm32_elf_link_hash_table_create (bfd *ab
struct elf_lm32_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_lm32_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -172,16 +172,6 @@ lm32_elf_link_hash_table_create (bfd *ab
return NULL;
}
- ret->sgot = NULL;
- ret->sgotplt = NULL;
- ret->srelgot = NULL;
- ret->sfixup32 = NULL;
- ret->splt = NULL;
- ret->srelplt = NULL;
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->relocs32 = 0;
-
return &ret->root.root;
}
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.110
diff -u -p -r1.110 elf32-m32r.c
--- bfd/elf32-m32r.c 2 Sep 2012 12:17:26 -0000 1.110
+++ bfd/elf32-m32r.c 9 Feb 2013 10:41:13 -0000
@@ -1585,7 +1585,7 @@ m32r_elf_link_hash_table_create (bfd *ab
struct elf_m32r_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_m32r_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -1598,15 +1598,6 @@ m32r_elf_link_hash_table_create (bfd *ab
return NULL;
}
- ret->sgot = NULL;
- ret->sgotplt = NULL;
- ret->srelgot = NULL;
- ret->splt = NULL;
- ret->srelplt = NULL;
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->sym_cache.abfd = NULL;
-
return &ret->root.root;
}
Index: bfd/elf32-m68hc1x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v
retrieving revision 1.49
diff -u -p -r1.49 elf32-m68hc1x.c
--- bfd/elf32-m68hc1x.c 10 Jan 2013 20:03:53 -0000 1.49
+++ bfd/elf32-m68hc1x.c 9 Feb 2013 10:41:13 -0000
@@ -67,11 +67,10 @@ m68hc11_elf_hash_table_create (bfd *abfd
struct m68hc11_elf_link_hash_table *ret;
bfd_size_type amt = sizeof (struct m68hc11_elf_link_hash_table);
- ret = (struct m68hc11_elf_link_hash_table *) bfd_malloc (amt);
+ ret = (struct m68hc11_elf_link_hash_table *) bfd_zmalloc (amt);
if (ret == (struct m68hc11_elf_link_hash_table *) NULL)
return NULL;
- memset (ret, 0, amt);
if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
_bfd_elf_link_hash_newfunc,
sizeof (struct elf_link_hash_entry),
@@ -93,11 +92,6 @@ m68hc11_elf_hash_table_create (bfd *abfd
sizeof (struct elf32_m68hc11_stub_hash_entry)))
return NULL;
- ret->stub_bfd = NULL;
- ret->stub_section = 0;
- ret->add_stub_section = NULL;
- ret->sym_cache.abfd = NULL;
-
return ret;
}
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.137
diff -u -p -r1.137 elf32-m68k.c
--- bfd/elf32-m68k.c 13 Jul 2012 14:22:47 -0000 1.137
+++ bfd/elf32-m68k.c 9 Feb 2013 10:41:14 -0000
@@ -950,7 +950,7 @@ elf_m68k_link_hash_table_create (bfd *ab
struct elf_m68k_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_m68k_link_hash_table);
- ret = (struct elf_m68k_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_m68k_link_hash_table *) bfd_zmalloc (amt);
if (ret == (struct elf_m68k_link_hash_table *) NULL)
return NULL;
@@ -963,12 +963,6 @@ elf_m68k_link_hash_table_create (bfd *ab
return NULL;
}
- ret->sym_cache.abfd = NULL;
- ret->plt_info = NULL;
- ret->local_gp_p = FALSE;
- ret->use_neg_got_offsets_p = FALSE;
- ret->allow_multigot_p = FALSE;
- ret->multi_got_.bfd2got = NULL;
ret->multi_got_.global_symndx = 1;
return &ret->root.root;
Index: bfd/elf32-metag.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-metag.c,v
retrieving revision 1.4
diff -u -p -r1.4 elf32-metag.c
--- bfd/elf32-metag.c 8 Feb 2013 17:14:49 -0000 1.4
+++ bfd/elf32-metag.c 9 Feb 2013 10:41:14 -0000
@@ -1027,7 +1027,7 @@ elf_metag_link_hash_table_create (bfd *a
struct elf_metag_link_hash_table *htab;
bfd_size_type amt = sizeof (*htab);
- htab = bfd_malloc (amt);
+ htab = bfd_zmalloc (amt);
if (htab == NULL)
return NULL;
@@ -1045,20 +1045,6 @@ elf_metag_link_hash_table_create (bfd *a
sizeof (struct elf_metag_stub_hash_entry)))
return NULL;
- htab->stub_bfd = NULL;
- htab->add_stub_section = NULL;
- htab->layout_sections_again = NULL;
- htab->stub_group = NULL;
- htab->sgot = NULL;
- htab->sgotplt = NULL;
- htab->srelgot = NULL;
- htab->splt = NULL;
- htab->srelplt = NULL;
- htab->sdynbss = NULL;
- htab->srelbss = NULL;
- htab->sym_cache.abfd = NULL;
- htab->tls_ldm_got.refcount = 0;
-
return &htab->etab.root;
}
Index: bfd/elf32-nios2.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-nios2.c,v
retrieving revision 1.1
diff -u -p -r1.1 elf32-nios2.c
--- bfd/elf32-nios2.c 6 Feb 2013 23:22:08 -0000 1.1
+++ bfd/elf32-nios2.c 9 Feb 2013 10:41:14 -0000
@@ -3958,7 +3958,7 @@ nios2_elf32_link_hash_table_create (bfd
struct elf32_nios2_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf32_nios2_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -3972,11 +3972,6 @@ nios2_elf32_link_hash_table_create (bfd
return NULL;
}
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->sbss = NULL;
- ret->tls_ldm_got.refcount = 0;
- ret->sym_cache.abfd = NULL;
return &ret->root.root;
}
Index: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.126
diff -u -p -r1.126 elf32-s390.c
--- bfd/elf32-s390.c 10 Jan 2013 20:03:53 -0000 1.126
+++ bfd/elf32-s390.c 9 Feb 2013 10:41:14 -0000
@@ -786,7 +786,7 @@ elf_s390_link_hash_table_create (bfd *ab
struct elf_s390_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
- ret = (struct elf_s390_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_s390_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -798,16 +798,6 @@ elf_s390_link_hash_table_create (bfd *ab
return NULL;
}
- ret->elf.sgot = NULL;
- ret->elf.sgotplt = NULL;
- ret->elf.srelgot = NULL;
- ret->elf.splt = NULL;
- ret->elf.srelplt = NULL;
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->tls_ldm_got.refcount = 0;
- ret->sym_cache.abfd = NULL;
-
return &ret->elf.root;
}
Index: bfd/elf32-score.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-score.c,v
retrieving revision 1.26
diff -u -p -r1.26 elf32-score.c
--- bfd/elf32-score.c 2 Sep 2012 12:17:26 -0000 1.26
+++ bfd/elf32-score.c 9 Feb 2013 10:41:14 -0000
@@ -4357,7 +4357,7 @@ elf32_score_link_hash_table_create (bfd
struct elf_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_link_hash_table);
- ret = (struct elf_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.106
diff -u -p -r1.106 elf32-spu.c
--- bfd/elf32-spu.c 10 Jan 2013 20:03:53 -0000 1.106
+++ bfd/elf32-spu.c 9 Feb 2013 10:41:15 -0000
@@ -440,7 +440,7 @@ spu_elf_link_hash_table_create (bfd *abf
{
struct spu_link_hash_table *htab;
- htab = bfd_malloc (sizeof (*htab));
+ htab = bfd_zmalloc (sizeof (*htab));
if (htab == NULL)
return NULL;
@@ -453,9 +453,6 @@ spu_elf_link_hash_table_create (bfd *abf
return NULL;
}
- memset (&htab->ovtab, 0,
- sizeof (*htab) - offsetof (struct spu_link_hash_table, ovtab));
-
htab->elf.init_got_refcount.refcount = 0;
htab->elf.init_got_refcount.glist = NULL;
htab->elf.init_got_offset.offset = 0;
Index: bfd/elf32-tic6x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-tic6x.c,v
retrieving revision 1.35
diff -u -p -r1.35 elf32-tic6x.c
--- bfd/elf32-tic6x.c 10 Jan 2013 20:03:53 -0000 1.35
+++ bfd/elf32-tic6x.c 9 Feb 2013 10:41:15 -0000
@@ -1570,7 +1570,7 @@ elf32_tic6x_link_hash_table_create (bfd
struct elf32_tic6x_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf32_tic6x_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -1583,7 +1583,6 @@ elf32_tic6x_link_hash_table_create (bfd
return NULL;
}
- ret->sym_cache.abfd = NULL;
ret->obfd = abfd;
ret->elf.is_relocatable_executable = 1;
Index: bfd/elf32-vax.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-vax.c,v
retrieving revision 1.73
diff -u -p -r1.73 elf32-vax.c
--- bfd/elf32-vax.c 2 Sep 2012 12:17:26 -0000 1.73
+++ bfd/elf32-vax.c 9 Feb 2013 10:41:15 -0000
@@ -465,7 +465,7 @@ elf_vax_link_hash_table_create (bfd *abf
struct elf_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
Index: bfd/elf32-xgate.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xgate.c,v
retrieving revision 1.3
diff -u -p -r1.3 elf32-xgate.c
--- bfd/elf32-xgate.c 29 Oct 2012 21:28:09 -0000 1.3
+++ bfd/elf32-xgate.c 9 Feb 2013 10:41:15 -0000
@@ -448,11 +448,10 @@ xgate_elf_bfd_link_hash_table_create (bf
struct xgate_elf_link_hash_table *ret;
bfd_size_type amt = sizeof(struct xgate_elf_link_hash_table);
- ret = (struct xgate_elf_link_hash_table *) bfd_malloc (amt);
+ ret = (struct xgate_elf_link_hash_table *) bfd_zmalloc (amt);
if (ret == (struct xgate_elf_link_hash_table *) NULL)
return NULL;
- memset (ret, 0, amt);
if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
_bfd_elf_link_hash_newfunc, sizeof(struct elf_link_hash_entry),
XGATE_ELF_DATA))
@@ -463,7 +462,7 @@ xgate_elf_bfd_link_hash_table_create (bf
/* Init the stub hash table too. */
amt = sizeof(struct bfd_hash_table);
- ret->stub_hash_table = (struct bfd_hash_table*) bfd_malloc (amt);
+ ret->stub_hash_table = (struct bfd_hash_table*) bfd_zmalloc (amt);
if (ret->stub_hash_table == NULL)
{
free (ret);
@@ -472,12 +471,11 @@ xgate_elf_bfd_link_hash_table_create (bf
if (!bfd_hash_table_init (ret->stub_hash_table, stub_hash_newfunc,
sizeof(struct elf32_xgate_stub_hash_entry)))
- return NULL;
-
- ret->stub_bfd = NULL;
- ret->stub_section = 0;
- ret->add_stub_section = NULL;
- ret->sym_cache.abfd = NULL;
+ {
+ free (ret->stub_hash_table);
+ free (ret);
+ return NULL;
+ }
return &ret->root.root;
}
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.137
diff -u -p -r1.137 elf32-xtensa.c
--- bfd/elf32-xtensa.c 10 Jan 2013 20:03:53 -0000 1.137
+++ bfd/elf32-xtensa.c 9 Feb 2013 10:41:15 -0000
@@ -655,7 +655,7 @@ elf_xtensa_link_hash_table_create (bfd *
struct elf_xtensa_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_xtensa_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -668,16 +668,6 @@ elf_xtensa_link_hash_table_create (bfd *
return NULL;
}
- ret->sgot = NULL;
- ret->sgotplt = NULL;
- ret->srelgot = NULL;
- ret->splt = NULL;
- ret->srelplt = NULL;
- ret->sgotloc = NULL;
- ret->spltlittbl = NULL;
-
- ret->plt_reloc_count = 0;
-
/* Create a hash entry for "_TLS_MODULE_BASE_" to speed up checking
for it later. */
tlsbase = elf_link_hash_lookup (&ret->elf, "_TLS_MODULE_BASE_",
Index: bfd/elf64-aarch64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-aarch64.c,v
retrieving revision 1.6
diff -u -p -r1.6 elf64-aarch64.c
--- bfd/elf64-aarch64.c 8 Feb 2013 12:32:42 -0000 1.6
+++ bfd/elf64-aarch64.c 9 Feb 2013 10:41:15 -0000
@@ -2093,7 +2093,7 @@ elf64_aarch64_link_hash_table_create (bf
struct elf64_aarch64_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf64_aarch64_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -2105,23 +2105,9 @@ elf64_aarch64_link_hash_table_create (bf
return NULL;
}
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
-
ret->plt_header_size = PLT_ENTRY_SIZE;
ret->plt_entry_size = PLT_SMALL_ENTRY_SIZE;
-
- ret->sym_cache.abfd = NULL;
ret->obfd = abfd;
-
- ret->stub_bfd = NULL;
- ret->add_stub_section = NULL;
- ret->layout_sections_again = NULL;
- ret->stub_group = NULL;
- ret->bfd_count = 0;
- ret->top_index = 0;
- ret->input_list = NULL;
- ret->tlsdesc_plt = 0;
ret->dt_tlsdesc_got = (bfd_vma) - 1;
if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc,
Index: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.125
diff -u -p -r1.125 elf64-s390.c
--- bfd/elf64-s390.c 10 Jan 2013 20:03:54 -0000 1.125
+++ bfd/elf64-s390.c 9 Feb 2013 10:41:15 -0000
@@ -699,7 +699,7 @@ elf_s390_link_hash_table_create (bfd *ab
struct elf_s390_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
- ret = (struct elf_s390_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_s390_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -711,16 +711,6 @@ elf_s390_link_hash_table_create (bfd *ab
return NULL;
}
- ret->elf.sgot = NULL;
- ret->elf.sgotplt = NULL;
- ret->elf.srelgot = NULL;
- ret->elf.splt = NULL;
- ret->elf.srelplt = NULL;
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->tls_ldm_got.refcount = 0;
- ret->sym_cache.abfd = NULL;
-
return &ret->elf.root;
}
Index: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.94
diff -u -p -r1.94 elf64-sh64.c
--- bfd/elf64-sh64.c 2 Sep 2012 12:17:26 -0000 1.94
+++ bfd/elf64-sh64.c 9 Feb 2013 10:41:15 -0000
@@ -3069,7 +3069,7 @@ sh64_elf64_link_hash_table_create (bfd *
{
struct elf_link_hash_table *ret;
- ret = (struct elf_link_hash_table *) bfd_malloc (sizeof (* ret));
+ ret = (struct elf_link_hash_table *) bfd_zmalloc (sizeof (* ret));
if (ret == (struct elf_link_hash_table *) NULL)
return NULL;
Index: bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.290
diff -u -p -r1.290 elf64-x86-64.c
--- bfd/elf64-x86-64.c 7 Feb 2013 02:15:29 -0000 1.290
+++ bfd/elf64-x86-64.c 9 Feb 2013 10:41:16 -0000
@@ -888,7 +888,7 @@ elf_x86_64_link_hash_table_create (bfd *
struct elf_x86_64_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_x86_64_link_hash_table);
- ret = (struct elf_x86_64_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_x86_64_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -901,18 +901,6 @@ elf_x86_64_link_hash_table_create (bfd *
return NULL;
}
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->plt_eh_frame = NULL;
- ret->sym_cache.abfd = NULL;
- ret->tlsdesc_plt = 0;
- ret->tlsdesc_got = 0;
- ret->tls_ld_got.refcount = 0;
- ret->sgotplt_jump_table_size = 0;
- ret->tls_module_base = NULL;
- ret->next_jump_slot_index = 0;
- ret->next_irelative_index = 0;
-
if (ABI_64_P (abfd))
{
ret->r_info = elf64_r_info;
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.465
diff -u -p -r1.465 elflink.c
--- bfd/elflink.c 8 Feb 2013 01:33:01 -0000 1.465
+++ bfd/elflink.c 9 Feb 2013 10:41:16 -0000
@@ -6908,7 +6908,8 @@ _bfd_elf_link_hash_hide_symbol (struct b
}
}
-/* Initialize an ELF linker hash table. */
+/* Initialize an ELF linker hash table. *TABLE has been zeroed by our
+ caller. */
bfd_boolean
_bfd_elf_link_hash_table_init
@@ -6923,7 +6924,6 @@ _bfd_elf_link_hash_table_init
bfd_boolean ret;
int can_refcount = get_elf_backend_data (abfd)->can_refcount;
- memset (table, 0, sizeof * table);
table->init_got_refcount.refcount = can_refcount - 1;
table->init_plt_refcount.refcount = can_refcount - 1;
table->init_got_offset.offset = -(bfd_vma) 1;
@@ -6947,7 +6947,7 @@ _bfd_elf_link_hash_table_create (bfd *ab
struct elf_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_link_hash_table);
- ret = (struct elf_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.322
diff -u -p -r1.322 elfxx-mips.c
--- bfd/elfxx-mips.c 10 Jan 2013 20:03:54 -0000 1.322
+++ bfd/elfxx-mips.c 9 Feb 2013 10:41:16 -0000
@@ -420,11 +420,6 @@ struct mips_elf_link_hash_entry
struct mips_elf_link_hash_table
{
struct elf_link_hash_table root;
-#if 0
- /* We no longer use this. */
- /* String section indices for the dynamic section symbols. */
- bfd_size_type dynsym_sec_strindex[SIZEOF_MIPS_DYNSYM_SECNAMES];
-#endif
/* The number of .rtproc entries. */
bfd_size_type procedure_count;
@@ -12949,7 +12944,7 @@ _bfd_mips_elf_link_hash_table_create (bf
struct mips_elf_link_hash_table *ret;
bfd_size_type amt = sizeof (struct mips_elf_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
@@ -12962,36 +12957,6 @@ _bfd_mips_elf_link_hash_table_create (bf
return NULL;
}
-#if 0
- /* We no longer use this. */
- for (i = 0; i < SIZEOF_MIPS_DYNSYM_SECNAMES; i++)
- ret->dynsym_sec_strindex[i] = (bfd_size_type) -1;
-#endif
- ret->procedure_count = 0;
- ret->compact_rel_size = 0;
- ret->use_rld_obj_head = FALSE;
- ret->rld_symbol = NULL;
- ret->mips16_stubs_seen = FALSE;
- ret->use_plts_and_copy_relocs = FALSE;
- ret->is_vxworks = FALSE;
- ret->small_data_overflow_reported = FALSE;
- ret->srelbss = NULL;
- ret->sdynbss = NULL;
- ret->srelplt = NULL;
- ret->srelplt2 = NULL;
- ret->sgotplt = NULL;
- ret->splt = NULL;
- ret->sstubs = NULL;
- ret->sgot = NULL;
- ret->got_info = NULL;
- ret->plt_header_size = 0;
- ret->plt_entry_size = 0;
- ret->lazy_stub_count = 0;
- ret->function_stub_size = 0;
- ret->strampoline = NULL;
- ret->la25_stubs = NULL;
- ret->add_stub_section = NULL;
-
return &ret->root.root;
}
Index: bfd/m68klinux.c
===================================================================
RCS file: /cvs/src/src/bfd/m68klinux.c,v
retrieving revision 1.27
diff -u -p -r1.27 m68klinux.c
--- bfd/m68klinux.c 13 Jul 2012 14:22:50 -0000 1.27
+++ bfd/m68klinux.c 9 Feb 2013 10:41:17 -0000
@@ -203,7 +203,7 @@ linux_link_hash_table_create (bfd *abfd)
struct linux_link_hash_table *ret;
bfd_size_type amt = sizeof (struct linux_link_hash_table);
- ret = (struct linux_link_hash_table *) bfd_malloc (amt);
+ ret = (struct linux_link_hash_table *) bfd_zmalloc (amt);
if (ret == (struct linux_link_hash_table *) NULL)
{
bfd_set_error (bfd_error_no_memory);
@@ -217,11 +217,6 @@ linux_link_hash_table_create (bfd *abfd)
return (struct bfd_link_hash_table *) NULL;
}
- ret->dynobj = NULL;
- ret->fixup_count = 0;
- ret->local_builtins = 0;
- ret->fixup_list = NULL;
-
return &ret->root.root;
}
Index: bfd/sparclinux.c
===================================================================
RCS file: /cvs/src/src/bfd/sparclinux.c,v
retrieving revision 1.27
diff -u -p -r1.27 sparclinux.c
--- bfd/sparclinux.c 13 Jul 2012 14:22:50 -0000 1.27
+++ bfd/sparclinux.c 9 Feb 2013 10:41:17 -0000
@@ -200,7 +200,7 @@ linux_link_hash_table_create (bfd *abfd)
struct linux_link_hash_table *ret;
bfd_size_type amt = sizeof (struct linux_link_hash_table);
- ret = (struct linux_link_hash_table *) bfd_malloc (amt);
+ ret = (struct linux_link_hash_table *) bfd_zmalloc (amt);
if (ret == (struct linux_link_hash_table *) NULL)
return (struct bfd_link_hash_table *) NULL;
if (!NAME(aout,link_hash_table_init) (&ret->root, abfd,
@@ -211,11 +211,6 @@ linux_link_hash_table_create (bfd *abfd)
return (struct bfd_link_hash_table *) NULL;
}
- ret->dynobj = NULL;
- ret->fixup_count = 0;
- ret->local_builtins = 0;
- ret->fixup_list = NULL;
-
return &ret->root.root;
}
Index: bfd/sunos.c
===================================================================
RCS file: /cvs/src/src/bfd/sunos.c,v
retrieving revision 1.28
diff -u -p -r1.28 sunos.c
--- bfd/sunos.c 2 Jul 2012 03:02:45 -0000 1.28
+++ bfd/sunos.c 9 Feb 2013 10:41:17 -0000
@@ -679,7 +679,7 @@ sunos_link_hash_table_create (bfd *abfd)
struct sunos_link_hash_table *ret;
bfd_size_type amt = sizeof (struct sunos_link_hash_table);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
if (!NAME (aout, link_hash_table_init) (&ret->root, abfd,
@@ -690,15 +690,6 @@ sunos_link_hash_table_create (bfd *abfd)
return NULL;
}
- ret->dynobj = NULL;
- ret->dynamic_sections_created = FALSE;
- ret->dynamic_sections_needed = FALSE;
- ret->got_needed = FALSE;
- ret->dynsymcount = 0;
- ret->bucketcount = 0;
- ret->needed = NULL;
- ret->got_base = 0;
-
return &ret->root.root;
}
Index: bfd/xcofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/xcofflink.c,v
retrieving revision 1.82
diff -u -p -r1.82 xcofflink.c
--- bfd/xcofflink.c 10 Jan 2013 20:03:55 -0000 1.82
+++ bfd/xcofflink.c 9 Feb 2013 10:41:17 -0000
@@ -580,7 +580,7 @@ _bfd_xcoff_bfd_link_hash_table_create (b
struct xcoff_link_hash_table *ret;
bfd_size_type amt = sizeof (* ret);
- ret = bfd_malloc (amt);
+ ret = bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
if (!_bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc,
@@ -591,20 +591,8 @@ _bfd_xcoff_bfd_link_hash_table_create (b
}
ret->debug_strtab = _bfd_xcoff_stringtab_init ();
- ret->debug_section = NULL;
- ret->loader_section = NULL;
- ret->ldrel_count = 0;
- memset (&ret->ldhdr, 0, sizeof (struct internal_ldhdr));
- ret->linkage_section = NULL;
- ret->toc_section = NULL;
- ret->descriptor_section = NULL;
- ret->imports = NULL;
- ret->file_align = 0;
- ret->textro = FALSE;
- ret->gc = FALSE;
ret->archive_info = htab_create (37, xcoff_archive_info_hash,
xcoff_archive_info_eq, NULL);
- memset (ret->special_sections, 0, sizeof ret->special_sections);
/* The linker will always generate a full a.out header. We need to
record that fact now, before the sizeof_headers routine could be
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list