[PATCH] RISC-V: fix linker message when relaxation deletes bytes

Jeff Law jeffreyalaw@gmail.com
Sat Oct 15 00:42:49 GMT 2022


On 10/14/22 01:24, Clément Chigot via Binutils wrote:
> On Fri, Oct 14, 2022 at 7:08 AM Nelson Chu <nelson@rivosinc.com> wrote:
>> Hi,
>>
>> On Thu, Oct 13, 2022 at 8:06 PM Clément Chigot via Binutils
>> <binutils@sourceware.org> wrote:
>>> Gentle ping
>>>
>>> Thanks,
>>> Clément
>>>
>>> On Thu, Oct 6, 2022 at 1:46 PM Clément Chigot <chigot@adacore.com> wrote:
>>>> The section relaxation can delete some bytes resulting in the symbols'
>>>> value being modified.
>>>> As the linker messages retrieve a symbol information using the
>>>> outsymbols field of abfd, it must be updated as well.
>> Interesting, I never noticed this.  If this is necessary, then other
>> targets should also update the output symbols when relaxing (nds32 and
>> sh), but it seems like they don't do that as well.
> Yeah, I agree there are probably other targets having a similar issue.
> I don't know at what extend outsymbols is being used for. But the fact
> that is being filled with "untouched" symbols in object files looks
> weird to me. Maybe there is something to look into this direction.
> For now, this patch aims just to fix ld-undefined on Risc-V targets.
>
>

The target has to adjust the local and global symbols defined in the 
relaxed section.      I haven't done relaxing in a long time, but the 
one I'm most familiar with is the H8.  If you look at 
elf32_h8_relax_delete_bytes you'll see suitable code to update the local 
and global symbols.

That code is very old and may not have seen many updates through the 
last 20 years, but it should give you a good idea of how ports have 
handled this.

Jeff



More information about the Binutils mailing list