public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Cc: Sandra Loosemore <sandra@codesourcery.com>,
	Andrew Jenner <andrew@codesourcery.com>
Subject: [PATCH] nios2: Don't check relocations in non-loaded, non-alloced sections
Date: Sun, 31 May 2020 05:23:51 -0700	[thread overview]
Message-ID: <20200531122351.61713-1-hjl.tools@gmail.com> (raw)

Don't do anything special with non-loaded, non-alloced sections.
In particular, any relocs in such sections should not affect GOT
and PLT reference counting (ie. we don't allow them to create GOT
or PLT entries), there's no possibility or desire to optimize TLS
relocs, and there's not much point in propagating relocs to shared
libs that the dynamic linker won't relocate.

This fixed:

FAIL: Common symbol override test

OK for master?

H.J.
---
	PR ld/26066
	* elf32-nios2.c (nios2_elf32_check_relocs): Skip non-loaded,
	non-alloced sections.
---
 bfd/elf32-nios2.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index 0b2e68ebd6..f0cdd5203a 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -4724,6 +4724,15 @@ nios2_elf32_check_relocs (bfd *abfd, struct bfd_link_info *info,
   if (bfd_link_relocatable (info))
     return TRUE;
 
+  /* Don't do anything special with non-loaded, non-alloced sections.
+     In particular, any relocs in such sections should not affect GOT
+     and PLT reference counting (ie. we don't allow them to create GOT
+     or PLT entries), there's no possibility or desire to optimize TLS
+     relocs, and there's not much point in propagating relocs to shared
+     libs that the dynamic linker won't relocate.  */
+  if ((sec->flags & SEC_ALLOC) == 0)
+    return TRUE;
+
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   sym_hashes_end = (sym_hashes
-- 
2.26.2


             reply	other threads:[~2020-05-31 12:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 12:23 H.J. Lu [this message]
2020-06-03 15:50 ` Nick Clifton

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=20200531122351.61713-1-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=andrew@codesourcery.com \
    --cc=binutils@sourceware.org \
    --cc=sandra@codesourcery.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).