[PATCH] D50632: [LLD][ELF] - Simplify TLS LD handling code.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 29 03:31:45 PST 2018
grimar updated this revision to Diff 175845.
grimar added a comment.
Rui, what do you think about this one?
I think the new code is better because it groups handling of the R_TLSLD_* relocations at one place.
- Rebased.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D50632/new/
https://reviews.llvm.org/D50632
Files:
ELF/Arch/PPC64.cpp
ELF/Relocations.cpp
Index: ELF/Relocations.cpp
===================================================================
--- ELF/Relocations.cpp
+++ ELF/Relocations.cpp
@@ -187,7 +187,7 @@
}
if (isRelExprOneOf<R_TLSLD_GOT, R_TLSLD_GOT_FROM_END, R_TLSLD_PC,
- R_TLSLD_HINT>(Expr)) {
+ R_TLSLD_HINT, R_TLSLD_GOT_OFF>(Expr)) {
// Local-Dynamic relocs can be relaxed to Local-Exec.
if (!Config->Shared) {
C.Relocations.push_back(
@@ -195,8 +195,20 @@
Offset, Addend, &Sym});
return Target->TlsGdRelaxSkip;
}
+
if (Expr == R_TLSLD_HINT)
return 1;
+
+ if (Expr == R_TLSLD_GOT_OFF) {
+ if (!Sym.isInGot()) {
+ In.Got->addEntry(Sym);
+ In.Got->Relocations.push_back(
+ {R_ABS, Target->TlsOffsetRel, Sym.getGotOffset(), 0, &Sym});
+ }
+ C.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
+ return 1;
+ }
+
if (In.Got->addTlsIndex())
In.RelaDyn->addReloc(Target->TlsModuleIndexRel, In.Got,
In.Got->getTlsIndexOff(), nullptr);
@@ -212,24 +224,6 @@
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()) {
- In.Got->addEntry(Sym);
- uint64_t Off = Sym.getGotOffset();
- In.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_AARCH64_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
@@ -737,8 +737,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.175845.patch
Type: text/x-patch
Size: 2566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181129/f2a4b2c0/attachment.bin>
More information about the llvm-commits
mailing list