diff options
Diffstat (limited to 'lld/ELF/InputFiles.h')
-rw-r--r-- | lld/ELF/InputFiles.h | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index 1ed47c8f3f5..ca41d16392b 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -36,7 +36,14 @@ class SymbolBody; // The root class of input files. class InputFile { public: - enum Kind { ObjectKind, SharedKind, ArchiveKind, BitcodeKind }; + enum Kind { + ObjectKind, + SharedKind, + LazyObjectKind, + ArchiveKind, + BitcodeKind, + }; + Kind kind() const { return FileKind; } StringRef getName() const { return MB.getBufferIdentifier(); } @@ -154,6 +161,36 @@ private: llvm::SpecificBumpPtrAllocator<EHInputSection<ELFT>> EHAlloc; }; +// LazyObjectFile is analogous to ArchiveFile in the sense that +// the file contains lazy symbols. The difference is that +// LazyObjectFile wraps a single file instead of multiple files. +// +// This class is used for --start-lib and --end-lib options which +// instruct the linker to link object files between them with the +// archive file semantics. +class LazyObjectFile : public InputFile { +public: + explicit LazyObjectFile(MemoryBufferRef M) : InputFile(LazyObjectKind, M) {} + + static bool classof(const InputFile *F) { + return F->kind() == LazyObjectKind; + } + + void parse(); + + llvm::MutableArrayRef<LazyObject> getLazySymbols() { return LazySymbols; } + +private: + std::vector<StringRef> getSymbols(); + template <class ELFT> std::vector<StringRef> getElfSymbols(); + std::vector<StringRef> getBitcodeSymbols(); + + llvm::BumpPtrAllocator Alloc; + llvm::StringSaver Saver{Alloc}; + std::vector<LazyObject> LazySymbols; +}; + +// An ArchiveFile object represents a .a file. class ArchiveFile : public InputFile { public: explicit ArchiveFile(MemoryBufferRef M) : InputFile(ArchiveKind, M) {} @@ -165,11 +202,11 @@ public: // (So that we don't instantiate same members more than once.) MemoryBufferRef getMember(const Archive::Symbol *Sym); - llvm::MutableArrayRef<Lazy> getLazySymbols() { return LazySymbols; } + llvm::MutableArrayRef<LazyArchive> getLazySymbols() { return LazySymbols; } private: std::unique_ptr<Archive> File; - std::vector<Lazy> LazySymbols; + std::vector<LazyArchive> LazySymbols; llvm::DenseSet<uint64_t> Seen; }; |