This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 7/9] [ARC] Fixed TLS for IE model.
- From: Cupertino Miranda <Cupertino dot Miranda at synopsys dot com>
- To: binutils at sourceware dot org
- Cc: Cupertino dot Miranda at synopsys dot com, Claudiu dot Zissulescu at synopsys dot com, Francois dot Bedard at synopsys dot com
- Date: Tue, 23 May 2017 17:40:54 +0200
- Subject: [PATCH 7/9] [ARC] Fixed TLS for IE model.
- Authentication-results: sourceware.org; auth=none
- References: <20170523154056.19234-1-cmiranda@synopsys.com>
In the case of static relocation, the GOT entries are fixed at link time
and are set by the linker.
In order to compute the right TLS offset it is necessary to add TCB_SIZE
to the offset, just in case the dynamic linker is not expected to be
executed (static linked case).
This problem does appear in dynamic linked applications, as the dynamic
linker is adding this TCB_SIZE by operating the TCB block structure.
Problem revealed in GLIBC with static linking.
bfd/ChangeLog:
Cupertino Miranda <cmiranda@synopsys.com>
arc-got.h (relocate_fix_got_relocs_for_got_info): Added TCB_SIZE to
patched section contents for TLS IE reloc.
elf32-arc.c: Remove TCB_SIZE preprocessor macro.
Rebase to 0006
---
bfd/arc-got.h | 7 ++++++-
bfd/elf32-arc.c | 1 -
ld/testsuite/ld-arc/tls_ie-01.d | 4 ++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/bfd/arc-got.h b/bfd/arc-got.h
index b8a6d15..f1f6c0e 100644
--- a/bfd/arc-got.h
+++ b/bfd/arc-got.h
@@ -22,6 +22,8 @@
#ifndef ARC_GOT_H
#define ARC_GOT_H
+#define TCB_SIZE (8)
+
enum tls_type_e
{
GOT_UNKNOWN = 0,
@@ -354,7 +356,8 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p,
= tls_sec->output_section->vma;
bfd_put_32 (output_bfd,
- sym_value - sec_vma,
+ sym_value - sec_vma
+ + (elf_hash_table (info)->dynamic_sections_created ? 0 : TCB_SIZE),
htab->sgot->contents + entry->offset
+ (entry->existing_entries == TLS_GOT_MOD_AND_OFF
? 4 : 0));
@@ -478,8 +481,10 @@ GOT_OFFSET = %#lx, GOT_VMA = %#lx, INDEX = %ld, ADDEND = 0x0\n",
{
bfd_vma addend = 0;
if (list->type == GOT_TLS_IE)
+ {
addend = bfd_get_32 (output_bfd,
htab->sgot->contents + got_offset);
+ }
ADD_RELA (output_bfd, got,
got_offset + (e == TLS_GOT_MOD_AND_OFF ? 4 : 0),
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 117253d..928dd68 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1183,7 +1183,6 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data,
#define TLS_REL (bfd_signed_vma) \
((elf_hash_table (info))->tls_sec->output_section->vma)
#define TLS_TBSS (8)
-#define TCB_SIZE (8)
#define none (0)
diff --git a/ld/testsuite/ld-arc/tls_ie-01.d b/ld/testsuite/ld-arc/tls_ie-01.d
index 304973c..62b3932 100644
--- a/ld/testsuite/ld-arc/tls_ie-01.d
+++ b/ld/testsuite/ld-arc/tls_ie-01.d
@@ -1,10 +1,10 @@
#source: tls_ie-01.s
#as: -mcpu=arc700
-#ld:
+#ld: -static
#objdump: -s -j .got
#xfail: arc*-*-elf*
[^:]+: file format elf32-littlearc
Contents of section \.got:
- [0-9a-f]+ 00000000 04000000 .+
+ [0-9a-f]+ 08000000 0c000000 +.+
--
2.9.0