public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H . J . Lu" <hjl@lucon.org>
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	[thread overview]
Message-ID: <20010827080637.A5591@lucon.org> (raw)
In-Reply-To: <20010826174901.A2794@lucon.org>

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

      reply	other threads:[~2001-08-27  8:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-26 17:49 H . J . Lu
2001-08-27  8:06 ` H . J . Lu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010827080637.A5591@lucon.org \
    --to=hjl@lucon.org \
    --cc=binutils@sourceware.cygnus.com \
    --cc=echristo@redhat.com \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).