diff options
author | Cupertino Miranda <cmiranda@synopsys.com> | 2018-10-04 10:17:03 +0100 |
---|---|---|
committer | Cupertino Miranda <cmiranda@synopsys.com> | 2018-11-09 15:34:37 +0000 |
commit | d07b621f4cc585607c7eee7cc58ce54a7dde52f5 (patch) | |
tree | 766c99bcb5938ebb172201b347c5ecf2fb42e183 /bfd/elf32-arc.c | |
parent | Updated French translation for the ld subdirectory. (diff) | |
download | binutils-gdb-d07b621f4cc585607c7eee7cc58ce54a7dde52f5.tar.gz binutils-gdb-d07b621f4cc585607c7eee7cc58ce54a7dde52f5.tar.bz2 binutils-gdb-d07b621f4cc585607c7eee7cc58ce54a7dde52f5.zip |
[ARC] More fixes for TLS.
Added warning for static TLS reloc.
Fixed issue related to TLS and partial static linking of libraries:
This issue was detected when throwing exceptions in C++ while linking with
-static-libstdc++.
TLS relocation from the libstdc++ wasn't being patched as local now that it was
static linked with the executable.
Fix for TLS with static and pie. Problem introduced by earlier patch:
Fixes the following glibc tests:
- elf/tst-tls1-static
bfd/
xxxx-xx-xx Cupertino Miranda <cmiranda@synopsys.com>
* arc-got.h (arc_got_entry_type_for_reloc): Changed to
correct static TLS relocs.
* elf32-arc.c (elf_arc_check_relocs): Introduced warning to
TLS relocs which require -fPIC.
(arc_create_forced_local_got_entries_for_tls): Created.
Traverses list of GOT entries to be resolved statically
when needed.
(elf_arc_finish_dynamic_sections): Changed. Calls
arc_create_forced_local_got_entries_for_tls for each known
possibly GOT symbol.
Diffstat (limited to 'bfd/elf32-arc.c')
-rw-r--r-- | bfd/elf32-arc.c | 116 |
1 files changed, 86 insertions, 30 deletions
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 668642c3024..e96b3f86974 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -1989,36 +1989,35 @@ elf_arc_check_relocs (bfd * abfd, switch (r_type) { - case R_ARC_32: - case R_ARC_32_ME: - /* During shared library creation, these relocs should not - appear in a shared library (as memory will be read only - and the dynamic linker can not resolve these. However - the error should not occur for e.g. debugging or - non-readonly sections. */ - if (h != NULL - && (bfd_link_dll (info) && !bfd_link_pie (info)) - && (sec->flags & SEC_ALLOC) != 0 - && (sec->flags & SEC_READONLY) != 0 - && ((sec->flags & SEC_CODE) != 0 - || (sec->flags & SEC_DEBUGGING) != 0)) - { - const char *name; - if (h) - name = h->root.root.string; - else - /* bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL); */ - name = "UNKNOWN"; - _bfd_error_handler - /* xgettext:c-format */ - (_("%pB: relocation %s against `%s' can not be used" - " when making a shared object; recompile with -fPIC"), - abfd, - arc_elf_howto (r_type)->name, - name); - bfd_set_error (bfd_error_bad_value); - return FALSE; - } + case R_ARC_32: + case R_ARC_32_ME: + /* During shared library creation, these relocs should not + appear in a shared library (as memory will be read only + and the dynamic linker can not resolve these. However + the error should not occur for e.g. debugging or + non-readonly sections. */ + if (h != NULL + && (bfd_link_dll (info) && !bfd_link_pie (info)) + && (sec->flags & SEC_ALLOC) != 0 + && (sec->flags & SEC_READONLY) != 0 + && ((sec->flags & SEC_CODE) != 0 + || (sec->flags & SEC_DEBUGGING) != 0)) + { + const char *name; + if (h) + name = h->root.root.string; + else + name = "UNKNOWN"; + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB: relocation %s against `%s' can not be used" + " when making a shared object; recompile with -fPIC"), + abfd, + arc_elf_howto (r_type)->name, + name); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } /* In some cases we are not setting the 'non_got_ref' flag, even though the relocations don't require a GOT @@ -2068,6 +2067,25 @@ elf_arc_check_relocs (bfd * abfd, if (is_reloc_for_GOT (howto) || is_reloc_for_TLS (howto)) { + if (bfd_link_dll (info) && !bfd_link_pie (info) + && (r_type == R_ARC_TLS_LE_32 || r_type == R_ARC_TLS_LE_S9)) + { + const char *name; + if (h) + name = h->root.root.string; + else + /* bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL); */ + name = "UNKNOWN"; + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB: relocation %s against `%s' can not be used" + " when making a shared object; recompile with -fPIC"), + abfd, + arc_elf_howto (r_type)->name, + name); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } if (! _bfd_elf_create_got_section (dynobj, info)) return FALSE; @@ -2490,6 +2508,38 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd, s = bfd_get_linker_section (dynobj, SECTION); \ break; + +struct obfd_info_group { + bfd *output_bfd; + struct bfd_link_info *info; +}; + +static bfd_boolean +arc_create_forced_local_got_entries_for_tls (struct bfd_hash_entry *bh, + void *data) +{ + struct elf_arc_link_hash_entry * h = + (struct elf_arc_link_hash_entry *) bh; + struct obfd_info_group *tmp = (struct obfd_info_group *) data; + + if (h->got_ents != NULL) + { + BFD_ASSERT (h); + + struct got_entry *list = h->got_ents; + + while (list != NULL) + { + create_got_dynrelocs_for_single_entry (list, tmp->output_bfd, + tmp->info, h); + list = list->next; + } + } + + return TRUE; +} + + /* Function : elf_arc_finish_dynamic_sections Brief : Finish up the dynamic sections handling. Args : output_bfd : @@ -2623,6 +2673,12 @@ elf_arc_finish_dynamic_sections (bfd * output_bfd, } } + struct obfd_info_group group; + group.output_bfd = output_bfd; + group.info = info; + bfd_hash_traverse (&info->hash->table, + arc_create_forced_local_got_entries_for_tls, &group); + return TRUE; } |