Don't convert R_X86_64_GOTPCREL if it will overflow
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 24 Jun 2015 17:13:55 +0000 (10:13 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 24 Jun 2015 17:20:41 +0000 (10:20 -0700)
commit59cab532835904f368b0aa99267afba5fda5ded2
tree8fb4af8a6efb9bbe553be48d6ab564eb15ee0f97
parent602a67cbeaf6b42bc513a873aec82e53235b8754
Don't convert R_X86_64_GOTPCREL if it will overflow

When converting "mov foo@GOTPCREL(%rip), %reg" to "lea foo(%rip), %reg"
with R_X86_64_PC32 relocation, it may overflow if the target section
is more than 2GB away.  This patch estimates distance between mov
instruction and the target section.  We convert R_X86_64_GOTPCREL to
R_X86_64_PC32 only if their distance is less than 2GB.

PR ld/18591
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Don't convert
R_X86_64_GOTPCREL to R_X86_64_PC32 if it will cause relocation
overflow.
bfd/ChangeLog
bfd/elf64-x86-64.c