Index: lld/trunk/ELF/ICF.cpp =================================================================== --- lld/trunk/ELF/ICF.cpp +++ lld/trunk/ELF/ICF.cpp @@ -244,8 +244,8 @@ if (&SA == &SB) return true; - auto *DA = dyn_cast>(&SA); - auto *DB = dyn_cast>(&SB); + auto *DA = dyn_cast(&SA); + auto *DB = dyn_cast(&SB); if (!DA || !DB) return false; if (DA->Value != DB->Value) Index: lld/trunk/ELF/InputFiles.cpp =================================================================== --- lld/trunk/ELF/InputFiles.cpp +++ lld/trunk/ELF/InputFiles.cpp @@ -514,8 +514,8 @@ return new (BAlloc) Undefined(Name, /*IsLocal=*/true, StOther, Type, this); - return new (BAlloc) DefinedRegular(Name, /*IsLocal=*/true, StOther, - Type, Value, Size, Sec, this); + return new (BAlloc) DefinedRegular(Name, /*IsLocal=*/true, StOther, Type, + Value, Size, Sec, this); } StringRef Name = check(Sym->getName(this->StringTable)); Index: lld/trunk/ELF/InputSection.h =================================================================== --- lld/trunk/ELF/InputSection.h +++ lld/trunk/ELF/InputSection.h @@ -27,7 +27,7 @@ class SymbolBody; struct SectionPiece; -template class DefinedRegular; +class DefinedRegular; template class EhFrameSection; template class MergeSyntheticSection; template class ObjectFile; @@ -117,8 +117,7 @@ return getFile()->getObj(); } - template - uint64_t getOffset(const DefinedRegular &Sym) const; + template uint64_t getOffset(const DefinedRegular &Sym) const; template InputSectionBase *getLinkOrderDep() const; // Translate an offset in the input section to an offset in the output Index: lld/trunk/ELF/InputSection.cpp =================================================================== --- lld/trunk/ELF/InputSection.cpp +++ lld/trunk/ELF/InputSection.cpp @@ -150,7 +150,7 @@ } template -uint64_t InputSectionBase::getOffset(const DefinedRegular &Sym) const { +uint64_t InputSectionBase::getOffset(const DefinedRegular &Sym) const { return getOffset(Sym.Value); } @@ -177,7 +177,7 @@ // Find a function symbol that encloses a given location. for (SymbolBody *B : getFile()->getSymbols()) - if (auto *D = dyn_cast>(B)) + if (auto *D = dyn_cast(B)) if (D->Section == this && D->Type == STT_FUNC) if (D->Value <= Offset && Offset < D->Value + D->Size) return SrcFile + ":(function " + toString(*D) + ")"; @@ -250,7 +250,7 @@ // avoid having to parse and recreate .eh_frame, we just replace any // relocation in it pointing to discarded sections with R_*_NONE, which // hopefully creates a frame that is ignored at runtime. - InputSectionBase *Section = cast>(Body).Section; + InputSectionBase *Section = cast(Body).Section; if (Section == &InputSection::Discarded) { P->setSymbolAndType(0, 0, false); continue; @@ -840,13 +840,13 @@ template InputSectionBase *InputSection::getRelocatedSection(); template uint64_t -InputSectionBase::getOffset(const DefinedRegular &Sym) const; +InputSectionBase::getOffset(const DefinedRegular &Sym) const; template uint64_t -InputSectionBase::getOffset(const DefinedRegular &Sym) const; +InputSectionBase::getOffset(const DefinedRegular &Sym) const; template uint64_t -InputSectionBase::getOffset(const DefinedRegular &Sym) const; +InputSectionBase::getOffset(const DefinedRegular &Sym) const; template uint64_t -InputSectionBase::getOffset(const DefinedRegular &Sym) const; +InputSectionBase::getOffset(const DefinedRegular &Sym) const; template uint64_t InputSectionBase::getOffset(uint64_t Offset) const; template uint64_t InputSectionBase::getOffset(uint64_t Offset) const; Index: lld/trunk/ELF/LinkerScript.cpp =================================================================== --- lld/trunk/ELF/LinkerScript.cpp +++ lld/trunk/ELF/LinkerScript.cpp @@ -63,9 +63,8 @@ Cmd->Name, /*Type*/ 0, Visibility, /*CanOmitFromDynSym*/ false, /*File*/ nullptr); Sym->Binding = STB_GLOBAL; - replaceBody>(Sym, Cmd->Name, /*IsLocal=*/false, - Visibility, STT_NOTYPE, 0, 0, nullptr, - nullptr); + replaceBody(Sym, Cmd->Name, /*IsLocal=*/false, Visibility, + STT_NOTYPE, 0, 0, nullptr, nullptr); return Sym->body(); } @@ -131,7 +130,7 @@ return; } - cast>(Cmd->Sym)->Value = Cmd->Expression(Dot); + cast(Cmd->Sym)->Value = Cmd->Expression(Dot); } template @@ -973,7 +972,7 @@ template bool LinkerScript::isAbsolute(StringRef S) { SymbolBody *Sym = Symtab::X->find(S); - auto *DR = dyn_cast_or_null>(Sym); + auto *DR = dyn_cast_or_null(Sym); return DR && !DR->Section; } Index: lld/trunk/ELF/MapFile.cpp =================================================================== --- lld/trunk/ELF/MapFile.cpp +++ lld/trunk/ELF/MapFile.cpp @@ -80,7 +80,7 @@ OS << '\n'; for (SymbolBody *Sym : File->getSymbols()) { - auto *DR = dyn_cast>(Sym); + auto *DR = dyn_cast(Sym); if (!DR) continue; if (DR->Section != IS) Index: lld/trunk/ELF/MarkLive.cpp =================================================================== --- lld/trunk/ELF/MarkLive.cpp +++ lld/trunk/ELF/MarkLive.cpp @@ -66,7 +66,7 @@ template static ResolvedReloc resolveReloc(InputSectionBase &Sec, RelT &Rel) { SymbolBody &B = Sec.getFile()->getRelocTargetSym(Rel); - auto *D = dyn_cast>(&B); + auto *D = dyn_cast(&B); if (!D || !D->Section) return {nullptr, 0}; typename ELFT::uint Offset = D->Value; @@ -215,7 +215,7 @@ }; auto MarkSymbol = [&](const SymbolBody *Sym) { - if (auto *D = dyn_cast_or_null>(Sym)) + if (auto *D = dyn_cast_or_null(Sym)) Enqueue({D->Section, D->Value}); }; Index: lld/trunk/ELF/OutputSections.h =================================================================== --- lld/trunk/ELF/OutputSections.h +++ lld/trunk/ELF/OutputSections.h @@ -31,7 +31,7 @@ template class ObjectFile; template class SharedFile; class SharedSymbol; -template class DefinedRegular; +class DefinedRegular; // This represents a section in an output file. // It is composed of multiple InputSections. Index: lld/trunk/ELF/Relocations.cpp =================================================================== --- lld/trunk/ELF/Relocations.cpp +++ lld/trunk/ELF/Relocations.cpp @@ -292,7 +292,7 @@ template static bool isAbsolute(const SymbolBody &Body) { if (Body.isUndefined()) return !Body.isLocal() && Body.symbol()->isWeak(); - if (const auto *DR = dyn_cast>(&Body)) + if (const auto *DR = dyn_cast(&Body)) return DR->Section == nullptr; // Absolute symbol. return false; } @@ -352,7 +352,7 @@ if (AbsVal && RelE) { if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak()) return true; - if (&Body == ElfSym::MipsGpDisp) + if (&Body == ElfSym::MipsGpDisp) return true; error(S.getLocation(RelOff) + ": relocation " + toString(Type) + " cannot refer to absolute symbol '" + toString(Body) + Index: lld/trunk/ELF/SymbolTable.h =================================================================== --- lld/trunk/ELF/SymbolTable.h +++ lld/trunk/ELF/SymbolTable.h @@ -46,11 +46,11 @@ ArrayRef getBinaryFiles() const { return BinaryFiles; } ArrayRef *> getSharedFiles() const { return SharedFiles; } - DefinedRegular *addAbsolute(StringRef Name, - uint8_t Visibility = llvm::ELF::STV_HIDDEN, - uint8_t Binding = llvm::ELF::STB_GLOBAL); - DefinedRegular *addIgnored(StringRef Name, - uint8_t Visibility = llvm::ELF::STV_HIDDEN); + DefinedRegular *addAbsolute(StringRef Name, + uint8_t Visibility = llvm::ELF::STV_HIDDEN, + uint8_t Binding = llvm::ELF::STB_GLOBAL); + DefinedRegular *addIgnored(StringRef Name, + uint8_t Visibility = llvm::ELF::STV_HIDDEN); Symbol *addUndefined(StringRef Name); Symbol *addUndefined(StringRef Name, bool IsLocal, uint8_t Binding, Index: lld/trunk/ELF/SymbolTable.cpp =================================================================== --- lld/trunk/ELF/SymbolTable.cpp +++ lld/trunk/ELF/SymbolTable.cpp @@ -126,19 +126,19 @@ } template -DefinedRegular *SymbolTable::addAbsolute(StringRef Name, - uint8_t Visibility, - uint8_t Binding) { +DefinedRegular *SymbolTable::addAbsolute(StringRef Name, + uint8_t Visibility, + uint8_t Binding) { Symbol *Sym = addRegular(Name, Visibility, STT_NOTYPE, 0, 0, Binding, nullptr, nullptr); - return cast>(Sym->body()); + return cast(Sym->body()); } // Add Name as an "ignored" symbol. An ignored symbol is a regular // linker-synthesized defined symbol, but is only defined if needed. template -DefinedRegular *SymbolTable::addIgnored(StringRef Name, - uint8_t Visibility) { +DefinedRegular *SymbolTable::addIgnored(StringRef Name, + uint8_t Visibility) { SymbolBody *S = find(Name); if (!S || S->isInCurrentDSO()) return nullptr; @@ -309,7 +309,7 @@ if (Config->WarnCommon) warn("common " + S->body()->getName() + " is overridden"); return 1; - } else if (auto *R = dyn_cast>(B)) { + } else if (auto *R = dyn_cast(B)) { if (R->Section == nullptr && Binding == STB_GLOBAL && IsAbsolute && R->Value == Value) return -1; @@ -363,7 +363,7 @@ template static void reportDuplicate(SymbolBody *Existing, InputSectionBase *ErrSec, typename ELFT::uint ErrOffset) { - DefinedRegular *D = dyn_cast>(Existing); + DefinedRegular *D = dyn_cast(Existing); if (!D || !D->Section || !ErrSec) { reportDuplicate(Existing, ErrSec ? ErrSec->getFile() : nullptr); return; @@ -388,8 +388,8 @@ int Cmp = compareDefinedNonCommon(S, WasInserted, Binding, Section == nullptr, Value); if (Cmp > 0) - replaceBody>(S, Name, /*IsLocal=*/false, StOther, Type, - Value, Size, Section, File); + replaceBody(S, Name, /*IsLocal=*/false, StOther, Type, + Value, Size, Section, File); else if (Cmp == 0) reportDuplicate(S->body(), Section, Value); return S; @@ -446,8 +446,8 @@ int Cmp = compareDefinedNonCommon(S, WasInserted, Binding, /*IsAbs*/ false, /*Value*/ 0); if (Cmp > 0) - replaceBody>(S, Name, /*IsLocal=*/false, StOther, Type, - 0, 0, nullptr, F); + replaceBody(S, Name, /*IsLocal=*/false, StOther, Type, 0, 0, + nullptr, F); else if (Cmp == 0) reportDuplicate(S->body(), F); return S; Index: lld/trunk/ELF/Symbols.h =================================================================== --- lld/trunk/ELF/Symbols.h +++ lld/trunk/ELF/Symbols.h @@ -174,13 +174,10 @@ }; // Regular defined symbols read from object file symbol tables. -template class DefinedRegular : public Defined { - typedef typename ELFT::Sym Elf_Sym; - typedef typename ELFT::uint uintX_t; - +class DefinedRegular : public Defined { public: DefinedRegular(StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type, - uintX_t Value, uintX_t Size, InputSectionBase *Section, + uint64_t Value, uint64_t Size, InputSectionBase *Section, InputFile *File) : Defined(SymbolBody::DefinedRegularKind, Name, IsLocal, StOther, Type), Value(Value), Size(Size), @@ -189,14 +186,14 @@ } // Return true if the symbol is a PIC function. - bool isMipsPIC() const; + template bool isMipsPIC() const; static bool classof(const SymbolBody *S) { return S->kind() == SymbolBody::DefinedRegularKind; } - uintX_t Value; - uintX_t Size; + uint64_t Value; + uint64_t Size; // The input section this symbol belongs to. Notice that this is // a reference to a pointer. We are using two levels of indirections @@ -210,8 +207,6 @@ static InputSectionBase *NullInputSection; }; -template InputSectionBase *DefinedRegular::NullInputSection; - // DefinedSynthetic is a class to represent linker-generated ELF symbols. // The difference from the regular symbol is that DefinedSynthetic symbols // don't belong to any input files or sections. Thus, its constructor @@ -337,7 +332,7 @@ // Some linker-generated symbols need to be created as // DefinedRegular symbols. -template struct ElfSym { +struct ElfSym { // The content for _etext and etext symbols. static DefinedSynthetic *Etext; static DefinedSynthetic *Etext2; @@ -351,21 +346,11 @@ static DefinedSynthetic *End2; // The content for _gp_disp/__gnu_local_gp symbols for MIPS target. - static DefinedRegular *MipsGpDisp; - static DefinedRegular *MipsLocalGp; - static DefinedRegular *MipsGp; + static DefinedRegular *MipsGpDisp; + static DefinedRegular *MipsLocalGp; + static DefinedRegular *MipsGp; }; -template DefinedSynthetic *ElfSym::Etext; -template DefinedSynthetic *ElfSym::Etext2; -template DefinedSynthetic *ElfSym::Edata; -template DefinedSynthetic *ElfSym::Edata2; -template DefinedSynthetic *ElfSym::End; -template DefinedSynthetic *ElfSym::End2; -template DefinedRegular *ElfSym::MipsGpDisp; -template DefinedRegular *ElfSym::MipsLocalGp; -template DefinedRegular *ElfSym::MipsGp; - // A real symbol object, SymbolBody, is usually stored within a Symbol. There's // always one Symbol for each symbol name. The resolver updates the SymbolBody // stored in the Body field of this object as it resolves symbols. Symbol also @@ -409,12 +394,9 @@ // This field is used to store the Symbol's SymbolBody. This instantiation of // AlignedCharArrayUnion gives us a struct with a char array field that is - // large and aligned enough to store any derived class of SymbolBody. We - // assume that the size and alignment of ELF64LE symbols is sufficient for any - // ELFT, and we verify this with the static_asserts in replaceBody. - llvm::AlignedCharArrayUnion< - DefinedCommon, DefinedRegular, DefinedSynthetic, - Undefined, SharedSymbol, LazyArchive, LazyObject> + // large and aligned enough to store any derived class of SymbolBody. + llvm::AlignedCharArrayUnion Body; SymbolBody *body() { return reinterpret_cast(Body.buffer); } Index: lld/trunk/ELF/Symbols.cpp =================================================================== --- lld/trunk/ELF/Symbols.cpp +++ lld/trunk/ELF/Symbols.cpp @@ -28,6 +28,18 @@ using namespace lld; using namespace lld::elf; +InputSectionBase *DefinedRegular::NullInputSection; + +DefinedSynthetic *ElfSym::Etext; +DefinedSynthetic *ElfSym::Etext2; +DefinedSynthetic *ElfSym::Edata; +DefinedSynthetic *ElfSym::Edata2; +DefinedSynthetic *ElfSym::End; +DefinedSynthetic *ElfSym::End2; +DefinedRegular *ElfSym::MipsGpDisp; +DefinedRegular *ElfSym::MipsLocalGp; +DefinedRegular *ElfSym::MipsGp; + template static typename ELFT::uint getSymVA(const SymbolBody &Body, int64_t &Addend) { typedef typename ELFT::uint uintX_t; @@ -43,7 +55,7 @@ return Sec->Addr + D.Value; } case SymbolBody::DefinedRegularKind: { - auto &D = cast>(Body); + auto &D = cast(Body); InputSectionBase *IS = D.Section; // According to the ELF spec reference to a local symbol from outside @@ -188,7 +200,7 @@ template typename ELFT::uint SymbolBody::getSize() const { if (const auto *C = dyn_cast(this)) return C->Size; - if (const auto *DR = dyn_cast>(this)) + if (const auto *DR = dyn_cast(this)) return DR->Size; if (const auto *S = dyn_cast(this)) return S->getSize(); @@ -197,7 +209,7 @@ template const OutputSection *SymbolBody::getOutputSection() const { - if (auto *S = dyn_cast>(this)) { + if (auto *S = dyn_cast(this)) { if (S->Section) return S->Section->template getOutputSection(); return nullptr; @@ -263,7 +275,7 @@ uint8_t Type) : SymbolBody(K, Name, IsLocal, StOther, Type) {} -template bool DefinedRegular::isMipsPIC() const { +template bool DefinedRegular::isMipsPIC() const { if (!Section || !isFunc()) return false; return (this->StOther & STO_MIPS_MIPS16) == STO_MIPS_PIC || @@ -416,10 +428,10 @@ template const OutputSection * SymbolBody::template getOutputSection() const; -template class elf::DefinedRegular; -template class elf::DefinedRegular; -template class elf::DefinedRegular; -template class elf::DefinedRegular; +template bool DefinedRegular::template isMipsPIC() const; +template bool DefinedRegular::template isMipsPIC() const; +template bool DefinedRegular::template isMipsPIC() const; +template bool DefinedRegular::template isMipsPIC() const; template uint64_t SharedSymbol::template getAlignment() const; template uint64_t SharedSymbol::template getAlignment() const; Index: lld/trunk/ELF/SyntheticSections.cpp =================================================================== --- lld/trunk/ELF/SyntheticSections.cpp +++ lld/trunk/ELF/SyntheticSections.cpp @@ -298,8 +298,8 @@ template SymbolBody *elf::addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value, uint64_t Size, InputSectionBase *Section) { - auto *S = make>(Name, /*IsLocal*/ true, STV_DEFAULT, - Type, Value, Size, Section, nullptr); + auto *S = make(Name, /*IsLocal*/ true, STV_DEFAULT, Type, + Value, Size, Section, nullptr); if (In::SymTab) In::SymTab->addSymbol(S); return S; @@ -448,7 +448,7 @@ return false; const RelTy &Rel = Rels[FirstRelI]; SymbolBody &B = Sec->template getFile()->getRelocTargetSym(Rel); - auto *D = dyn_cast>(&B); + auto *D = dyn_cast(&B); if (!D || !D->Section) return false; InputSectionBase *Target = D->Section->Repl; @@ -700,7 +700,7 @@ // sections referenced by GOT relocations. Then later in the `finalize` // method calculate number of "pages" required to cover all saved output // section and allocate appropriate number of GOT entries. - auto *DefSym = cast>(&Sym); + auto *DefSym = cast(&Sym); PageIndexMap.insert( {DefSym->Section->template getOutputSection(), 0}); return; @@ -773,8 +773,7 @@ MipsGotSection::getPageEntryOffset(const SymbolBody &B, int64_t Addend) const { const OutputSection *OutSec = - cast>(&B) - ->Section->template getOutputSection(); + cast(&B)->Section->template getOutputSection(); uintX_t SecAddr = getMipsPageAddr(OutSec->Addr); uintX_t SymAddr = getMipsPageAddr(B.getVA(Addend)); uintX_t Index = PageIndexMap.lookup(OutSec) + (SymAddr - SecAddr) / 0xffff; @@ -852,7 +851,7 @@ template typename MipsGotSection::uintX_t MipsGotSection::getGp() const { - return ElfSym::MipsGp->template getVA(0); + return ElfSym::MipsGp->template getVA(0); } template @@ -1344,8 +1343,8 @@ // This is used for -r, so we have to handle multiple section // symbols being combined. if (Body->Type == STT_SECTION && E.Symbol->Type == STT_SECTION) - return cast>(Body)->Section->OutSec == - cast>(E.Symbol)->Section->OutSec; + return cast(Body)->Section->OutSec == + cast(E.Symbol)->Section->OutSec; return false; }); if (I == Symbols.end()) @@ -1377,7 +1376,7 @@ // Set a section index. if (const OutputSection *OutSec = Body->getOutputSection()) ESym->st_shndx = OutSec->SectionIndex; - else if (isa>(Body)) + else if (isa(Body)) ESym->st_shndx = SHN_ABS; else if (isa(Body)) ESym->st_shndx = SHN_COMMON; @@ -1406,8 +1405,8 @@ ESym->st_other |= STO_MIPS_PLT; if (Config->Relocatable) - if (auto *D = dyn_cast>(Body)) - if (D->isMipsPIC()) + if (auto *D = dyn_cast(Body)) + if (D->isMipsPIC()) ESym->st_other |= STO_MIPS_PIC; ++ESym; } Index: lld/trunk/ELF/Target.cpp =================================================================== --- lld/trunk/ELF/Target.cpp +++ lld/trunk/ELF/Target.cpp @@ -2086,7 +2086,7 @@ // offset between start of function and 'gp' value which by default // equal to the start of .got section. In that case we consider these // relocations as relative. - if (&S == ElfSym::MipsGpDisp) + if (&S == ElfSym::MipsGpDisp) return R_PC; return R_ABS; case R_MIPS_PC32: @@ -2245,10 +2245,10 @@ // If current file has PIC code, LA25 stub is not required. if (F->getObj().getHeader()->e_flags & EF_MIPS_PIC) return false; - auto *D = dyn_cast>(&S); + auto *D = dyn_cast(&S); // LA25 is required if target file has PIC code // or target symbol is a PIC symbol. - return D && D->isMipsPIC(); + return D && D->isMipsPIC(); } template Index: lld/trunk/ELF/Thunks.cpp =================================================================== --- lld/trunk/ELF/Thunks.cpp +++ lld/trunk/ELF/Thunks.cpp @@ -225,7 +225,7 @@ template InputSection *MipsThunk::getTargetInputSection() const { - auto *DR = dyn_cast>(&this->Destination); + auto *DR = dyn_cast(&this->Destination); return dyn_cast(DR->Section); } Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -483,7 +483,7 @@ if (!B.isLocal() && !B.symbol()->IsUsedInRegularObj) return false; - if (auto *D = dyn_cast>(&B)) { + if (auto *D = dyn_cast(&B)) { // Always include absolute symbols. if (!D->Section) return true; @@ -507,7 +507,7 @@ if (!B->IsLocal) fatal(toString(F) + ": broken object: getLocalSymbols returns a non-local symbol"); - auto *DR = dyn_cast>(B); + auto *DR = dyn_cast(B); // No reason to keep local undefined symbol in symtab. if (!DR) @@ -534,8 +534,8 @@ IS->Type == SHT_RELA) continue; auto *B = new (BAlloc) - DefinedRegular("", /*IsLocal=*/true, /*StOther*/ 0, STT_SECTION, - /*Value*/ 0, /*Size*/ 0, IS, nullptr); + DefinedRegular("", /*IsLocal=*/true, /*StOther*/ 0, STT_SECTION, + /*Value*/ 0, /*Size*/ 0, IS, nullptr); In::SymTab->addSymbol(B); } @@ -788,15 +788,14 @@ // to GOT. Default offset is 0x7ff0. // See "Global Data Symbols" in Chapter 6 in the following document: // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf - ElfSym::MipsGp = - Symtab::X->addAbsolute("_gp", STV_HIDDEN, STB_LOCAL); + ElfSym::MipsGp = Symtab::X->addAbsolute("_gp", STV_HIDDEN, STB_LOCAL); // On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between // start of function and 'gp' pointer into GOT. To simplify relocation // calculation we assign _gp value to it and calculate corresponding // relocations as relative to this value. if (Symtab::X->find("_gp_disp")) - ElfSym::MipsGpDisp = + ElfSym::MipsGpDisp = Symtab::X->addAbsolute("_gp_disp", STV_HIDDEN, STB_LOCAL); // The __gnu_local_gp is a magic symbol equal to the current value of 'gp' @@ -804,7 +803,7 @@ // in case of using -mno-shared option. // https://sourceware.org/ml/binutils/2004-12/msg00094.html if (Symtab::X->find("__gnu_local_gp")) - ElfSym::MipsLocalGp = + ElfSym::MipsLocalGp = Symtab::X->addAbsolute("__gnu_local_gp", STV_HIDDEN, STB_LOCAL); } @@ -847,9 +846,9 @@ Sym2 = addOptionalSynthetic(S, nullptr, 0, STV_DEFAULT); }; - Define("_end", ElfSym::End, ElfSym::End2); - Define("_etext", ElfSym::Etext, ElfSym::Etext2); - Define("_edata", ElfSym::Edata, ElfSym::Edata2); + Define("_end", ElfSym::End, ElfSym::End2); + Define("_etext", ElfSym::Etext, ElfSym::Etext2); + Define("_edata", ElfSym::Edata, ElfSym::Edata2); } // Sort input sections by section name suffixes for @@ -883,7 +882,7 @@ DenseMap SectionOrder; for (elf::ObjectFile *File : Symtab::X->getObjectFiles()) { for (SymbolBody *Body : File->getSymbols()) { - auto *D = dyn_cast>(Body); + auto *D = dyn_cast(Body); if (!D || !D->Section) continue; int &Priority = SectionOrder[D->Section]; @@ -1652,18 +1651,16 @@ LastRO = &P; } if (Last) - Set(ElfSym::End, ElfSym::End2, Last->First, Last->p_memsz); + Set(ElfSym::End, ElfSym::End2, Last->First, Last->p_memsz); if (LastRO) - Set(ElfSym::Etext, ElfSym::Etext2, LastRO->First, - LastRO->p_filesz); + Set(ElfSym::Etext, ElfSym::Etext2, LastRO->First, LastRO->p_filesz); if (LastRW) - Set(ElfSym::Edata, ElfSym::Edata2, LastRW->First, - LastRW->p_filesz); + Set(ElfSym::Edata, ElfSym::Edata2, LastRW->First, LastRW->p_filesz); // Setup MIPS _gp_disp/__gnu_local_gp symbols which should // be equal to the _gp symbol's value. if (Config->EMachine == EM_MIPS) { - if (!ElfSym::MipsGp->Value) { + if (!ElfSym::MipsGp->Value) { // Find GP-relative section with the lowest address // and use this address to calculate default _gp value. uintX_t Gp = -1; @@ -1671,12 +1668,12 @@ if ((OS->Flags & SHF_MIPS_GPREL) && OS->Addr < Gp) Gp = OS->Addr; if (Gp != (uintX_t)-1) - ElfSym::MipsGp->Value = Gp + 0x7ff0; + ElfSym::MipsGp->Value = Gp + 0x7ff0; } - if (ElfSym::MipsGpDisp) - ElfSym::MipsGpDisp->Value = ElfSym::MipsGp->Value; - if (ElfSym::MipsLocalGp) - ElfSym::MipsLocalGp->Value = ElfSym::MipsGp->Value; + if (ElfSym::MipsGpDisp) + ElfSym::MipsGpDisp->Value = ElfSym::MipsGp->Value; + if (ElfSym::MipsLocalGp) + ElfSym::MipsLocalGp->Value = ElfSym::MipsGp->Value; } }