[PowerPC64] correct tprel offset limit

Message ID 20190718124505.GB3303@bubble.grove.modra.org
State New
Headers show
Series
  • [PowerPC64] correct tprel offset limit
Related show

Commit Message

Alan Modra July 18, 2019, 12:45 p.m.
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.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

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;
 			}
 		    }