public inbox for openrisc@lists.librecores.org
 help / color / mirror / Atom feed
From: Stafford Horne <shorne@gmail.com>
To: openrisc@lists.librecores.org
Subject: [OpenRISC] [PATCH 2/8] or1k: Fix dynamic TLS symbol flag
Date: Fri, 15 May 2020 06:00:12 +0900	[thread overview]
Message-ID: <20200514210018.2749462-3-shorne@gmail.com> (raw)
In-Reply-To: <20200514210018.2749462-1-shorne@gmail.com>

The dynamic flag used for TLS relocations was not properly being set
for some cases causing link failure.  The fix here was mostly copied
from other BFD implementations.

bfd/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* bfd/elf32-or1k.c (or1k_elf_relocate_section): Fixup dynamic
	symbol detection.
---
 bfd/elf32-or1k.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index 221a14c5b1..99a36c7f04 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -1592,6 +1592,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
 	    asection *srelgot;
 	    bfd_byte *loc;
 	    int dynamic;
+	    int indx = 0;
 
 	    srelgot = htab->root.srelgot;
 
@@ -1618,13 +1619,23 @@ or1k_elf_relocate_section (bfd *output_bfd,
 	    BFD_ASSERT (elf_hash_table (info)->hgot == NULL
 			|| elf_hash_table (info)->hgot->root.u.def.value == 0);
 
+	    if (h != NULL)
+	      {
+		bfd_boolean dyn = htab->root.dynamic_sections_created;
+		bfd_boolean pic = bfd_link_pic (info);
+
+		if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, pic, h)
+		    && (!pic || !SYMBOL_REFERENCES_LOCAL (info, h)))
+		  indx = h->dynindx;
+	      }
+
 	    /* Dynamic entries will require relocations.  If we do not need
 	       them we will just use the default R_OR1K_NONE and
 	       not set anything.  */
-	    dynamic = bfd_link_pic (info)
-	      || (sec && (sec->flags & SEC_ALLOC) != 0
-		  && h != NULL
-		  && (h->root.type == bfd_link_hash_defweak || !h->def_regular));
+	    dynamic = (bfd_link_pic (info) || indx != 0)
+		       && (h == NULL
+			   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+			   || h->root.type != bfd_link_hash_undefweak);
 
 	    /* Shared GD.  */
 	    if (dynamic
-- 
2.26.2


  parent reply	other threads:[~2020-05-14 21:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 21:00 [OpenRISC] [PATCH 0/8] OpenRISC BFD fixups for Glibc Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 1/8] or1k: Fix static linking when with .rela.got relocations Stafford Horne
2020-05-14 21:00 ` Stafford Horne [this message]
2020-05-14 21:00 ` [OpenRISC] [PATCH 3/8] or1k: Add TLS mask to handle multiple model access Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 4/8] or1k: Fix issue with multiple PCREL relocations Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 5/8] or1k: TLS offset to use tcb size and section alignment Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 6/8] or1k: refactor: Rename p to sec_relocs Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 7/8] or1k: refactor: Rename s to sgot and splt Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 8/8] or1k: Add dynamic flag to tpoff Stafford Horne
2020-05-19 13:30 ` [OpenRISC] [PATCH 0/8] OpenRISC BFD fixups for Glibc Nick Clifton
2020-05-19 20:42   ` Stafford Horne
2020-05-20 10:41     ` 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=20200514210018.2749462-3-shorne@gmail.com \
    --to=shorne@gmail.com \
    --cc=openrisc@lists.librecores.org \
    /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