[PowerPC64] correct tprel offset limit
authorAlan Modra <amodra@gmail.com>
Thu, 18 Jul 2019 01:01:44 +0000 (10:31 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 18 Jul 2019 12:47:29 +0000 (22:17 +0930)
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.

bfd/ChangeLog
bfd/elf64-ppc.c

index 7d841e29e59da1b26196078cea4d68d5bbe7a936..bbef105a2c3ebf55918e1b5e3f842082b3cf4731 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-18  Alan Modra  <amodra@gmail.com>
+
+       * elf64-ppc.c (ppc64_elf_tls_optimize): Correct test for allowed
+       range of tp-relative offsets.
+
 2019-07-15  Alan Modra  <amodra@gmail.com>
 
        * elflink.c (_bfd_elf_fix_symbol_flags): If the def for an
index d77cfdf9d250635daa51283ecc26c9178118d3be..9d3ba36c02e50c1ccfd38dafa6032dfdcbddae69 100644 (file)
@@ -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;
                        }
                    }