__tls_get_addr_opt GOT entries
[external/binutils.git] / bfd / elf64-ppc.c
index 42abb96..70ad6c5 100644 (file)
@@ -12634,18 +12634,19 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
 
                  if (stub_type == ppc_stub_plt_call)
                    {
-                     if (irela + 1 < irelaend
-                         && irela[1].r_offset == irela->r_offset + 4
-                         && ELF64_R_TYPE (irela[1].r_info) == R_PPC64_TOCSAVE)
+                     if (!htab->opd_abi
+                         && htab->params->plt_localentry0 != 0
+                         && is_elfv2_localentry0 (&hash->elf))
+                       htab->has_plt_localentry0 = 1;
+                     else if (irela + 1 < irelaend
+                              && irela[1].r_offset == irela->r_offset + 4
+                              && (ELF64_R_TYPE (irela[1].r_info)
+                                  == R_PPC64_TOCSAVE))
                        {
                          if (!tocsave_find (htab, INSERT,
                                             &local_syms, irela + 1, input_bfd))
                            goto error_ret_free_internal;
                        }
-                     else if (!htab->opd_abi
-                              && htab->params->plt_localentry0 != 0
-                              && is_elfv2_localentry0 (&hash->elf))
-                       htab->has_plt_localentry0 = 1;
                      else
                        stub_type = ppc_stub_plt_call_r2save;
                    }
@@ -14212,10 +14213,19 @@ ppc64_elf_relocate_section (bfd *output_bfd,
            {
              bfd_boolean can_plt_call = FALSE;
 
+             if (stub_entry->stub_type == ppc_stub_plt_call
+                 && !htab->opd_abi
+                 && htab->params->plt_localentry0 != 0
+                 && is_elfv2_localentry0 (&h->elf))
+               {
+                 /* The function doesn't use or change r2.  */
+                 can_plt_call = TRUE;
+               }
+
              /* All of these stubs may modify r2, so there must be a
                 branch and link followed by a nop.  The nop is
                 replaced by an insn to restore r2.  */
-             if (rel->r_offset + 8 <= input_section->size)
+             else if (rel->r_offset + 8 <= input_section->size)
                {
                  unsigned long br;
 
@@ -14237,13 +14247,6 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                            {
                              /* Special stub used, leave nop alone.  */
                            }
-                         else if (stub_entry->stub_type == ppc_stub_plt_call
-                                  && !htab->opd_abi
-                                  && htab->params->plt_localentry0 != 0
-                                  && is_elfv2_localentry0 (&h->elf))
-                           {
-                             /* The function doesn't use or change r2.  */
-                           }
                          else
                            bfd_put_32 (input_bfd,
                                        LD_R2_0R1 + STK_TOC (htab),
@@ -14644,11 +14647,6 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                   emitting a reloc.  */
                else
                  {
-                   int tlsopt
-                     = (htab->params->tls_get_addr_opt
-                        && htab->tls_get_addr_fd != NULL
-                        && htab->tls_get_addr_fd->elf.plt.plist != NULL);
-
                    relocation += addend;
                    if (tls_type != 0)
                      {
@@ -14660,8 +14658,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                              relocation = 0;
                            else
                              relocation -= htab->elf.tls_sec->vma + DTP_OFFSET;
-                           if ((tls_type & TLS_TPREL)
-                               || (tlsopt && !(tls_type & TLS_DTPREL)))
+                           if (tls_type & TLS_TPREL)
                              relocation += DTP_OFFSET - TP_OFFSET;
                          }
 
@@ -14669,7 +14666,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                          {
                            bfd_put_64 (output_bfd, relocation,
                                        got->contents + off + 8);
-                           relocation = !tlsopt;
+                           relocation = 1;
                          }
                      }
                    bfd_put_64 (output_bfd, relocation,
@@ -15077,32 +15074,6 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                    addend = outrel.r_offset;
                }
            }
-         else if (r_type == R_PPC64_DTPMOD64
-                  && htab->params->tls_get_addr_opt
-                  && htab->tls_get_addr_fd != NULL
-                  && htab->tls_get_addr_fd->elf.plt.plist != NULL)
-           {
-             /* Set up for __tls_get_addr_opt stub, when this entry
-                does not have dynamic relocs.  */
-             relocation = 0;
-             /* Set up the next word for local dynamic.  If it turns
-                out to be global dynamic, the reloc will overwrite
-                this value.  */
-             if (rel->r_offset + 16 <= input_section->size)
-               bfd_put_64 (input_bfd, DTP_OFFSET - TP_OFFSET,
-                           contents + rel->r_offset + 8);
-           }
-         else if (r_type == R_PPC64_DTPREL64
-                  && htab->params->tls_get_addr_opt
-                  && htab->tls_get_addr_fd != NULL
-                  && htab->tls_get_addr_fd->elf.plt.plist != NULL
-                  && rel > relocs
-                  && rel[-1].r_info == ELF64_R_INFO (r_symndx, R_PPC64_DTPMOD64)
-                  && rel[-1].r_offset + 8 == rel->r_offset)
-           {
-             /* __tls_get_addr_opt stub value.  */
-             addend += DTP_OFFSET - TP_OFFSET;
-           }
          break;
 
        case R_PPC64_COPY:
@@ -15896,4 +15867,3 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
 #define elf64_bed      elf64_powerpc_fbsd_bed
 
 #include "elf64-target.h"
-