From a0abe74332bd25aeb68acfadd74280c0f117c493 Mon Sep 17 00:00:00 2001 From: Cupertino Miranda Date: Thu, 29 Dec 2016 17:10:01 +0100 Subject: [PATCH] [ARC] Fixed TLS for IE model. 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 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/ChangeLog | 6 ++++++ bfd/arc-got.h | 7 ++++++- bfd/elf32-arc.c | 1 - ld/ChangeLog | 4 ++++ ld/testsuite/ld-arc/tls_ie-01.d | 4 ++-- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9ee1bf4..7fb198a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2017-06-08 Cupertino Miranda + * 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. + +2017-06-08 Cupertino Miranda + * elf32-arc.c (elf_arc_relocate_section): Added "call" to RELOC_FOR_GLOBAL_SYMBOL macro. 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 f424f13..c1286b2 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -1187,7 +1187,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/ChangeLog b/ld/ChangeLog index 9dd4256..2cbe09d 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,7 @@ +2017-06-08 Cupertino Miranda + + * testsuite/ld-arc/tls_ie-01.d: Changed expected result. + 2017-06-08 H.J. Lu * testsuite/ld-ifunc/ifunc-1-local-x86.d: Pass 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.7.4