tile: Mark __tls_get_addr in gc_mark_hook
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 18 Oct 2017 22:46:57 +0000 (15:46 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 18 Oct 2017 22:47:35 +0000 (15:47 -0700)
TLS_GD_CALL relocations implicitly reference __tls_get_addr.  Since
elf_gc_mark_hook is called before check_relocs now, we need to call
_bfd_generic_link_add_one_symbol to mark __tls_get_addr for garbage
collection.

* elf32-tilepro.c (tilepro_elf_gc_mark_hook): Call
_bfd_generic_link_add_one_symbol to mark __tls_get_addr.
* elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise.

bfd/ChangeLog
bfd/elf32-tilepro.c
bfd/elfxx-tilegx.c

index c574a9abc6497a17f42df912241a4db5bb840750..a300d1c4271d2fc4dbc1b0d5305086846e359c17 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-tilepro.c (tilepro_elf_gc_mark_hook): Call
+       _bfd_generic_link_add_one_symbol to mark __tls_get_addr.
+       * elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise.
+
 2017-10-17  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-microblaze.c (microblaze_elf_check_relocs): Check for
index 7ab60bbacaa12bdedc23381ea04266c9d3d6c4b0..0bdb6c46e8eb4e0c9adf46d98754968130f394e2 100644 (file)
@@ -1864,6 +1864,8 @@ tilepro_elf_gc_mark_hook (asection *sec,
      dealing with TLS optimization, ought to be !bfd_link_executable (info).  */
   if (bfd_link_pic (info))
     {
+      struct bfd_link_hash_entry *bh;
+
       switch (ELF32_R_TYPE (rel->r_info))
        {
        case R_TILEPRO_TLS_GD_CALL:
@@ -1872,8 +1874,14 @@ tilepro_elf_gc_mark_hook (asection *sec,
             on this reloc, so the real symbol and section will be
             gc marked when processing the other reloc.  That lets
             us handle __tls_get_addr here.  */
-         h = elf_link_hash_lookup (elf_hash_table (info), "__tls_get_addr",
-                                   FALSE, FALSE, TRUE);
+         bh = NULL;
+         if (! _bfd_generic_link_add_one_symbol (info, sec->owner,
+                                                 "__tls_get_addr", 0,
+                                                 bfd_und_section_ptr,
+                                                 0, NULL, FALSE,
+                                                 FALSE, &bh))
+           return NULL;
+         h = (struct elf_link_hash_entry *) bh;
          BFD_ASSERT (h != NULL);
          h->mark = 1;
          if (h->u.weakdef != NULL)
index c9e860a70c914786d2c0e6a34a36935b6875e17b..d7b04193ef983e8b5d60a4eb34113e83674a8a1b 100644 (file)
@@ -2103,6 +2103,8 @@ tilegx_elf_gc_mark_hook (asection *sec,
      dealing with TLS optimization, ought to be !bfd_link_executable (info).  */
   if (bfd_link_pic (info))
     {
+      struct bfd_link_hash_entry *bh;
+
       switch (TILEGX_ELF_R_TYPE (rel->r_info))
        {
        case R_TILEGX_TLS_GD_CALL:
@@ -2111,8 +2113,14 @@ tilegx_elf_gc_mark_hook (asection *sec,
             on this reloc, so the real symbol and section will be
             gc marked when processing the other reloc.  That lets
             us handle __tls_get_addr here.  */
-         h = elf_link_hash_lookup (elf_hash_table (info), "__tls_get_addr",
-                                   FALSE, FALSE, TRUE);
+         bh = NULL;
+         if (! _bfd_generic_link_add_one_symbol (info, sec->owner,
+                                                 "__tls_get_addr", 0,
+                                                 bfd_und_section_ptr,
+                                                 0, NULL, FALSE,
+                                                 FALSE, &bh))
+           return NULL;
+         h = (struct elf_link_hash_entry *) bh;
          BFD_ASSERT (h != NULL);
          h->mark = 1;
          if (h->u.weakdef != NULL)
This page took 0.030528 seconds and 4 git commands to generate.