@@ -974,6 +974,11 @@ static bool relax(Ctx &ctx, InputSection &sec) {
974
974
if (relaxable (relocs, i))
975
975
relaxTlsLe (ctx, sec, i, loc, r, remove );
976
976
break ;
977
+ case R_LARCH_TLS_IE_PC_HI20:
978
+ if (relaxable (relocs, i) && r.expr == R_RELAX_TLS_IE_TO_LE &&
979
+ isUInt<12 >(r.sym ->getVA (ctx, r.addend )))
980
+ remove = 4 ;
981
+ break ;
977
982
}
978
983
979
984
// For all anchors whose offsets are <= r.offset, they are preceded by
@@ -1048,7 +1053,7 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
1048
1053
secAddr += s->outSecOff ;
1049
1054
else if (auto *ehIn = dyn_cast<EhInputSection>(&sec))
1050
1055
secAddr += ehIn->getParent ()->outSecOff ;
1051
- bool isExtreme = false ;
1056
+ bool isExtreme = false , isRelax = false ;
1052
1057
const MutableArrayRef<Relocation> relocs = sec.relocs ();
1053
1058
for (size_t i = 0 , size = relocs.size (); i != size; ++i) {
1054
1059
Relocation &rel = relocs[i];
@@ -1077,6 +1082,9 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
1077
1082
bits);
1078
1083
relocateNoSym (loc, rel.type , val);
1079
1084
} else {
1085
+ isRelax = relaxable (relocs, i);
1086
+ if (isRelax && rel.type == R_LARCH_TLS_IE_PC_HI20 && isUInt<12 >(val))
1087
+ continue ;
1080
1088
tlsIeToLe (loc, rel, val);
1081
1089
}
1082
1090
continue ;
0 commit comments