RFC: should objcopy convert .rel.* to .rela and back?

Alexey Neyman stilor@att.net
Tue Aug 21 17:57:00 GMT 2018


Hi Nick,

On 08/21/2018 09:46 AM, Nick Clifton wrote:
> The objcopy command above, however, does not change the format of the relocation sections: the resulting output.o, despite being an x86-64 object, contains .rel.* sections.
>   
>> 1. Should objcopy have an ability to convert .rel.* to .rela.* and back?
> Eww - well I suppose that it could, but I think that it might not do what you want.
> You see the issue is not only that the type of the relocs is different, but also that
> the relocs themselves are have different values (when comparing x86 and x86_64).  So
> you cannot just change the type, you also need to look at each reloc and possibly
> change its type, its offset, and maybe other things too.
Well, objcopy already changes the relocation type when converting 
between i386 and x86_64 and it seems to be doing the right thing at 
least in the examples I tried - type/offset/addend are all valid. The 
only thing that seems to be missing is the ability to control where the 
addend gets emitted: in the .rela, or in the section in which the 
relocation is.
>> 2. Shouldn't ld detect that it must update the addends and has no way to do so?
> Well if it can, then yes.  But I am not sure that the linker will be able to detect
> this situation.  If you give it files that violate the ABI and lie about the
> architecture type that they support, then you are going to have problems.
I think it should be possible to detect this: after all ld knows that 
the input had a non-ABI-compliant relocation section, so it can mark 
such input as "relocation-incompatible". Then, if any of the addends 
change during the link in this input - bail.
> If however you have a patch that you would like us to consider, I will be happy
> to review it.
Not yet, I wanted first to confirm these are indeed valid issues. I'll 
try to produce a patch that does both (objcopy conversion, ld detection).

Regards,
Alexey.



More information about the Binutils mailing list