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

Jan Beulich jbeulich@suse.com
Thu Jan 15 15:14:41 GMT 2026


On 15.01.2026 14:48, Nick Clifton wrote:
>> On 15.01.2026 12:17, Nick Clifton wrote:
>>>    Attached is a small patch which allows the Risc-V assembler to adjust
>>>    fixups against symbols in mergeable sections.  Doing this results in
>>>    relocations against the section's symbol instead of local symbols.
> 
>> 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?

If really only x86 has such, I wonder if it shouldn't be dropped. Maybe it
was a workaround for something that meanwhile works properly.

As to x86 specific - the logic above may be, but the dependency on reloc
types certainly isn't. (I'm actually surprised by the variety of what targets
do, when some of the properties checked for look as if they would want to be
generic.)

Jan


More information about the Binutils mailing list