This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: Fix the mips dynamic relocation for weak definiton.


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  <hjl@gnu.org>
> 
> 	* 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  <hjl@gnu.org>

	* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]