diff options
| author | George Rimar <grimar@accesssoftek.com> | 2015-12-01 18:24:07 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2015-12-01 18:24:07 +0000 |
| commit | b17f739808a7956b6b443ac1e005c42872fdc4a8 (patch) | |
| tree | dbbc57d3606f04b65db0a121b274f9c188117482 | |
| parent | 60849f291340b3599219eb42dce91062b2f3596c (diff) | |
| download | bcm5719-llvm-b17f739808a7956b6b443ac1e005c42872fdc4a8.tar.gz bcm5719-llvm-b17f739808a7956b6b443ac1e005c42872fdc4a8.zip | |
Reapply r254428.
Fix was:
uint32_t getLocalTlsIndexVA() { return getVA() + LocalTlsIndexOff; }
=>
uint32_t getLocalTlsIndexVA() { return Base::getVA() + LocalTlsIndexOff; }
Both works for my MSVS.
Original commit message:
[ELF] - Refactor of tls_index implementation for tls local dynamic model.
Patch contains the next 2 changes:
1) static variable Out<ELFT>::LocalModuleTlsIndexOffset moved to Out<ELFT>::Got. At fact there is no meaning for it to be separated from GOT class because at each place of using it anyways needs to call GOT`s getVA(). Also it is impossible to have that offset and not have GOT.
2) addLocalModuleTlsIndex -> addLocalModelTlsIndex (word "Module" changed to "Model"). Not sure was it a mistype or not but I think that update is closer to Urlich terminology.
Differential revision: http://reviews.llvm.org/D15113
llvm-svn: 254433
| -rw-r--r-- | lld/ELF/InputSection.cpp | 3 | ||||
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 10 | ||||
| -rw-r--r-- | lld/ELF/OutputSections.h | 7 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 5 |
4 files changed, 12 insertions, 13 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 64559f7fc3f..3cc979077dd 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -113,8 +113,7 @@ void InputSectionBase<ELFT>::relocate( if (Target->isTlsLocalDynamicReloc(Type) && !Target->isTlsOptimized(Type, nullptr)) { Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc, - Out<ELFT>::Got->getVA() + - Out<ELFT>::LocalModuleTlsIndexOffset + + Out<ELFT>::Got->getLocalTlsIndexVA() + getAddend<ELFT>(RI)); continue; } diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index e3c910f5230..57d1e76b617 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -87,10 +87,13 @@ template <class ELFT> void GotSection<ELFT>::addDynTlsEntry(SymbolBody *Sym) { Entries.push_back(nullptr); } -template <class ELFT> uint32_t GotSection<ELFT>::addLocalModuleTlsIndex() { +template <class ELFT> bool GotSection<ELFT>::addLocalModelTlsIndex() { + if (LocalTlsIndexOff != uint32_t(-1)) + return false; Entries.push_back(nullptr); Entries.push_back(nullptr); - return (Entries.size() - 2) * sizeof(uintX_t); + LocalTlsIndexOff = (Entries.size() - 2) * sizeof(uintX_t); + return true; } template <class ELFT> @@ -201,8 +204,7 @@ bool RelocationSection<ELFT>::applyTlsDynamicReloc(SymbolBody *Body, Elf_Rel *N) { if (Target->isTlsLocalDynamicReloc(Type)) { P->setSymbolAndType(0, Target->getTlsModuleIndexReloc(), Config->Mips64EL); - P->r_offset = - Out<ELFT>::Got->getVA() + Out<ELFT>::LocalModuleTlsIndexOffset; + P->r_offset = Out<ELFT>::Got->getLocalTlsIndexVA(); return true; } diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index dea9bb3c120..25c489affc7 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -119,7 +119,7 @@ public: void writeTo(uint8_t *Buf) override; void addEntry(SymbolBody *Sym); void addDynTlsEntry(SymbolBody *Sym); - uint32_t addLocalModuleTlsIndex(); + bool addLocalModelTlsIndex(); bool empty() const { return Entries.empty(); } uintX_t getEntryAddr(const SymbolBody &B) const; @@ -133,8 +133,11 @@ public: // the number of reserved entries. This method is MIPS-specific. unsigned getMipsLocalEntriesNum() const; + uint32_t getLocalTlsIndexVA() { return Base::getVA() + LocalTlsIndexOff; } + private: std::vector<const SymbolBody *> Entries; + uint32_t LocalTlsIndexOff = -1; }; template <class ELFT> @@ -430,7 +433,6 @@ template <class ELFT> struct Out { static SymbolTableSection<ELFT> *DynSymTab; static SymbolTableSection<ELFT> *SymTab; static Elf_Phdr *TlsPhdr; - static uint32_t LocalModuleTlsIndexOffset; }; template <class ELFT> DynamicSection<ELFT> *Out<ELFT>::Dynamic; @@ -452,7 +454,6 @@ template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::StrTab; template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab; template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab; template <class ELFT> typename Out<ELFT>::Elf_Phdr *Out<ELFT>::TlsPhdr; -template <class ELFT> uint32_t Out<ELFT>::LocalModuleTlsIndexOffset = -1; } // namespace elf2 } // namespace lld diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 11fb9b020d4..16dedc53a4e 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -205,11 +205,8 @@ void Writer<ELFT>::scanRelocs( if (Target->isTlsLocalDynamicReloc(Type)) { if (Target->isTlsOptimized(Type, nullptr)) continue; - if (Out<ELFT>::LocalModuleTlsIndexOffset == uint32_t(-1)) { - Out<ELFT>::LocalModuleTlsIndexOffset = - Out<ELFT>::Got->addLocalModuleTlsIndex(); + if (Out<ELFT>::Got->addLocalModelTlsIndex()) Out<ELFT>::RelaDyn->addReloc({&C, &RI}); - } continue; } |

