diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-08 17:13:44 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-08 17:13:44 +0000 |
commit | fbe69f787ace06f44b6cb1bd3cd45ac703a16a05 (patch) | |
tree | 71baf2dfe04008283f87b4c0ae75a2268033cd62 /ELF/InputFiles.cpp | |
parent | d803cda42997f42649910309ac18170d2d6f2214 (diff) |
Notes
Diffstat (limited to 'ELF/InputFiles.cpp')
-rw-r--r-- | ELF/InputFiles.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ELF/InputFiles.cpp b/ELF/InputFiles.cpp index 260a78ebbf8e..5f94fc9338a4 100644 --- a/ELF/InputFiles.cpp +++ b/ELF/InputFiles.cpp @@ -596,17 +596,13 @@ SymbolBody *elf::ObjectFile<ELFT>::createSymbolBody(const Elf_Sym *Sym) { } } -template <class ELFT> void ArchiveFile::parse() { - File = check(Archive::create(MB), - MB.getBufferIdentifier() + ": failed to parse archive"); +ArchiveFile::ArchiveFile(std::unique_ptr<Archive> &&File) + : InputFile(ArchiveKind, File->getMemoryBufferRef()), + File(std::move(File)) {} - // Read the symbol table to construct Lazy objects. - for (const Archive::Symbol &Sym : File->symbols()) { +template <class ELFT> void ArchiveFile::parse() { + for (const Archive::Symbol &Sym : File->symbols()) Symtab<ELFT>::X->addLazyArchive(this, Sym); - } - - if (File->symbols().begin() == File->symbols().end()) - Config->ArchiveWithoutSymbolsSeen = true; } // Returns a buffer pointing to a member file containing a given symbol. @@ -981,6 +977,13 @@ MemoryBufferRef LazyObjectFile::getBuffer() { return MB; } +InputFile *LazyObjectFile::fetch() { + MemoryBufferRef MBRef = getBuffer(); + if (MBRef.getBuffer().empty()) + return nullptr; + return createObjectFile(MBRef, ArchiveName, OffsetInArchive); +} + template <class ELFT> void LazyObjectFile::parse() { for (StringRef Sym : getSymbols()) Symtab<ELFT>::X->addLazyObject(Sym, *this); |