Re: [PATCH v2 4/4] LoongArch: Support modules with new relocation types

From: Xi Ruoyao
Date: Thu Jul 28 2022 - 09:31:04 EST


On Thu, 2022-07-28 at 20:41 +0800, Youling Tang wrote:
> Unaligned is handled more efficiently before overflow checking, while
> being consistent with apply_r_larch_sop_imm_field.

Will move unaligned before overflow in V3.

> > +
> > +       *location &= ~(u32)0x3ffffff;
> > +       *location |= (offset >> 18) & 0x3ff;
> > +       *location |= ((offset >> 2) & 0xffff) << 10;
>
> It may be better to use the loongarch_instruction format to modify the
> immediate field of the instruction, similar to the following:
>
> union loongarch_instruction *insn = (union loongarch_instruction *)location;
>
> offset >>= 2;
> insn->reg0i26_format.immediate_l = offset & 0xffff;
> insn->reg0i26_format.immediate_h = (offset >> 16) & 0x3ff;

Will use union loongarch_instruction in V3. Why didn't I notice it
before? :(

Thanks for the review!

--
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University