summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index cc7bbaa9216..5eabb298c2a 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -181,10 +181,14 @@ SymbolBody *elf2::ObjectFile<ELFT>::createSymbolBody(StringRef StringTable,
}
}
-void ArchiveFile::parse() {
+static std::unique_ptr<Archive> openArchive(MemoryBufferRef MB) {
ErrorOr<std::unique_ptr<Archive>> ArchiveOrErr = Archive::create(MB);
error(ArchiveOrErr, "Failed to parse archive");
- File = std::move(*ArchiveOrErr);
+ return std::move(*ArchiveOrErr);
+}
+
+void ArchiveFile::parse() {
+ File = openArchive(MB);
// Allocate a buffer for Lazy objects.
size_t NumSyms = File->getNumberOfSymbols();
@@ -211,6 +215,20 @@ MemoryBufferRef ArchiveFile::getMember(const Archive::Symbol *Sym) {
return *Ret;
}
+std::vector<MemoryBufferRef> ArchiveFile::getMembers() {
+ File = openArchive(MB);
+
+ std::vector<MemoryBufferRef> Result;
+ for (const Archive::Child &Child : File->children()) {
+ ErrorOr<MemoryBufferRef> MbOrErr = Child.getMemoryBufferRef();
+ error(MbOrErr,
+ Twine("Could not get the buffer for a child of the archive ") +
+ File->getFileName());
+ Result.push_back(MbOrErr.get());
+ }
+ return Result;
+}
+
template <class ELFT>
SharedFile<ELFT>::SharedFile(MemoryBufferRef M)
: SharedFileBase(getStaticELFKind<ELFT>(), M), ELFData<ELFT>(M) {}
OpenPOWER on IntegriCloud