diff options
Diffstat (limited to 'ELF/InputFiles.h')
-rw-r--r-- | ELF/InputFiles.h | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/ELF/InputFiles.h b/ELF/InputFiles.h index 95888061d877a..40a8b23c5ef4a 100644 --- a/ELF/InputFiles.h +++ b/ELF/InputFiles.h @@ -30,6 +30,7 @@ namespace llvm { class DWARFDebugLine; class TarWriter; +struct DILineInfo; namespace lto { class InputFile; } @@ -74,25 +75,34 @@ public: StringRef getName() const { return MB.getBufferIdentifier(); } MemoryBufferRef MB; + // Returns sections. It is a runtime error to call this function + // on files that don't have the notion of sections. + ArrayRef<InputSectionBase *> getSections() const { + assert(FileKind == ObjectKind || FileKind == BinaryKind); + return Sections; + } + // Filename of .a which contained this file. If this file was // not in an archive file, it is the empty string. We use this // string for creating error messages. StringRef ArchiveName; - // If this file is in an archive, the member contains the offset of - // the file in the archive. Otherwise, it's just zero. We store this - // field so that we can pass it to lib/LTO in order to disambiguate - // between objects. - uint64_t OffsetInArchive; - // If this is an architecture-specific file, the following members // have ELF type (i.e. ELF{32,64}{LE,BE}) and target machine type. ELFKind EKind = ELFNoneKind; uint16_t EMachine = llvm::ELF::EM_NONE; uint8_t OSABI = 0; + // For SharedKind inputs, the string to use in DT_NEEDED when the library + // has no soname. + std::string DefaultSoName; + + // Cache for toString(). Only toString() should use this member. + mutable std::string ToStringCache; + protected: - InputFile(Kind K, MemoryBufferRef M) : MB(M), FileKind(K) {} + InputFile(Kind K, MemoryBufferRef M); + std::vector<InputSectionBase *> Sections; private: const Kind FileKind; @@ -136,9 +146,7 @@ template <class ELFT> class ObjectFile : public ELFFileBase<ELFT> { typedef typename ELFT::Rela Elf_Rela; typedef typename ELFT::Sym Elf_Sym; typedef typename ELFT::Shdr Elf_Shdr; - typedef typename ELFT::SymRange Elf_Sym_Range; typedef typename ELFT::Word Elf_Word; - typedef typename ELFT::uint uintX_t; StringRef getShtGroupSignature(ArrayRef<Elf_Shdr> Sections, const Elf_Shdr &Sec); @@ -151,13 +159,11 @@ public: ArrayRef<SymbolBody *> getSymbols(); ArrayRef<SymbolBody *> getLocalSymbols(); - ArrayRef<SymbolBody *> getNonLocalSymbols(); explicit ObjectFile(MemoryBufferRef M); void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups); - ArrayRef<InputSectionBase<ELFT> *> getSections() const { return Sections; } - InputSectionBase<ELFT> *getSection(const Elf_Sym &Sym) const; + InputSectionBase *getSection(const Elf_Sym &Sym) const; SymbolBody &getSymbolBody(uint32_t SymbolIndex) const { if (SymbolIndex >= SymbolBodies.size()) @@ -167,13 +173,14 @@ public: template <typename RelT> SymbolBody &getRelocTargetSym(const RelT &Rel) const { - uint32_t SymIndex = Rel.getSymbol(Config->Mips64EL); + uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL); return getSymbolBody(SymIndex); } // Returns source line information for a given offset. // If no information is available, returns "". - std::string getLineInfo(InputSectionBase<ELFT> *S, uintX_t Offset); + std::string getLineInfo(InputSectionBase *S, uint64_t Offset); + llvm::Optional<llvm::DILineInfo> getDILineInfo(InputSectionBase *, uint64_t); // MIPS GP0 value defined by this file. This value represents the gp value // used to create the relocatable object and required to support @@ -190,16 +197,13 @@ private: initializeSections(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups); void initializeSymbols(); void initializeDwarfLine(); - InputSectionBase<ELFT> *getRelocTarget(const Elf_Shdr &Sec); - InputSectionBase<ELFT> *createInputSection(const Elf_Shdr &Sec, - StringRef SectionStringTable); + InputSectionBase *getRelocTarget(const Elf_Shdr &Sec); + InputSectionBase *createInputSection(const Elf_Shdr &Sec, + StringRef SectionStringTable); bool shouldMerge(const Elf_Shdr &Sec); SymbolBody *createSymbolBody(const Elf_Sym *Sym); - // List of all sections defined by this file. - std::vector<InputSectionBase<ELFT> *> Sections; - // List of all symbols referenced or defined by this file. std::vector<SymbolBody *> SymbolBodies; @@ -256,7 +260,8 @@ private: class BitcodeFile : public InputFile { public: - explicit BitcodeFile(MemoryBufferRef M); + BitcodeFile(MemoryBufferRef M, StringRef ArchiveName, + uint64_t OffsetInArchive); static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; } template <class ELFT> void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups); @@ -276,8 +281,6 @@ template <class ELFT> class SharedFile : public ELFFileBase<ELFT> { typedef typename ELFT::SymRange Elf_Sym_Range; typedef typename ELFT::Verdef Elf_Verdef; typedef typename ELFT::Versym Elf_Versym; - typedef typename ELFT::Word Elf_Word; - typedef typename ELFT::uint uintX_t; std::vector<StringRef> Undefs; StringRef SoName; @@ -285,7 +288,7 @@ template <class ELFT> class SharedFile : public ELFFileBase<ELFT> { const Elf_Shdr *VerdefSec = nullptr; public: - StringRef getSoName() const { return SoName; } + StringRef getSoName() const; const Elf_Shdr *getSection(const Elf_Sym &Sym) const; llvm::ArrayRef<StringRef> getUndefinedSymbols() { return Undefs; } @@ -322,10 +325,6 @@ public: explicit BinaryFile(MemoryBufferRef M) : InputFile(BinaryKind, M) {} static bool classof(const InputFile *F) { return F->kind() == BinaryKind; } template <class ELFT> void parse(); - ArrayRef<InputSectionData *> getSections() const { return Sections; } - -private: - std::vector<InputSectionData *> Sections; }; InputFile *createObjectFile(MemoryBufferRef MB, StringRef ArchiveName = "", |