diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-05-11 21:33:30 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-05-11 21:33:30 +0000 |
commit | b3aa2c9b9e478a940ae3514a49d2da8bb1ed4d6b (patch) | |
tree | 4a0f94b20fd219982b07ac603a26296278d90b92 | |
parent | 45a13e1b5477d2d651801c318b68526fa60c0db8 (diff) | |
download | bcm5719-llvm-b3aa2c9b9e478a940ae3514a49d2da8bb1ed4d6b.tar.gz bcm5719-llvm-b3aa2c9b9e478a940ae3514a49d2da8bb1ed4d6b.zip |
Reduce template usage. NFC.
llvm-svn: 302828
-rw-r--r-- | lld/ELF/InputSection.cpp | 25 | ||||
-rw-r--r-- | lld/ELF/Relocations.cpp | 20 | ||||
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 14 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 8 |
4 files changed, 32 insertions, 35 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index c082f128a9b..bd6d3baf32c 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -425,15 +425,15 @@ getRelocTargetVA(uint32_t Type, int64_t A, typename ELFT::uint P, case R_TLSDESC_CALL: llvm_unreachable("cannot relocate hint relocs"); case R_MIPS_GOTREL: - return Body.getVA(A) - In<ELFT>::MipsGot->getGp(); + return Body.getVA(A) - InX::MipsGot->getGp(); case R_MIPS_GOT_GP: - return In<ELFT>::MipsGot->getGp() + A; + return InX::MipsGot->getGp() + A; case R_MIPS_GOT_GP_PC: { // R_MIPS_LO16 expression has R_MIPS_GOT_GP_PC type iif the target // is _gp_disp symbol. In that case we should use the following // formula for calculation "AHL + GP - P + 4". For details see p. 4-19 at // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf - uint64_t V = In<ELFT>::MipsGot->getGp() + A - P; + uint64_t V = InX::MipsGot->getGp() + A - P; if (Type == R_MIPS_LO16) V += 4; return V; @@ -442,24 +442,21 @@ getRelocTargetVA(uint32_t Type, int64_t A, typename ELFT::uint P, // If relocation against MIPS local symbol requires GOT entry, this entry // should be initialized by 'page address'. This address is high 16-bits // of sum the symbol's value and the addend. - return In<ELFT>::MipsGot->getVA() + - In<ELFT>::MipsGot->getPageEntryOffset(Body, A) - - In<ELFT>::MipsGot->getGp(); + return InX::MipsGot->getVA() + InX::MipsGot->getPageEntryOffset(Body, A) - + InX::MipsGot->getGp(); case R_MIPS_GOT_OFF: case R_MIPS_GOT_OFF32: // In case of MIPS if a GOT relocation has non-zero addend this addend // should be applied to the GOT entry content not to the GOT entry offset. // That is why we use separate expression type. - return In<ELFT>::MipsGot->getVA() + - In<ELFT>::MipsGot->getBodyEntryOffset(Body, A) - - In<ELFT>::MipsGot->getGp(); + return InX::MipsGot->getVA() + InX::MipsGot->getBodyEntryOffset(Body, A) - + InX::MipsGot->getGp(); case R_MIPS_TLSGD: - return In<ELFT>::MipsGot->getVA() + In<ELFT>::MipsGot->getTlsOffset() + - In<ELFT>::MipsGot->getGlobalDynOffset(Body) - - In<ELFT>::MipsGot->getGp(); + return InX::MipsGot->getVA() + InX::MipsGot->getTlsOffset() + + InX::MipsGot->getGlobalDynOffset(Body) - InX::MipsGot->getGp(); case R_MIPS_TLSLD: - return In<ELFT>::MipsGot->getVA() + In<ELFT>::MipsGot->getTlsOffset() + - In<ELFT>::MipsGot->getTlsIndexOff() - In<ELFT>::MipsGot->getGp(); + return InX::MipsGot->getVA() + InX::MipsGot->getTlsOffset() + + InX::MipsGot->getTlsIndexOff() - InX::MipsGot->getGp(); case R_PAGE_PC: case R_PLT_PAGE_PC: if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak()) diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 0570ed08631..9b1cd1de4e6 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -106,21 +106,21 @@ static unsigned handleMipsTlsRelocation(uint32_t Type, SymbolBody &Body, InputSectionBase &C, uint64_t Offset, int64_t Addend, RelExpr Expr) { if (Expr == R_MIPS_TLSLD) { - if (In<ELFT>::MipsGot->addTlsIndex() && Config->Pic) - In<ELFT>::RelaDyn->addReloc({Target->TlsModuleIndexRel, In<ELFT>::MipsGot, - In<ELFT>::MipsGot->getTlsIndexOff(), false, + if (InX::MipsGot->addTlsIndex() && Config->Pic) + In<ELFT>::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::MipsGot, + InX::MipsGot->getTlsIndexOff(), false, nullptr, 0}); C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); return 1; } if (Expr == R_MIPS_TLSGD) { - if (In<ELFT>::MipsGot->addDynTlsEntry(Body) && Body.isPreemptible()) { - uint64_t Off = In<ELFT>::MipsGot->getGlobalDynOffset(Body); + if (InX::MipsGot->addDynTlsEntry(Body) && Body.isPreemptible()) { + uint64_t Off = InX::MipsGot->getGlobalDynOffset(Body); In<ELFT>::RelaDyn->addReloc( - {Target->TlsModuleIndexRel, In<ELFT>::MipsGot, Off, false, &Body, 0}); + {Target->TlsModuleIndexRel, InX::MipsGot, Off, false, &Body, 0}); if (Body.isPreemptible()) - In<ELFT>::RelaDyn->addReloc({Target->TlsOffsetRel, In<ELFT>::MipsGot, + In<ELFT>::RelaDyn->addReloc({Target->TlsOffsetRel, InX::MipsGot, Off + Config->Wordsize, false, &Body, 0}); } C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); @@ -891,9 +891,9 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef<RelTy> Rels) { // See "Global Offset Table" in Chapter 5 in the following document // for detailed description: // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf - In<ELFT>::MipsGot->addEntry(Body, Addend, Expr); + InX::MipsGot->addEntry(Body, Addend, Expr); if (Body.isTls() && Body.isPreemptible()) - In<ELFT>::RelaDyn->addReloc({Target->TlsGotRel, In<ELFT>::MipsGot, + In<ELFT>::RelaDyn->addReloc({Target->TlsGotRel, InX::MipsGot, Body.getGotOffset(), false, &Body, 0}); } else if (!Body.isInGot()) { addGotEntry<ELFT>(Body, Preemptible); @@ -927,7 +927,7 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef<RelTy> Rels) { // a dynamic relocation. // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf p.4-19 if (Config->EMachine == EM_MIPS) - In<ELFT>::MipsGot->addEntry(Body, Addend, Expr); + InX::MipsGot->addEntry(Body, Addend, Expr); continue; } diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 6d6d22fb66d..595350ec0e4 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -186,7 +186,7 @@ template <class ELFT> void MipsOptionsSection<ELFT>::writeTo(uint8_t *Buf) { Options->size = getSize(); if (!Config->Relocatable) - Reginfo.ri_gp_value = In<ELFT>::MipsGot->getGp(); + Reginfo.ri_gp_value = InX::MipsGot->getGp(); memcpy(Buf + sizeof(Elf_Mips_Options), &Reginfo, sizeof(Reginfo)); } @@ -244,7 +244,7 @@ MipsReginfoSection<ELFT>::MipsReginfoSection(Elf_Mips_RegInfo Reginfo) template <class ELFT> void MipsReginfoSection<ELFT>::writeTo(uint8_t *Buf) { if (!Config->Relocatable) - Reginfo.ri_gp_value = In<ELFT>::MipsGot->getGp(); + Reginfo.ri_gp_value = InX::MipsGot->getGp(); memcpy(Buf, &Reginfo, sizeof(Reginfo)); } @@ -1143,12 +1143,12 @@ template <class ELFT> void DynamicSection<ELFT>::finalizeContents() { add({DT_MIPS_FLAGS, RHF_NOTPOT}); add({DT_MIPS_BASE_ADDRESS, Config->ImageBase}); add({DT_MIPS_SYMTABNO, In<ELFT>::DynSymTab->getNumSymbols()}); - add({DT_MIPS_LOCAL_GOTNO, In<ELFT>::MipsGot->getLocalEntriesNum()}); - if (const SymbolBody *B = In<ELFT>::MipsGot->getFirstGlobalEntry()) + add({DT_MIPS_LOCAL_GOTNO, InX::MipsGot->getLocalEntriesNum()}); + if (const SymbolBody *B = InX::MipsGot->getFirstGlobalEntry()) add({DT_MIPS_GOTSYM, B->DynsymIndex}); else add({DT_MIPS_GOTSYM, In<ELFT>::DynSymTab->getNumSymbols()}); - add({DT_PLTGOT, In<ELFT>::MipsGot}); + add({DT_PLTGOT, InX::MipsGot}); if (In<ELFT>::MipsRldMap) add({DT_MIPS_RLD_MAP, In<ELFT>::MipsRldMap}); } @@ -1235,11 +1235,11 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) { if (Config->IsRela) P->r_addend = Rel.getAddend(); P->r_offset = Rel.getOffset(); - if (Config->EMachine == EM_MIPS && Rel.getInputSec() == In<ELFT>::MipsGot) + if (Config->EMachine == EM_MIPS && Rel.getInputSec() == InX::MipsGot) // Dynamic relocation against MIPS GOT section make deal TLS entries // allocated in the end of the GOT. We need to adjust the offset to take // in account 'local' and 'global' GOT entries. - P->r_offset += In<ELFT>::MipsGot->getTlsOffset(); + P->r_offset += InX::MipsGot->getTlsOffset(); P->setSymbolAndType(Rel.getSymIndex(), Rel.Type, Config->IsMips64EL); } diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 5be4eb2c5f2..6c119b14b16 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -401,8 +401,8 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() { // Add .got. MIPS' .got is so different from the other archs, // it has its own class. if (Config->EMachine == EM_MIPS) { - In<ELFT>::MipsGot = make<MipsGotSection>(); - Add(In<ELFT>::MipsGot); + InX::MipsGot = make<MipsGotSection>(); + Add(InX::MipsGot); } else { In<ELFT>::Got = make<GotSection<ELFT>>(); Add(In<ELFT>::Got); @@ -1185,7 +1185,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() { In<ELFT>::GnuHashTab, In<ELFT>::HashTab, In<ELFT>::SymTab, In<ELFT>::ShStrTab, In<ELFT>::StrTab, In<ELFT>::VerDef, In<ELFT>::DynStrTab, In<ELFT>::GdbIndex, In<ELFT>::Got, - In<ELFT>::MipsGot, In<ELFT>::IgotPlt, InX::GotPlt, + InX::MipsGot, In<ELFT>::IgotPlt, InX::GotPlt, In<ELFT>::RelaDyn, In<ELFT>::RelaIplt, In<ELFT>::RelaPlt, In<ELFT>::Plt, In<ELFT>::Iplt, In<ELFT>::Plt, In<ELFT>::EhFrameHdr, In<ELFT>::VerSym, In<ELFT>::VerNeed, @@ -1204,7 +1204,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() { // when no more Thunks are added ThunkCreator<ELFT> TC; if (TC.createThunks(OutputSections)) - applySynthetic({In<ELFT>::MipsGot}, + applySynthetic({InX::MipsGot}, [](SyntheticSection *SS) { SS->updateAllocSize(); }); } // Fill other section headers. The dynamic table is finalized |