RISC-V: Fix TLS copy relocs
authorAndrew Waterman <andrew@sifive.com>
Wed, 28 Jun 2017 05:44:24 +0000 (22:44 -0700)
committerPalmer Dabbelt <palmer@dabbelt.com>
Thu, 29 Jun 2017 16:38:50 +0000 (09:38 -0700)
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.

bfd/ChangeLog
bfd/elfnn-riscv.c

index 7195221c0c957fa4021b24bd9fa218ad245e3514..c384a0f028bd7963707f048ba3025c19e9762a6d 100644 (file)
@@ -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
index 455f2ff2922e2ebca58c2129d31b38a06e4655eb..6d297cea7d73ca6ceb02d559c4a73bb5d3041780 100644 (file)
@@ -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);
 }
 
This page took 0.029271 seconds and 4 git commands to generate.