diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -197,9 +197,9 @@ return 1; } - bool canRelax = config->emachine != EM_ARM && - config->emachine != EM_HEXAGON && - config->emachine != EM_RISCV; + bool toExecRelax = !config->shared && config->emachine != EM_ARM && + config->emachine != EM_HEXAGON && + config->emachine != EM_RISCV; // If we are producing an executable and the symbol is non-preemptable, it // must be defined and the code sequence can be relaxed to use Local-Exec. @@ -217,7 +217,7 @@ if (oneof( expr)) { // Local-Dynamic relocs can be relaxed to Local-Exec. - if (canRelax && !config->shared) { + if (toExecRelax) { c.relocations.push_back( {target->adjustRelaxExpr(type, nullptr, R_RELAX_TLS_LD_TO_LE), type, offset, addend, &sym}); @@ -238,7 +238,7 @@ } // Local-Dynamic relocs can be relaxed to Local-Exec. - if (expr == R_DTPREL && canRelax && !config->shared) { + if (expr == R_DTPREL && toExecRelax) { c.relocations.push_back( {target->adjustRelaxExpr(type, nullptr, R_RELAX_TLS_LD_TO_LE), type, offset, addend, &sym}); @@ -260,7 +260,7 @@ if (oneof(expr)) { - if (!canRelax || config->shared) { + if (!toExecRelax) { if (in.got->addDynTlsEntry(sym)) { uint64_t off = in.got->getGlobalDynOffset(sym); @@ -308,7 +308,7 @@ // defined. if (oneof(expr) && - canRelax && isLocalInExecutable) { + toExecRelax && isLocalInExecutable) { c.relocations.push_back({R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym}); return 1; }