[PATCH] x86: Restore PC16 relocation overflow check

Jan Beulich jbeulich@suse.com
Fri May 28 06:48:32 GMT 2021


On 27.05.2021 19:38, H.J. Lu wrote:
> The x86-64 psABI has
> 
> ---
> 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.
> ---
> 
> Since x86 PC16 relocations were intended for 16-bit programs in an ELF32
> or ELF64 container, PC16 relocation should wrap-around in 16-bit address
> space.

This, to me at least, does not follow from the ABI wording. Or else
the same would apply to PC8.

>  Revert
> 
> 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

I disagree with this revert, at least as long as there's no clear
plan for an alternative. As long as PC8 and PC16 aren't specifically
called out as _intentionally_ having different behavior, their
behavior ought to match. I do realize that my opinion in such matters
counts next to nothing, but then - at the very least - the test cases
from this commit should be left in place and converted to XFAILs, to
make obvious that there is something wrong.

> and
> 
> commit 50c95a739c91ae70cf8481936611aa1f5397a384
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Wed May 26 12:13:13 2021 -0700
> 
>     x86: Propery check PC16 reloc overflow in 16-bit mode instructions
> 
> while keeping PR ld/27905 tests for PC16 relocation in 16-bit programs.

Interestingly you keep this commit's test cases.

Jan


More information about the Binutils mailing list