summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/include/lld/Core/File.h8
-rw-r--r--lld/lib/ReaderWriter/ELF/DynamicFile.h1
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFFile.h4
-rw-r--r--lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h1
-rw-r--r--lld/lib/ReaderWriter/FileArchive.cpp23
-rw-r--r--lld/lib/ReaderWriter/MachO/File.h1
6 files changed, 21 insertions, 17 deletions
diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h
index 04be2465cea..1edf943c258 100644
--- a/lld/include/lld/Core/File.h
+++ b/lld/include/lld/Core/File.h
@@ -154,10 +154,6 @@ public:
/// all AbsoluteAtoms in this File.
virtual const atom_collection<AbsoluteAtom> &absolute() const = 0;
- /// \brief Subclasses should override this method to parse the
- /// memory buffer passed to this file's constructor.
- virtual std::error_code doParse() { return std::error_code(); }
-
/// \brief If a file is parsed using a different method than doParse(),
/// one must use this method to set the last error status, so that
/// doParse will not be called twice. Only YAML reader uses this
@@ -184,6 +180,10 @@ protected:
File(StringRef p, Kind kind)
: _path(p), _kind(kind), _ordinal(UINT64_MAX) {}
+ /// \brief Subclasses should override this method to parse the
+ /// memory buffer passed to this file's constructor.
+ virtual std::error_code doParse() { return std::error_code(); }
+
/// \brief This is a convenience class for File subclasses which manage their
/// atoms as a simple std::vector<>.
template <typename T>
diff --git a/lld/lib/ReaderWriter/ELF/DynamicFile.h b/lld/lib/ReaderWriter/ELF/DynamicFile.h
index 73211c7d308..64139f52a1c 100644
--- a/lld/lib/ReaderWriter/ELF/DynamicFile.h
+++ b/lld/lib/ReaderWriter/ELF/DynamicFile.h
@@ -55,6 +55,7 @@ public:
*this, name, _soname, sym->second._symbol);
}
+protected:
std::error_code doParse() override {
std::error_code ec;
_objFile.reset(
diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h
index 8ca4c2de7f1..baab0d3a5ba 100644
--- a/lld/lib/ReaderWriter/ELF/ELFFile.h
+++ b/lld/lib/ReaderWriter/ELF/ELFFile.h
@@ -122,8 +122,6 @@ public:
: File(mb->getBufferIdentifier(), kindObject), _mb(std::move(mb)),
_ordinal(0), _doStringsMerge(atomizeStrings) {}
- virtual std::error_code doParse() override;
-
static ErrorOr<std::unique_ptr<ELFFile>>
create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings);
@@ -171,6 +169,8 @@ protected:
const Elf_Shdr *section, ArrayRef<uint8_t> symContent,
ArrayRef<uint8_t> secContent);
+ std::error_code doParse() override;
+
/// \brief Iterate over Elf_Rela relocations list and create references.
virtual void createRelocationReferences(const Elf_Sym &symbol,
ArrayRef<uint8_t> content,
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h b/lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
index dd874f755fc..3bae86ed3ff 100644
--- a/lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
+++ b/lld/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
@@ -100,6 +100,7 @@ public:
uint64_t getTPOffset() const { return *_tpOff; }
uint64_t getDTPOffset() const { return *_dtpOff; }
+protected:
std::error_code doParse() override {
if (std::error_code ec = ELFFile<ELFT>::doParse())
return ec;
diff --git a/lld/lib/ReaderWriter/FileArchive.cpp b/lld/lib/ReaderWriter/FileArchive.cpp
index 3f86682871a..ccb156e20e6 100644
--- a/lld/lib/ReaderWriter/FileArchive.cpp
+++ b/lld/lib/ReaderWriter/FileArchive.cpp
@@ -39,17 +39,6 @@ public:
: ArchiveLibraryFile(path), _mb(std::shared_ptr<MemoryBuffer>(mb.release())),
_registry(reg), _logLoading(logLoading) {}
- std::error_code doParse() override {
- // Make Archive object which will be owned by FileArchive object.
- std::error_code ec;
- _archive.reset(new Archive(_mb->getMemBufferRef(), ec));
- if (ec)
- return ec;
- if ((ec = buildTableOfContents()))
- return ec;
- return std::error_code();
- }
-
virtual ~FileArchive() {}
/// \brief Check if any member of the archive contains an Atom with the
@@ -136,6 +125,18 @@ public:
return ret;
}
+protected:
+ std::error_code doParse() override {
+ // Make Archive object which will be owned by FileArchive object.
+ std::error_code ec;
+ _archive.reset(new Archive(_mb->getMemBufferRef(), ec));
+ if (ec)
+ return ec;
+ if ((ec = buildTableOfContents()))
+ return ec;
+ return std::error_code();
+ }
+
private:
std::error_code
instantiateMember(Archive::child_iterator member,
diff --git a/lld/lib/ReaderWriter/MachO/File.h b/lld/lib/ReaderWriter/MachO/File.h
index fdb7d3ba2f4..ae0fbfbf34e 100644
--- a/lld/lib/ReaderWriter/MachO/File.h
+++ b/lld/lib/ReaderWriter/MachO/File.h
@@ -175,6 +175,7 @@ public:
visitor(offAndAtom.atom, offAndAtom.offset);
}
+protected:
std::error_code doParse() override {
// Convert binary file to normalized mach-o.
auto normFile = normalized::readBinary(_mb, _ctx->arch());
OpenPOWER on IntegriCloud