Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ddb64ee

Browse filesBrowse files
committed
Support relaxation during TLSDESC GD/LD to IE/LE conversion.
Complement https://. When relaxation enable, remove redundant NOPs.
1 parent 653281c commit ddb64ee
Copy full SHA for ddb64ee

File tree

Expand file treeCollapse file tree

1 file changed

+29
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+29
-3
lines changed

‎lld/ELF/Arch/LoongArch.cpp

Copy file name to clipboardExpand all lines: lld/ELF/Arch/LoongArch.cpp
+29-3Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,16 @@ static bool relax(Ctx &ctx, InputSection &sec) {
965965
case R_LARCH_GOT_PC_HI20:
966966
case R_LARCH_TLS_GD_PC_HI20:
967967
case R_LARCH_TLS_LD_PC_HI20:
968-
case R_LARCH_TLS_DESC_PC_HI20:
969968
// The overflow check for i+2 will be carried out in isPairRelaxable.
970-
if (r.expr != RE_LOONGARCH_RELAX_TLS_GD_TO_IE_PAGE_PC &&
971-
r.expr != R_RELAX_TLS_GD_TO_LE && isPairRelaxable(relocs, i))
969+
if (isPairRelaxable(relocs, i))
970+
relaxPCHi20Lo12(ctx, sec, i, loc, r, relocs[i + 2], remove);
971+
break;
972+
case R_LARCH_TLS_DESC_PC_HI20:
973+
if (r.expr == RE_LOONGARCH_RELAX_TLS_GD_TO_IE_PAGE_PC ||
974+
r.expr == R_RELAX_TLS_GD_TO_LE) {
975+
if (relaxable(relocs, i))
976+
remove = 4;
977+
} else if (isPairRelaxable(relocs, i))
972978
relaxPCHi20Lo12(ctx, sec, i, loc, r, relocs[i + 2], remove);
973979
break;
974980
case R_LARCH_CALL36:
@@ -986,6 +992,17 @@ static bool relax(Ctx &ctx, InputSection &sec) {
986992
isUInt<12>(r.sym->getVA(ctx, r.addend)))
987993
remove = 4;
988994
break;
995+
case R_LARCH_TLS_DESC_PC_LO12:
996+
if (relaxable(relocs, i) &&
997+
(r.expr == RE_LOONGARCH_RELAX_TLS_GD_TO_IE_PAGE_PC ||
998+
r.expr == R_RELAX_TLS_GD_TO_LE))
999+
remove = 4;
1000+
break;
1001+
case R_LARCH_TLS_DESC_LD:
1002+
if (relaxable(relocs, i) && r.expr == R_RELAX_TLS_GD_TO_LE &&
1003+
isUInt<12>(r.sym->getVA(ctx, r.addend)))
1004+
remove = 4;
1005+
break;
9891006
}
9901007

9911008
// For all anchors whose offsets are <= r.offset, they are preceded by
@@ -1214,6 +1231,10 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
12141231
bits);
12151232
relocateNoSym(loc, rel.type, val);
12161233
} else {
1234+
isRelax = relaxable(relocs, i);
1235+
if (isRelax && (rel.type == R_LARCH_TLS_DESC_PC_HI20 ||
1236+
rel.type == R_LARCH_TLS_DESC_PC_LO12))
1237+
continue;
12171238
tlsdescToIe(loc, rel, val);
12181239
}
12191240
continue;
@@ -1230,6 +1251,11 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
12301251
bits);
12311252
relocateNoSym(loc, rel.type, val);
12321253
} else {
1254+
isRelax = relaxable(relocs, i);
1255+
if (isRelax && (rel.type == R_LARCH_TLS_DESC_PC_HI20 ||
1256+
rel.type == R_LARCH_TLS_DESC_PC_LO12 ||
1257+
(rel.type == R_LARCH_TLS_DESC_LD && isUInt<12>(val))))
1258+
continue;
12331259
tlsdescToLe(loc, rel, val);
12341260
}
12351261
continue;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.