[PowerPC64] correct tprel offset limit

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PowerPC64] correct tprel offset limit

Alan Modra-3
I don't expect anyone will have hit this bug.  You'd need a TLS
segment of 2G before you'd notice.

        * elf64-ppc.c (ppc64_elf_tls_optimize): Correct test for allowed
        range of tp-relative offsets.

diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index d77cfdf9d2..9d3ba36c02 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -7734,9 +7734,8 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
  {
   value += sym_sec->output_offset;
   value += sym_sec->output_section->vma;
-  value -= htab->elf.tls_sec->vma;
-  ok_tprel = (value + TP_OFFSET + ((bfd_vma) 1 << 31)
-      < (bfd_vma) 1 << 32);
+  value -= htab->elf.tls_sec->vma + TP_OFFSET;
+  ok_tprel = value + 0x80008000ULL < 1ULL << 32;
  }
     }
 

--
Alan Modra
Australia Development Lab, IBM