RFC: Risc-V: Allow assembler to adjust relocs against symbols in mergeable sections

Jan Beulich jbeulich@suse.com
Fri Jan 16 06:38:56 GMT 2026


On 15.01.2026 19:38, Maciej W. Rozycki wrote:
> On Thu, 15 Jan 2026, Jan Beulich wrote:
> 
>>>> Doesn't whether to adjust also depend on relocation type?
>>>
>>> Maybe...
>>>
>>>> For example, the
>>>> very first thing checked on x86 is
>>>>
>>>>    /* Don't adjust pc-relative references to merge sections in 64-bit
>>>>       mode.  */
>>>>    if (use_rela_relocations
>>>>        && (S_GET_SEGMENT (fixP->fx_addsy)->flags & SEC_MERGE) != 0
>>>>        && fixP->fx_pcrel)
>>>>      return 0;
>>>
>>> I saw that, but I could not work out why it was there.  What is special
>>> about pc-relative relocations against symbols in mergeable sections ?
>>> Is it an x86 specific thing ?  (Or do pc-relative relocations in mergeable
>>> sections only happen for x86 specific reasons ?)
>>
>> I don't know; it has been like that for over 20 years. The commit introducing
>> it, as usual, doesn't say why. But Andreas, the author, is still around. So,
>> Andreas: Do you recall any details?
> 
>  Cf. <https://inbox.sourceware.org/binutils/hoy9i0lyj2.fsf@gee.suse.de/>.

Thanks for digging this out. Nick, the discussion there clearly suggests
that in principle this shouldn't be x86-64-only. I guess I'll need to do
some experimenting ...

Jan


More information about the Binutils mailing list