This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] RISC-V: Fix TLS copy relocs
- From: Palmer Dabbelt <palmer at dabbelt dot com>
- To: binutils at sourceware dot org
- Cc: Andrew Waterman <andrew at sifive dot com>
- Date: Wed, 28 Jun 2017 13:02:15 -0700
- Subject: [PATCH] RISC-V: Fix TLS copy relocs
- Authentication-results: sourceware.org; auth=none
From: Andrew Waterman <andrew@sifive.com>
The dynrelro introduction wasn't implemented quite right for RISC-V,
as it didn't consider TLS copy relocs.
bfd/ChangeLog
2017-06-28 Andrew Waterman <andrew@sifive.com>
* elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Fix TLS copy
relocs.
---
bfd/elfnn-riscv.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 811a37035e..05530270d7 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -968,7 +968,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;
@@ -984,9 +989,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);
}
--
2.13.0