@@ -1014,8 +1014,8 @@ static bool relax(Ctx &ctx, InputSection &sec) {
10141014// * ld.d $a0, $a0, %ie_pc_lo12(sym)
10151015//
10161016// The code sequence converted is as follows:
1017- // * lu12i.w $a0, %le_hi20(sym) # le_hi20 != 0, otherwise NOP
1018- // * ori $a0 $a0, %le_lo12(sym)
1017+ // * lu12i.w $a0, %le_hi20(sym) # le_hi20 != 0, otherwise NOP
1018+ // * ori $a0, src, %le_lo12(sym) # le_hi20 != 0, src = $a0, otherwise src = $zero
10191019//
10201020// When relaxation enables, redundant NOPs can be removed.
10211021void LoongArch::tlsIeToLe (uint8_t *loc, const Relocation &rel,
@@ -1036,7 +1036,7 @@ void LoongArch::tlsIeToLe(uint8_t *loc, const Relocation &rel,
10361036 case R_LARCH_TLS_IE_PC_LO12:
10371037 if (isUInt12)
10381038 write32le (loc, insn (ORI, getD5 (currInsn), R_ZERO,
1039- val)); // ori $a0, $r0 , %le_lo12
1039+ val)); // ori $a0, $zero , %le_lo12
10401040 else
10411041 write32le (loc, insn (ORI, getD5 (currInsn), getJ5 (currInsn),
10421042 lo12 (val))); // ori $a0, $a0, %le_lo12
@@ -1064,7 +1064,7 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
10641064 continue ;
10651065 case R_RELAX_TLS_IE_TO_LE:
10661066 if (rel.type == R_LARCH_TLS_IE_PC_HI20) {
1067- // LoongArch does not support IE to LE optimize in the extreme code
1067+ // LoongArch does not support IE to LE optimization in the extreme code
10681068 // model. In this case, the relocs are as follows:
10691069 //
10701070 // * i -- R_LARCH_TLS_IE_PC_HI20
@@ -1079,8 +1079,9 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
10791079 val = SignExtend64 (sec.getRelocTargetVA (ctx, rel, secAddr + rel.offset ),
10801080 bits);
10811081 relocateNoSym (loc, rel.type , val);
1082- } else
1082+ } else {
10831083 tlsIeToLe (loc, rel, val);
1084+ }
10841085 continue ;
10851086 default :
10861087 break ;
0 commit comments