R_X86_64_PC16 overflow behavior is undefined
Binutils commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=a7664973b24a242cd9ea17deb5eaf503065fc0bd
commit a7664973b24a242cd9ea17deb5eaf503065fc0bd
Author: Jan Beulich <jbeulich@suse.com>
Date: Mon Apr 26 10:41:35 2021 +0200
x86: correct overflow checking for 16-bit PC-relative relocs
The only insn requiring a truly 16-bit PC-relative relocation outside of
16-bit mode is XBEGIN (with an operand size override). For it, the
relocation generated should behave similar to 8- and (for 64-bit) 32-bit
PC-relatives ones, i.e. be checked for a signed value to fit the field.
This same mode is also correct for 16-bit code. Outside of 16-bit code,
branches with operand size overrides act in a truly PC-relative way only
when living in the low 32k of address space, as they truncate rIP to 16
bits. This can't be expressed by a PC-relative relocation.
changed R_X86_64_PC16 overflow treatment. The current psABI says
A program or object file using R_X86_64_8, R_X86_64_16, R_X86_64_PC16
or R_X86_64_PC8 relocations is not conformant to this ABI, these relocations are only
added for documentation purposes.
But it leaves R_X86_64_PC16 overflow behavior undefined. The main usages of R_X86_64_PC16 are in 16-bit programs. The binutils commit above caused: https://sourceware.org/bugzilla/show_bug.cgi?id=27905.