[PATCH] x86: Restore PC16 relocation overflow check
Jan Beulich
jbeulich@suse.com
Fri May 28 12:27:50 GMT 2021
On 28.05.2021 14:05, H.J. Lu wrote:
> On Fri, May 28, 2021 at 4:56 AM Jan Beulich <jbeulich@suse.com> wrote:
>> On 28.05.2021 13:40, H.J. Lu wrote:
>>> On Thu, May 27, 2021 at 11:48 PM Jan Beulich <jbeulich@suse.com> wrote:
>>>> On 27.05.2021 19:38, H.J. Lu wrote:
>>>>> 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
>>>
>>> PC16 is different and used for 16-bit programs.
>>
>> PC8 when used by 16-bit programs is also different from PC8 when
>> used by 32- or 64-bit ones. Yet one and the same relocation shouldn't
>> have different meaning.
>>
>
> How is it different? Does binutils use PC8?
Funny you should ask. I've just made two small examples each using
one of the two relocation types to set up a doubly linked list of
objects, with the links optimized for size (i.e. just large enough,
except I'm intentionally adding one too many objects). You'll
observe a relocation overflow with PC8, but not with PC16 (unless
my change is in place which has regressed SeaBIOS). And this is all
data, i.e. could be used in a 64-bit, a 32-bit, or a 16-bit program.
Jan
-------------- next part --------------
.text
.global _start
_start:
ret
.macro entry idx, nxt, prv
.section .rdata\idx, "a", @progbits
e\idx: .byte e\nxt - ., e\prv - .
.fill 8, 2, -1
.size e\idx, . -e\idx
.type e\idx, @object
.endm
entry 0, 1, 9
entry 1, 2, 0
entry 2, 4, 1
entry 4, 8, 2
entry 8, C, 4
entry C, 6, 8
entry 6, 3, C
entry 3, 9, 6
entry 9, 0, 3
-------------- next part --------------
.text
.global _start
_start:
ret
.macro entry idx, nxt, prv
.section .rdata\idx, "a", @progbits
e\idx: .word e\nxt - ., e\prv - .
.fill 0x800, 2, -1
.size e\idx, . -e\idx
.type e\idx, @object
.endm
entry 0, 1, 9
entry 1, 2, 0
entry 2, 4, 1
entry 4, 8, 2
entry 8, C, 4
entry C, 6, 8
entry 6, 3, C
entry 3, 9, 6
entry 9, 0, 3
More information about the Binutils
mailing list