From 32078624b4ac88b56ec856db5cb648dc1fe49f3e Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 23 Jan 2015 23:59:37 +0000 Subject: [PATCH] ELF: Remove virtual from non-overriden functions. If it's overridden by a derived class, add override to the derived class. llvm-svn: 226971 --- lld/lib/ReaderWriter/ELF/ELFFile.h | 64 +++++++++---------- .../ReaderWriter/ELF/Hexagon/HexagonELFFile.h | 10 +-- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h index 6a66f979cfac..4708a9749716 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.h +++ b/lld/lib/ReaderWriter/ELF/ELFFile.h @@ -131,19 +131,19 @@ public: /// \brief Read input sections and populate necessary data structures /// to read them later and create atoms - virtual std::error_code createAtomizableSections(); + std::error_code createAtomizableSections(); /// \brief Create mergeable atoms from sections that have the merge attribute /// set - virtual std::error_code createMergeableAtoms(); + std::error_code createMergeableAtoms(); /// \brief Add the symbols that the sections contain. The symbols will be /// converted to atoms for /// Undefined symbols, absolute symbols - virtual std::error_code createSymbolsFromAtomizableSections(); + std::error_code createSymbolsFromAtomizableSections(); /// \brief Create individual atoms - virtual std::error_code createAtoms(); + std::error_code createAtoms(); const atom_collection &defined() const override { return _definedAtoms; @@ -186,97 +186,95 @@ protected: /// \brief After all the Atoms and References are created, update each /// Reference's target with the Atom pointer it refers to. - virtual void updateReferences(); + void updateReferences(); /// \brief Update the reference if the access corresponds to a merge string /// section. - virtual void updateReferenceForMergeStringAccess(ELFReference *ref, - const Elf_Sym *symbol, - const Elf_Shdr *shdr); + void updateReferenceForMergeStringAccess(ELFReference *ref, + const Elf_Sym *symbol, + const Elf_Shdr *shdr); /// \brief Return true if the symbol is corresponding to an architecture /// specific section. We will let the TargetHandler handle such atoms. - virtual bool isTargetSpecificAtom(const Elf_Shdr *shdr, const Elf_Sym *sym); + bool isTargetSpecificAtom(const Elf_Shdr *shdr, const Elf_Sym *sym); /// \brief Do we want to ignore the section. Ignored sections are /// not processed to create atoms - virtual bool isIgnoredSection(const Elf_Shdr *section); + bool isIgnoredSection(const Elf_Shdr *section); /// \brief Is the current section be treated as a mergeable string section. /// The contents of a mergeable string section are null-terminated strings. /// If the section have mergeable strings, the linker would need to split /// the section into multiple atoms and mark them mergeByContent. - virtual bool isMergeableStringSection(const Elf_Shdr *section); + bool isMergeableStringSection(const Elf_Shdr *section); /// \brief Returns a new anonymous atom whose size is equal to the /// section size. That atom will be used to represent the entire /// section that have no symbols. - virtual ELFDefinedAtom *createSectionAtom(const Elf_Shdr *section, - StringRef sectionName, - ArrayRef contents); + ELFDefinedAtom *createSectionAtom(const Elf_Shdr *section, + StringRef sectionName, + ArrayRef contents); /// Returns the symbol's content size. The nextSymbol should be null if the /// symbol is the last one in the section. - virtual uint64_t symbolContentSize(const Elf_Shdr *section, - const Elf_Sym *symbol, - const Elf_Sym *nextSymbol); - - virtual void createEdge(ELFDefinedAtom *from, ELFDefinedAtom *to, - uint32_t edgeKind); + uint64_t symbolContentSize(const Elf_Shdr *section, + const Elf_Sym *symbol, + const Elf_Sym *nextSymbol); /// Determines if the reader needs to create atoms for the section. - virtual bool ignoreCreateAtomsForSection(const Elf_Shdr *shdr) { + bool ignoreCreateAtomsForSection(const Elf_Shdr *shdr) { return false; } + void createEdge(ELFDefinedAtom *from, ELFDefinedAtom *to, + uint32_t edgeKind); + /// Get the section name for a section. - virtual ErrorOr getSectionName(const Elf_Shdr *shdr) const { + ErrorOr getSectionName(const Elf_Shdr *shdr) const { if (!shdr) return StringRef(); return _objFile->getSectionName(shdr); } /// Determines if the section occupy memory space. - virtual bool sectionOccupiesMemorySpace(const Elf_Shdr *shdr) const { + bool sectionOccupiesMemorySpace(const Elf_Shdr *shdr) const { return (shdr->sh_type != llvm::ELF::SHT_NOBITS); } /// Return the section contents. - virtual ErrorOr> - getSectionContents(const Elf_Shdr *shdr) const { + ErrorOr> getSectionContents(const Elf_Shdr *shdr) const { if (!shdr || !sectionOccupiesMemorySpace(shdr)) return ArrayRef(); return _objFile->getSectionContents(shdr); } /// Returns true if the symbol is a undefined symbol. - virtual bool isUndefinedSymbol(const Elf_Sym *sym) const { + bool isUndefinedSymbol(const Elf_Sym *sym) const { return (sym->st_shndx == llvm::ELF::SHN_UNDEF); } /// Determines if the target wants to create an atom for a section that has no /// symbol references. - virtual bool - handleSectionWithNoSymbols(const Elf_Shdr *shdr, - std::vector &symbols) const { + bool handleSectionWithNoSymbols(const Elf_Shdr *shdr, + std::vector &symbols) const { if (shdr && shdr->sh_type == llvm::ELF::SHT_PROGBITS && symbols.empty()) return true; return false; } /// Process the Undefined symbol and create an atom for it. - virtual ErrorOr *> + ErrorOr *> handleUndefinedSymbol(StringRef symName, const Elf_Sym *sym) { return new (_readerStorage) ELFUndefinedAtom(*this, symName, sym); } /// Returns true if the symbol is a absolute symbol. - virtual bool isAbsoluteSymbol(const Elf_Sym *sym) const { + bool isAbsoluteSymbol(const Elf_Sym *sym) const { return (sym->st_shndx == llvm::ELF::SHN_ABS); } /// Process the Absolute symbol and create an atom for it. - virtual ErrorOr *> + ErrorOr *> handleAbsoluteSymbol(StringRef symName, const Elf_Sym *sym, int64_t value) { return new (_readerStorage) ELFAbsoluteAtom(*this, symName, sym, value); @@ -322,7 +320,7 @@ protected: } /// Process the Merge string and create an atom for it. - virtual ErrorOr *> + ErrorOr *> handleMergeString(StringRef sectionName, const Elf_Shdr *sectionHdr, ArrayRef contentData, unsigned int offset) { ELFMergeAtom *mergeAtom = new (_readerStorage) diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h index 03bfe7fdddec..2bea795dfc92 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h @@ -123,7 +123,7 @@ public: new HexagonELFFile(std::move(mb), atomizeStrings)); } - virtual bool isCommonSymbol(const Elf_Sym *symbol) const { + bool isCommonSymbol(const Elf_Sym *symbol) const override { switch (symbol->st_shndx) { // Common symbols case llvm::ELF::SHN_HEXAGON_SCOMMON: @@ -139,20 +139,20 @@ public: } /// Process the Defined symbol and create an atom for it. - virtual ErrorOr *> + ErrorOr *> handleDefinedSymbol(StringRef symName, StringRef sectionName, const Elf_Sym *sym, const Elf_Shdr *sectionHdr, ArrayRef contentData, unsigned int referenceStart, unsigned int referenceEnd, - std::vector *> &referenceList) { + std::vector *> &referenceList) override { return new (this->_readerStorage) HexagonELFDefinedAtom( *this, symName, sectionName, sym, sectionHdr, contentData, referenceStart, referenceEnd, referenceList); } /// Process the Common symbol and create an atom for it. - virtual ErrorOr *> - handleCommonSymbol(StringRef symName, const Elf_Sym *sym) { + ErrorOr *> + handleCommonSymbol(StringRef symName, const Elf_Sym *sym) override { return new (this->_readerStorage) HexagonELFCommonAtom(*this, symName, sym); } -- 2.34.1