diff options
author | Nick Kledzik <kledzik@apple.com> | 2013-12-19 21:58:00 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2013-12-19 21:58:00 +0000 |
commit | e555277780fc1bfd3c1fccf6b6ab905cc89c993a (patch) | |
tree | 88b653613f4cbd836edb0d36dfb28187e917a729 /lld/include/lld/ReaderWriter/PECOFFLinkingContext.h | |
parent | 61a57138c281ecc7ed40e9c9068b3fb5ee8c4b11 (diff) | |
download | bcm5719-llvm-e555277780fc1bfd3c1fccf6b6ab905cc89c993a.tar.gz bcm5719-llvm-e555277780fc1bfd3c1fccf6b6ab905cc89c993a.zip |
[lld] Introduce registry and Reference kind tuple
The main changes are in:
include/lld/Core/Reference.h
include/lld/ReaderWriter/Reader.h
Everything else is details to support the main change.
1) Registration based Readers
Previously, lld had a tangled interdependency with all the Readers. It would
have been impossible to make a streamlined linker (say for a JIT) which
just supported one file format and one architecture (no yaml, no archives, etc).
The old model also required a LinkingContext to read an object file, which
would have made .o inspection tools awkward.
The new model is that there is a global Registry object. You programmatically
register the Readers you want with the registry object. Whenever you need to
read/parse a file, you ask the registry to do it, and the registry tries each
registered reader.
For ease of use with the existing lld code base, there is one Registry
object inside the LinkingContext object.
2) Changing kind value to be a tuple
Beside Readers, the registry also keeps track of the mapping for Reference
Kind values to and from strings. Along with that, this patch also fixes
an ambiguity with the previous Reference::Kind values. The problem was that
we wanted to reuse existing relocation type values as Reference::Kind values.
But then how can the YAML write know how to convert a value to a string? The
fix is to change the 32-bit Reference::Kind into a tuple with an 8-bit namespace
(e.g. ELF, COFFF, etc), an 8-bit architecture (e.g. x86_64, PowerPC, etc), and
a 16-bit value. This tuple system allows conversion to and from strings with
no ambiguities.
llvm-svn: 197727
Diffstat (limited to 'lld/include/lld/ReaderWriter/PECOFFLinkingContext.h')
-rw-r--r-- | lld/include/lld/ReaderWriter/PECOFFLinkingContext.h | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h index 6db00a4afeb..3eadde11f4e 100644 --- a/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h +++ b/lld/include/lld/ReaderWriter/PECOFFLinkingContext.h @@ -73,8 +73,6 @@ public: IMAGE_DLL }; - virtual Reader &getDefaultReader() const { return *_reader; } - virtual Writer &writer() const; virtual bool validateImpl(raw_ostream &diagnostics); @@ -198,6 +196,9 @@ public: StringRef from, StringRef to); StringRef getAlternateName(StringRef def) const; + const std::map<std::string, std::string> &alternateNames() { + return _alternateNames; + } void setAlternateName(StringRef def, StringRef weak); void addNoDefaultLib(StringRef path) { _noDefaultLibs.insert(path); } @@ -208,9 +209,6 @@ public: void setNoDefaultLibAll(bool val) { _noDefaultLibAll = val; } bool getNoDefaultLibAll() const { return _noDefaultLibAll; } - virtual ErrorOr<Reference::Kind> relocKindFromString(StringRef str) const; - virtual ErrorOr<std::string> stringFromRelocKind(Reference::Kind kind) const; - void setSectionSetMask(StringRef sectionName, uint32_t flags); void setSectionClearMask(StringRef sectionName, uint32_t flags); uint32_t getSectionAttributes(StringRef sectionName, uint32_t flags) const; @@ -284,7 +282,6 @@ private: std::set<std::string> _noDefaultLibs; std::vector<StringRef> _inputSearchPaths; - std::unique_ptr<Reader> _reader; std::unique_ptr<Writer> _writer; // A map for weak aliases. |