[PATCH] D15012: [ELF] - split RelocationSection<ELFT>::writeTo function.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 26 05:02:51 PST 2015
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
Splitted writeTo to separate tls relocs handling stuff. Actually its NFC.
http://reviews.llvm.org/D15012
Files:
ELF/OutputSections.cpp
ELF/OutputSections.h
Index: ELF/OutputSections.h
===================================================================
--- ELF/OutputSections.h
+++ ELF/OutputSections.h
@@ -223,6 +223,9 @@
bool isRela() const { return IsRela; }
private:
+ bool isTlsIsolatedDynamicReloc(SymbolBody *Body, uint32_t Type, Elf_Rel *P,
+ Elf_Rel *N);
+
std::vector<DynamicReloc<ELFT>> Relocs;
const bool IsRela;
};
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -193,6 +193,30 @@
this->Header.sh_addralign = ELFT::Is64Bits ? 8 : 4;
}
+template <class ELFT>
+bool RelocationSection<ELFT>::isTlsIsolatedDynamicReloc(SymbolBody *Body,
+ uint32_t Type,
+ Elf_Rel *P,
+ Elf_Rel *N) {
+ if (Target->isTlsLocalDynamicReloc(Type)) {
+ P->setSymbolAndType(0, Target->getTlsModuleIndexReloc(), Config->Mips64EL);
+ P->r_offset =
+ Out<ELFT>::Got->getVA() + Out<ELFT>::LocalModuleTlsIndexOffset;
+ return true;
+ }
+
+ if (Body && Target->isTlsGlobalDynamicReloc(Type)) {
+ P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
+ Target->getTlsModuleIndexReloc(), Config->Mips64EL);
+ P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);
+ N->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
+ Target->getTlsOffsetReloc(), Config->Mips64EL);
+ N->r_offset = Out<ELFT>::Got->getEntryAddr(*Body) + sizeof(uintX_t);
+ return true;
+ }
+ return false;
+}
+
template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
const unsigned EntrySize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
for (const DynamicReloc<ELFT> &Rel : Relocs) {
@@ -213,26 +237,9 @@
Body = Body->repl();
uint32_t Type = RI.getType(Config->Mips64EL);
-
- if (Target->isTlsLocalDynamicReloc(Type)) {
- P->setSymbolAndType(0, Target->getTlsModuleIndexReloc(),
- Config->Mips64EL);
- P->r_offset =
- Out<ELFT>::Got->getVA() + Out<ELFT>::LocalModuleTlsIndexOffset;
+ if (isTlsIsolatedDynamicReloc(Body, Type, P,
+ reinterpret_cast<Elf_Rel *>(Buf)))
continue;
- }
-
- if (Body && Target->isTlsGlobalDynamicReloc(Type)) {
- P->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
- Target->getTlsModuleIndexReloc(), Config->Mips64EL);
- P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);
- auto *PNext = reinterpret_cast<Elf_Rel *>(Buf);
- PNext->setSymbolAndType(Body->getDynamicSymbolTableIndex(),
- Target->getTlsOffsetReloc(), Config->Mips64EL);
- PNext->r_offset = Out<ELFT>::Got->getEntryAddr(*Body) + sizeof(uintX_t);
- continue;
- }
-
bool NeedsCopy = Body && Target->relocNeedsCopy(Type, *Body);
bool NeedsGot = Body && Target->relocNeedsGot(Type, *Body);
bool CanBePreempted = canBePreempted(Body, NeedsGot);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15012.41233.patch
Type: text/x-patch
Size: 3173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151126/519819f5/attachment.bin>
More information about the llvm-commits
mailing list