inconsistencies if (at least) ELF relocation handling

Jan Beulich jbeulich@suse.com
Thu Apr 22 11:15:44 GMT 2021


On 20.04.2021 14:00, H.J. Lu wrote:
> On Tue, Apr 20, 2021 at 3:47 AM Jan Beulich <jbeulich@suse.com> wrote:
>> On 19.04.2021 19:34, H.J. Lu wrote:
>>> On Mon, Apr 19, 2021 at 2:05 AM Jan Beulich <jbeulich@suse.com> wrote:
>>>> while further learning how exactly bfd processes relocations, I
>>>> came to notice that even ELF RELA relocations have section contents
>>>> read and whatever was found added into the new value to be stored
>>>> (which I take to mean that there is an assumption that these fields
>>>> are emitted as all zero by whichever tool creates the object files,
>>>> which even with gas can be easily violated using the .reloc pseudo).
>>>> The comment next to struct reloc_howto_struct's partial_inplace field
>>>> suggests that this is to be avoided by setting src_mask to zero. I
>>>
>>> I have noticed this issue on x8-64.
>>
>> IOW you wouldn't mind correcting this? Of course I can't tell yet what
>> amount of testsuite fallout there would be. But presumably not much,
>> as binutils themselves (with the exception of .reloc, which I'd likely
>> use for a new testcase here) ought to zero-fill such fields. Of course,
>> if as the result gas also zeroes the fields targeted by .reloc, an ld
>> test may be more difficult to invent. (I have to admit though that I'm
>> not certain yet whether I'd consider gas leaving such fields non-zero
>> a bug or intended behavior. As per the spec there's nothing wrong with
>> them being non-zero in relocatable files while a rela relocation is
>> still attached to them.)
> 
> I think I tried to fix it once.  But I ran into so many issues and gave it up
> in the end.

At least there's no testsuite fallout at all. Of course I'm yet to create
a testcase for it, and it sits on top of quite a few further patches, so
it may take a little while until I get to submit the change ...

Jan


More information about the Binutils mailing list