This is the mail archive of the binutils-cvs@sourceware.org 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]
Other format: [Raw text]

[binutils-gdb] RISC-V: Fix TLS copy relocs


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3df5cd139455a1448de00e1e173f3ce566a25a48

commit 3df5cd139455a1448de00e1e173f3ce566a25a48
Author: Andrew Waterman <andrew@sifive.com>
Date:   Tue Jun 27 22:44:24 2017 -0700

    RISC-V: Fix TLS copy relocs
    
    The dynrelro introduction wasn't implemented quite right for RISC-V,
    as it didn't consider TLS copy relocs.
    
    bfd/ChangeLog
    
    2017-06-29  Andrew Waterman  <andrew@sifive.com>
    
            * elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Fix TLS copy
            relocs.

Diff:
---
 bfd/ChangeLog     |  5 +++++
 bfd/elfnn-riscv.c | 10 ++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7195221..c384a0f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-29  Andrew Waterman  <andrew@sifive.com>
+
+	* elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Fix TLS copy
+	relocs.
+
 2017-06-29  Egeyar Bagcioglu  <egeyar.bagcioglu@oracle.com>
 
 	* elfxx-sparc.c (allocate_dynrelocs): Don't make a symbol dynamic
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 455f2ff..6d297ce 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -965,7 +965,12 @@ riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
      to copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rel.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+  if (eh->tls_type & ~GOT_NORMAL)
+    {
+      s = htab->sdyntdata;
+      srel = htab->elf.srelbss;
+    }
+  else if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
     {
       s = htab->elf.sdynrelro;
       srel = htab->elf.sreldynrelro;
@@ -981,9 +986,6 @@ riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       h->needs_copy = 1;
     }
 
-  if (eh->tls_type & ~GOT_NORMAL)
-    return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdyntdata);
-
   return _bfd_elf_adjust_dynamic_copy (info, h, s);
 }


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