[PATCH v2] LoongArch: Fix the infinite loop caused by calling undefweak symbol
Xi Ruoyao
xry111@xry111.site
Wed Nov 20 01:53:49 GMT 2024
On Wed, 2024-11-20 at 09:28 +0800, Lulu Cai wrote:
> The undefweak symbol value of non-default visibility is 0 and does
> not use plt entry, and will not be relocated in the relocate_secion
> function. As a result, an infinite loop is generated because
> bl %plt(sym) => bl 0.
>
> Fix this by converting the bl/call36 instructions to nop or removing
> them.
IMO it's better to convert it to "jirl $ra, $zero, 0". Semantically an
undefined weak symbol should be resolved to address 0 so we should make
a call to address 0, instead of silently ignore the call.
Also "b %plt(sym)" should be turned to "jirl $zero, $zero, 0" as well
when sym is non-default visibility and weak undefined.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the Binutils
mailing list