Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -272,7 +272,7 @@ } if (Config->isRela()) { - P->r_addend += Body.getVA() - Section->getOutputSection()->Addr; + P->r_addend += Body.getVA() - Section->getOutputSection()->Addr; } else if (Config->Relocatable) { const uint8_t *BufLoc = RelocatedSection->Data.begin() + Rel.r_offset; RelocatedSection->Relocations.push_back( @@ -344,17 +344,16 @@ return getAArch64Page(In::Got->getGlobalDynAddr(Body) + A) - getAArch64Page(P); case R_PLT: - return Body.getPltVA() + A; + return Body.getPltVA() + A; case R_PLT_PC: case R_PPC_PLT_OPD: - return Body.getPltVA() + A - P; + return Body.getPltVA() + A - P; case R_SIZE: return Body.getSize() + A; case R_GOTREL: - return Body.getVA(A) - In::Got->getVA(); + return Body.getVA(A) - In::Got->getVA(); case R_GOTREL_FROM_END: - return Body.getVA(A) - In::Got->getVA() - - In::Got->getSize(); + return Body.getVA(A) - In::Got->getVA() - In::Got->getSize(); case R_RELAX_TLS_GD_TO_IE_END: case R_GOT_FROM_END: return Body.getGotOffset() + A - In::Got->getSize(); @@ -384,15 +383,14 @@ Body.symbol()->isWeak()) return 0; if (Target->TcbSize) - return Body.getVA(A) + - alignTo(Target->TcbSize, Out::TlsPhdr->p_align); - return Body.getVA(A) - Out::TlsPhdr->p_memsz; + return Body.getVA(A) + alignTo(Target->TcbSize, Out::TlsPhdr->p_align); + return Body.getVA(A) - Out::TlsPhdr->p_memsz; case R_RELAX_TLS_GD_TO_LE_NEG: case R_NEG_TLS: - return Out::TlsPhdr->p_memsz - Body.getVA(A); + return Out::TlsPhdr->p_memsz - Body.getVA(A); case R_ABS: case R_RELAX_GOT_PC_NOPIC: - return Body.getVA(A); + return Body.getVA(A); case R_GOT_OFF: return Body.getGotOffset() + A; case R_MIPS_GOT_LOCAL_PAGE: @@ -411,7 +409,7 @@ In::MipsGot->getBodyEntryOffset(Body, A) - In::MipsGot->getGp(); case R_MIPS_GOTREL: - return Body.getVA(A) - In::MipsGot->getGp(); + return Body.getVA(A) - In::MipsGot->getGp(); case R_MIPS_TLSGD: return In::MipsGot->getVA() + In::MipsGot->getTlsOffset() + In::MipsGot->getGlobalDynOffset(Body) - @@ -420,7 +418,7 @@ return In::MipsGot->getVA() + In::MipsGot->getTlsOffset() + In::MipsGot->getTlsIndexOff() - In::MipsGot->getGp(); case R_PPC_OPD: { - uint64_t SymVA = Body.getVA(A); + uint64_t SymVA = Body.getVA(A); // If we have an undefined weak symbol, we might get here with a symbol // address of zero. That could overflow, but the code must be unreachable, // so don't bother doing anything at all. @@ -447,12 +445,12 @@ return getAArch64UndefinedRelativeWeakVA(Type, A, P); } case R_RELAX_GOT_PC: - return Body.getVA(A) - P; + return Body.getVA(A) - P; case R_PLT_PAGE_PC: case R_PAGE_PC: if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak()) return getAArch64Page(A); - return getAArch64Page(Body.getVA(A)) - getAArch64Page(P); + return getAArch64Page(Body.getVA(A)) - getAArch64Page(P); } llvm_unreachable("Invalid expression"); } Index: ELF/LinkerScript.h =================================================================== --- ELF/LinkerScript.h +++ ELF/LinkerScript.h @@ -268,11 +268,11 @@ OutputSection *getOutputSection(const Twine &Loc, StringRef S); uint64_t getOutputSectionSize(StringRef S); - virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0; - virtual bool isDefined(StringRef S) = 0; - virtual bool isAbsolute(StringRef S) = 0; - virtual OutputSection *getSymbolSection(StringRef S) = 0; - + uint64_t getSymbolValue(const Twine &Loc, StringRef S); + bool isDefined(StringRef S); + bool isAbsolute(StringRef S); + OutputSection *getSymbolSection(StringRef S); + void discard(ArrayRef V); std::vector *OutputSections; void addOrphanSections(OutputSectionFactory &Factory); void removeEmptyCommands(); @@ -300,13 +300,7 @@ void writeDataBytes(StringRef Name, uint8_t *Buf); void addSymbol(SymbolAssignment *Cmd); - void discard(ArrayRef V); void processCommands(OutputSectionFactory &Factory); - - uint64_t getSymbolValue(const Twine &Loc, StringRef S) override; - bool isDefined(StringRef S) override; - bool isAbsolute(StringRef S) override; - OutputSection *getSymbolSection(StringRef S) override; }; // Variable template is a C++14 feature, so we can't template Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -148,7 +148,7 @@ // If a symbol was in PROVIDE(), we need to define it only when // it is a referenced undefined symbol. - SymbolBody *B = Symtab::X->find(Cmd->Name); + SymbolBody *B = findSymbol(Cmd->Name); if (Cmd->Provide && (!B || B->isDefined())) return; @@ -288,11 +288,10 @@ } } -template -void LinkerScript::discard(ArrayRef V) { +void LinkerScriptBase::discard(ArrayRef V) { for (InputSectionBase *S : V) { S->Live = false; - if (S == In::ShStrTab) + if (S == InX::ShStrTab) error("discarding .shstrtab section is not allowed"); discard(S->DependentSections); } @@ -912,24 +911,38 @@ return INT_MAX; } -template -uint64_t LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) { +static SymbolBody *findSymbol(StringRef S) { + switch (Config->EKind) { + case ELF32LEKind: + return Symtab::X->find(S); + case ELF32BEKind: + return Symtab::X->find(S); + case ELF64LEKind: + return Symtab::X->find(S); + case ELF64BEKind: + return Symtab::X->find(S); + default: + llvm_unreachable("unknown Config->EKind"); + } +} + +uint64_t LinkerScriptBase::getSymbolValue(const Twine &Loc, StringRef S) { if (S == ".") return Dot; - if (SymbolBody *B = Symtab::X->find(S)) - return B->getVA(); + if (SymbolBody *B = findSymbol(S)) + return B->getVA(); error(Loc + ": symbol not found: " + S); return 0; } -template bool LinkerScript::isDefined(StringRef S) { - return Symtab::X->find(S) != nullptr; +bool LinkerScriptBase::isDefined(StringRef S) { + return findSymbol(S) != nullptr; } -template bool LinkerScript::isAbsolute(StringRef S) { +bool LinkerScriptBase::isAbsolute(StringRef S) { if (S == ".") return false; - SymbolBody *Sym = Symtab::X->find(S); + SymbolBody *Sym = findSymbol(S); auto *DR = dyn_cast_or_null(Sym); return DR && !DR->Section; } @@ -937,10 +950,9 @@ // Gets section symbol belongs to. Symbol "." doesn't belong to any // specific section but isn't absolute at the same time, so we try // to find suitable section for it as well. -template -OutputSection *LinkerScript::getSymbolSection(StringRef S) { - if (SymbolBody *Sym = Symtab::X->find(S)) - return Sym->getOutputSection(); +OutputSection *LinkerScriptBase::getSymbolSection(StringRef S) { + if (SymbolBody *Sym = findSymbol(S)) + return Sym->getOutputSection(); return CurOutSec; } Index: ELF/MapFile.cpp =================================================================== --- ELF/MapFile.cpp +++ ELF/MapFile.cpp @@ -87,7 +87,7 @@ continue; if (DR->isSection()) continue; - writeSymbolLine(OS, Width, Sym->getVA(), Sym->getSize(), + writeSymbolLine(OS, Width, Sym->getVA(), Sym->getSize(), toString(*Sym)); OS << '\n'; } Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -789,16 +789,16 @@ continue; if (Body.isGnuIFunc() && !Preemptible) { - In::Iplt->addEntry(Body); + In::Iplt->addEntry(Body); In::IgotPlt->addEntry(Body); In::RelaIplt->addReloc({Target->IRelativeRel, In::IgotPlt, - Body.getGotPltOffset(), - !Preemptible, &Body, 0}); + Body.getGotPltOffset(), !Preemptible, + &Body, 0}); } else { - In::Plt->addEntry(Body); + In::Plt->addEntry(Body); In::GotPlt->addEntry(Body); In::RelaPlt->addReloc({Target->PltRel, In::GotPlt, - Body.getGotPltOffset(), !Preemptible, + Body.getGotPltOffset(), !Preemptible, &Body, 0}); } continue; Index: ELF/Symbols.h =================================================================== --- ELF/Symbols.h +++ ELF/Symbols.h @@ -75,15 +75,15 @@ bool isInGot() const { return GotIndex != -1U; } bool isInPlt() const { return PltIndex != -1U; } - template typename ELFT::uint getVA(int64_t Addend = 0) const; + uint64_t getVA(int64_t Addend = 0) const; template typename ELFT::uint getGotOffset() const; template typename ELFT::uint getGotVA() const; - template typename ELFT::uint getGotPltOffset() const; - template typename ELFT::uint getGotPltVA() const; - template typename ELFT::uint getPltVA() const; + unsigned getGotPltOffset() const; + uint64_t getGotPltVA() const; + uint64_t getPltVA() const; template typename ELFT::uint getSize() const; - template OutputSection *getOutputSection() const; + OutputSection *getOutputSection() const; // The file from which this symbol was created. InputFile *File = nullptr; Index: ELF/Symbols.cpp =================================================================== --- ELF/Symbols.cpp +++ ELF/Symbols.cpp @@ -38,8 +38,7 @@ DefinedRegular *ElfSym::MipsLocalGp; DefinedRegular *ElfSym::MipsGp; -template -static typename ELFT::uint getSymVA(const SymbolBody &Body, int64_t &Addend) { +static uint64_t getSymVA(const SymbolBody &Body, int64_t &Addend) { switch (Body.kind()) { case SymbolBody::DefinedRegularKind: { auto &D = cast(Body); @@ -101,7 +100,7 @@ case SymbolBody::DefinedCommonKind: if (!Config->DefineCommon) return 0; - return In::Common->OutSec->Addr + In::Common->OutSecOff + + return InX::Common->OutSec->Addr + InX::Common->OutSecOff + cast(Body).Offset; case SymbolBody::SharedKind: { auto &SS = cast(Body); @@ -109,7 +108,7 @@ return SS.CopyRelSec->OutSec->Addr + SS.CopyRelSec->OutSecOff + SS.CopyRelSecOff; if (SS.NeedsPltAddr) - return Body.getPltVA(); + return Body.getPltVA(); return 0; } case SymbolBody::UndefinedKind: @@ -158,9 +157,8 @@ return true; } -template -typename ELFT::uint SymbolBody::getVA(int64_t Addend) const { - typename ELFT::uint OutVA = getSymVA(*this, Addend); +uint64_t SymbolBody::getVA(int64_t Addend) const { + uint64_t OutVA = getSymVA(*this, Addend); return OutVA + Addend; } @@ -172,20 +170,20 @@ return GotIndex * Target->GotEntrySize; } -template typename ELFT::uint SymbolBody::getGotPltVA() const { +uint64_t SymbolBody::getGotPltVA() const { if (this->IsInIgot) - return In::IgotPlt->getVA() + getGotPltOffset(); - return In::GotPlt->getVA() + getGotPltOffset(); + return InX::IgotPlt->getVA() + getGotPltOffset(); + return InX::GotPlt->getVA() + getGotPltOffset(); } -template typename ELFT::uint SymbolBody::getGotPltOffset() const { +unsigned SymbolBody::getGotPltOffset() const { return GotPltIndex * Target->GotPltEntrySize; } -template typename ELFT::uint SymbolBody::getPltVA() const { +uint64_t SymbolBody::getPltVA() const { if (this->IsInIplt) - return In::Iplt->getVA() + PltIndex * Target->PltEntrySize; - return In::Plt->getVA() + Target->PltHeaderSize + + return InX::Iplt->getVA() + PltIndex * Target->PltEntrySize; + return InX::Plt->getVA() + Target->PltHeaderSize + PltIndex * Target->PltEntrySize; } @@ -199,7 +197,7 @@ return 0; } -template OutputSection *SymbolBody::getOutputSection() const { +OutputSection *SymbolBody::getOutputSection() const { if (auto *S = dyn_cast(this)) { if (S->Section) return S->Section->getOutputSection(); @@ -214,7 +212,7 @@ if (isa(this)) { if (Config->DefineCommon) - return In::Common->OutSec; + return InX::Common->OutSec; return nullptr; } @@ -377,11 +375,6 @@ return B.getName(); } -template uint32_t SymbolBody::template getVA(int64_t) const; -template uint32_t SymbolBody::template getVA(int64_t) const; -template uint64_t SymbolBody::template getVA(int64_t) const; -template uint64_t SymbolBody::template getVA(int64_t) const; - template uint32_t SymbolBody::template getGotVA() const; template uint32_t SymbolBody::template getGotVA() const; template uint64_t SymbolBody::template getGotVA() const; @@ -392,31 +385,11 @@ template uint64_t SymbolBody::template getGotOffset() const; template uint64_t SymbolBody::template getGotOffset() const; -template uint32_t SymbolBody::template getGotPltVA() const; -template uint32_t SymbolBody::template getGotPltVA() const; -template uint64_t SymbolBody::template getGotPltVA() const; -template uint64_t SymbolBody::template getGotPltVA() const; - -template uint32_t SymbolBody::template getGotPltOffset() const; -template uint32_t SymbolBody::template getGotPltOffset() const; -template uint64_t SymbolBody::template getGotPltOffset() const; -template uint64_t SymbolBody::template getGotPltOffset() const; - -template uint32_t SymbolBody::template getPltVA() const; -template uint32_t SymbolBody::template getPltVA() const; -template uint64_t SymbolBody::template getPltVA() const; -template uint64_t SymbolBody::template getPltVA() const; - template uint32_t SymbolBody::template getSize() const; template uint32_t SymbolBody::template getSize() const; template uint64_t SymbolBody::template getSize() const; template uint64_t SymbolBody::template getSize() const; -template OutputSection *SymbolBody::template getOutputSection() const; -template OutputSection *SymbolBody::template getOutputSection() const; -template OutputSection *SymbolBody::template getOutputSection() const; -template OutputSection *SymbolBody::template getOutputSection() const; - template bool DefinedRegular::template isMipsPIC() const; template bool DefinedRegular::template isMipsPIC() const; template bool DefinedRegular::template isMipsPIC() const; Index: ELF/SyntheticSections.h =================================================================== --- ELF/SyntheticSections.h +++ ELF/SyntheticSections.h @@ -481,15 +481,16 @@ // header as its first entry that is used at run-time to resolve lazy binding. // The latter is used for GNU Ifunc symbols, that will be subject to a // Target->IRelativeRel. -template class PltSection : public SyntheticSection { +class PltSection : public SyntheticSection { public: PltSection(size_t HeaderSize); void writeTo(uint8_t *Buf) override; size_t getSize() const override; - void addEntry(SymbolBody &Sym); bool empty() const override { return Entries.empty(); } void addSymbols(); + template void addEntry(SymbolBody &Sym); + private: void writeHeader(uint8_t *Buf){}; void addHeaderSymbols(){}; @@ -757,15 +758,26 @@ SymbolBody *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value, uint64_t Size, InputSectionBase *Section); -// Linker generated sections which can be used as inputs. -template struct In { +struct InX { static InputSection *ARMAttributes; - static BuildIdSection *BuildId; static BssSection *Bss; static BssSection *BssRelRo; static InputSection *Common; - static DynamicSection *Dynamic; static StringTableSection *DynStrTab; + static InputSection *Interp; + static GotPltSection *GotPlt; + static IgotPltSection *IgotPlt; + static MipsRldMapSection *MipsRldMap; + static PltSection *Plt; + static PltSection *Iplt; + static StringTableSection *ShStrTab; + static StringTableSection *StrTab; +}; + +// Linker generated sections which can be used as inputs. +template struct In : public InX { + static BuildIdSection *BuildId; + static DynamicSection *Dynamic; static SymbolTableSection *DynSymTab; static EhFrameHeader *EhFrameHdr; static GnuHashTableSection *GnuHashTab; @@ -773,31 +785,18 @@ static GotSection *Got; static EhFrameSection *EhFrame; static MipsGotSection *MipsGot; - static GotPltSection *GotPlt; - static IgotPltSection *IgotPlt; static HashTableSection *HashTab; - static InputSection *Interp; - static MipsRldMapSection *MipsRldMap; - static PltSection *Plt; - static PltSection *Iplt; static RelocationSection *RelaDyn; static RelocationSection *RelaPlt; static RelocationSection *RelaIplt; - static StringTableSection *ShStrTab; - static StringTableSection *StrTab; static SymbolTableSection *SymTab; static VersionDefinitionSection *VerDef; static VersionTableSection *VerSym; static VersionNeedSection *VerNeed; }; -template InputSection *In::ARMAttributes; -template BssSection *In::Bss; -template BssSection *In::BssRelRo; template BuildIdSection *In::BuildId; -template InputSection *In::Common; template DynamicSection *In::Dynamic; -template StringTableSection *In::DynStrTab; template SymbolTableSection *In::DynSymTab; template EhFrameHeader *In::EhFrameHdr; template GdbIndexSection *In::GdbIndex; @@ -805,18 +804,10 @@ template GotSection *In::Got; template EhFrameSection *In::EhFrame; template MipsGotSection *In::MipsGot; -template GotPltSection *In::GotPlt; -template IgotPltSection *In::IgotPlt; template HashTableSection *In::HashTab; -template InputSection *In::Interp; -template MipsRldMapSection *In::MipsRldMap; -template PltSection *In::Plt; -template PltSection *In::Iplt; template RelocationSection *In::RelaDyn; template RelocationSection *In::RelaPlt; template RelocationSection *In::RelaIplt; -template StringTableSection *In::ShStrTab; -template StringTableSection *In::StrTab; template SymbolTableSection *In::SymTab; template VersionDefinitionSection *In::VerDef; template VersionTableSection *In::VerSym; Index: ELF/SyntheticSections.cpp =================================================================== --- ELF/SyntheticSections.cpp +++ ELF/SyntheticSections.cpp @@ -789,7 +789,7 @@ const OutputSection *OutSec = cast(&B)->Section->getOutputSection(); uintX_t SecAddr = getMipsPageAddr(OutSec->Addr); - uintX_t SymAddr = getMipsPageAddr(B.getVA(Addend)); + uintX_t SymAddr = getMipsPageAddr(B.getVA(Addend)); uintX_t Index = PageIndexMap.lookup(OutSec) + (SymAddr - SecAddr) / 0xffff; assert(Index < PageEntriesNum); return (HeaderEntriesNum + Index) * sizeof(uintX_t); @@ -869,7 +869,7 @@ template typename MipsGotSection::uintX_t MipsGotSection::getGp() const { - return ElfSym::MipsGp->template getVA(0); + return ElfSym::MipsGp->getVA(0); } template @@ -910,7 +910,7 @@ uint8_t *Entry = Buf; Buf += sizeof(uintX_t); const SymbolBody *Body = SA.first; - uintX_t VA = Body->template getVA(SA.second); + uintX_t VA = Body->getVA(SA.second); writeUint(Entry, VA); }; std::for_each(std::begin(LocalEntries), std::end(LocalEntries), AddEntry); @@ -926,7 +926,7 @@ for (const SymbolBody *B : TlsEntries) { if (!B || B->isPreemptible()) continue; - uintX_t VA = B->getVA(); + uintX_t VA = B->getVA(); if (B->GotIndex != -1U) { uint8_t *Entry = Buf + B->GotIndex * sizeof(uintX_t); writeUint(Entry, VA - 0x7000); @@ -1186,7 +1186,7 @@ P->d_un.d_val = E.OutSec->Size; break; case Entry::SymAddr: - P->d_un.d_ptr = E.Sym->template getVA(); + P->d_un.d_ptr = E.Sym->getVA(); break; case Entry::PlainInt: P->d_un.d_val = E.Val; @@ -1203,7 +1203,7 @@ template int64_t DynamicReloc::getAddend() const { if (UseSymVA) - return Sym->getVA(Addend); + return Sym->getVA(Addend); return Addend; } @@ -1391,7 +1391,7 @@ ESym->st_size = Body->getSize(); // Set a section index. - if (const OutputSection *OutSec = Body->getOutputSection()) + if (const OutputSection *OutSec = Body->getOutputSection()) ESym->st_shndx = OutSec->SectionIndex; else if (isa(Body)) ESym->st_shndx = SHN_ABS; @@ -1404,7 +1404,7 @@ if (!Config->DefineCommon && isa(Body)) ESym->st_value = cast(Body)->Alignment; else - ESym->st_value = Body->getVA(); + ESym->st_value = Body->getVA(); ++ESym; } @@ -1644,12 +1644,11 @@ } } -template -PltSection::PltSection(size_t S) +PltSection::PltSection(size_t S) : SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16, ".plt"), HeaderSize(S) {} -template void PltSection::writeTo(uint8_t *Buf) { +void PltSection::writeTo(uint8_t *Buf) { // At beginning of PLT but not the IPLT, we have code to call the dynamic // linker to resolve dynsyms at runtime. Write such code. if (HeaderSize != 0) @@ -1661,14 +1660,14 @@ for (auto &I : Entries) { const SymbolBody *B = I.first; unsigned RelOff = I.second + PltOff; - uint64_t Got = B->getGotPltVA(); + uint64_t Got = B->getGotPltVA(); uint64_t Plt = this->getVA() + Off; Target->writePlt(Buf + Off, Got, Plt, B->PltIndex, RelOff); Off += Target->PltEntrySize; } } -template void PltSection::addEntry(SymbolBody &Sym) { +template void PltSection::addEntry(SymbolBody &Sym) { Sym.PltIndex = Entries.size(); RelocationSection *PltRelocSection = In::RelaPlt; if (HeaderSize == 0) { @@ -1679,13 +1678,13 @@ Entries.push_back(std::make_pair(&Sym, RelOff)); } -template size_t PltSection::getSize() const { +size_t PltSection::getSize() const { return HeaderSize + Entries.size() * Target->PltEntrySize; } // Some architectures such as additional symbols in the PLT section. For // example ARM uses mapping symbols to aid disassembly -template void PltSection::addSymbols() { +void PltSection::addSymbols() { // The PLT may have symbols defined for the Header, the IPLT has no header if (HeaderSize != 0) Target->addPltHeaderSymbols(this); @@ -1696,8 +1695,8 @@ } } -template unsigned PltSection::getPltRelocOff() const { - return (HeaderSize == 0) ? In::Plt->getSize() : 0; +unsigned PltSection::getPltRelocOff() const { + return (HeaderSize == 0) ? InX::Plt->getSize() : 0; } template @@ -2263,6 +2262,29 @@ return T->getTargetInputSection(); } +namespace lld { +namespace elf { +template void PltSection::addEntry(SymbolBody &Sym); +template void PltSection::addEntry(SymbolBody &Sym); +template void PltSection::addEntry(SymbolBody &Sym); +template void PltSection::addEntry(SymbolBody &Sym); +} +} + +InputSection *InX::ARMAttributes; +BssSection *InX::Bss; +BssSection *InX::BssRelRo; +InputSection *InX::Common; +StringTableSection *InX::DynStrTab; +InputSection *InX::Interp; +GotPltSection *InX::GotPlt; +IgotPltSection *InX::IgotPlt; +MipsRldMapSection *InX::MipsRldMap; +PltSection *InX::Plt; +PltSection *InX::Iplt; +StringTableSection *InX::ShStrTab; +StringTableSection *InX::StrTab; + template InputSection *elf::createCommonSection(); template InputSection *elf::createCommonSection(); template InputSection *elf::createCommonSection(); @@ -2341,11 +2363,6 @@ template class elf::HashTableSection; template class elf::HashTableSection; -template class elf::PltSection; -template class elf::PltSection; -template class elf::PltSection; -template class elf::PltSection; - template class elf::GdbIndexSection; template class elf::GdbIndexSection; template class elf::GdbIndexSection; Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -415,12 +415,12 @@ void X86TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const { // Entries in .got.plt initially points back to the corresponding // PLT entries with a fixed offset to skip the first instruction. - write32le(Buf, S.getPltVA() + 6); + write32le(Buf, S.getPltVA() + 6); } void X86TargetInfo::writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const { // An x86 entry is the address of the ifunc resolver function. - write32le(Buf, S.getVA()); + write32le(Buf, S.getVA()); } uint32_t X86TargetInfo::getDynRel(uint32_t Type) const { @@ -704,7 +704,7 @@ void X86_64TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const { // See comments in X86TargetInfo::writeGotPlt. - write32le(Buf, S.getPltVA() + 6); + write32le(Buf, S.getPltVA() + 6); } template @@ -1743,7 +1743,7 @@ void ARMTargetInfo::writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const { // An ARM entry is the address of the ifunc resolver function. - write32le(Buf, S.getVA()); + write32le(Buf, S.getVA()); } void ARMTargetInfo::writePltHeader(uint8_t *Buf) const { @@ -1807,14 +1807,14 @@ case R_ARM_JUMP24: // Source is ARM, all PLT entries are ARM so no interworking required. // Otherwise we need to interwork if Symbol has bit 0 set (Thumb). - if (Expr == R_PC && ((S.getVA() & 1) == 1)) + if (Expr == R_PC && ((S.getVA() & 1) == 1)) return true; break; case R_ARM_THM_JUMP19: case R_ARM_THM_JUMP24: // Source is Thumb, all PLT entries are ARM so interworking is required. // Otherwise we need to interwork if Symbol has bit 0 clear (ARM). - if (Expr == R_PLT_PC || ((S.getVA() & 1) == 0)) + if (Expr == R_PLT_PC || ((S.getVA() & 1) == 0)) return true; break; } Index: ELF/Thunks.cpp =================================================================== --- ELF/Thunks.cpp +++ ELF/Thunks.cpp @@ -106,8 +106,8 @@ } // end anonymous namespace // ARM Target Thunks -template static uint64_t getARMThunkDestVA(const SymbolBody &S) { - uint64_t V = S.isInPlt() ? S.getPltVA() : S.getVA(); +static uint64_t getARMThunkDestVA(const SymbolBody &S) { + uint64_t V = S.isInPlt() ? S.getPltVA() : S.getVA(); return SignExtend64<32>(V); } @@ -119,7 +119,7 @@ 0x00, 0xc0, 0x40, 0xe3, // movt ip,:upper16:S 0x1c, 0xff, 0x2f, 0xe1, // bx ip }; - uint64_t S = getARMThunkDestVA(this->Destination); + uint64_t S = getARMThunkDestVA(this->Destination); memcpy(Buf, Data, sizeof(Data)); Target->relocateOne(Buf, R_ARM_MOVW_ABS_NC, S); Target->relocateOne(Buf + 4, R_ARM_MOVT_ABS, S); @@ -141,7 +141,7 @@ 0xc0, 0xf2, 0x00, 0x0c, // movt ip, :upper16:S 0x60, 0x47, // bx ip }; - uint64_t S = getARMThunkDestVA(this->Destination); + uint64_t S = getARMThunkDestVA(this->Destination); memcpy(Buf, Data, sizeof(Data)); Target->relocateOne(Buf, R_ARM_THM_MOVW_ABS_NC, S); Target->relocateOne(Buf + 4, R_ARM_THM_MOVT_ABS, S); @@ -164,8 +164,8 @@ 0x0f, 0xc0, 0x8c, 0xe0, // L1: add ip, ip, pc 0x1c, 0xff, 0x2f, 0xe1, // bx r12 }; - uint64_t S = getARMThunkDestVA(this->Destination); - uint64_t P = this->ThunkSym->template getVA(); + uint64_t S = getARMThunkDestVA(this->Destination); + uint64_t P = this->ThunkSym->getVA(); memcpy(Buf, Data, sizeof(Data)); Target->relocateOne(Buf, R_ARM_MOVW_PREL_NC, S - P - 16); Target->relocateOne(Buf + 4, R_ARM_MOVT_PREL, S - P - 12); @@ -188,8 +188,8 @@ 0xfc, 0x44, // L1: add r12, pc 0x60, 0x47, // bx r12 }; - uint64_t S = getARMThunkDestVA(this->Destination); - uint64_t P = this->ThunkSym->template getVA(); + uint64_t S = getARMThunkDestVA(this->Destination); + uint64_t P = this->ThunkSym->getVA(); memcpy(Buf, Data, sizeof(Data)); Target->relocateOne(Buf, R_ARM_THM_MOVW_PREL_NC, S - P - 12); Target->relocateOne(Buf + 4, R_ARM_THM_MOVT_PREL, S - P - 8); @@ -208,7 +208,7 @@ void MipsThunk::writeTo(uint8_t *Buf, ThunkSection &) const { const endianness E = ELFT::TargetEndianness; - uint64_t S = this->Destination.template getVA(); + uint64_t S = this->Destination.getVA(); write32(Buf, 0x3c190000); // lui $25, %hi(func) write32(Buf + 4, 0x08000000 | (S >> 2)); // j func write32(Buf + 8, 0x27390000); // addiu $25, $25, %lo(func) Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -452,9 +452,9 @@ false /*Sort*/); Add(In::RelaIplt); - In::Plt = make>(Target->PltHeaderSize); + In::Plt = make(Target->PltHeaderSize); Add(In::Plt); - In::Iplt = make>(0); + In::Iplt = make(0); Add(In::Iplt); if (!Config->Relocatable) { @@ -1620,7 +1620,7 @@ // Case 1, 2 or 3. As a special case, if the symbol is actually // a number, we'll use that number as an address. if (SymbolBody *B = Symtab::X->find(Config->Entry)) - return B->getVA(); + return B->getVA(); uint64_t Addr; if (!Config->Entry.getAsInteger(0, Addr)) return Addr;