From mboxrd@z Thu Jan 1 00:00:00 1970 From: "H . J . Lu" To: binutils@sourceware.cygnus.com Cc: nickc@redhat.com, echristo@redhat.com Subject: Re: PATCH: Fix the mips dynamic relocation for weak definiton. Date: Mon, 27 Aug 2001 08:06:00 -0000 Message-id: <20010827080637.A5591@lucon.org> References: <20010826174901.A2794@lucon.org> X-SW-Source: 2001-08/msg00628.html On Sun, Aug 26, 2001 at 05:49:02PM -0700, H . J . Lu wrote: > I cannot believe that we didn't catch this bug much earlier. I copied > the same logic in elf_i386_check_relocs (). I also added the missing > prototype. Is that ok to check in? > > > H.J. > ---- > 2001-08-26 H.J. Lu > > * elf32-mips.c (mips_elf_create_dynamic_relocation): Add the > sanity check. > (mips_elf_calculate_relocation): Create dynamic relocation for > symbols with weak definition or the ELF_LINK_HASH_DEF_REGULAR > bit is not set. > (_bfd_mips_elf_hide_symbol): Add prototype. > (_bfd_mips_elf_copy_indirect_symbol): Likewise. > (_bfd_elf32_mips_grok_prstatus): Likewise. > (_bfd_elf32_mips_grok_psinfo): Likewise. > (_bfd_mips_elf_hide_symbol): Make it static and cast to > `struct mips_elf_link_hash_entry *'. > (_bfd_mips_elf_copy_indirect_symbol): Make it static. > I checked in the prototype part of the patch. Here is an updated patch for mips dynamic relocation only. I will check it in today as an obvious fix. Thanks. H.J. ---- 2001-08-27 H.J. Lu * elf32-mips.c (mips_elf_create_dynamic_relocation): Add more sanity check. (mips_elf_calculate_relocation): Create dynamic relocation for symbols with weak definition or the ELF_LINK_HASH_DEF_REGULAR bit is not set. --- bfd/elf32-mips.c.assert Mon Aug 27 07:47:46 2001 +++ bfd/elf32-mips.c Mon Aug 27 07:57:09 2001 @@ -5830,6 +5830,8 @@ mips_elf_create_dynamic_relocation (outp MIPS_ELF_REL_DYN_SECTION_NAME (output_bfd)); BFD_ASSERT (sreloc != NULL); BFD_ASSERT (sreloc->contents != NULL); + BFD_ASSERT (sreloc->reloc_count * MIPS_ELF_REL_SIZE (output_bfd) + < sreloc->_raw_size); skip = false; @@ -6330,8 +6332,9 @@ mips_elf_calculate_relocation (abfd, if ((info->shared || (elf_hash_table (info)->dynamic_sections_created && h != NULL - && ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) - != 0))) + && (h->root.type == bfd_link_hash_defweak + || (h->root.elf_link_hash_flags + & ELF_LINK_HASH_DEF_REGULAR) == 0))) && (input_section->flags & SEC_ALLOC) != 0) { /* If we're creating a shared library, or this relocation is