summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core/LinkingContext.cpp
diff options
context:
space:
mode:
authorShankar Easwaran <shankare@codeaurora.org>2013-08-31 05:27:38 +0000
committerShankar Easwaran <shankare@codeaurora.org>2013-08-31 05:27:38 +0000
commitd26c8e346344eec7d178b0cf5fe2fa30813c076e (patch)
treea5ffbb94f8c35f0bb9eeb760d1b75a515307bdab /lld/lib/Core/LinkingContext.cpp
parent2c4f8b7ee87fb6f77688bee1dd00e10ae2707f00 (diff)
downloadbcm5719-llvm-d26c8e346344eec7d178b0cf5fe2fa30813c076e.tar.gz
bcm5719-llvm-d26c8e346344eec7d178b0cf5fe2fa30813c076e.zip
[lld][LinkingContext] Atoms created from command line options should be available in YAML
This adds an API to the LinkingContext for flavors to add Internal files containing atoms that need to appear in the YAML output as well, when -emit-yaml switch is used. Flavors can add more internal files for other options that are needed. llvm-svn: 189718
Diffstat (limited to 'lld/lib/Core/LinkingContext.cpp')
-rw-r--r--lld/lib/Core/LinkingContext.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/lld/lib/Core/LinkingContext.cpp b/lld/lib/Core/LinkingContext.cpp
index 5d628aa7a07..e341a886eac 100644
--- a/lld/lib/Core/LinkingContext.cpp
+++ b/lld/lib/Core/LinkingContext.cpp
@@ -8,7 +8,9 @@
//===----------------------------------------------------------------------===//
#include "lld/Core/LinkingContext.h"
+#include "lld/Core/InputFiles.h"
#include "lld/ReaderWriter/Writer.h"
+#include "lld/ReaderWriter/Simple.h"
#include "llvm/ADT/Triple.h"
@@ -50,6 +52,39 @@ void LinkingContext::addImplicitFiles(InputFiles &inputs) const {
this->writer().addFiles(inputs);
}
+std::unique_ptr<File> LinkingContext::createEntrySymbolFile() {
+ if (entrySymbolName().empty())
+ return nullptr;
+ std::unique_ptr<SimpleFile> entryFile(
+ new SimpleFile(*this, "command line option -entry"));
+ entryFile->addAtom(
+ *(new (_allocator) SimpleUndefinedAtom(*entryFile, entrySymbolName())));
+ return std::move(entryFile);
+}
+
+std::unique_ptr<File> LinkingContext::createUndefinedSymbolFile() {
+ if (_initialUndefinedSymbols.empty())
+ return nullptr;
+ std::unique_ptr<SimpleFile> undefinedSymFile(
+ new SimpleFile(*this, "command line option -u"));
+ for (auto undefSymStr : _initialUndefinedSymbols)
+ undefinedSymFile->addAtom(*(new (_allocator) SimpleUndefinedAtom(
+ *undefinedSymFile, undefSymStr)));
+ return std::move(undefinedSymFile);
+}
+
+std::vector<std::unique_ptr<File> > LinkingContext::createInternalFiles() {
+ std::vector<std::unique_ptr<File> > result;
+ std::unique_ptr<File> internalFile;
+ internalFile = createEntrySymbolFile();
+ if (internalFile)
+ result.push_back(std::move(internalFile));
+ internalFile = createUndefinedSymbolFile();
+ if (internalFile)
+ result.push_back(std::move(internalFile));
+ return result;
+}
+
void LinkingContext::addPasses(PassManager &pm) const {}
} // end namespace lld
OpenPOWER on IntegriCloud