summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/ELFLinkingContext.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/ReaderWriter/ELF/ELFLinkingContext.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/ReaderWriter/ELF/ELFLinkingContext.cpp')
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
index e19a4be573b..7e013705647 100644
--- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
@@ -9,6 +9,7 @@
#include "lld/ReaderWriter/ELFLinkingContext.h"
+#include "File.h"
#include "TargetHandler.h"
#include "Targets.h"
@@ -22,6 +23,17 @@
#include "llvm/Support/Path.h"
namespace lld {
+
+class CommandLineUndefinedAtom : public SimpleUndefinedAtom {
+public:
+ CommandLineUndefinedAtom(const File &f, StringRef name)
+ : SimpleUndefinedAtom(f, name) {}
+
+ virtual CanBeNull canBeNull() const {
+ return CanBeNull::canBeNullAtBuildtime;
+ }
+};
+
ELFLinkingContext::ELFLinkingContext(
llvm::Triple triple, std::unique_ptr<TargetHandlerBase> targetHandler)
: _outputFileType(elf::ET_EXEC), _triple(triple),
@@ -29,8 +41,7 @@ ELFLinkingContext::ELFLinkingContext(
_isStaticExecutable(false), _outputYAML(false), _noInhibitExec(false),
_mergeCommonStrings(false), _runLayoutPass(true),
_useShlibUndefines(false), _dynamicLinkerArg(false),
- _noAllowDynamicLibraries(false),
- _outputMagic(OutputMagic::DEFAULT) {}
+ _noAllowDynamicLibraries(false), _outputMagic(OutputMagic::DEFAULT) {}
bool ELFLinkingContext::is64Bits() const { return getTriple().isArch64Bit(); }
@@ -59,11 +70,13 @@ uint16_t ELFLinkingContext::getOutputMachine() const {
}
}
-bool ELFLinkingContext::validateImpl(raw_ostream &diagnostics) {
- if (_outputFileType == elf::ET_EXEC && _entrySymbolName.empty()) {
- _entrySymbolName = "_start";
- }
+StringRef ELFLinkingContext::entrySymbolName() const {
+ if (_outputFileType == elf::ET_EXEC && _entrySymbolName.empty())
+ return "_start";
+ return _entrySymbolName;
+}
+bool ELFLinkingContext::validateImpl(raw_ostream &diagnostics) {
_elfReader = createReaderELF(*this);
_linkerScriptReader.reset(new ReaderLinkerScript(*this));
_writer = _outputYAML ? createWriterYAML(*this) : createWriterELF(*this);
@@ -157,4 +170,15 @@ StringRef ELFLinkingContext::searchLibrary(
return libName;
}
+std::unique_ptr<File> ELFLinkingContext::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) CommandLineUndefinedAtom(
+ *undefinedSymFile, undefSymStr)));
+ return std::move(undefinedSymFile);
+}
+
} // end namespace lld
OpenPOWER on IntegriCloud