From 7bf52ea2ca60774385b8d2678729abb52572b594 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 10 Feb 2013 04:36:33 +0000 Subject: [PATCH] * 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. --- bfd/ChangeLog | 36 ++++++++++++++++++++++++++++++++++++ bfd/coff-arm.c | 6 +----- bfd/coff-h8300.c | 7 +------ bfd/elf-m10300.c | 8 ++------ bfd/elf32-arm.c | 37 +------------------------------------ bfd/elf32-avr.c | 11 +---------- bfd/elf32-cr16.c | 2 +- bfd/elf32-cris.c | 5 +---- bfd/elf32-hppa.c | 20 +------------------- bfd/elf32-i386.c | 14 +------------- bfd/elf32-lm32.c | 12 +----------- bfd/elf32-m32r.c | 11 +---------- bfd/elf32-m68hc1x.c | 8 +------- bfd/elf32-m68k.c | 8 +------- bfd/elf32-metag.c | 16 +--------------- bfd/elf32-nios2.c | 7 +------ bfd/elf32-s390.c | 12 +----------- bfd/elf32-score.c | 2 +- bfd/elf32-spu.c | 5 +---- bfd/elf32-tic6x.c | 3 +-- bfd/elf32-vax.c | 2 +- bfd/elf32-xgate.c | 16 +++++++--------- bfd/elf32-xtensa.c | 12 +----------- bfd/elf64-aarch64.c | 16 +--------------- bfd/elf64-s390.c | 12 +----------- bfd/elf64-sh64.c | 2 +- bfd/elf64-x86-64.c | 14 +------------- bfd/elflink.c | 6 +++--- bfd/elfxx-mips.c | 37 +------------------------------------ bfd/m68klinux.c | 7 +------ bfd/sparclinux.c | 7 +------ bfd/sunos.c | 11 +---------- bfd/xcofflink.c | 14 +------------- 33 files changed, 77 insertions(+), 309 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 4342fa4b54..44ff651207 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,39 @@ +2013-02-10 Alan Modra + + * 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. + 2013-02-10 Alan Modra * i386linux.c (linux_link_hash_table_create): Allocate table diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index 4cdf1acc27..efcf522a34 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -918,7 +918,7 @@ coff_arm_link_hash_table_create (bfd * abfd) 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 * abfd) return NULL; } - ret->thumb_glue_size = 0; - ret->arm_glue_size = 0; - ret->bfd_of_glue_owner = NULL; - return & ret->root.root; } diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c index 0f1de573f1..1e3427502c 100644 --- a/bfd/coff-h8300.c +++ b/bfd/coff-h8300.c @@ -173,7 +173,7 @@ h8300_coff_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 1dd502039b..fb38f34315 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -4603,7 +4603,7 @@ elf32_mn10300_link_hash_table_create (bfd *abfd) 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 (bfd *abfd) 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); diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 6197f95041..ee37915d0c 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3417,7 +3417,7 @@ elf32_arm_link_hash_table_create (bfd *abfd) 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 *abfd) 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 *abfd) 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))) diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index 2236fc7142..6cec6843b1 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -672,7 +672,7 @@ elf32_avr_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c index 2c0502320a..4b3aa733b5 100644 --- a/bfd/elf32-cr16.c +++ b/bfd/elf32-cr16.c @@ -1660,7 +1660,7 @@ elf32_cr16_link_hash_table_create (bfd *abfd) 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; diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index f85ba0d36e..5f0eca9aad 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -884,7 +884,7 @@ elf_cris_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 9a05c381b7..2c1b9dbaeb 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -419,7 +419,7 @@ elf32_hppa_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index f8ad1d1c1f..b6004ef987 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -937,7 +937,7 @@ elf_i386_link_hash_table_create (bfd *abfd) 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 *abfd) 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, diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 2579034dab..f5d03e57b2 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -159,7 +159,7 @@ lm32_elf_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 70ddaab205..93b5021c3c 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1585,7 +1585,7 @@ m32r_elf_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c index deb3c6243c..6cef46d085 100644 --- a/bfd/elf32-m68hc1x.c +++ b/bfd/elf32-m68hc1x.c @@ -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; } diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 6946841e44..26fef9fcac 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -950,7 +950,7 @@ elf_m68k_link_hash_table_create (bfd *abfd) 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 *abfd) 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; diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c index 8a696be0bc..821cea1552 100644 --- a/bfd/elf32-metag.c +++ b/bfd/elf32-metag.c @@ -1027,7 +1027,7 @@ elf_metag_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c index 2d6f07a32c..35fda54c23 100644 --- a/bfd/elf32-nios2.c +++ b/bfd/elf32-nios2.c @@ -3958,7 +3958,7 @@ nios2_elf32_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 491daf38ff..2c0822b962 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -786,7 +786,7 @@ elf_s390_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c index 7b16ea2d15..ee3a668a1e 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -4357,7 +4357,7 @@ elf32_score_link_hash_table_create (bfd *abfd) 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; diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index 97935d0454..cb4ff525f9 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -440,7 +440,7 @@ spu_elf_link_hash_table_create (bfd *abfd) { 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 *abfd) 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; diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index fb30e923a5..d376fe1d43 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -1570,7 +1570,7 @@ elf32_tic6x_link_hash_table_create (bfd *abfd) 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 *abfd) return NULL; } - ret->sym_cache.abfd = NULL; ret->obfd = abfd; ret->elf.is_relocatable_executable = 1; diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index 3fbc289570..0e79a2ae35 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -465,7 +465,7 @@ elf_vax_link_hash_table_create (bfd *abfd) 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; diff --git a/bfd/elf32-xgate.c b/bfd/elf32-xgate.c index 2169c569b4..ad2190b3a2 100644 --- a/bfd/elf32-xgate.c +++ b/bfd/elf32-xgate.c @@ -448,11 +448,10 @@ xgate_elf_bfd_link_hash_table_create (bfd *abfd) 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 (bfd *abfd) /* 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 (bfd *abfd) 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; } diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index e48bf4b9ae..1e4bb4600e 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -655,7 +655,7 @@ elf_xtensa_link_hash_table_create (bfd *abfd) 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 *abfd) 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_", diff --git a/bfd/elf64-aarch64.c b/bfd/elf64-aarch64.c index e0583d730e..e588d82c24 100644 --- a/bfd/elf64-aarch64.c +++ b/bfd/elf64-aarch64.c @@ -2093,7 +2093,7 @@ elf64_aarch64_link_hash_table_create (bfd *abfd) 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 (bfd *abfd) 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, diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 2515cb5bfc..eece2c26f9 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -699,7 +699,7 @@ elf_s390_link_hash_table_create (bfd *abfd) 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 *abfd) 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; } diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index 3e6d081f77..7a9297cf32 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -3069,7 +3069,7 @@ sh64_elf64_link_hash_table_create (bfd *abfd) { 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; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 79b6dc6060..f709c7a098 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -888,7 +888,7 @@ elf_x86_64_link_hash_table_create (bfd *abfd) 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 *abfd) 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; diff --git a/bfd/elflink.c b/bfd/elflink.c index e6c835153f..1bae437fc3 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -6908,7 +6908,8 @@ _bfd_elf_link_hash_hide_symbol (struct bfd_link_info *info, } } -/* 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 *abfd) 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; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 61bd4bcbd6..b281971bc5 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -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 (bfd *abfd) 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 (bfd *abfd) 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; } diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c index 9bbbd440e3..f612782ac0 100644 --- a/bfd/m68klinux.c +++ b/bfd/m68klinux.c @@ -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; } diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c index 6edfeeb359..7ed255f41e 100644 --- a/bfd/sparclinux.c +++ b/bfd/sparclinux.c @@ -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; } diff --git a/bfd/sunos.c b/bfd/sunos.c index 028fb280e3..6d84f43fb6 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -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; } diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index a409dcbf01..e769e03535 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -580,7 +580,7 @@ _bfd_xcoff_bfd_link_hash_table_create (bfd *abfd) 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 (bfd *abfd) } 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 -- 2.34.1