@@ -1100,8 +1100,9 @@ void LoongArch::tlsdescToIe(uint8_t *loc, const Relocation &rel,
1100
1100
1101
1101
// Convert TLSDESC GD/LD to LE.
1102
1102
// The code sequence obtained in the normal or medium code model is as follows:
1103
- // * lu12i.w $a0, %le_hi20(sym_le) # le_hi20 != 0
1104
- // * ori $a0 $a0, %le_lo12(sym_le)
1103
+ // * lu12i.w $a0, %le_hi20(sym) # le_hi20 != 0, otherwise NOP
1104
+ // * ori $a0, src, %le_lo12(sym) # le_hi20 != 0, src = $a0,
1105
+ // # otherwise, src = $zero
1105
1106
// See the comment in tlsdescToIe for detailed information.
1106
1107
void LoongArch::tlsdescToLe (uint8_t *loc, const Relocation &rel,
1107
1108
uint64_t val) const {
@@ -1124,7 +1125,7 @@ void LoongArch::tlsdescToLe(uint8_t *loc, const Relocation &rel,
1124
1125
break ;
1125
1126
case R_LARCH_TLS_DESC_CALL:
1126
1127
if (isUInt12)
1127
- write32le (loc, insn (ORI, R_A0, R_ZERO, val)); // ori $a0, $r0 , %le_lo12
1128
+ write32le (loc, insn (ORI, R_A0, R_ZERO, val)); // ori $a0, $zero , %le_lo12
1128
1129
else
1129
1130
write32le (loc,
1130
1131
insn (ORI, R_A0, R_A0, lo12 (val))); // ori $a0, $a0, %le_lo12
@@ -1179,7 +1180,7 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
1179
1180
// * i+2 -- R_LARCH_TLS_IE64_PC_LO20
1180
1181
// * i+3 -- R_LARCH_TLS_IE64_PC_HI12
1181
1182
isExtreme =
1182
- ( i + 2 < size && relocs[i + 2 ].type == R_LARCH_TLS_IE64_PC_LO20) ;
1183
+ i + 2 < size && relocs[i + 2 ].type == R_LARCH_TLS_IE64_PC_LO20;
1183
1184
}
1184
1185
if (isExtreme) {
1185
1186
rel.expr = getRelExpr (rel.type , *rel.sym , loc);
@@ -1203,7 +1204,7 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
1203
1204
// * i+2 -- R_LARCH_TLS_DESC64_PC_LO20
1204
1205
// * i+3 -- R_LARCH_TLS_DESC64_PC_HI12
1205
1206
isExtreme =
1206
- ( i + 2 < size && relocs[i + 2 ].type == R_LARCH_TLS_DESC64_PC_LO20) ;
1207
+ i + 2 < size && relocs[i + 2 ].type == R_LARCH_TLS_DESC64_PC_LO20;
1207
1208
}
1208
1209
[[fallthrough]];
1209
1210
case R_RELAX_TLS_GD_TO_IE_ABS:
@@ -1221,7 +1222,7 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
1221
1222
case R_RELAX_TLS_GD_TO_LE:
1222
1223
if (rel.type == R_LARCH_TLS_DESC_PC_HI20) {
1223
1224
isExtreme =
1224
- ( i + 2 < size && relocs[i + 2 ].type == R_LARCH_TLS_DESC64_PC_LO20) ;
1225
+ i + 2 < size && relocs[i + 2 ].type == R_LARCH_TLS_DESC64_PC_LO20;
1225
1226
}
1226
1227
if (isExtreme) {
1227
1228
if (rel.type == R_LARCH_TLS_DESC_CALL)
0 commit comments