Re: [PATCH v4 2/5] LoongArch: Use la.pcrel instead of la.abs for exception handlers

From: Youling Tang
Date: Thu Feb 16 2023 - 03:03:23 EST




On 02/16/2023 03:10 PM, Xi Ruoyao wrote:
On Thu, 2023-02-16 at 14:59 +0800, Jinyang He wrote:
+.macro la.abs reg, sym
+766:
+ nop
+ nop
+ nop
+ nop

In the "formal" version we can code

lu12i.w reg, 0
ori reg, reg, 0
lu32i.d reg, 0
lu52i.d reg, reg, 0

here. Then we only need to fixup the immediate slot so we can avoid
using parse_r.


+ .pushsection ".laabs", "aw", %progbits
+768:
+ .word 768b-766b
+ parse_r regno, \reg
+ .word regno
+ .dword \sym
+ .popsection
+.endm

I will try to modify a version for testing, using the following
definition, when the RELOCATABLE is turned on, the "la.abs macro" is
used, otherwise the "la.abs pseudo instruction" is still used as before.

#ifdef CONFIG_RELOCATABLE
.macro la.abs reg, sym
lu12i.w reg, 0
ori reg, reg, 0
lu32i.d reg, 0
lu52i.d reg, reg, 0
.endm
#endif

Youling.