Index: lib/ReaderWriter/ELF/ELFFile.h =================================================================== --- lib/ReaderWriter/ELF/ELFFile.h +++ lib/ReaderWriter/ELF/ELFFile.h @@ -197,11 +197,6 @@ return _objFile->getSectionContents(shdr); } - /// Returns true if the symbol is a undefined symbol. - 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. bool handleSectionWithNoSymbols(const Elf_Shdr *shdr, @@ -225,11 +220,6 @@ return new (_readerStorage) ELFUndefinedAtom(*this, symName, sym); } - /// Returns true if the symbol is a absolute symbol. - 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. ELFAbsoluteAtom *createAbsoluteAtom(StringRef symName, const Elf_Sym *sym, int64_t value) { @@ -237,14 +227,9 @@ ELFAbsoluteAtom(*this, symName, sym, value); } - /// Returns true if the symbol is common symbol. A common symbol represents a - /// tentive definition in C. It has name, size and alignment constraint, but - /// actual storage has not yet been allocated. (The linker will allocate - /// storage for them in the later pass after coalescing tentative symbols by - /// name.) + // This will go away. Blame Hexagon. virtual bool isCommonSymbol(const Elf_Sym *symbol) const { - return symbol->getType() == llvm::ELF::STT_COMMON || - symbol->st_shndx == llvm::ELF::SHN_COMMON; + return _objFile->isCommonSymbol(symbol); } /// Returns true if the section is a gnulinkonce section. @@ -281,17 +266,6 @@ return new (_readerStorage) ELFCommonAtom(*this, symName, sym); } - /// Returns true if the symbol is a defined symbol. - virtual bool isDefinedSymbol(const Elf_Sym *sym) const { - return (sym->getType() == llvm::ELF::STT_NOTYPE || - sym->getType() == llvm::ELF::STT_OBJECT || - sym->getType() == llvm::ELF::STT_FUNC || - sym->getType() == llvm::ELF::STT_GNU_IFUNC || - sym->getType() == llvm::ELF::STT_SECTION || - sym->getType() == llvm::ELF::STT_FILE || - sym->getType() == llvm::ELF::STT_TLS); - } - /// Creates an atom for a given defined symbol. virtual ELFDefinedAtom * createDefinedAtom(StringRef symName, StringRef sectionName, Index: lib/ReaderWriter/ELF/ELFFile.cpp =================================================================== --- lib/ReaderWriter/ELF/ELFFile.cpp +++ lib/ReaderWriter/ELF/ELFFile.cpp @@ -223,12 +223,12 @@ if (std::error_code ec = symbolName.getError()) return ec; - if (isAbsoluteSymbol(&*SymI)) { + if (_objFile->isAbsoluteSymbol(&*SymI)) { ELFAbsoluteAtom *absAtom = createAbsoluteAtom( *symbolName, &*SymI, (int64_t)getSymbolValue(&*SymI)); addAtom(*absAtom); _symbolToAtomMapping.insert(std::make_pair(&*SymI, absAtom)); - } else if (isUndefinedSymbol(&*SymI)) { + } else if (_objFile->isUndefinedSymbol(&*SymI)) { if (_useWrap && (_wrapSymbolMap.find(*symbolName) != _wrapSymbolMap.end())) { auto wrapAtom = _wrapSymbolMap.find(*symbolName); @@ -240,12 +240,12 @@ createUndefinedAtom(*symbolName, &*SymI); addAtom(*undefAtom); _symbolToAtomMapping.insert(std::make_pair(&*SymI, undefAtom)); - } else if (isCommonSymbol(&*SymI)) { + } else if (_objFile->isCommonSymbol(&*SymI)) { ELFCommonAtom *commonAtom = createCommonAtom(*symbolName, &*SymI); commonAtom->setOrdinal(++_ordinal); addAtom(*commonAtom); _symbolToAtomMapping.insert(std::make_pair(&*SymI, commonAtom)); - } else if (isDefinedSymbol(&*SymI)) { + } else if (_objFile->isDefinedSymbol(&*SymI)) { _sectionSymbols[section].push_back(SymI); } else { llvm::errs() << "Unable to create atom for: " << *symbolName << "\n"; Index: lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h @@ -110,21 +110,6 @@ HexagonELFFile(std::unique_ptr mb, ELFLinkingContext &ctx) : ELFFile(std::move(mb), ctx) {} - bool isCommonSymbol(const Elf_Sym *symbol) const override { - switch (symbol->st_shndx) { - // Common symbols - case llvm::ELF::SHN_HEXAGON_SCOMMON: - case llvm::ELF::SHN_HEXAGON_SCOMMON_1: - case llvm::ELF::SHN_HEXAGON_SCOMMON_2: - case llvm::ELF::SHN_HEXAGON_SCOMMON_4: - case llvm::ELF::SHN_HEXAGON_SCOMMON_8: - return true; - default: - break; - } - return ELFFile::isCommonSymbol(symbol); - } - /// Process the Defined symbol and create an atom for it. ELFDefinedAtom *createDefinedAtom( StringRef symName, StringRef sectionName, const Elf_Sym *sym,