From: Peter Collingbourne Date: Mon, 6 Nov 2017 04:35:31 +0000 (+0000) Subject: ELF: Merge DefinedRegular and Defined. X-Git-Tag: llvmorg-6.0.0-rc1~4102 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9a9e0a1e7101ee69d2c015e0430cae4202b1039;p=platform%2Fupstream%2Fllvm.git ELF: Merge DefinedRegular and Defined. Now that DefinedRegular is the only remaining derived class of Defined, we can merge the two classes. Differential Revision: https://reviews.llvm.org/D39667 llvm-svn: 317448 --- diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp index 50d8949..534ea5d 100644 --- a/lld/ELF/Arch/Mips.cpp +++ b/lld/ELF/Arch/Mips.cpp @@ -346,7 +346,7 @@ bool MIPS::needsThunk(RelExpr Expr, RelType Type, const InputFile *File, // 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(); diff --git a/lld/ELF/GdbIndex.cpp b/lld/ELF/GdbIndex.cpp index 275e081..db1c82a 100644 --- a/lld/ELF/GdbIndex.cpp +++ b/lld/ELF/GdbIndex.cpp @@ -67,7 +67,7 @@ LLDDwarfObj::findAux(const InputSectionBase &Sec, uint64_t Pos, const typename ELFT::Sym &Sym = File->getELFSyms()[SymIndex]; uint32_t SecIndex = File->getSectionIndex(Sym); Symbol &B = File->getRelocTargetSym(Rel); - auto &DR = cast(B); + auto &DR = cast(B); uint64_t Val = DR.Value + getAddend(Rel); // FIXME: We should be consistent about always adding the file diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index c60a878..ae10d48 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -228,8 +228,8 @@ bool ICF::constantEq(const InputSection *SecA, ArrayRef RA, return false; } - 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; @@ -300,8 +300,8 @@ bool ICF::variableEq(const InputSection *SecA, ArrayRef RA, if (&SA == &SB) continue; - auto *DA = cast(&SA); - auto *DB = cast(&SB); + auto *DA = cast(&SA); + auto *DB = cast(&SB); // We already dealt with absolute and non-InputSection symbols in // constantEq, and for InputSections we have already checked everything diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 9327dc0..a5fdded 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -600,8 +600,8 @@ template Symbol *ObjFile::createSymbol(const Elf_Sym *Sym) { if (Sym->st_shndx == SHN_UNDEF) return make(Name, /*IsLocal=*/true, StOther, Type); - return make(Name, /*IsLocal=*/true, StOther, Type, Value, - Size, Sec); + return make(Name, /*IsLocal=*/true, StOther, Type, Value, Size, + Sec); } StringRef Name = check(Sym->getName(this->StringTable), toString(this)); diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 60ad5a9..bdc56c8 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -61,7 +61,7 @@ DenseMap elf::buildSectionOrder() { // Build a map from sections to their priorities. for (InputFile *File : ObjectFiles) { for (Symbol *Sym : File->getSymbols()) { - auto *D = dyn_cast(Sym); + auto *D = dyn_cast(Sym); if (!D || !D->Section) continue; int &Priority = SectionOrder[D->Section]; @@ -214,7 +214,7 @@ void InputSectionBase::maybeUncompress() { this->Flags &= ~(uint64_t)SHF_COMPRESSED; } -uint64_t SectionBase::getOffset(const DefinedRegular &Sym) const { +uint64_t SectionBase::getOffset(const Defined &Sym) const { return getOffset(Sym.Value); } @@ -251,7 +251,7 @@ std::string InputSectionBase::getLocation(uint64_t Offset) { // Find a function symbol that encloses a given location. for (Symbol *B : File->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) + ")"; @@ -317,7 +317,7 @@ std::string InputSectionBase::getObjMsg(uint64_t Off) { // Find a symbol that encloses a given location. for (Symbol *B : File->getSymbols()) - if (auto *D = dyn_cast(B)) + if (auto *D = dyn_cast(B)) if (D->Section == this && D->Value <= Off && Off < D->Value + D->Size) return Filename + ":(" + toString(*D) + ")" + Archive; @@ -404,7 +404,7 @@ void InputSection::copyRelocations(uint8_t *Buf, ArrayRef Rels) { // 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. - SectionBase *Section = cast(Sym).Section; + SectionBase *Section = cast(Sym).Section; if (Section == &InputSection::Discarded) { P->setSymbolAndType(0, 0, false); continue; diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 344943e..de2cc68 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -27,7 +27,7 @@ namespace elf { class Symbol; struct SectionPiece; -class DefinedRegular; +class Defined; class SyntheticSection; class MergeSyntheticSection; template class ObjFile; @@ -73,7 +73,7 @@ public: // section. uint64_t getOffset(uint64_t Offset) const; - uint64_t getOffset(const DefinedRegular &Sym) const; + uint64_t getOffset(const Defined &Sym) const; protected: SectionBase(Kind SectionKind, StringRef Name, uint64_t Flags, diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 35e6392..9434bce 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -149,9 +149,9 @@ void LinkerScript::addSymbol(SymbolAssignment *Cmd) { // write expressions like this: `alignment = 16; . = ALIGN(., alignment)`. uint64_t SymValue = Value.Sec ? 0 : Value.getValue(); - replaceSymbol(Sym, nullptr, Cmd->Name, /*IsLocal=*/false, - Visibility, STT_NOTYPE, SymValue, 0, Sec); - Cmd->Sym = cast(Sym); + replaceSymbol(Sym, nullptr, Cmd->Name, /*IsLocal=*/false, Visibility, + STT_NOTYPE, SymValue, 0, Sec); + Cmd->Sym = cast(Sym); } // This function is called from assignAddresses, while we are @@ -977,7 +977,7 @@ ExprValue LinkerScript::getSymbolValue(StringRef Name, const Twine &Loc) { return 0; } - if (auto *Sym = dyn_cast_or_null(Symtab->find(Name))) + if (auto *Sym = dyn_cast_or_null(Symtab->find(Name))) return {Sym->Section, false, Sym->Value, Loc}; error(Loc + ": symbol not found: " + Name); diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index b937e7f..954ac08 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -29,7 +29,7 @@ namespace lld { namespace elf { -class DefinedRegular; +class Defined; class Symbol; class InputSectionBase; class InputSection; @@ -96,7 +96,7 @@ struct SymbolAssignment : BaseCommand { // The LHS of an expression. Name is either a symbol name or ".". StringRef Name; - DefinedRegular *Sym = nullptr; + Defined *Sym = nullptr; // The RHS of an expression. Expr Expression; diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp index 4786749..5aa7309 100644 --- a/lld/ELF/MapFile.cpp +++ b/lld/ELF/MapFile.cpp @@ -51,7 +51,7 @@ static std::vector getSymbols() { std::vector V; for (InputFile *File : ObjectFiles) for (Symbol *B : File->getSymbols()) - if (auto *DR = dyn_cast(B)) + if (auto *DR = dyn_cast(B)) if (DR->getFile() == File && !DR->isSection() && DR->Section && DR->Section->Live) V.push_back(DR); @@ -62,7 +62,7 @@ static std::vector getSymbols() { static SymbolMapTy getSectionSyms(ArrayRef Syms) { SymbolMapTy Ret; for (Defined *S : Syms) - if (auto *DR = dyn_cast(S)) + if (auto *DR = dyn_cast(S)) Ret[DR->Section].push_back(S); // Sort symbols by address. We want to print out symbols in the diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index 139c18c..c639198 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -64,7 +64,7 @@ static void resolveReloc(InputSectionBase &Sec, RelT &Rel, std::function Fn) { Symbol &B = Sec.getFile()->getRelocTargetSym(Rel); - if (auto *D = dyn_cast(&B)) { + if (auto *D = dyn_cast(&B)) { if (!D->Section) return; uint64_t Offset = D->Value; @@ -212,7 +212,7 @@ template static void doGcSections() { }; auto MarkSymbol = [&](Symbol *Sym) { - if (auto *D = dyn_cast_or_null(Sym)) + if (auto *D = dyn_cast_or_null(Sym)) if (auto *IS = cast_or_null(D->Section)) Enqueue(IS, D->Value); }; diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index e421123..c95cbbe 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -33,7 +33,7 @@ class OutputSection; template class ObjFile; template class SharedFile; class SharedSymbol; -class DefinedRegular; +class Defined; // This represents a section in an output file. // It is composed of multiple InputSections. diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index dcf10b0..f157b3a 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -326,7 +326,7 @@ static RelType getMipsPairType(RelType Type, bool IsLocal) { static bool isAbsolute(const Symbol &Sym) { if (Sym.isUndefWeak()) return true; - if (const auto *DR = dyn_cast(&Sym)) + if (const auto *DR = dyn_cast(&Sym)) return DR->Section == nullptr; // Absolute symbol. return false; } diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 8dd300e..6e2f151 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -135,11 +135,11 @@ template void SymbolTable::addCombinedLTOObject() { } template -DefinedRegular *SymbolTable::addAbsolute(StringRef Name, uint8_t Visibility, - uint8_t Binding) { +Defined *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); + return cast(Sym); } // Set a flag for --trace-symbol so that we can print out a log message @@ -366,7 +366,7 @@ static int compareDefinedNonCommon(Symbol *S, bool WasInserted, uint8_t Binding, S->Binding = Binding; return Cmp; } - if (auto *R = dyn_cast(S)) { + if (auto *R = dyn_cast(S)) { if (R->Section && isa(R->Section)) { // Non-common symbols take precedence over common symbols. if (Config->WarnCommon) @@ -395,10 +395,10 @@ Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, uint32_t Alignment, InputSections.push_back(Bss); S->Binding = Binding; - replaceSymbol(S, File, N, /*IsLocal=*/false, StOther, Type, - 0, Size, Bss); + replaceSymbol(S, File, N, /*IsLocal=*/false, StOther, Type, 0, + Size, Bss); } else if (Cmp == 0) { - auto *D = cast(S); + auto *D = cast(S); auto *Bss = dyn_cast_or_null(D->Section); if (!Bss) { // Non-common symbols take precedence over common symbols. @@ -435,7 +435,7 @@ static void reportDuplicate(Symbol *Sym, InputFile *NewFile) { template static void reportDuplicate(Symbol *Sym, InputSectionBase *ErrSec, typename ELFT::uint ErrOffset) { - DefinedRegular *D = dyn_cast(Sym); + Defined *D = dyn_cast(Sym); if (!D || !D->Section || !ErrSec) { reportDuplicate(Sym, ErrSec ? ErrSec->File : nullptr); return; @@ -475,8 +475,8 @@ Symbol *SymbolTable::addRegular(StringRef Name, uint8_t StOther, uint8_t Type, int Cmp = compareDefinedNonCommon(S, WasInserted, Binding, Section == nullptr, Value, Name); if (Cmp > 0) - replaceSymbol(S, File, Name, /*IsLocal=*/false, StOther, - Type, Value, Size, Section); + replaceSymbol(S, File, Name, /*IsLocal=*/false, StOther, Type, + Value, Size, Section); else if (Cmp == 0) reportDuplicate(S, dyn_cast_or_null(Section), Value); @@ -519,8 +519,8 @@ Symbol *SymbolTable::addBitcode(StringRef Name, uint8_t Binding, int Cmp = compareDefinedNonCommon(S, WasInserted, Binding, /*IsAbs*/ false, /*Value*/ 0, Name); if (Cmp > 0) - replaceSymbol(S, F, Name, /*IsLocal=*/false, StOther, Type, - 0, 0, nullptr); + replaceSymbol(S, F, Name, /*IsLocal=*/false, StOther, Type, 0, 0, + nullptr); else if (Cmp == 0) reportDuplicate(S, F); return S; @@ -818,14 +818,14 @@ template Symbol *SymbolTable::addRegular(StringRef, uint8_t, uint8_t, uint64_t, uint64_t, uint8_t, SectionBase *, InputFile *); -template DefinedRegular *SymbolTable::addAbsolute(StringRef, uint8_t, - uint8_t); -template DefinedRegular *SymbolTable::addAbsolute(StringRef, uint8_t, - uint8_t); -template DefinedRegular *SymbolTable::addAbsolute(StringRef, uint8_t, - uint8_t); -template DefinedRegular *SymbolTable::addAbsolute(StringRef, uint8_t, - uint8_t); +template Defined *SymbolTable::addAbsolute(StringRef, uint8_t, + uint8_t); +template Defined *SymbolTable::addAbsolute(StringRef, uint8_t, + uint8_t); +template Defined *SymbolTable::addAbsolute(StringRef, uint8_t, + uint8_t); +template Defined *SymbolTable::addAbsolute(StringRef, uint8_t, + uint8_t); template Symbol * SymbolTable::addLazyArchive(StringRef, ArchiveFile *, diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index 789f023..f43e701 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -41,9 +41,9 @@ public: ArrayRef getSymbols() const { return SymVector; } template - DefinedRegular *addAbsolute(StringRef Name, - uint8_t Visibility = llvm::ELF::STV_HIDDEN, - uint8_t Binding = llvm::ELF::STB_GLOBAL); + Defined *addAbsolute(StringRef Name, + uint8_t Visibility = llvm::ELF::STV_HIDDEN, + uint8_t Binding = llvm::ELF::STB_GLOBAL); template Symbol *addUndefined(StringRef Name); template diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 504d3b6..523a82a 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -28,22 +28,22 @@ using namespace llvm::ELF; using namespace lld; using namespace lld::elf; -DefinedRegular *ElfSym::Bss; -DefinedRegular *ElfSym::Etext1; -DefinedRegular *ElfSym::Etext2; -DefinedRegular *ElfSym::Edata1; -DefinedRegular *ElfSym::Edata2; -DefinedRegular *ElfSym::End1; -DefinedRegular *ElfSym::End2; -DefinedRegular *ElfSym::GlobalOffsetTable; -DefinedRegular *ElfSym::MipsGp; -DefinedRegular *ElfSym::MipsGpDisp; -DefinedRegular *ElfSym::MipsLocalGp; +Defined *ElfSym::Bss; +Defined *ElfSym::Etext1; +Defined *ElfSym::Etext2; +Defined *ElfSym::Edata1; +Defined *ElfSym::Edata2; +Defined *ElfSym::End1; +Defined *ElfSym::End2; +Defined *ElfSym::GlobalOffsetTable; +Defined *ElfSym::MipsGp; +Defined *ElfSym::MipsGpDisp; +Defined *ElfSym::MipsLocalGp; static uint64_t getSymVA(const Symbol &Sym, int64_t &Addend) { switch (Sym.kind()) { - case Symbol::DefinedRegularKind: { - auto &D = cast(Sym); + case Symbol::DefinedKind: { + auto &D = cast(Sym); SectionBase *IS = D.Section; if (auto *ISB = dyn_cast_or_null(IS)) IS = ISB->Repl; @@ -125,7 +125,7 @@ bool Symbol::isUndefWeak() const { InputFile *Symbol::getFile() const { if (isLocal()) { - const SectionBase *Sec = cast(this)->Section; + const SectionBase *Sec = cast(this)->Section; // Local absolute symbols actually have a file, but that is not currently // used. We could support that by having a mostly redundant InputFile in // Symbol, or having a special absolute section if needed. @@ -180,7 +180,7 @@ uint64_t Symbol::getPltVA() const { } uint64_t Symbol::getSize() const { - 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->Size; @@ -188,7 +188,7 @@ uint64_t Symbol::getSize() const { } OutputSection *Symbol::getOutputSection() const { - if (auto *S = dyn_cast(this)) { + if (auto *S = dyn_cast(this)) { if (S->Section) return S->Section->getOutputSection(); return nullptr; @@ -247,7 +247,7 @@ void Symbol::parseSymbolVersion() { Verstr); } -template bool DefinedRegular::isMipsPIC() const { +template bool Defined::isMipsPIC() const { typedef typename ELFT::Ehdr Elf_Ehdr; if (!Section || !isFunc()) return false; @@ -315,7 +315,7 @@ void elf::printTraceSymbol(Symbol *Sym) { S = ": lazy definition of "; else if (Sym->isShared()) S = ": shared definition of "; - else if (dyn_cast_or_null(cast(Sym)->Section)) + else if (dyn_cast_or_null(cast(Sym)->Section)) S = ": common definition of "; else S = ": definition of "; @@ -331,7 +331,7 @@ std::string lld::toString(const Symbol &B) { return B.getName(); } -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 bool Defined::template isMipsPIC() const; +template bool Defined::template isMipsPIC() const; +template bool Defined::template isMipsPIC() const; +template bool Defined::template isMipsPIC() const; diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index e1ff6c1..8475646 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -38,9 +38,7 @@ template class SharedFile; class Symbol { public: enum Kind { - DefinedFirst, - DefinedRegularKind = DefinedFirst, - DefinedLast = DefinedRegularKind, + DefinedKind, SharedKind, UndefinedKind, LazyArchiveKind, @@ -95,7 +93,7 @@ public: bool isWeak() const { return Binding == llvm::ELF::STB_WEAK; } bool isUndefined() const { return SymbolKind == UndefinedKind; } - bool isDefined() const { return SymbolKind <= DefinedLast; } + bool isDefined() const { return SymbolKind == DefinedKind; } bool isShared() const { return SymbolKind == SharedKind; } bool isLocal() const { return IsLocal; } @@ -103,9 +101,7 @@ public: return SymbolKind == LazyArchiveKind || SymbolKind == LazyObjectKind; } - bool isInCurrentOutput() const { - return SymbolKind == DefinedRegularKind; - } + bool isInCurrentOutput() const { return isDefined(); } // True is this is an undefined weak symbol. This only works once // all input files have been added. @@ -188,29 +184,18 @@ protected: StringRefZ Name; }; -// The base class for any defined symbols. +// Represents a symbol that is defined in the current output file. class Defined : public Symbol { public: - Defined(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type) - : Symbol(K, Name, IsLocal, StOther, Type) {} - - static bool classof(const Symbol *S) { return S->isDefined(); } -}; - -// Regular defined symbols read from object file symbol tables. -class DefinedRegular : public Defined { -public: - DefinedRegular(StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type, - uint64_t Value, uint64_t Size, SectionBase *Section) - : Defined(DefinedRegularKind, Name, IsLocal, StOther, Type), Value(Value), + Defined(StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type, + uint64_t Value, uint64_t Size, SectionBase *Section) + : Symbol(DefinedKind, Name, IsLocal, StOther, Type), Value(Value), Size(Size), Section(Section) {} // Return true if the symbol is a PIC function. template bool isMipsPIC() const; - static bool classof(const Symbol *S) { - return S->kind() == DefinedRegularKind; - } + static bool classof(const Symbol *S) { return S->isDefined(); } uint64_t Value; uint64_t Size; @@ -323,39 +308,39 @@ public: }; // Some linker-generated symbols need to be created as -// DefinedRegular symbols. +// Defined symbols. struct ElfSym { // __bss_start - static DefinedRegular *Bss; + static Defined *Bss; // etext and _etext - static DefinedRegular *Etext1; - static DefinedRegular *Etext2; + static Defined *Etext1; + static Defined *Etext2; // edata and _edata - static DefinedRegular *Edata1; - static DefinedRegular *Edata2; + static Defined *Edata1; + static Defined *Edata2; // end and _end - static DefinedRegular *End1; - static DefinedRegular *End2; + static Defined *End1; + static Defined *End2; // The _GLOBAL_OFFSET_TABLE_ symbol is defined by target convention to // be at some offset from the base of the .got section, usually 0 or // the end of the .got. - static DefinedRegular *GlobalOffsetTable; + static Defined *GlobalOffsetTable; // _gp, _gp_disp and __gnu_local_gp symbols. Only for MIPS. - static DefinedRegular *MipsGp; - static DefinedRegular *MipsGpDisp; - static DefinedRegular *MipsLocalGp; + static Defined *MipsGp; + static Defined *MipsGpDisp; + static Defined *MipsLocalGp; }; // A buffer class that is large enough to hold any Symbol-derived // object. We allocate memory using this class and instantiate a symbol // using the placement new. union SymbolUnion { - alignas(DefinedRegular) char A[sizeof(DefinedRegular)]; + alignas(Defined) char A[sizeof(Defined)]; alignas(Undefined) char C[sizeof(Undefined)]; alignas(SharedSymbol) char D[sizeof(SharedSymbol)]; alignas(LazyArchive) char E[sizeof(LazyArchive)]; diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 95ef5f5..a37ad2f 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -275,8 +275,8 @@ InputSection *elf::createInterpSection() { Symbol *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); + auto *S = make(Name, /*IsLocal*/ true, STV_DEFAULT, Type, Value, + Size, Section); if (InX::SymTab) InX::SymTab->addSymbol(S); return S; @@ -428,7 +428,7 @@ bool EhFrameSection::isFdeLive(EhSectionPiece &Fde, ArrayRef Rels) { Symbol &B = Sec->template getFile()->getRelocTargetSym(Rel); // FDEs for garbage-collected or merged-by-ICF sections are dead. - if (auto *D = dyn_cast(&B)) + if (auto *D = dyn_cast(&B)) if (auto *Sec = cast_or_null(D->Section)) return Sec->Live && (Sec == Sec->Repl); return false; @@ -1576,13 +1576,13 @@ template void SymbolTableSection::writeTo(uint8_t *Buf) { // Set a section index. BssSection *CommonSec = nullptr; if (!Config->DefineCommon) - if (auto *D = dyn_cast(Sym)) + if (auto *D = dyn_cast(Sym)) CommonSec = dyn_cast_or_null(D->Section); if (CommonSec) ESym->st_shndx = SHN_COMMON; else if (const OutputSection *OutSec = Sym->getOutputSection()) ESym->st_shndx = OutSec->SectionIndex; - else if (isa(Sym)) + else if (isa(Sym)) ESym->st_shndx = SHN_ABS; else ESym->st_shndx = SHN_UNDEF; @@ -1621,7 +1621,7 @@ template void SymbolTableSection::writeTo(uint8_t *Buf) { ESym->st_other |= STO_MIPS_PLT; if (Config->Relocatable) - if (auto *D = dyn_cast(Sym)) + if (auto *D = dyn_cast(Sym)) if (D->isMipsPIC()) ESym->st_other |= STO_MIPS_PIC; ++ESym; diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp index e0fb346..c87070d 100644 --- a/lld/ELF/Thunks.cpp +++ b/lld/ELF/Thunks.cpp @@ -251,7 +251,7 @@ void MipsThunk::addSymbols(ThunkSection &IS) { } InputSection *MipsThunk::getTargetInputSection() const { - auto *DR = dyn_cast(&Destination); + auto *DR = dyn_cast(&Destination); return dyn_cast(DR->Section); } @@ -276,7 +276,7 @@ void MicroMipsThunk::addSymbols(ThunkSection &IS) { } InputSection *MicroMipsThunk::getTargetInputSection() const { - auto *DR = dyn_cast(&Destination); + auto *DR = dyn_cast(&Destination); return dyn_cast(DR->Section); } @@ -301,7 +301,7 @@ void MicroMipsR6Thunk::addSymbols(ThunkSection &IS) { } InputSection *MicroMipsR6Thunk::getTargetInputSection() const { - auto *DR = dyn_cast(&Destination); + auto *DR = dyn_cast(&Destination); return dyn_cast(DR->Section); } diff --git a/lld/ELF/Thunks.h b/lld/ELF/Thunks.h index e49be21..828fac0 100644 --- a/lld/ELF/Thunks.h +++ b/lld/ELF/Thunks.h @@ -23,7 +23,7 @@ class ThunkSection; // include transferring control from non-pi to pi and changing state on // targets like ARM. // -// Thunks can be created for DefinedRegular, Shared and Undefined Symbols. +// Thunks can be created for Defined, Shared and Undefined Symbols. // Thunks are assigned to synthetic ThunkSections class Thunk { public: diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 7bd7c2b..3785ed2 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -426,7 +426,7 @@ static bool includeInSymtab(const Symbol &B) { if (!B.isLocal() && !B.IsUsedInRegularObj) return false; - if (auto *D = dyn_cast(&B)) { + if (auto *D = dyn_cast(&B)) { // Always include absolute symbols. SectionBase *Sec = D->Section; if (!Sec) @@ -456,7 +456,7 @@ template void Writer::copyLocalSymbols() { 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) @@ -491,9 +491,8 @@ template void Writer::addSectionSymbols() { IS->Type == SHT_RELA) continue; - auto *Sym = - make("", /*IsLocal=*/true, /*StOther=*/0, STT_SECTION, - /*Value=*/0, /*Size=*/0, IS); + auto *Sym = make("", /*IsLocal=*/true, /*StOther=*/0, STT_SECTION, + /*Value=*/0, /*Size=*/0, IS); InX::SymTab->addSymbol(Sym); } } @@ -735,16 +734,16 @@ void PhdrEntry::add(OutputSection *Sec) { } template -static DefinedRegular * -addOptionalRegular(StringRef Name, SectionBase *Sec, uint64_t Val, - uint8_t StOther = STV_HIDDEN, uint8_t Binding = STB_GLOBAL) { +static Defined *addOptionalRegular(StringRef Name, SectionBase *Sec, + uint64_t Val, uint8_t StOther = STV_HIDDEN, + uint8_t Binding = STB_GLOBAL) { Symbol *S = Symtab->find(Name); if (!S || S->isInCurrentOutput()) return nullptr; Symbol *Sym = Symtab->addRegular(Name, StOther, STT_NOTYPE, Val, /*Size=*/0, Binding, Sec, /*File=*/nullptr); - return cast(Sym); + return cast(Sym); } // The beginning and the ending of .rel[a].plt section are marked