]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[PowerPC64] Nop out ld 2,24(1) after old-style __tls_get_addr
authorAlan Modra <amodra@gmail.com>
Mon, 31 Dec 2018 01:41:42 +0000 (12:11 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 31 Dec 2018 01:42:38 +0000 (12:12 +1030)
When optimising inline plt calls to __tls_get_addr without tls marker
relocs, ld should zap any toc restore insn after the bctrl, to stop a
load-hit-store stall.

* elf64-ppc.c (ppc64_elf_relocate_section <tls_ldgd_opt>): When
editing an old-style __tls_get_addr call, replace a toc restore
insn with a nop.

bfd/ChangeLog
bfd/elf64-ppc.c

index 1396c7034e915779e805625fbb7926edea5b35fa..fbdd0c25b60f60db25bda6dc77fed6a23e3d1aab 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-31  Alan Modra  <amodra@gmail.com>
+
+       * elf64-ppc.c (ppc64_elf_relocate_section <tls_ldgd_opt>): When
+       editing an old-style __tls_get_addr call, replace a toc restore
+       insn with a nop.
+
 2018-12-28  Alan Modra  <amodra@gmail.com>
 
        PR 24015
index 2f4cfaaf338e8de246b7120e176da989e5d5b8d1..e42cefcd419a5a10ac84bb2e4d2f02ceea720786 100644 (file)
@@ -13841,7 +13841,15 @@ ppc64_elf_relocate_section (bfd *output_bfd,
              bfd_put_32 (input_bfd, insn1,
                          contents + rel->r_offset - d_offset);
              if (offset != (bfd_vma) -1)
-               bfd_put_32 (input_bfd, insn2, contents + offset);
+               {
+                 bfd_put_32 (input_bfd, insn2, contents + offset);
+                 if (offset + 8 <= input_section->size)
+                   {
+                     insn2 = bfd_get_32 (input_bfd, contents + offset + 4);
+                     if (insn2 == LD_R2_0R1 + STK_TOC (htab))
+                       bfd_put_32 (input_bfd, NOP, contents + offset + 4);
+                   }
+               }
              if ((tls_mask & tls_gd) == 0
                  && (tls_gd == 0 || toc_symndx != 0))
                {