Skip to content

Commit 83d8b7e

Browse files
committed
Support relaxation during IE to LE conversion.
Complement https://. When relaxation enable, remove redundant NOPs.
1 parent 31a9dab commit 83d8b7e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lld/ELF/Arch/LoongArch.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,11 @@ static bool relax(Ctx &ctx, InputSection &sec) {
975975
if (relaxable(relocs, i))
976976
relaxTlsLe(ctx, sec, i, loc, r, remove);
977977
break;
978+
case R_LARCH_TLS_IE_PC_HI20:
979+
if (relaxable(relocs, i) && r.expr == R_RELAX_TLS_IE_TO_LE &&
980+
isUInt<12>(r.sym->getVA(ctx, r.addend)))
981+
remove = 4;
982+
break;
978983
}
979984

980985
// For all anchors whose offsets are <= r.offset, they are preceded by
@@ -1049,7 +1054,7 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
10491054
secAddr += s->outSecOff;
10501055
else if (auto *ehIn = dyn_cast<EhInputSection>(&sec))
10511056
secAddr += ehIn->getParent()->outSecOff;
1052-
bool isExtreme = false;
1057+
bool isExtreme = false, isRelax = false;
10531058
const MutableArrayRef<Relocation> relocs = sec.relocs();
10541059
for (size_t i = 0, size = relocs.size(); i != size; ++i) {
10551060
Relocation &rel = relocs[i];
@@ -1077,8 +1082,12 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
10771082
val = SignExtend64(sec.getRelocTargetVA(ctx, rel, secAddr + rel.offset),
10781083
bits);
10791084
relocateNoSym(loc, rel.type, val);
1080-
} else
1085+
} else {
1086+
isRelax = relaxable(relocs, i);
1087+
if (isRelax && rel.type == R_LARCH_TLS_IE_PC_HI20 && isUInt<12>(val))
1088+
continue;
10811089
tlsIeToLe(loc, rel, val);
1090+
}
10821091
continue;
10831092
default:
10841093
break;

0 commit comments

Comments
 (0)