@@ -1286,17 +1286,16 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
1286
1286
}
1287
1287
1288
1288
// ARM, Hexagon, LoongArch and RISC-V do not support GD/LD to IE/LE
1289
- // relaxation .
1289
+ // optimizations .
1290
1290
// 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 ;
1297
1296
1298
1297
// 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.
1300
1299
//
1301
1300
// ARM and RISC-V do not support any relaxations for TLS relocations, however,
1302
1301
// we can omit the DTPMOD dynamic relocations and resolve them at link time
@@ -1309,8 +1308,8 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
1309
1308
// module index, with a special value of 0 for the current module. GOT[e1] is
1310
1309
// unused. There only needs to be one module index entry.
1311
1310
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 ) {
1314
1313
c.addReloc ({target->adjustTlsExpr (type, R_RELAX_TLS_LD_TO_LE), type,
1315
1314
offset, addend, &sym});
1316
1315
return target->getTlsGdRelaxSkip (type);
@@ -1322,16 +1321,17 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
1322
1321
return 1 ;
1323
1322
}
1324
1323
1325
- // Local-Dynamic relocs can be relaxed to Local-Exec.
1324
+ // Local-Dynamic relocs can be optimized to Local-Exec.
1326
1325
if (expr == R_DTPREL) {
1327
- if (toExecRelax )
1326
+ if (execOptimize )
1328
1327
expr = target->adjustTlsExpr (type, R_RELAX_TLS_LD_TO_LE);
1329
1328
c.addReloc ({expr, type, offset, addend, &sym});
1330
1329
return 1 ;
1331
1330
}
1332
1331
1333
1332
// 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.
1335
1335
if (expr == R_TLSLD_GOT_OFF) {
1336
1336
sym.setFlags (NEEDS_GOT_DTPREL);
1337
1337
c.addReloc ({expr, type, offset, addend, &sym});
@@ -1341,13 +1341,13 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
1341
1341
if (oneof<R_AARCH64_TLSDESC_PAGE, R_TLSDESC, R_TLSDESC_CALL, R_TLSDESC_PC,
1342
1342
R_TLSDESC_GOTPLT, R_TLSGD_GOT, R_TLSGD_GOTPLT, R_TLSGD_PC,
1343
1343
R_LOONGARCH_TLSGD_PAGE_PC>(expr)) {
1344
- if (!toExecRelax ) {
1344
+ if (!execOptimize ) {
1345
1345
sym.setFlags (NEEDS_TLSGD);
1346
1346
c.addReloc ({expr, type, offset, addend, &sym});
1347
1347
return 1 ;
1348
1348
}
1349
1349
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
1351
1351
// depending on the symbol being locally defined or not.
1352
1352
if (sym.isPreemptible ) {
1353
1353
sym.setFlags (NEEDS_TLSGD_TO_IE);
@@ -1363,9 +1363,9 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
1363
1363
if (oneof<R_GOT, R_GOTPLT, R_GOT_PC, R_AARCH64_GOT_PAGE_PC,
1364
1364
R_LOONGARCH_GOT_PAGE_PC, R_GOT_OFF, R_TLSIE_HINT>(expr)) {
1365
1365
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) {
1369
1369
c.addReloc ({R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym});
1370
1370
} else if (expr != R_TLSIE_HINT) {
1371
1371
sym.setFlags (NEEDS_TLSIE);
@@ -1463,7 +1463,7 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
1463
1463
in.got ->hasGotOffRel .store (true , std::memory_order_relaxed);
1464
1464
}
1465
1465
1466
- // Process TLS relocations, including relaxing TLS relocations . Note that
1466
+ // Process TLS relocations, including TLS optimizations . Note that
1467
1467
// R_TPREL and R_TPREL_NEG relocations are resolved in processAux.
1468
1468
if (sym.isTls ()) {
1469
1469
if (unsigned processed =
0 commit comments