summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/include/lld/Driver/DarwinInputGraph.h47
-rw-r--r--lld/lib/Driver/CMakeLists.txt1
-rw-r--r--lld/lib/Driver/DarwinInputGraph.cpp69
3 files changed, 71 insertions, 46 deletions
diff --git a/lld/include/lld/Driver/DarwinInputGraph.h b/lld/include/lld/Driver/DarwinInputGraph.h
index be4635b01c5..7021ef3811c 100644
--- a/lld/include/lld/Driver/DarwinInputGraph.h
+++ b/lld/include/lld/Driver/DarwinInputGraph.h
@@ -18,11 +18,6 @@
#define LLD_DRIVER_DARWIN_INPUT_GRAPH_H
#include "lld/Core/InputGraph.h"
-#include "lld/Core/ArchiveLibraryFile.h"
-#include "lld/Core/SharedLibraryFile.h"
-#include "lld/ReaderWriter/MachOLinkingContext.h"
-
-#include <map>
namespace lld {
@@ -34,47 +29,7 @@ public:
/// \brief Parse the input file to lld::File.
std::error_code parse(const LinkingContext &ctx,
- raw_ostream &diagnostics) override {
- ErrorOr<StringRef> filePath = getPath(ctx);
- if (std::error_code ec = filePath.getError())
- return ec;
-
- if (std::error_code ec = getBuffer(*filePath))
- return ec;
-
- if (ctx.logInputFiles())
- diagnostics << *filePath << "\n";
-
- std::vector<std::unique_ptr<File>> parsedFiles;
- if (_isWholeArchive) {
- std::error_code ec = ctx.registry().parseFile(_buffer, parsedFiles);
- if (ec)
- return ec;
- assert(parsedFiles.size() == 1);
- std::unique_ptr<File> f(parsedFiles[0].release());
- if (auto archive =
- reinterpret_cast<const ArchiveLibraryFile *>(f.get())) {
- // FIXME: something needs to own archive File
- //_files.push_back(std::move(archive));
- return archive->parseAllMembers(_files);
- } else {
- // if --whole-archive is around non-archive, just use it as normal.
- _files.push_back(std::move(f));
- return std::error_code();
- }
- }
- if (std::error_code ec = ctx.registry().parseFile(_buffer, parsedFiles))
- return ec;
- for (std::unique_ptr<File> &pf : parsedFiles) {
- // If a dylib was parsed, inform LinkingContext about it.
- if (SharedLibraryFile *shl = dyn_cast<SharedLibraryFile>(pf.get())) {
- MachOLinkingContext *mctx = (MachOLinkingContext*)(&ctx);
- mctx->registerDylib(reinterpret_cast<mach_o::MachODylibFile*>(shl));
- }
- _files.push_back(std::move(pf));
- }
- return std::error_code();
- }
+ raw_ostream &diagnostics) override;
/// \brief Return the file that has to be processed by the resolver
/// to resolve atoms. This iterates over all the files thats part
diff --git a/lld/lib/Driver/CMakeLists.txt b/lld/lib/Driver/CMakeLists.txt
index cfb47076c14..2eb985229c6 100644
--- a/lld/lib/Driver/CMakeLists.txt
+++ b/lld/lib/Driver/CMakeLists.txt
@@ -12,6 +12,7 @@ add_public_tablegen_target(DriverOptionsTableGen)
add_lld_library(lldDriver
CoreDriver.cpp
+ DarwinInputGraph.cpp
DarwinLdDriver.cpp
Driver.cpp
GnuLdDriver.cpp
diff --git a/lld/lib/Driver/DarwinInputGraph.cpp b/lld/lib/Driver/DarwinInputGraph.cpp
new file mode 100644
index 00000000000..2be95310ca6
--- /dev/null
+++ b/lld/lib/Driver/DarwinInputGraph.cpp
@@ -0,0 +1,69 @@
+//===- lib/ReaderWriter/MachO/DarwinInputGraph.cpp ------------------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lld/Driver/DarwinInputGraph.h"
+
+#include "lld/Core/ArchiveLibraryFile.h"
+#include "lld/Core/DefinedAtom.h"
+#include "lld/Core/File.h"
+#include "lld/Core/LLVM.h"
+#include "lld/Core/Reference.h"
+#include "lld/Core/SharedLibraryFile.h"
+
+#include "lld/ReaderWriter/MachOLinkingContext.h"
+
+namespace lld {
+
+/// \brief Parse the input file to lld::File.
+std::error_code MachOFileNode::parse(const LinkingContext &ctx,
+ raw_ostream &diagnostics) {
+ ErrorOr<StringRef> filePath = getPath(ctx);
+ if (std::error_code ec = filePath.getError())
+ return ec;
+
+ if (std::error_code ec = getBuffer(*filePath))
+ return ec;
+
+ if (ctx.logInputFiles())
+ diagnostics << *filePath << "\n";
+
+ std::vector<std::unique_ptr<File>> parsedFiles;
+ if (_isWholeArchive) {
+ std::error_code ec = ctx.registry().parseFile(_buffer, parsedFiles);
+ if (ec)
+ return ec;
+ assert(parsedFiles.size() == 1);
+ std::unique_ptr<File> f(parsedFiles[0].release());
+ if (auto archive =
+ reinterpret_cast<const ArchiveLibraryFile *>(f.get())) {
+ // FIXME: something needs to own archive File
+ //_files.push_back(std::move(archive));
+ return archive->parseAllMembers(_files);
+ } else {
+ // if --whole-archive is around non-archive, just use it as normal.
+ _files.push_back(std::move(f));
+ return std::error_code();
+ }
+ }
+ if (std::error_code ec = ctx.registry().parseFile(_buffer, parsedFiles))
+ return ec;
+ for (std::unique_ptr<File> &pf : parsedFiles) {
+ // If a dylib was parsed, inform LinkingContext about it.
+ if (SharedLibraryFile *shl = dyn_cast<SharedLibraryFile>(pf.get())) {
+ MachOLinkingContext *mctx = (MachOLinkingContext*)(&ctx);
+ mctx->registerDylib(reinterpret_cast<mach_o::MachODylibFile*>(shl));
+ }
+ _files.push_back(std::move(pf));
+ }
+ return std::error_code();
+}
+
+
+
+} // end namesapce lld
OpenPOWER on IntegriCloud