Skip to content

Commit 849951f

Browse files
committed
[ELF] Fix terminology: TLS optimizations instead of TLS relaxation. NFC
1 parent 30279dc commit 849951f

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

lld/ELF/Relocations.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,17 +1286,16 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
12861286
}
12871287

12881288
// ARM, Hexagon, LoongArch and RISC-V do not support GD/LD to IE/LE
1289-
// relaxation.
1289+
// optimizations.
12901290
// For PPC64, if the file has missing R_PPC64_TLSGD/R_PPC64_TLSLD, disable
1291-
// relaxation as well.
1292-
bool toExecRelax = !config->shared && config->emachine != EM_ARM &&
1293-
config->emachine != EM_HEXAGON &&
1294-
config->emachine != EM_LOONGARCH &&
1295-
config->emachine != EM_RISCV &&
1296-
!c.file->ppc64DisableTLSRelax;
1291+
// optimization as well.
1292+
bool execOptimize =
1293+
!config->shared && config->emachine != EM_ARM &&
1294+
config->emachine != EM_HEXAGON && config->emachine != EM_LOONGARCH &&
1295+
config->emachine != EM_RISCV && !c.file->ppc64DisableTLSRelax;
12971296

12981297
// If we are producing an executable and the symbol is non-preemptable, it
1299-
// must be defined and the code sequence can be relaxed to use Local-Exec.
1298+
// must be defined and the code sequence can be optimized to use Local-Exec.
13001299
//
13011300
// ARM and RISC-V do not support any relaxations for TLS relocations, however,
13021301
// we can omit the DTPMOD dynamic relocations and resolve them at link time
@@ -1309,8 +1308,8 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
13091308
// module index, with a special value of 0 for the current module. GOT[e1] is
13101309
// unused. There only needs to be one module index entry.
13111310
if (oneof<R_TLSLD_GOT, R_TLSLD_GOTPLT, R_TLSLD_PC, R_TLSLD_HINT>(expr)) {
1312-
// Local-Dynamic relocs can be relaxed to Local-Exec.
1313-
if (toExecRelax) {
1311+
// Local-Dynamic relocs can be optimized to Local-Exec.
1312+
if (execOptimize) {
13141313
c.addReloc({target->adjustTlsExpr(type, R_RELAX_TLS_LD_TO_LE), type,
13151314
offset, addend, &sym});
13161315
return target->getTlsGdRelaxSkip(type);
@@ -1322,16 +1321,17 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
13221321
return 1;
13231322
}
13241323

1325-
// Local-Dynamic relocs can be relaxed to Local-Exec.
1324+
// Local-Dynamic relocs can be optimized to Local-Exec.
13261325
if (expr == R_DTPREL) {
1327-
if (toExecRelax)
1326+
if (execOptimize)
13281327
expr = target->adjustTlsExpr(type, R_RELAX_TLS_LD_TO_LE);
13291328
c.addReloc({expr, type, offset, addend, &sym});
13301329
return 1;
13311330
}
13321331

13331332
// Local-Dynamic sequence where offset of tls variable relative to dynamic
1334-
// thread pointer is stored in the got. This cannot be relaxed to Local-Exec.
1333+
// thread pointer is stored in the got. This cannot be optimized to
1334+
// Local-Exec.
13351335
if (expr == R_TLSLD_GOT_OFF) {
13361336
sym.setFlags(NEEDS_GOT_DTPREL);
13371337
c.addReloc({expr, type, offset, addend, &sym});
@@ -1341,13 +1341,13 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
13411341
if (oneof<R_AARCH64_TLSDESC_PAGE, R_TLSDESC, R_TLSDESC_CALL, R_TLSDESC_PC,
13421342
R_TLSDESC_GOTPLT, R_TLSGD_GOT, R_TLSGD_GOTPLT, R_TLSGD_PC,
13431343
R_LOONGARCH_TLSGD_PAGE_PC>(expr)) {
1344-
if (!toExecRelax) {
1344+
if (!execOptimize) {
13451345
sym.setFlags(NEEDS_TLSGD);
13461346
c.addReloc({expr, type, offset, addend, &sym});
13471347
return 1;
13481348
}
13491349

1350-
// Global-Dynamic relocs can be relaxed to Initial-Exec or Local-Exec
1350+
// Global-Dynamic/TLSDESC can be optimized to Initial-Exec or Local-Exec
13511351
// depending on the symbol being locally defined or not.
13521352
if (sym.isPreemptible) {
13531353
sym.setFlags(NEEDS_TLSGD_TO_IE);
@@ -1363,9 +1363,9 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
13631363
if (oneof<R_GOT, R_GOTPLT, R_GOT_PC, R_AARCH64_GOT_PAGE_PC,
13641364
R_LOONGARCH_GOT_PAGE_PC, R_GOT_OFF, R_TLSIE_HINT>(expr)) {
13651365
ctx.hasTlsIe.store(true, std::memory_order_relaxed);
1366-
// Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
1367-
// defined.
1368-
if (toExecRelax && isLocalInExecutable) {
1366+
// Initial-Exec relocs can be optimized to Local-Exec if the symbol is
1367+
// locally defined.
1368+
if (execOptimize && isLocalInExecutable) {
13691369
c.addReloc({R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym});
13701370
} else if (expr != R_TLSIE_HINT) {
13711371
sym.setFlags(NEEDS_TLSIE);
@@ -1463,7 +1463,7 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
14631463
in.got->hasGotOffRel.store(true, std::memory_order_relaxed);
14641464
}
14651465

1466-
// Process TLS relocations, including relaxing TLS relocations. Note that
1466+
// Process TLS relocations, including TLS optimizations. Note that
14671467
// R_TPREL and R_TPREL_NEG relocations are resolved in processAux.
14681468
if (sym.isTls()) {
14691469
if (unsigned processed =

0 commit comments

Comments
 (0)