[PATCH] D50632: [LLD][ELF] - Simplify TLS LD handling code.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 4 03:04:35 PDT 2018
grimar updated this revision to Diff 163771.
grimar added a comment.
- Addressed review comment.
https://reviews.llvm.org/D50632
Files:
ELF/Arch/PPC64.cpp
ELF/Relocations.cpp
Index: ELF/Relocations.cpp
===================================================================
--- ELF/Relocations.cpp
+++ ELF/Relocations.cpp
@@ -186,48 +186,42 @@
}
if (isRelExprOneOf<R_TLSLD_GOT, R_TLSLD_GOT_FROM_END, R_TLSLD_PC,
- R_TLSLD_HINT>(Expr)) {
- // Local-Dynamic relocs can be relaxed to Local-Exec.
+ R_TLSLD_HINT, R_TLSLD_GOT_OFF>(Expr)) {
if (!Config->Shared) {
+ // Local-Dynamic relocs can be relaxed to Local-Exec.
C.Relocations.push_back(
{Target->adjustRelaxExpr(Type, nullptr, R_RELAX_TLS_LD_TO_LE), Type,
Offset, Addend, &Sym});
return Target->TlsGdRelaxSkip;
}
+
if (Expr == R_TLSLD_HINT)
return 1;
+
+ if (Expr == R_TLSLD_GOT_OFF) {
+ if (!Sym.isInGot()) {
+ InX::Got->addEntry(Sym);
+ InX::Got->Relocations.push_back(
+ {R_ABS, Target->TlsOffsetRel, Sym.getGotOffset(), 0, &Sym});
+ }
+ C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
+ return 1;
+ }
+
if (InX::Got->addTlsIndex())
InX::RelaDyn->addReloc(Target->TlsModuleIndexRel, InX::Got,
InX::Got->getTlsIndexOff(), nullptr);
C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
return 1;
}
- // Local-Dynamic relocs can be relaxed to Local-Exec.
if (Expr == R_ABS && !Config->Shared) {
C.Relocations.push_back(
{Target->adjustRelaxExpr(Type, nullptr, R_RELAX_TLS_LD_TO_LE), Type,
Offset, Addend, &Sym});
return 1;
}
- // Local-Dynamic sequence where offset of tls variable relative to dynamic
- // thread pointer is stored in the got.
- if (Expr == R_TLSLD_GOT_OFF) {
- // Local-Dynamic relocs can be relaxed to local-exec
- if (!Config->Shared) {
- C.Relocations.push_back({R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Sym});
- return 1;
- }
- if (!Sym.isInGot()) {
- InX::Got->addEntry(Sym);
- uint64_t Off = Sym.getGotOffset();
- InX::Got->Relocations.push_back({R_ABS, Target->TlsOffsetRel, Off, 0, &Sym});
- }
- C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
- return 1;
- }
-
if (isRelExprOneOf<R_TLSDESC, R_TLSDESC_PAGE, R_TLSDESC_CALL, R_TLSGD_GOT,
R_TLSGD_GOT_FROM_END, R_TLSGD_PC>(Expr)) {
if (Config->Shared) {
Index: ELF/Arch/PPC64.cpp
===================================================================
--- ELF/Arch/PPC64.cpp
+++ ELF/Arch/PPC64.cpp
@@ -580,8 +580,13 @@
RelExpr Expr) const {
if (Expr == R_RELAX_TLS_GD_TO_IE)
return R_RELAX_TLS_GD_TO_IE_GOT_OFF;
- if (Expr == R_RELAX_TLS_LD_TO_LE)
+
+ if (Expr == R_RELAX_TLS_LD_TO_LE) {
+ if (Type == R_PPC64_GOT_DTPREL16_HA || Type == R_PPC64_GOT_DTPREL16_LO_DS ||
+ Type == R_PPC64_GOT_DTPREL16_DS || Type == R_PPC64_GOT_DTPREL16_HI)
+ return Expr;
return R_RELAX_TLS_LD_TO_LE_ABS;
+ }
return Expr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50632.163771.patch
Type: text/x-patch
Size: 2995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180904/85b84fb2/attachment.bin>
More information about the llvm-commits
mailing list