[PATCH v2] LoongArch: Add overflow check and new relaxations when relaxing pcalau12i+ld.d
Lulu Cai
cailulu@loongson.cn
Fri Nov 15 08:24:52 GMT 2024
On 11/15/24 3:54 PM, Xi Ruoyao wrote:
> On Fri, 2024-11-15 at 15:09 +0800, Lulu Cai wrote:
>> On 11/15/24 2:13 PM, Xi Ruoyao wrote:
>>> On Fri, 2024-11-15 at 10:51 +0800, Lulu Cai wrote:
>>>> For pcalau12i+ld.d that can be relaxed, the relaxation is
>>>> pcalau12i+ld.d => pcalau12i+addi.d => pcaddi and there is no
>>>> overflow check.
>>>>
>>>> So the overflow check in the pcalau12i+ld.d relaxation and the
>>>> relaxation of pcalau12i+ld.d => pcaddi are added.
>>>>
>>>> Changes from v1:
>>>> * Add relaxation for pcalau12i+ld.d=>pcaddi.
>>> Why do we need this?
>>>
>>> /* snip */
>>>
>>>> - if (relax_func (abfd, sec, sym_sec, rel, symval,
>>>> - info, again, max_alignment)
>>>> - && relax_func == loongarch_relax_pcala_ld)
>>>> - loongarch_relax_pcala_addi (abfd, sec, sym_sec, rel, symval,
>>>> - info, again, max_alignment);
>>> If pcalau12i + ld.d can be relaxed to pcaddi, here the pair will be
>>> relaxed to pcalau12i + addi.d by loongarch_relax_pcala_ld and then
>>> further relaxed to pcaddi anyway.
>>>
>> The idea here is to do the relaxation of pcalau12i + ld.d once instead
>> of twice if possible.
>> But is this necessary in your opinion?
> "If things are not broken don't fix it." Besides that there's another
> reason to keep them separated:
>
> A key difference between pcalau12i + ld.d => pcalau12i + addi.d and
> pcalau12i + addi.d => pcaddi is the latter deletes bytes but the former
> does not. So the latter must happens in elf_relax_section, but the
> former can be moved to early_size_sections, like where
> R_X86_64_GOTPCRELX is handled for x86_64.
It's reasonable...
> Moving pcalau12i + ld.d => pcalau12i + addi.d earlier will allow us to
> resolve https://github.com/loongson-community/discussions/issues/58. I
> just have not got enough time to do the work myself...
>
I also found this problem and want to solve it, but it is still in the
initial stage.
I will pay attention to this issue later.
Thanks.
More information about the Binutils
mailing list