[PATCH] gas: force a NULL value for BFD_RELOC_PPC*_TLSM on XCOFF.

CHIGOT, CLEMENT clement.chigot@atos.net
Wed Jun 16 13:01:57 GMT 2021


>> What I want to do is to ensure that any symbol's value which
>> has a BFD_RELOC_PPC_TLSM relocation is always NULL.
>> By default, bfd backend will set this value to the address of the
>> symbol targeted by BFD_RELOC_PPC_TLSM.
>> 
>> For example, if "a" is a R_TLSM pointer to "b", I want "*a" to be
>> NULL, but for now "*a" is "@b". AIX linker is refusing it.
>
> If I understand you correctly, the section contents against which one
> of these relocations applies, should be set to zero.

Yes, that's exactly that. I wasn't sure how to formulate that. Thanks ! 

>> The only way I've managed to fix that is to set addend to be the
>> opposite of that bfd_install_relocation will put.
>
> Except that what you have isn't quite correct yet.  That shouldn't be
> too difficult to fix, just subtract S_GET_VALUE (fixP->fx_addsy) as
> well I think.  Please change the comment to
>     /* AIX ld expects the section contents for these relocations
>        to be zero.  Arrange for that to occur when
>        bfd_install_relocation is called.  */
> Also, please add a testcase to gas/testsuite/gas/ppc that verifies the
> assembler produces the expected values.

Done in the new patch attached. 
 
> Another approach is to give the reloc howtos for these quite unusual
> relocations a special_function entry, with that function setting the
> section contents to zero and returning bfd_reloc_ok.  You don't need
> to go in this direction, in fact I'm not recommending it.  (Mostly
> because the the xcoff backend code ignores quite a lot of existing bfd
> support.)

Yes, XCOFF backend have its own functions to manage relocations. 
However, they are only used by ld and not by gas AFAIK. gas is using the 
classic bfd functions. So it should be able to make this approach. But
if I can avoid it I'll do it with pleasure ! 
One day, I should try to remove the XCOFF way but I'm not sure this is 
possible as XCOFF relocations aren't as fixed as ELF ones. The size can
changed, etc. Are we the only one doing it ? Or some backend also 
avoid the BFD way ? 


More information about the Binutils mailing list