<p dir="ltr">Thank you so much! </p>
<div class="gmail_quote">On Apr 10, 2015 5:28 PM, "Rui Ueyama" <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Fri Apr 10 16:23:51 2015<br>
New Revision: 234641<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=234641&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=234641&view=rev</a><br>
Log:<br>
Remove the Native file format.<br>
<br>
The Native file format was designed to be the fastest on-memory or<br>
on-disk file format for object files. The problem is that no one<br>
is working on that. No LLVM tools can produce object files in<br>
the Native, thus the feature of supporting the format is useless<br>
in the linker.<br>
<br>
This patch removes the Native file support. We can add it back<br>
if we really want it in future.<br>
<br>
Removed:<br>
    lld/trunk/lib/Core/TODO.txt<br>
    lld/trunk/lib/ReaderWriter/Native/CMakeLists.txt<br>
    lld/trunk/lib/ReaderWriter/Native/NativeFileFormat.h<br>
    lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp<br>
    lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp<br>
Modified:<br>
    lld/trunk/docs/Readers.rst<br>
    lld/trunk/docs/design.rst<br>
    lld/trunk/docs/index.rst<br>
    lld/trunk/include/lld/Core/Error.h<br>
    lld/trunk/include/lld/Core/LinkingContext.h<br>
    lld/trunk/include/lld/Core/Reader.h<br>
    lld/trunk/include/lld/Core/TODO.txt<br>
    lld/trunk/include/lld/Core/Writer.h<br>
    lld/trunk/lib/Core/Error.cpp<br>
    lld/trunk/lib/Driver/CoreDriver.cpp<br>
    lld/trunk/lib/Driver/DarwinLdDriver.cpp<br>
    lld/trunk/lib/Driver/GnuLdDriver.cpp<br>
    lld/trunk/lib/Driver/GnuLdOptions.td<br>
    lld/trunk/lib/Driver/WinLinkDriver.cpp<br>
    lld/trunk/lib/ReaderWriter/CMakeLists.txt<br>
    lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp<br>
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp<br>
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp<br>
<br>
Modified: lld/trunk/docs/Readers.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/docs/Readers.rst?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/docs/Readers.rst?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/docs/Readers.rst (original)<br>
+++ lld/trunk/docs/Readers.rst Fri Apr 10 16:23:51 2015<br>
@@ -52,10 +52,9 @@ Where to start<br>
 --------------<br>
<br>
 The lld project already has a skeleton of source code for Readers for<br>
-``ELF``, ``PECOFF``, ``MachO``, and lld's native Atom graph format<br>
-(both binary ``Native`` and ``YAML`` representations).  If your file format<br>
-is a variant of one of those, you should modify the existing Reader to<br>
-support your variant. This is done by customizing the Options<br>
+``ELF``, ``PECOFF``, ``MachO``, and lld's native ``YAML`` graph format.<br>
+If your file format is a variant of one of those, you should modify the<br>
+existing Reader to support your variant. This is done by customizing the Options<br>
 class for the Reader and making appropriate changes to the ``.cpp`` file to<br>
 interpret those options and act accordingly.<br>
<br>
<br>
Modified: lld/trunk/docs/design.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/docs/design.rst?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/docs/design.rst?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/docs/design.rst (original)<br>
+++ lld/trunk/docs/design.rst Fri Apr 10 16:23:51 2015<br>
@@ -300,60 +300,13 @@ and the ivars programmatically set.<br>
 lld::File representations<br>
 -------------------------<br>
<br>
-Just as LLVM has three representations of its IR model, lld has three<br>
+Just as LLVM has three representations of its IR model, lld has two<br>
 representations of its File/Atom/Reference model:<br>
<br>
  * In memory, abstract C++ classes (lld::Atom, lld::Reference, and lld::File).<br>
<br>
  * textual (in YAML)<br>
<br>
- * binary format ("native")<br>
-<br>
-Binary File Format<br>
-~~~~~~~~~~~~~~~~~~<br>
-<br>
-In theory, lld::File objects could be written to disk in an existing Object File<br>
-format standard (e.g. ELF).  Instead we choose to define a new binary file<br>
-format. There are two main reasons for this: fidelity and performance.  In order<br>
-for lld to work as a linker on all platforms, its internal model must be rich<br>
-enough to model all CPU and OS linking features.  But if we choose an existing<br>
-Object File format as the lld binary format, that means an on going need to<br>
-retrofit each platform specific feature needed from alternate platforms into the<br>
-existing Object File format.  Having our own "native" binary format side steps<br>
-that issue.  We still need to be able to binary encode all the features, but<br>
-once the in-memory model can represent the feature, it is straight forward to<br>
-binary encode it.<br>
-<br>
-The reason to use a binary file format at all, instead of a textual file format,<br>
-is speed.  You want the binary format to be as fast as possible to read into the<br>
-in-memory model. Given that we control the in-memory model and the binary<br>
-format, the obvious way to make reading super fast it to make the file format be<br>
-basically just an array of atoms.  The reader just mmaps in the file and looks<br>
-at the header to see how many atoms there are and instantiate that many atom<br>
-objects with the atom attribute information coming from that array.  The trick<br>
-is designing this in a way that can be extended as the Atom mode evolves and new<br>
-attributes are added.<br>
-<br>
-The native object file format starts with a header that lists how many "chunks"<br>
-are in the file.  A chunk is an array of "ivar data".  The native file reader<br>
-instantiates an array of Atom objects (with one large malloc call).  Each atom<br>
-contains just a pointer to its vtable and a pointer to its ivar data.  All<br>
-methods on lld::Atom are virtual, so all the method implementations return<br>
-values based on the ivar data to which it has a pointer.  If a new linking<br>
-features is added which requires a change to the lld::Atom model, a new native<br>
-reader class (e.g. version 2) is defined which knows how to read the new feature<br>
-information from the new ivar data.  The old reader class (e.g. version 1) is<br>
-updated to do its best to model (the lack of the new feature) given the old ivar<br>
-data in existing native object files.<br>
-<br>
-With this model for the native file format, files can be read and turned<br>
-into the in-memory graph of lld::Atoms with just a few memory allocations.<br>
-And the format can easily adapt over time to new features.<br>
-<br>
-The binary file format follows the ReaderWriter patterns used in lld. The lld<br>
-library comes with the classes: ReaderNative and WriterNative.  So, switching<br>
-between file formats is as easy as switching which Reader subclass is used.<br>
-<br>
<br>
 Textual representations in YAML<br>
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
<br>
Modified: lld/trunk/docs/index.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/docs/index.rst?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/docs/index.rst?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/docs/index.rst (original)<br>
+++ lld/trunk/docs/index.rst Fri Apr 10 16:23:51 2015<br>
@@ -26,8 +26,6 @@ lld is a new set of modular code for cre<br>
<br>
   * Extensive unit tests<br>
   * Internal linker model can be dumped/read to textual format<br>
-  * Internal linker model can be dumped/read to a new native format<br>
-  * Native format designed to be fast to read and write<br>
   * Additional linking features can be plugged in as "passes"<br>
   * OS specific and CPU specific code factored out<br>
<br>
<br>
Modified: lld/trunk/include/lld/Core/Error.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Error.h?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Error.h?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/Core/Error.h (original)<br>
+++ lld/trunk/include/lld/Core/Error.h Fri Apr 10 16:23:51 2015<br>
@@ -19,22 +19,6 @@<br>
<br>
 namespace lld {<br>
<br>
-const std::error_category &native_reader_category();<br>
-<br>
-enum class NativeReaderError {<br>
-  success = 0,<br>
-  unknown_file_format,<br>
-  file_too_short,<br>
-  file_malformed,<br>
-  unknown_chunk_type,<br>
-  memory_error,<br>
-  conflicting_target_machine,<br>
-};<br>
-<br>
-inline std::error_code make_error_code(NativeReaderError e) {<br>
-  return std::error_code(static_cast<int>(e), native_reader_category());<br>
-}<br>
-<br>
 const std::error_category &YamlReaderCategory();<br>
<br>
 enum class YamlReaderError {<br>
@@ -72,8 +56,6 @@ std::error_code make_dynamic_error_code(<br>
 } // end namespace lld<br>
<br>
 namespace std {<br>
-template <><br>
-struct is_error_code_enum<lld::NativeReaderError> : std::true_type {};<br>
 template <> struct is_error_code_enum<lld::YamlReaderError> : std::true_type {};<br>
 template <><br>
 struct is_error_code_enum<lld::LinkerScriptReaderError> : std::true_type {};<br>
<br>
Modified: lld/trunk/include/lld/Core/LinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/Core/LinkingContext.h (original)<br>
+++ lld/trunk/include/lld/Core/LinkingContext.h Fri Apr 10 16:23:51 2015<br>
@@ -41,7 +41,6 @@ public:<br>
   enum class OutputFileType : uint8_t {<br>
     Default, // The default output type for this target<br>
     YAML,    // The output type is set to YAML<br>
-    Native   // The output file format is Native (Atoms)<br>
   };<br>
<br>
   virtual ~LinkingContext();<br>
@@ -273,13 +272,11 @@ public:<br>
   /// Set the various output file types that the linker would<br>
   /// create<br>
   bool setOutputFileType(StringRef outputFileType) {<br>
-    if (outputFileType.equals_lower("yaml"))<br>
+    if (outputFileType.equals_lower("yaml")) {<br>
       _outputFileType = OutputFileType::YAML;<br>
-    else if (outputFileType.equals_lower("native"))<br>
-      _outputFileType = OutputFileType::YAML;<br>
-    else<br>
-      return false;<br>
-    return true;<br>
+      return true;<br>
+    }<br>
+    return false;<br>
   }<br>
<br>
   /// Returns the output file type that that the linker needs to create.<br>
<br>
Modified: lld/trunk/include/lld/Core/Reader.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Reader.h?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Reader.h?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/Core/Reader.h (original)<br>
+++ lld/trunk/include/lld/Core/Reader.h Fri Apr 10 16:23:51 2015<br>
@@ -36,7 +36,7 @@ class MachOLinkingContext;<br>
 /// \brief An abstract class for reading object files, library files, and<br>
 /// executable files.<br>
 ///<br>
-/// Each file format (e.g. ELF, mach-o, PECOFF, native, etc) have a concrete<br>
+/// Each file format (e.g. ELF, mach-o, PECOFF, etc) have a concrete<br>
 /// subclass of Reader.<br>
 class Reader {<br>
 public:<br>
@@ -115,7 +115,6 @@ public:<br>
   // as parameters to the addSupport*() method.<br>
   void addSupportArchives(bool logLoading);<br>
   void addSupportYamlFiles();<br>
-  void addSupportNativeObjects();<br>
   void addSupportCOFFObjects(PECOFFLinkingContext &);<br>
   void addSupportCOFFImportLibraries(PECOFFLinkingContext &);<br>
   void addSupportMachOObjects(MachOLinkingContext &);<br>
<br>
Modified: lld/trunk/include/lld/Core/TODO.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/TODO.txt?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/TODO.txt?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/Core/TODO.txt (original)<br>
+++ lld/trunk/include/lld/Core/TODO.txt Fri Apr 10 16:23:51 2015<br>
@@ -1,7 +1,7 @@<br>
 include/lld/Core<br>
 ~~~~~~~~~~~~~~~~<br>
<br>
-* The native/yaml reader/writer interfaces should be changed to return<br>
+* The yaml reader/writer interfaces should be changed to return<br>
   an explanatory string if there is an error.  The existing error_code<br>
   abstraction only works for returning low level OS errors.  It does not<br>
   work for describing formatting issues.<br>
<br>
Modified: lld/trunk/include/lld/Core/Writer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Writer.h?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Writer.h?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/Core/Writer.h (original)<br>
+++ lld/trunk/include/lld/Core/Writer.h Fri Apr 10 16:23:51 2015<br>
@@ -23,7 +23,7 @@ class PECOFFLinkingContext;<br>
<br>
 /// \brief The Writer is an abstract class for writing object files, shared<br>
 /// library files, and executable files.  Each file format (e.g. ELF, mach-o,<br>
-/// PECOFF, native, etc) have a concrete subclass of Writer.<br>
+/// PECOFF, etc) have a concrete subclass of Writer.<br>
 class Writer {<br>
 public:<br>
   virtual ~Writer();<br>
@@ -44,7 +44,6 @@ protected:<br>
 std::unique_ptr<Writer> createWriterELF(const ELFLinkingContext &);<br>
 std::unique_ptr<Writer> createWriterMachO(const MachOLinkingContext &);<br>
 std::unique_ptr<Writer> createWriterPECOFF(const PECOFFLinkingContext &);<br>
-std::unique_ptr<Writer> createWriterNative();<br>
 std::unique_ptr<Writer> createWriterYAML(const LinkingContext &);<br>
 } // end namespace lld<br>
<br>
<br>
Modified: lld/trunk/lib/Core/Error.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Error.cpp?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Error.cpp?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Core/Error.cpp (original)<br>
+++ lld/trunk/lib/Core/Error.cpp Fri Apr 10 16:23:51 2015<br>
@@ -16,39 +16,6 @@<br>
<br>
 using namespace lld;<br>
<br>
-class _NativeReaderErrorCategory : public std::error_category {<br>
-public:<br>
-  const char* name() const LLVM_NOEXCEPT override {<br>
-    return "lld.native.reader";<br>
-  }<br>
-<br>
-  std::string message(int ev) const override {<br>
-    switch (static_cast<NativeReaderError>(ev)) {<br>
-    case NativeReaderError::success:<br>
-      return "Success";<br>
-    case NativeReaderError::unknown_file_format:<br>
-      return "Unknown file format";<br>
-    case NativeReaderError::file_too_short:<br>
-      return "file truncated";<br>
-    case NativeReaderError::file_malformed:<br>
-      return "file malformed";<br>
-    case NativeReaderError::memory_error:<br>
-      return "out of memory";<br>
-    case NativeReaderError::unknown_chunk_type:<br>
-      return "unknown chunk type";<br>
-    case NativeReaderError::conflicting_target_machine:<br>
-      return "conflicting target machine";<br>
-    }<br>
-    llvm_unreachable("An enumerator of NativeReaderError does not have a "<br>
-                     "message defined.");<br>
-  }<br>
-};<br>
-<br>
-const std::error_category &lld::native_reader_category() {<br>
-  static _NativeReaderErrorCategory o;<br>
-  return o;<br>
-}<br>
-<br>
 class _YamlReaderErrorCategory : public std::error_category {<br>
 public:<br>
   const char* name() const LLVM_NOEXCEPT override {<br>
<br>
Removed: lld/trunk/lib/Core/TODO.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/TODO.txt?rev=234640&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/TODO.txt?rev=234640&view=auto</a><br>
==============================================================================<br>
--- lld/trunk/lib/Core/TODO.txt (original)<br>
+++ lld/trunk/lib/Core/TODO.txt (removed)<br>
@@ -1,18 +0,0 @@<br>
-lib/Core<br>
-~~~~~~~~<br>
-<br>
-* Add endianness support to the native reader and writer.<br>
-<br>
-* The NativeReader has lots of similar code for converting arrays of ivar<br>
-  data in mapped memory into arrays of objects.  The commonality can be<br>
-  factored out, maybe templatized.<br>
-<br>
-* The NativeFileFormat.h is old school C structs and constants.  We scope<br>
-  things better by defining constants used with a struct inside the struct<br>
-  declaration.<br>
-<br>
-* The native reader and writer currently just blast in memory enumeration<br>
-  values (e.g. DefinedAtom::Scope) into a byte in the disk format.  To support<br>
-  future changes to the enumerations, there should be a translation layer<br>
-  to map disk values to in-memory values.<br>
-<br>
<br>
Modified: lld/trunk/lib/Driver/CoreDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CoreDriver.cpp?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CoreDriver.cpp?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/CoreDriver.cpp (original)<br>
+++ lld/trunk/lib/Driver/CoreDriver.cpp Fri Apr 10 16:23:51 2015<br>
@@ -77,7 +77,6 @@ bool CoreDriver::link(int argc, const ch<br>
   CoreLinkingContext ctx;<br>
<br>
   // Register possible input file parsers.<br>
-  ctx.registry().addSupportNativeObjects();<br>
   ctx.registry().addSupportYamlFiles();<br>
   ctx.registry().addKindTable(Reference::KindNamespace::testing,<br>
                               Reference::KindArch::all, coreKindStrings);<br>
<br>
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)<br>
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Fri Apr 10 16:23:51 2015<br>
@@ -544,7 +544,6 @@ bool DarwinLdDriver::parse(int argc, con<br>
   if (!ctx.doNothing()) {<br>
     ctx.registry().addSupportMachOObjects(ctx);<br>
     ctx.registry().addSupportArchives(ctx.logInputFiles());<br>
-    ctx.registry().addSupportNativeObjects();<br>
     ctx.registry().addSupportYamlFiles();<br>
   }<br>
<br>
<br>
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)<br>
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Fri Apr 10 16:23:51 2015<br>
@@ -645,7 +645,6 @@ bool GnuLdDriver::parse(int argc, const<br>
   ctx->registry().addSupportELFObjects(*ctx);<br>
   ctx->registry().addSupportArchives(ctx->logInputFiles());<br>
   ctx->registry().addSupportYamlFiles();<br>
-  ctx->registry().addSupportNativeObjects();<br>
   if (ctx->allowLinkWithDynamicLibraries())<br>
     ctx->registry().addSupportELFDynamicSharedObjects(*ctx);<br>
<br>
@@ -752,9 +751,6 @@ bool GnuLdDriver::parse(int argc, const<br>
     case LinkingContext::OutputFileType::YAML:<br>
       ctx->setOutputPath("-");<br>
       break;<br>
-    case LinkingContext::OutputFileType::Native:<br>
-      ctx->setOutputPath("a.native");<br>
-      break;<br>
     default:<br>
       ctx->setOutputPath("a.out");<br>
       break;<br>
<br>
Modified: lld/trunk/lib/Driver/GnuLdOptions.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdOptions.td?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdOptions.td?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/GnuLdOptions.td (original)<br>
+++ lld/trunk/lib/Driver/GnuLdOptions.td Fri Apr 10 16:23:51 2015<br>
@@ -313,7 +313,7 @@ def stats : Flag<["--"], "stats">,<br>
 def grp_extns : OptionGroup<"opts">,<br>
      HelpText<"Extensions">;<br>
 def output_filetype: Separate<["--"], "output-filetype">,<br>
-      HelpText<"Specify what type of output file that lld creates, YAML/Native">,<br>
+      HelpText<"Specify yaml to create an output in YAML format">,<br>
       Group<grp_extns>;<br>
 def alias_output_filetype: Joined<["--"], "output-filetype=">,<br>
       Alias<output_filetype>;<br>
<br>
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)<br>
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Fri Apr 10 16:23:51 2015<br>
@@ -862,7 +862,6 @@ bool WinLinkDriver::linkPECOFF(int argc,<br>
   ctx.registry().addSupportCOFFObjects(ctx);<br>
   ctx.registry().addSupportCOFFImportLibraries(ctx);<br>
   ctx.registry().addSupportArchives(ctx.logInputFiles());<br>
-  ctx.registry().addSupportNativeObjects();<br>
   ctx.registry().addSupportYamlFiles();<br>
<br>
   std::vector<const char *> newargv = processLinkEnv(ctx, argc, argv);<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CMakeLists.txt?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CMakeLists.txt?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/CMakeLists.txt (original)<br>
+++ lld/trunk/lib/ReaderWriter/CMakeLists.txt Fri Apr 10 16:23:51 2015<br>
@@ -1,6 +1,5 @@<br>
 add_subdirectory(ELF)<br>
 add_subdirectory(MachO)<br>
-add_subdirectory(Native)<br>
 add_subdirectory(PECOFF)<br>
 add_subdirectory(YAML)<br>
<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Fri Apr 10 16:23:51 2015<br>
@@ -75,9 +75,6 @@ bool ELFLinkingContext::validateImpl(raw<br>
   case LinkingContext::OutputFileType::YAML:<br>
     _writer = createWriterYAML(*this);<br>
     break;<br>
-  case LinkingContext::OutputFileType::Native:<br>
-    llvm_unreachable("Unimplemented");<br>
-    break;<br>
   default:<br>
     _writer = createWriterELF(*this);<br>
     break;<br>
<br>
Removed: lld/trunk/lib/ReaderWriter/Native/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/CMakeLists.txt?rev=234640&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/CMakeLists.txt?rev=234640&view=auto</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/Native/CMakeLists.txt (original)<br>
+++ lld/trunk/lib/ReaderWriter/Native/CMakeLists.txt (removed)<br>
@@ -1,7 +0,0 @@<br>
-add_llvm_library(lldNative<br>
-  ReaderNative.cpp<br>
-  WriterNative.cpp<br>
-  LINK_LIBS<br>
-    lldCore<br>
-    LLVMSupport<br>
-  )<br>
<br>
Removed: lld/trunk/lib/ReaderWriter/Native/NativeFileFormat.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/NativeFileFormat.h?rev=234640&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/NativeFileFormat.h?rev=234640&view=auto</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/Native/NativeFileFormat.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/Native/NativeFileFormat.h (removed)<br>
@@ -1,258 +0,0 @@<br>
-//===- lib/ReaderWriter/Native/NativeFileFormat.h -------------------------===//<br>
-//<br>
-//                             The LLVM Linker<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#ifndef LLD_READER_WRITER_NATIVE_NATIVE_FILE_FORMAT_H<br>
-#define LLD_READER_WRITER_NATIVE_NATIVE_FILE_FORMAT_H<br>
-<br>
-#include "llvm/Support/DataTypes.h"<br>
-#include <cstdint><br>
-<br>
-namespace lld {<br>
-<br>
-//<br>
-// Overview:<br>
-//<br>
-// The number one design goal of this file format is enable the linker to<br>
-// read object files into in-memory Atom objects extremely quickly.<br>
-// The second design goal is to enable future modifications to the<br>
-// Atom attribute model.<br>
-//<br>
-// The llvm native object file format is not like traditional object file<br>
-// formats (e.g. ELF, COFF, mach-o).  There is no symbol table and no<br>
-// sections.  Instead the file is essentially an array of archived Atoms.<br>
-// It is *not* serialized Atoms which would require deserialization into<br>
-// in memory objects.  Instead it is an array of read-only info about each<br>
-// Atom.  The NativeReader bulk creates in-memory Atoms which just have<br>
-// an ivar which points to the read-only info for that Atom. No additional<br>
-// processing is done to construct the in-memory Atoms. All Atom attribute<br>
-// getter methods are virtual calls which dig up the info they need from the<br>
-// ivar data.<br>
-//<br>
-// To support the gradual evolution of Atom attributes, the Atom read-only<br>
-// data is versioned. The NativeReader chooses which in-memory Atom class<br>
-// to use based on the version. What this means is that if new attributes<br>
-// are added (or changed) in the Atom model, a new native atom class and<br>
-// read-only atom info struct needs to be defined.  Then, all the existing<br>
-// native reader atom classes need to be modified to do their best effort<br>
-// to map their old style read-only data to the new Atom model.  At some point<br>
-// some classes to support old versions may be dropped.<br>
-//<br>
-//<br>
-// Details:<br>
-//<br>
-// The native object file format consists of a header that specifies the<br>
-// endianness of the file and the architecture along with a list of "chunks"<br>
-// in the file.  A Chunk is simply a tagged range of the file.  There is<br>
-// one chunk for the array of atom infos.  There is another chunk for the<br>
-// string pool, and another for the content pool.<br>
-//<br>
-// It turns out there most atoms have very similar sets of attributes, only<br>
-// the name and content attribute vary. To exploit this fact to reduce the file<br>
-// size, the atom read-only info contains just the name and content info plus<br>
-// a reference to which attribute set it uses.  The attribute sets are stored<br>
-// in another chunk.<br>
-//<br>
-<br>
-<br>
-//<br>
-// An entry in the NativeFileHeader that describes one chunk of the file.<br>
-//<br>
-struct NativeChunk {<br>
-  uint32_t    signature;<br>
-  uint32_t    fileOffset;<br>
-  uint32_t    fileSize;<br>
-  uint32_t    elementCount;<br>
-};<br>
-<br>
-<br>
-//<br>
-// The header in a native object file<br>
-//<br>
-struct NativeFileHeader {<br>
-  uint8_t     magic[16];<br>
-  uint32_t    endian;<br>
-  uint32_t    architecture;<br>
-  uint32_t    fileSize;<br>
-  uint32_t    chunkCount;<br>
-  // NativeChunk chunks[]<br>
-};<br>
-<br>
-//<br>
-// Possible values for NativeChunk.signature field<br>
-//<br>
-enum NativeChunkSignatures {<br>
-  NCS_DefinedAtomsV1 = 1,<br>
-  NCS_AttributesArrayV1 = 2,<br>
-  NCS_AbsoluteAttributesV1 = 12,<br>
-  NCS_UndefinedAtomsV1 = 3,<br>
-  NCS_SharedLibraryAtomsV1 = 4,<br>
-  NCS_AbsoluteAtomsV1 = 5,<br>
-  NCS_Strings = 6,<br>
-  NCS_ReferencesArrayV1 = 7,<br>
-  NCS_ReferencesArrayV2 = 8,<br>
-  NCS_TargetsTable = 9,<br>
-  NCS_AddendsTable = 10,<br>
-  NCS_Content = 11,<br>
-};<br>
-<br>
-//<br>
-// The 16-bytes at the start of a native object file<br>
-//<br>
-#define NATIVE_FILE_HEADER_MAGIC "llvm nat obj v1 "<br>
-<br>
-//<br>
-// Possible values for the NativeFileHeader.endian field<br>
-//<br>
-enum {<br>
-  NFH_BigEndian     = 0x42696745,<br>
-  NFH_LittleEndian  = 0x4574696c<br>
-};<br>
-<br>
-<br>
-//<br>
-// Possible values for the NativeFileHeader.architecture field<br>
-//<br>
-enum {<br>
-  NFA_x86     = 1,<br>
-  NFA_x86_64  = 2,<br>
-  NFA_armv6   = 3,<br>
-  NFA_armv7   = 4,<br>
-};<br>
-<br>
-<br>
-//<br>
-// The NCS_DefinedAtomsV1 chunk contains an array of these structs<br>
-//<br>
-struct NativeDefinedAtomIvarsV1 {<br>
-  uint32_t  nameOffset;<br>
-  uint32_t  attributesOffset;<br>
-  uint32_t  referencesStartIndex;<br>
-  uint32_t  referencesCount;<br>
-  uint32_t  contentOffset;<br>
-  uint32_t  contentSize;<br>
-  uint64_t  sectionSize;<br>
-};<br>
-<br>
-<br>
-//<br>
-// The NCS_AttributesArrayV1 chunk contains an array of these structs<br>
-//<br>
-struct NativeAtomAttributesV1 {<br>
-  uint32_t  sectionNameOffset;<br>
-  uint16_t  align;<br>
-  uint16_t  alignModulus;<br>
-  uint8_t   scope;<br>
-  uint8_t   interposable;<br>
-  uint8_t   merge;<br>
-  uint8_t   contentType;<br>
-  uint8_t   sectionChoice;<br>
-  uint8_t   deadStrip;<br>
-  uint8_t   dynamicExport;<br>
-  uint8_t   permissions;<br>
-  uint8_t   alias;<br>
-  uint8_t   codeModel;<br>
-};<br>
-<br>
-<br>
-<br>
-//<br>
-// The NCS_UndefinedAtomsV1 chunk contains an array of these structs<br>
-//<br>
-struct NativeUndefinedAtomIvarsV1 {<br>
-  uint32_t  nameOffset;<br>
-  uint32_t  flags;<br>
-  uint32_t  fallbackNameOffset;<br>
-};<br>
-<br>
-<br>
-//<br>
-// The NCS_SharedLibraryAtomsV1 chunk contains an array of these structs<br>
-//<br>
-struct NativeSharedLibraryAtomIvarsV1 {<br>
-  uint64_t  size;<br>
-  uint32_t  nameOffset;<br>
-  uint32_t  loadNameOffset;<br>
-  uint32_t  type;<br>
-  uint32_t  flags;<br>
-};<br>
-<br>
-<br>
-<br>
-//<br>
-// The NCS_AbsoluteAtomsV1 chunk contains an array of these structs<br>
-//<br>
-struct NativeAbsoluteAtomIvarsV1 {<br>
-  uint32_t  nameOffset;<br>
-  uint32_t  attributesOffset;<br>
-  uint32_t  reserved;<br>
-  uint64_t  value;<br>
-};<br>
-<br>
-<br>
-<br>
-//<br>
-// The NCS_ReferencesArrayV1 chunk contains an array of these structs<br>
-//<br>
-struct NativeReferenceIvarsV1 {<br>
-  enum {<br>
-    noTarget = UINT16_MAX<br>
-  };<br>
-  uint32_t  offsetInAtom;<br>
-  uint16_t  kindValue;<br>
-  uint8_t   kindNamespace;<br>
-  uint8_t   kindArch;<br>
-  uint16_t  targetIndex;<br>
-  uint16_t  addendIndex;<br>
-};<br>
-<br>
-<br>
-//<br>
-// The NCS_ReferencesArrayV2 chunk contains an array of these structs<br>
-//<br>
-struct NativeReferenceIvarsV2 {<br>
-  enum : unsigned {<br>
-    noTarget = UINT32_MAX<br>
-  };<br>
-  uint64_t  offsetInAtom;<br>
-  int64_t   addend;<br>
-  uint16_t  kindValue;<br>
-  uint8_t   kindNamespace;<br>
-  uint8_t   kindArch;<br>
-  uint32_t  targetIndex;<br>
-  uint32_t  tag;<br>
-};<br>
-<br>
-<br>
-//<br>
-// The NCS_TargetsTable chunk contains an array of uint32_t entries.<br>
-// The C++ class Reference has a target() method that returns a<br>
-// pointer to another Atom.  We can't have pointers in object files,<br>
-// so instead  NativeReferenceIvarsV1 contains an index to the target.<br>
-// The index is into this NCS_TargetsTable of uint32_t entries.<br>
-// The values in this table are the index of the (target) atom in this file.<br>
-// For DefinedAtoms the value is from 0 to NCS_DefinedAtomsV1.elementCount.<br>
-// For UndefinedAtoms the value is from NCS_DefinedAtomsV1.elementCount to<br>
-// NCS_DefinedAtomsV1.elementCount+NCS_UndefinedAtomsV1.elementCount.<br>
-//<br>
-<br>
-<br>
-//<br>
-// The NCS_AddendsTable chunk contains an array of int64_t entries.<br>
-// If we allocated space for addends directly in NativeReferenceIvarsV1<br>
-// it would double the size of that struct.  But since addends are rare,<br>
-// we instead just keep a pool of addends and have NativeReferenceIvarsV1<br>
-// (if it needs an addend) just store the index (into the pool) of the<br>
-// addend it needs.<br>
-//<br>
-<br>
-<br>
-<br>
-} // namespace lld<br>
-<br>
-#endif // LLD_READER_WRITER_NATIVE_NATIVE_FILE_FORMAT_H<br>
<br>
Removed: lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp?rev=234640&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp?rev=234640&view=auto</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp (removed)<br>
@@ -1,881 +0,0 @@<br>
-//===- lib/ReaderWriter/Native/ReaderNative.cpp ---------------------------===//<br>
-//<br>
-//                             The LLVM Linker<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#include "NativeFileFormat.h"<br>
-#include "lld/Core/Atom.h"<br>
-#include "lld/Core/Error.h"<br>
-#include "lld/Core/File.h"<br>
-#include "lld/Core/Reader.h"<br>
-#include "lld/Core/Simple.h"<br>
-#include "llvm/ADT/ArrayRef.h"<br>
-#include "llvm/ADT/StringRef.h"<br>
-#include "llvm/Support/Debug.h"<br>
-#include "llvm/Support/ErrorHandling.h"<br>
-#include "llvm/Support/Format.h"<br>
-#include "llvm/Support/MemoryBuffer.h"<br>
-#include "llvm/Support/raw_ostream.h"<br>
-#include <memory><br>
-#include <vector><br>
-<br>
-namespace lld {<br>
-namespace native {<br>
-<br>
-// forward reference<br>
-class File;<br>
-<br>
-//<br>
-// An object of this class is instantied for each NativeDefinedAtomIvarsV1<br>
-// struct in the NCS_DefinedAtomsV1 chunk.<br>
-//<br>
-class NativeDefinedAtomV1 : public DefinedAtom {<br>
-public:<br>
-      NativeDefinedAtomV1(const File& f,<br>
-                          const NativeDefinedAtomIvarsV1* ivarData)<br>
-        : _file(&f), _ivarData(ivarData) { }<br>
-<br>
-  const lld::File& file() const override;<br>
-<br>
-  uint64_t ordinal() const override;<br>
-<br>
-  StringRef name() const override;<br>
-<br>
-  uint64_t size() const override { return _ivarData->contentSize; }<br>
-<br>
-  uint64_t sectionSize() const override { return _ivarData->sectionSize; }<br>
-<br>
-  DefinedAtom::Scope scope() const override {<br>
-    return (DefinedAtom::Scope)(attributes().scope);<br>
-  }<br>
-<br>
-  DefinedAtom::Interposable interposable() const override {<br>
-    return (DefinedAtom::Interposable)(attributes().interposable);<br>
-  }<br>
-<br>
-  DefinedAtom::Merge merge() const override {<br>
-    return (DefinedAtom::Merge)(attributes().merge);<br>
-  }<br>
-<br>
-  DefinedAtom::ContentType contentType() const override {<br>
-    const NativeAtomAttributesV1& attr = attributes();<br>
-    return (DefinedAtom::ContentType)(attr.contentType);<br>
-  }<br>
-<br>
-  DefinedAtom::Alignment alignment() const override {<br>
-    return DefinedAtom::Alignment(attributes().align,<br>
-                                  attributes().alignModulus);<br>
-  }<br>
-<br>
-  DefinedAtom::SectionChoice sectionChoice() const override {<br>
-    return (DefinedAtom::SectionChoice)(attributes().sectionChoice);<br>
-  }<br>
-<br>
-  StringRef customSectionName() const override;<br>
-<br>
-  DefinedAtom::DeadStripKind deadStrip() const override {<br>
-     return (DefinedAtom::DeadStripKind)(attributes().deadStrip);<br>
-  }<br>
-<br>
-  DynamicExport dynamicExport() const override {<br>
-    return (DynamicExport)attributes().dynamicExport;<br>
-  }<br>
-<br>
-  DefinedAtom::CodeModel codeModel() const override {<br>
-    return DefinedAtom::CodeModel(attributes().codeModel);<br>
-  }<br>
-<br>
-  DefinedAtom::ContentPermissions permissions() const override {<br>
-     return (DefinedAtom::ContentPermissions)(attributes().permissions);<br>
-  }<br>
-<br>
-  ArrayRef<uint8_t> rawContent() const override;<br>
-<br>
-  reference_iterator begin() const override;<br>
-<br>
-  reference_iterator end() const override;<br>
-<br>
-  const Reference* derefIterator(const void*) const override;<br>
-<br>
-  void incrementIterator(const void*& it) const override;<br>
-<br>
-private:<br>
-  const NativeAtomAttributesV1& attributes() const;<br>
-<br>
-  const File                     *_file;<br>
-  const NativeDefinedAtomIvarsV1 *_ivarData;<br>
-};<br>
-<br>
-<br>
-<br>
-//<br>
-// An object of this class is instantied for each NativeUndefinedAtomIvarsV1<br>
-// struct in the NCS_UndefinedAtomsV1 chunk.<br>
-//<br>
-class NativeUndefinedAtomV1 : public UndefinedAtom {<br>
-public:<br>
-       NativeUndefinedAtomV1(const File& f,<br>
-                             const NativeUndefinedAtomIvarsV1* ivarData)<br>
-        : _file(&f), _ivarData(ivarData) { }<br>
-<br>
-  const lld::File& file() const override;<br>
-  StringRef name() const override;<br>
-<br>
-  CanBeNull canBeNull() const override {<br>
-    return (CanBeNull)(_ivarData->flags & 0x3);<br>
-  }<br>
-<br>
-  const UndefinedAtom *fallback() const override;<br>
-<br>
-private:<br>
-  const File                        *_file;<br>
-  const NativeUndefinedAtomIvarsV1  *_ivarData;<br>
-  mutable std::unique_ptr<const SimpleUndefinedAtom> _fallback;<br>
-};<br>
-<br>
-<br>
-//<br>
-// An object of this class is instantied for each NativeUndefinedAtomIvarsV1<br>
-// struct in the NCS_SharedLibraryAtomsV1 chunk.<br>
-//<br>
-class NativeSharedLibraryAtomV1 : public SharedLibraryAtom {<br>
-public:<br>
-       NativeSharedLibraryAtomV1(const File& f,<br>
-                             const NativeSharedLibraryAtomIvarsV1* ivarData)<br>
-        : _file(&f), _ivarData(ivarData) { }<br>
-<br>
-  const lld::File& file() const override;<br>
-  StringRef name() const override;<br>
-  StringRef loadName() const override;<br>
-<br>
-  bool canBeNullAtRuntime() const override {<br>
-    return (_ivarData->flags & 0x1);<br>
-  }<br>
-<br>
-  Type type() const override {<br>
-    return (Type)_ivarData->type;<br>
-  }<br>
-<br>
-  uint64_t size() const override {<br>
-    return _ivarData->size;<br>
-  }<br>
-<br>
-private:<br>
-  const File                           *_file;<br>
-  const NativeSharedLibraryAtomIvarsV1 *_ivarData;<br>
-};<br>
-<br>
-<br>
-//<br>
-// An object of this class is instantied for each NativeAbsoluteAtomIvarsV1<br>
-// struct in the NCS_AbsoluteAtomsV1 chunk.<br>
-//<br>
-class NativeAbsoluteAtomV1 : public AbsoluteAtom {<br>
-public:<br>
-       NativeAbsoluteAtomV1(const File& f,<br>
-                             const NativeAbsoluteAtomIvarsV1* ivarData)<br>
-        : _file(&f), _ivarData(ivarData) { }<br>
-<br>
-  const lld::File& file() const override;<br>
-  StringRef name() const override;<br>
-  Scope scope() const override {<br>
-    const NativeAtomAttributesV1& attr = absAttributes();<br>
-    return (Scope)(attr.scope);<br>
-  }<br>
-  uint64_t value() const override {<br>
-    return _ivarData->value;<br>
-  }<br>
-<br>
-private:<br>
-  const NativeAtomAttributesV1& absAttributes() const;<br>
-  const File                      *_file;<br>
-  const NativeAbsoluteAtomIvarsV1 *_ivarData;<br>
-};<br>
-<br>
-<br>
-//<br>
-// An object of this class is instantied for each NativeReferenceIvarsV1<br>
-// struct in the NCS_ReferencesArrayV1 chunk.<br>
-//<br>
-class NativeReferenceV1 : public Reference {<br>
-public:<br>
-  NativeReferenceV1(const File &f, const NativeReferenceIvarsV1 *ivarData)<br>
-      : Reference((KindNamespace)ivarData->kindNamespace,<br>
-                  (KindArch)ivarData->kindArch, ivarData->kindValue),<br>
-        _file(&f), _ivarData(ivarData) {}<br>
-<br>
-  uint64_t offsetInAtom() const override {<br>
-    return _ivarData->offsetInAtom;<br>
-  }<br>
-<br>
-  const Atom* target() const override;<br>
-  Addend addend() const override;<br>
-  void setTarget(const Atom* newAtom) override;<br>
-  void setAddend(Addend a) override;<br>
-<br>
-private:<br>
-  const File                    *_file;<br>
-  const NativeReferenceIvarsV1  *_ivarData;<br>
-};<br>
-<br>
-<br>
-//<br>
-// An object of this class is instantied for each NativeReferenceIvarsV1<br>
-// struct in the NCS_ReferencesArrayV1 chunk.<br>
-//<br>
-class NativeReferenceV2 : public Reference {<br>
-public:<br>
-  NativeReferenceV2(const File &f, const NativeReferenceIvarsV2 *ivarData)<br>
-      : Reference((KindNamespace)ivarData->kindNamespace,<br>
-                  (KindArch)ivarData->kindArch, ivarData->kindValue),<br>
-        _file(&f), _ivarData(ivarData) {}<br>
-<br>
-  uint64_t offsetInAtom() const override {<br>
-    return _ivarData->offsetInAtom;<br>
-  }<br>
-<br>
-  const Atom* target() const override;<br>
-  Addend addend() const override;<br>
-  void setTarget(const Atom* newAtom) override;<br>
-  void setAddend(Addend a) override;<br>
-  uint32_t tag() const override;<br>
-<br>
-private:<br>
-  const File                    *_file;<br>
-  const NativeReferenceIvarsV2  *_ivarData;<br>
-};<br>
-<br>
-<br>
-//<br>
-// lld::File object for native llvm object file<br>
-//<br>
-class File : public lld::File {<br>
-public:<br>
-  File(std::unique_ptr<MemoryBuffer> mb)<br>
-      : lld::File(mb->getBufferIdentifier(), kindObject),<br>
-        _mb(std::move(mb)), // Reader now takes ownership of buffer<br>
-        _header(nullptr), _targetsTable(nullptr), _targetsTableCount(0),<br>
-        _strings(nullptr), _stringsMaxOffset(0), _addends(nullptr),<br>
-        _addendsMaxIndex(0), _contentStart(nullptr), _contentEnd(nullptr) {<br>
-    _header =<br>
-        reinterpret_cast<const NativeFileHeader *>(_mb->getBufferStart());<br>
-  }<br>
-<br>
-  /// Parses a File object from a native object file.<br>
-  std::error_code doParse() override {<br>
-    const uint8_t *const base =<br>
-        reinterpret_cast<const uint8_t *>(_mb->getBufferStart());<br>
-    StringRef path(_mb->getBufferIdentifier());<br>
-    const NativeFileHeader *const header =<br>
-        reinterpret_cast<const NativeFileHeader *>(base);<br>
-    const NativeChunk *const chunks =<br>
-        reinterpret_cast<const NativeChunk *>(base + sizeof(NativeFileHeader));<br>
-    // make sure magic matches<br>
-    if (memcmp(header->magic, NATIVE_FILE_HEADER_MAGIC,<br>
-               sizeof(header->magic)) != 0)<br>
-      return make_error_code(NativeReaderError::unknown_file_format);<br>
-<br>
-    // make sure mapped file contains all needed data<br>
-    const size_t fileSize = _mb->getBufferSize();<br>
-    if (header->fileSize > fileSize)<br>
-      return make_error_code(NativeReaderError::file_too_short);<br>
-<br>
-    DEBUG_WITH_TYPE("ReaderNative",<br>
-                    llvm::dbgs() << " Native File Header:" << " fileSize="<br>
-                                 << header->fileSize << " chunkCount="<br>
-                                 << header->chunkCount << "\n");<br>
-<br>
-    // process each chunk<br>
-    for (uint32_t i = 0; i < header->chunkCount; ++i) {<br>
-      std::error_code ec;<br>
-      const NativeChunk* chunk = &chunks[i];<br>
-      // sanity check chunk is within file<br>
-      if ( chunk->fileOffset > fileSize )<br>
-        return make_error_code(NativeReaderError::file_malformed);<br>
-      if ( (chunk->fileOffset + chunk->fileSize) > fileSize)<br>
-        return make_error_code(NativeReaderError::file_malformed);<br>
-      // process chunk, based on signature<br>
-      switch ( chunk->signature ) {<br>
-        case NCS_DefinedAtomsV1:<br>
-          ec = processDefinedAtomsV1(base, chunk);<br>
-          break;<br>
-        case NCS_AttributesArrayV1:<br>
-          ec = processAttributesV1(base, chunk);<br>
-          break;<br>
-        case NCS_UndefinedAtomsV1:<br>
-          ec = processUndefinedAtomsV1(base, chunk);<br>
-          break;<br>
-        case NCS_SharedLibraryAtomsV1:<br>
-          ec = processSharedLibraryAtomsV1(base, chunk);<br>
-          break;<br>
-        case NCS_AbsoluteAtomsV1:<br>
-          ec = processAbsoluteAtomsV1(base, chunk);<br>
-          break;<br>
-        case NCS_AbsoluteAttributesV1:<br>
-          ec = processAbsoluteAttributesV1(base, chunk);<br>
-          break;<br>
-        case NCS_ReferencesArrayV1:<br>
-          ec = processReferencesV1(base, chunk);<br>
-          break;<br>
-        case NCS_ReferencesArrayV2:<br>
-          ec = processReferencesV2(base, chunk);<br>
-          break;<br>
-        case NCS_TargetsTable:<br>
-          ec = processTargetsTable(base, chunk);<br>
-          break;<br>
-        case NCS_AddendsTable:<br>
-          ec = processAddendsTable(base, chunk);<br>
-          break;<br>
-        case NCS_Content:<br>
-          ec = processContent(base, chunk);<br>
-          break;<br>
-        case NCS_Strings:<br>
-          ec = processStrings(base, chunk);<br>
-          break;<br>
-        default:<br>
-          return make_error_code(NativeReaderError::unknown_chunk_type);<br>
-      }<br>
-      if ( ec ) {<br>
-        return ec;<br>
-      }<br>
-    }<br>
-    // TO DO: validate enough chunks were used<br>
-<br>
-    DEBUG_WITH_TYPE("ReaderNative", {<br>
-      llvm::dbgs() << " ReaderNative DefinedAtoms:\n";<br>
-      for (const DefinedAtom *a : defined()) {<br>
-        llvm::dbgs() << llvm::format("    0x%09lX", a)<br>
-                     << ", name=" << a->name()<br>
-                     << ", size=" << a->size() << "\n";<br>
-        for (const Reference *r : *a) {<br>
-          llvm::dbgs() << "        offset="<br>
-                       << llvm::format("0x%03X", r->offsetInAtom())<br>
-                       << ", kind=" << r->kindValue()<br>
-                       << ", target=" << r->target() << "\n";<br>
-        }<br>
-      }<br>
-    });<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  virtual ~File() {<br>
-    // _mb is automatically deleted because of std::unique_ptr<><br>
-<br>
-    // All other ivar pointers are pointers into the MemoryBuffer, except<br>
-    // the _definedAtoms array which was allocated to contain an array<br>
-    // of Atom objects.  The atoms have empty destructors, so it is ok<br>
-    // to just delete the memory.<br>
-    delete _referencesV1.arrayStart;<br>
-    delete _referencesV2.arrayStart;<br>
-    delete [] _targetsTable;<br>
-  }<br>
-<br>
-  const AtomVector<DefinedAtom> &defined() const override {<br>
-    return _definedAtoms;<br>
-  }<br>
-  const AtomVector<UndefinedAtom> &undefined() const override {<br>
-      return _undefinedAtoms;<br>
-  }<br>
-  const AtomVector<SharedLibraryAtom> &sharedLibrary() const override {<br>
-      return _sharedLibraryAtoms;<br>
-  }<br>
-  const AtomVector<AbsoluteAtom> &absolute() const override {<br>
-    return _absoluteAtoms;<br>
-  }<br>
-<br>
-private:<br>
-  friend NativeDefinedAtomV1;<br>
-  friend NativeUndefinedAtomV1;<br>
-  friend NativeSharedLibraryAtomV1;<br>
-  friend NativeAbsoluteAtomV1;<br>
-  friend NativeReferenceV1;<br>
-  friend NativeReferenceV2;<br>
-  template <typename T> class AtomArray;<br>
-<br>
-  // instantiate array of BASeT from IvarsT data in file<br>
-  template <typename BaseT, typename AtomT, typename IvarsT><br>
-  std::error_code processAtoms(AtomVector<BaseT> &result, const uint8_t *base,<br>
-                               const NativeChunk *chunk) {<br>
-    std::vector<const BaseT *> vec(chunk->elementCount);<br>
-    const size_t ivarElementSize = chunk->fileSize / chunk->elementCount;<br>
-    if (ivarElementSize != sizeof(IvarsT))<br>
-      return make_error_code(NativeReaderError::file_malformed);<br>
-    auto *ivar = reinterpret_cast<const IvarsT *>(base + chunk->fileOffset);<br>
-    for (size_t i = 0; i < chunk->elementCount; ++i)<br>
-      vec[i] = new (_alloc) AtomT(*this, ivar++);<br>
-    result = std::move(vec);<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  // instantiate array of DefinedAtoms from v1 ivar data in file<br>
-  std::error_code processDefinedAtomsV1(const uint8_t *base,<br>
-                                        const NativeChunk *chunk) {<br>
-    return processAtoms<DefinedAtom, NativeDefinedAtomV1,<br>
-                        NativeDefinedAtomIvarsV1>(this->_definedAtoms, base,<br>
-                                                  chunk);<br>
-  }<br>
-<br>
-  // set up pointers to attributes array<br>
-  std::error_code processAttributesV1(const uint8_t *base,<br>
-                                      const NativeChunk *chunk) {<br>
-    this->_attributes = base + chunk->fileOffset;<br>
-    this->_attributesMaxOffset = chunk->fileSize;<br>
-    DEBUG_WITH_TYPE("ReaderNative", llvm::dbgs()<br>
-                    << " chunk AttributesV1:        "<br>
-                    << " count=" << chunk->elementCount<br>
-                    << " chunkSize=" << chunk->fileSize<br>
-                    << "\n");<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  // set up pointers to attributes array<br>
-  std::error_code processAbsoluteAttributesV1(const uint8_t *base,<br>
-                                              const NativeChunk *chunk) {<br>
-    this->_absAttributes = base + chunk->fileOffset;<br>
-    this->_absAbsoluteMaxOffset = chunk->fileSize;<br>
-    DEBUG_WITH_TYPE("ReaderNative", llvm::dbgs()<br>
-                    << " chunk AbsoluteAttributesV1:        "<br>
-                    << " count=" << chunk->elementCount<br>
-                    << " chunkSize=" << chunk->fileSize<br>
-                    << "\n");<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  // instantiate array of UndefinedAtoms from v1 ivar data in file<br>
-  std::error_code processUndefinedAtomsV1(const uint8_t *base,<br>
-                                          const NativeChunk *chunk) {<br>
-    return processAtoms<UndefinedAtom, NativeUndefinedAtomV1,<br>
-                        NativeUndefinedAtomIvarsV1>(this->_undefinedAtoms, base,<br>
-                                                    chunk);<br>
-  }<br>
-<br>
-<br>
-  // instantiate array of ShareLibraryAtoms from v1 ivar data in file<br>
-  std::error_code processSharedLibraryAtomsV1(const uint8_t *base,<br>
-                                              const NativeChunk *chunk) {<br>
-    return processAtoms<SharedLibraryAtom, NativeSharedLibraryAtomV1,<br>
-                        NativeSharedLibraryAtomIvarsV1>(<br>
-        this->_sharedLibraryAtoms, base, chunk);<br>
-  }<br>
-<br>
-<br>
-   // instantiate array of AbsoluteAtoms from v1 ivar data in file<br>
-  std::error_code processAbsoluteAtomsV1(const uint8_t *base,<br>
-                                         const NativeChunk *chunk) {<br>
-    return processAtoms<AbsoluteAtom, NativeAbsoluteAtomV1,<br>
-                        NativeAbsoluteAtomIvarsV1>(this->_absoluteAtoms, base,<br>
-                                                   chunk);<br>
-  }<br>
-<br>
-  template <class T, class U><br>
-  std::error_code<br>
-  processReferences(const uint8_t *base, const NativeChunk *chunk,<br>
-                    uint8_t *&refsStart, uint8_t *&refsEnd) const {<br>
-    if (chunk->elementCount == 0)<br>
-      return make_error_code(NativeReaderError::success);<br>
-    size_t refsArraySize = chunk->elementCount * sizeof(T);<br>
-    refsStart = reinterpret_cast<uint8_t *>(<br>
-        operator new(refsArraySize, std::nothrow));<br>
-    if (refsStart == nullptr)<br>
-      return make_error_code(NativeReaderError::memory_error);<br>
-    const size_t ivarElementSize = chunk->fileSize / chunk->elementCount;<br>
-    if (ivarElementSize != sizeof(U))<br>
-      return make_error_code(NativeReaderError::file_malformed);<br>
-    refsEnd = refsStart + refsArraySize;<br>
-    const U* ivarData = reinterpret_cast<const U *>(base + chunk->fileOffset);<br>
-    for (uint8_t *s = refsStart; s != refsEnd; s += sizeof(T), ++ivarData) {<br>
-      T *atomAllocSpace = reinterpret_cast<T *>(s);<br>
-      new (atomAllocSpace) T(*this, ivarData);<br>
-    }<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  // instantiate array of References from v1 ivar data in file<br>
-  std::error_code processReferencesV1(const uint8_t *base,<br>
-                                      const NativeChunk *chunk) {<br>
-    uint8_t *refsStart, *refsEnd;<br>
-    if (std::error_code ec =<br>
-            processReferences<NativeReferenceV1, NativeReferenceIvarsV1>(<br>
-                base, chunk, refsStart, refsEnd))<br>
-      return ec;<br>
-    this->_referencesV1.arrayStart = refsStart;<br>
-    this->_referencesV1.arrayEnd = refsEnd;<br>
-    this->_referencesV1.elementSize = sizeof(NativeReferenceV1);<br>
-    this->_referencesV1.elementCount = chunk->elementCount;<br>
-    DEBUG_WITH_TYPE("ReaderNative", {<br>
-      llvm::dbgs() << " chunk ReferencesV1:        "<br>
-                   << " count=" << chunk->elementCount<br>
-                   << " chunkSize=" << chunk->fileSize << "\n";<br>
-    });<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  // instantiate array of References from v2 ivar data in file<br>
-  std::error_code processReferencesV2(const uint8_t *base,<br>
-                                      const NativeChunk *chunk) {<br>
-    uint8_t *refsStart, *refsEnd;<br>
-    if (std::error_code ec =<br>
-            processReferences<NativeReferenceV2, NativeReferenceIvarsV2>(<br>
-                base, chunk, refsStart, refsEnd))<br>
-      return ec;<br>
-    this->_referencesV2.arrayStart = refsStart;<br>
-    this->_referencesV2.arrayEnd = refsEnd;<br>
-    this->_referencesV2.elementSize = sizeof(NativeReferenceV2);<br>
-    this->_referencesV2.elementCount = chunk->elementCount;<br>
-    DEBUG_WITH_TYPE("ReaderNative", {<br>
-      llvm::dbgs() << " chunk ReferencesV2:        "<br>
-                   << " count=" << chunk->elementCount<br>
-                   << " chunkSize=" << chunk->fileSize << "\n";<br>
-    });<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  // set up pointers to target table<br>
-  std::error_code processTargetsTable(const uint8_t *base,<br>
-                                      const NativeChunk *chunk) {<br>
-    const uint32_t* targetIndexes = reinterpret_cast<const uint32_t*><br>
-                                                  (base + chunk->fileOffset);<br>
-    this->_targetsTableCount = chunk->elementCount;<br>
-    this->_targetsTable = new const Atom*[chunk->elementCount];<br>
-    for (uint32_t i=0; i < chunk->elementCount; ++i) {<br>
-      const uint32_t index = targetIndexes[i];<br>
-      if (index < _definedAtoms.size()) {<br>
-        this->_targetsTable[i] = _definedAtoms[index];<br>
-        continue;<br>
-      }<br>
-      const uint32_t undefIndex = index - _definedAtoms.size();<br>
-      if (undefIndex < _undefinedAtoms.size()) {<br>
-        this->_targetsTable[i] = _undefinedAtoms[index];<br>
-        continue;<br>
-      }<br>
-      const uint32_t slIndex = undefIndex - _undefinedAtoms.size();<br>
-      if (slIndex < _sharedLibraryAtoms.size()) {<br>
-        this->_targetsTable[i] = _sharedLibraryAtoms[slIndex];<br>
-        continue;<br>
-      }<br>
-      const uint32_t abIndex = slIndex - _sharedLibraryAtoms.size();<br>
-      if (abIndex < _absoluteAtoms.size()) {<br>
-        this->_targetsTable[i] = _absoluteAtoms[abIndex];<br>
-        continue;<br>
-      }<br>
-     return make_error_code(NativeReaderError::file_malformed);<br>
-    }<br>
-    DEBUG_WITH_TYPE("ReaderNative", llvm::dbgs()<br>
-                    << " chunk Targets Table:       "<br>
-                    << " count=" << chunk->elementCount<br>
-                    << " chunkSize=" << chunk->fileSize<br>
-                    << "\n");<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-<br>
-  // set up pointers to addend pool in file<br>
-  std::error_code processAddendsTable(const uint8_t *base,<br>
-                                      const NativeChunk *chunk) {<br>
-    this->_addends = reinterpret_cast<const Reference::Addend*><br>
-                                                  (base + chunk->fileOffset);<br>
-    this->_addendsMaxIndex = chunk->elementCount;<br>
-    DEBUG_WITH_TYPE("ReaderNative", llvm::dbgs()<br>
-                    << " chunk Addends:             "<br>
-                    << " count=" << chunk->elementCount<br>
-                    << " chunkSize=" << chunk->fileSize<br>
-                    << "\n");<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  // set up pointers to string pool in file<br>
-  std::error_code processStrings(const uint8_t *base,<br>
-                                 const NativeChunk *chunk) {<br>
-    this->_strings = reinterpret_cast<const char*>(base + chunk->fileOffset);<br>
-    this->_stringsMaxOffset = chunk->fileSize;<br>
-    DEBUG_WITH_TYPE("ReaderNative", llvm::dbgs()<br>
-                    << " chunk Strings:             "<br>
-                    << " chunkSize=" << chunk->fileSize<br>
-                    << "\n");<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  // set up pointers to content area in file<br>
-  std::error_code processContent(const uint8_t *base,<br>
-                                 const NativeChunk *chunk) {<br>
-    this->_contentStart = base + chunk->fileOffset;<br>
-    this->_contentEnd = base + chunk->fileOffset + chunk->fileSize;<br>
-    DEBUG_WITH_TYPE("ReaderNative", llvm::dbgs()<br>
-                    << " chunk content:             "<br>
-                    << " chunkSize=" << chunk->fileSize<br>
-                    << "\n");<br>
-    return make_error_code(NativeReaderError::success);<br>
-  }<br>
-<br>
-  StringRef string(uint32_t offset) const {<br>
-    assert(offset < _stringsMaxOffset);<br>
-    return StringRef(&_strings[offset]);<br>
-  }<br>
-<br>
-  Reference::Addend addend(uint32_t index) const {<br>
-    if ( index == 0 )<br>
-      return 0; // addend index zero is used to mean "no addend"<br>
-    assert(index <= _addendsMaxIndex);<br>
-    return _addends[index-1]; // one-based indexing<br>
-  }<br>
-<br>
-  const NativeAtomAttributesV1& attribute(uint32_t off) const {<br>
-    assert(off < _attributesMaxOffset);<br>
-    return *reinterpret_cast<const NativeAtomAttributesV1*>(_attributes + off);<br>
-  }<br>
-<br>
-  const NativeAtomAttributesV1& absAttribute(uint32_t off) const {<br>
-    assert(off < _absAbsoluteMaxOffset);<br>
-    return *reinterpret_cast<const NativeAtomAttributesV1*>(_absAttributes + off);<br>
-  }<br>
-<br>
-  const uint8_t* content(uint32_t offset, uint32_t size) const {<br>
-    const uint8_t* result = _contentStart + offset;<br>
-    assert((result+size) <= _contentEnd);<br>
-    return result;<br>
-  }<br>
-<br>
-  const Reference* referenceByIndex(uintptr_t index) const {<br>
-    if (index < _referencesV1.elementCount) {<br>
-      return reinterpret_cast<const NativeReferenceV1*>(<br>
-          _referencesV1.arrayStart + index * _referencesV1.elementSize);<br>
-    }<br>
-    assert(index < _referencesV2.elementCount);<br>
-    return reinterpret_cast<const NativeReferenceV2*>(<br>
-        _referencesV2.arrayStart + index * _referencesV2.elementSize);<br>
-  }<br>
-<br>
-  const Atom* targetV1(uint16_t index) const {<br>
-    if ( index == NativeReferenceIvarsV1::noTarget )<br>
-      return nullptr;<br>
-    assert(index < _targetsTableCount);<br>
-    return _targetsTable[index];<br>
-  }<br>
-<br>
-  void setTargetV1(uint16_t index, const Atom* newAtom) const {<br>
-    assert(index != NativeReferenceIvarsV1::noTarget);<br>
-    assert(index > _targetsTableCount);<br>
-    _targetsTable[index] = newAtom;<br>
-  }<br>
-<br>
-  const Atom* targetV2(uint32_t index) const {<br>
-    if (index == NativeReferenceIvarsV2::noTarget)<br>
-      return nullptr;<br>
-    assert(index < _targetsTableCount);<br>
-    return _targetsTable[index];<br>
-  }<br>
-<br>
-  void setTargetV2(uint32_t index, const Atom* newAtom) const {<br>
-    assert(index != NativeReferenceIvarsV2::noTarget);<br>
-    assert(index > _targetsTableCount);<br>
-    _targetsTable[index] = newAtom;<br>
-  }<br>
-<br>
-  struct IvarArray {<br>
-                      IvarArray() :<br>
-                        arrayStart(nullptr),<br>
-                        arrayEnd(nullptr),<br>
-                        elementSize(0),<br>
-                        elementCount(0) { }<br>
-<br>
-    const uint8_t*     arrayStart;<br>
-    const uint8_t*     arrayEnd;<br>
-    uint32_t           elementSize;<br>
-    uint32_t           elementCount;<br>
-  };<br>
-<br>
-  std::unique_ptr<MemoryBuffer>   _mb;<br>
-  const NativeFileHeader*         _header;<br>
-  AtomVector<DefinedAtom> _definedAtoms;<br>
-  AtomVector<UndefinedAtom> _undefinedAtoms;<br>
-  AtomVector<SharedLibraryAtom> _sharedLibraryAtoms;<br>
-  AtomVector<AbsoluteAtom> _absoluteAtoms;<br>
-  const uint8_t*                  _absAttributes;<br>
-  uint32_t                        _absAbsoluteMaxOffset;<br>
-  const uint8_t*                  _attributes;<br>
-  uint32_t                        _attributesMaxOffset;<br>
-  IvarArray                       _referencesV1;<br>
-  IvarArray                       _referencesV2;<br>
-  const Atom**                    _targetsTable;<br>
-  uint32_t                        _targetsTableCount;<br>
-  const char*                     _strings;<br>
-  uint32_t                        _stringsMaxOffset;<br>
-  const Reference::Addend*        _addends;<br>
-  uint32_t                        _addendsMaxIndex;<br>
-  const uint8_t                  *_contentStart;<br>
-  const uint8_t                  *_contentEnd;<br>
-  llvm::BumpPtrAllocator _alloc;<br>
-};<br>
-<br>
-inline const lld::File &NativeDefinedAtomV1::file() const {<br>
-  return *_file;<br>
-}<br>
-<br>
-inline uint64_t NativeDefinedAtomV1::ordinal() const {<br>
-  const uint8_t* p = reinterpret_cast<const uint8_t*>(_ivarData);<br>
-  auto *start = reinterpret_cast<const NativeDefinedAtomV1 *>(<br>
-      _file->_definedAtoms[0]);<br>
-  const uint8_t *startp = reinterpret_cast<const uint8_t *>(start->_ivarData);<br>
-  return p - startp;<br>
-}<br>
-<br>
-inline StringRef NativeDefinedAtomV1::name() const {<br>
-  return _file->string(_ivarData->nameOffset);<br>
-}<br>
-<br>
-inline const NativeAtomAttributesV1& NativeDefinedAtomV1::attributes() const {<br>
-  return _file->attribute(_ivarData->attributesOffset);<br>
-}<br>
-<br>
-inline ArrayRef<uint8_t> NativeDefinedAtomV1::rawContent() const {<br>
-  if (!occupiesDiskSpace())<br>
-    return ArrayRef<uint8_t>();<br>
-  const uint8_t* p = _file->content(_ivarData->contentOffset,<br>
-                                    _ivarData->contentSize);<br>
-  return ArrayRef<uint8_t>(p, _ivarData->contentSize);<br>
-}<br>
-<br>
-inline StringRef NativeDefinedAtomV1::customSectionName() const {<br>
-  uint32_t offset = attributes().sectionNameOffset;<br>
-  return _file->string(offset);<br>
-}<br>
-<br>
-DefinedAtom::reference_iterator NativeDefinedAtomV1::begin() const {<br>
-  uintptr_t index = _ivarData->referencesStartIndex;<br>
-  const void* it = reinterpret_cast<const void*>(index);<br>
-  return reference_iterator(*this, it);<br>
-}<br>
-<br>
-DefinedAtom::reference_iterator NativeDefinedAtomV1::end() const {<br>
-  uintptr_t index = _ivarData->referencesStartIndex+_ivarData->referencesCount;<br>
-  const void* it = reinterpret_cast<const void*>(index);<br>
-  return reference_iterator(*this, it);<br>
-}<br>
-<br>
-const Reference* NativeDefinedAtomV1::derefIterator(const void* it) const {<br>
-  uintptr_t index = reinterpret_cast<uintptr_t>(it);<br>
-  return _file->referenceByIndex(index);<br>
-}<br>
-<br>
-void NativeDefinedAtomV1::incrementIterator(const void*& it) const {<br>
-  uintptr_t index = reinterpret_cast<uintptr_t>(it);<br>
-  ++index;<br>
-  it = reinterpret_cast<const void*>(index);<br>
-}<br>
-<br>
-inline const lld::File& NativeUndefinedAtomV1::file() const {<br>
-  return *_file;<br>
-}<br>
-<br>
-inline StringRef NativeUndefinedAtomV1::name() const {<br>
-  return _file->string(_ivarData->nameOffset);<br>
-}<br>
-<br>
-inline const UndefinedAtom *NativeUndefinedAtomV1::fallback() const {<br>
-  if (!_ivarData->fallbackNameOffset)<br>
-    return nullptr;<br>
-  if (!_fallback)<br>
-    _fallback.reset(new SimpleUndefinedAtom(<br>
-        *_file, _file->string(_ivarData->fallbackNameOffset)));<br>
-  return _fallback.get();<br>
-}<br>
-<br>
-inline const lld::File& NativeSharedLibraryAtomV1::file() const {<br>
-  return *_file;<br>
-}<br>
-<br>
-inline StringRef NativeSharedLibraryAtomV1::name() const {<br>
-  return _file->string(_ivarData->nameOffset);<br>
-}<br>
-<br>
-inline StringRef NativeSharedLibraryAtomV1::loadName() const {<br>
-  return _file->string(_ivarData->loadNameOffset);<br>
-}<br>
-<br>
-<br>
-<br>
-inline const lld::File& NativeAbsoluteAtomV1::file() const {<br>
-  return *_file;<br>
-}<br>
-<br>
-inline StringRef NativeAbsoluteAtomV1::name() const {<br>
-  return _file->string(_ivarData->nameOffset);<br>
-}<br>
-<br>
-inline const NativeAtomAttributesV1& NativeAbsoluteAtomV1::absAttributes() const {<br>
-  return _file->absAttribute(_ivarData->attributesOffset);<br>
-}<br>
-<br>
-inline const Atom* NativeReferenceV1::target() const {<br>
-  return _file->targetV1(_ivarData->targetIndex);<br>
-}<br>
-<br>
-inline Reference::Addend NativeReferenceV1::addend() const {<br>
-  return _file->addend(_ivarData->addendIndex);<br>
-}<br>
-<br>
-inline void NativeReferenceV1::setTarget(const Atom* newAtom) {<br>
-  return _file->setTargetV1(_ivarData->targetIndex, newAtom);<br>
-}<br>
-<br>
-inline void NativeReferenceV1::setAddend(Addend a) {<br>
-  // Do nothing if addend value is not being changed.<br>
-  if (addend() == a)<br>
-    return;<br>
-  llvm_unreachable("setAddend() not supported");<br>
-}<br>
-<br>
-inline const Atom* NativeReferenceV2::target() const {<br>
-  return _file->targetV2(_ivarData->targetIndex);<br>
-}<br>
-<br>
-inline Reference::Addend NativeReferenceV2::addend() const {<br>
-  return _ivarData->addend;<br>
-}<br>
-<br>
-inline void NativeReferenceV2::setTarget(const Atom* newAtom) {<br>
-  return _file->setTargetV2(_ivarData->targetIndex, newAtom);<br>
-}<br>
-<br>
-inline void NativeReferenceV2::setAddend(Addend a) {<br>
-  // Do nothing if addend value is not being changed.<br>
-  if (addend() == a)<br>
-    return;<br>
-  llvm_unreachable("setAddend() not supported");<br>
-}<br>
-<br>
-uint32_t NativeReferenceV2::tag() const { return _ivarData->tag; }<br>
-<br>
-} // end namespace native<br>
-<br>
-namespace {<br>
-<br>
-class NativeReader : public Reader {<br>
-public:<br>
-  bool canParse(file_magic magic, const MemoryBuffer &mb) const override {<br>
-    const NativeFileHeader *const header =<br>
-        reinterpret_cast<const NativeFileHeader *>(mb.getBufferStart());<br>
-    return (memcmp(header->magic, NATIVE_FILE_HEADER_MAGIC,<br>
-                   sizeof(header->magic)) == 0);<br>
-  }<br>
-<br>
-  virtual std::error_code<br>
-  loadFile(std::unique_ptr<MemoryBuffer> mb, const class Registry &,<br>
-           std::vector<std::unique_ptr<File>> &result) const override {<br>
-    auto *file = new lld::native::File(std::move(mb));<br>
-    result.push_back(std::unique_ptr<File>(file));<br>
-    return std::error_code();<br>
-  }<br>
-};<br>
-<br>
-}<br>
-<br>
-void Registry::addSupportNativeObjects() {<br>
-  add(std::unique_ptr<Reader>(new NativeReader()));<br>
-}<br>
-<br>
-} // end namespace lld<br>
<br>
Removed: lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp?rev=234640&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp?rev=234640&view=auto</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp (removed)<br>
@@ -1,566 +0,0 @@<br>
-//===- lib/ReaderWriter/Native/WriterNative.cpp ---------------------------===//<br>
-//<br>
-//                             The LLVM Linker<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#include "NativeFileFormat.h"<br>
-#include "lld/Core/File.h"<br>
-#include "lld/Core/LinkingContext.h"<br>
-#include "lld/Core/Writer.h"<br>
-#include "llvm/ADT/ArrayRef.h"<br>
-#include "llvm/ADT/DenseMap.h"<br>
-#include "llvm/ADT/StringRef.h"<br>
-#include "llvm/Support/raw_ostream.h"<br>
-#include <cstdint><br>
-#include <set><br>
-#include <system_error><br>
-#include <vector><br>
-<br>
-namespace lld {<br>
-namespace native {<br>
-<br>
-///<br>
-/// Class for writing native object files.<br>
-///<br>
-class Writer : public lld::Writer {<br>
-public:<br>
-  std::error_code writeFile(const lld::File &file, StringRef outPath) override {<br>
-    // reserve first byte for unnamed atoms<br>
-    _stringPool.push_back('\0');<br>
-    // visit all atoms<br>
-    for ( const DefinedAtom *defAtom : file.defined() ) {<br>
-      this->addIVarsForDefinedAtom(*defAtom);<br>
-      // We are trying to process all atoms, but the defined() iterator does not<br>
-      // return group children. So, when a group parent is found, we need to<br>
-      // handle each child atom.<br>
-      if (defAtom->isGroupParent()) {<br>
-        for (const Reference *r : *defAtom) {<br>
-          if (r->kindNamespace() != lld::Reference::KindNamespace::all)<br>
-            continue;<br>
-          if (r->kindValue() == lld::Reference::kindGroupChild) {<br>
-            const DefinedAtom *target = dyn_cast<DefinedAtom>(r->target());<br>
-            assert(target && "Internal Error: kindGroupChild references need "<br>
-                             "to be associated with Defined Atoms only");<br>
-            this->addIVarsForDefinedAtom(*target);<br>
-          }<br>
-        }<br>
-      }<br>
-    }<br>
-    for ( const UndefinedAtom *undefAtom : file.undefined() ) {<br>
-      this->addIVarsForUndefinedAtom(*undefAtom);<br>
-    }<br>
-    for ( const SharedLibraryAtom *shlibAtom : file.sharedLibrary() ) {<br>
-      this->addIVarsForSharedLibraryAtom(*shlibAtom);<br>
-    }<br>
-    for ( const AbsoluteAtom *absAtom : file.absolute() ) {<br>
-      this->addIVarsForAbsoluteAtom(*absAtom);<br>
-    }<br>
-<br>
-    maybeConvertReferencesToV1();<br>
-<br>
-    // construct file header based on atom information accumulated<br>
-    this->makeHeader();<br>
-<br>
-    std::error_code ec;<br>
-    llvm::raw_fd_ostream out(outPath, ec, llvm::sys::fs::F_None);<br>
-    if (ec)<br>
-      return ec;<br>
-<br>
-    this->write(out);<br>
-<br>
-    return std::error_code();<br>
-  }<br>
-<br>
-  virtual ~Writer() {<br>
-  }<br>
-<br>
-private:<br>
-<br>
-  // write the lld::File in native format to the specified stream<br>
-  void write(raw_ostream &out) {<br>
-    assert(out.tell() == 0);<br>
-    out.write((char*)_headerBuffer, _headerBufferSize);<br>
-<br>
-    writeChunk(out, _definedAtomIvars, NCS_DefinedAtomsV1);<br>
-    writeChunk(out, _attributes, NCS_AttributesArrayV1);<br>
-    writeChunk(out, _undefinedAtomIvars, NCS_UndefinedAtomsV1);<br>
-    writeChunk(out, _sharedLibraryAtomIvars, NCS_SharedLibraryAtomsV1);<br>
-    writeChunk(out, _absoluteAtomIvars, NCS_AbsoluteAtomsV1);<br>
-    writeChunk(out, _absAttributes, NCS_AbsoluteAttributesV1);<br>
-    writeChunk(out, _stringPool, NCS_Strings);<br>
-    writeChunk(out, _referencesV1, NCS_ReferencesArrayV1);<br>
-    writeChunk(out, _referencesV2, NCS_ReferencesArrayV2);<br>
-<br>
-    if (!_targetsTableIndex.empty()) {<br>
-      assert(out.tell() == findChunk(NCS_TargetsTable).fileOffset);<br>
-      writeTargetTable(out);<br>
-    }<br>
-<br>
-    if (!_addendsTableIndex.empty()) {<br>
-      assert(out.tell() == findChunk(NCS_AddendsTable).fileOffset);<br>
-      writeAddendTable(out);<br>
-    }<br>
-<br>
-    writeChunk(out, _contentPool, NCS_Content);<br>
-  }<br>
-<br>
-  template<class T><br>
-  void writeChunk(raw_ostream &out, std::vector<T> &vector, uint32_t signature) {<br>
-    if (vector.empty())<br>
-      return;<br>
-    assert(out.tell() == findChunk(signature).fileOffset);<br>
-    out.write((char*)&vector[0], vector.size() * sizeof(T));<br>
-  }<br>
-<br>
-  void addIVarsForDefinedAtom(const DefinedAtom& atom) {<br>
-    _definedAtomIndex[&atom] = _definedAtomIvars.size();<br>
-    NativeDefinedAtomIvarsV1 ivar;<br>
-    unsigned refsCount;<br>
-    ivar.nameOffset = getNameOffset(atom);<br>
-    ivar.attributesOffset = getAttributeOffset(atom);<br>
-    ivar.referencesStartIndex = getReferencesIndex(atom, refsCount);<br>
-    ivar.referencesCount = refsCount;<br>
-    ivar.contentOffset = getContentOffset(atom);<br>
-    ivar.contentSize = atom.size();<br>
-    ivar.sectionSize = atom.sectionSize();<br>
-    _definedAtomIvars.push_back(ivar);<br>
-  }<br>
-<br>
-  void addIVarsForUndefinedAtom(const UndefinedAtom& atom) {<br>
-    _undefinedAtomIndex[&atom] = _undefinedAtomIvars.size();<br>
-    NativeUndefinedAtomIvarsV1 ivar;<br>
-    ivar.nameOffset = getNameOffset(atom);<br>
-    ivar.flags = (atom.canBeNull() & 0x03);<br>
-    ivar.fallbackNameOffset = 0;<br>
-    if (atom.fallback())<br>
-      ivar.fallbackNameOffset = getNameOffset(*atom.fallback());<br>
-    _undefinedAtomIvars.push_back(ivar);<br>
-  }<br>
-<br>
-  void addIVarsForSharedLibraryAtom(const SharedLibraryAtom& atom) {<br>
-    _sharedLibraryAtomIndex[&atom] = _sharedLibraryAtomIvars.size();<br>
-    NativeSharedLibraryAtomIvarsV1 ivar;<br>
-    ivar.size = atom.size();<br>
-    ivar.nameOffset = getNameOffset(atom);<br>
-    ivar.loadNameOffset = getSharedLibraryNameOffset(atom.loadName());<br>
-    ivar.type = (uint32_t)atom.type();<br>
-    ivar.flags = atom.canBeNullAtRuntime();<br>
-    _sharedLibraryAtomIvars.push_back(ivar);<br>
-  }<br>
-<br>
-  void addIVarsForAbsoluteAtom(const AbsoluteAtom& atom) {<br>
-    _absoluteAtomIndex[&atom] = _absoluteAtomIvars.size();<br>
-    NativeAbsoluteAtomIvarsV1 ivar;<br>
-    ivar.nameOffset = getNameOffset(atom);<br>
-    ivar.attributesOffset = getAttributeOffset(atom);<br>
-    ivar.reserved = 0;<br>
-    ivar.value = atom.value();<br>
-    _absoluteAtomIvars.push_back(ivar);<br>
-  }<br>
-<br>
-  void convertReferencesToV1() {<br>
-    for (const NativeReferenceIvarsV2 &v2 : _referencesV2) {<br>
-      NativeReferenceIvarsV1 v1;<br>
-      v1.offsetInAtom = v2.offsetInAtom;<br>
-      v1.kindNamespace = v2.kindNamespace;<br>
-      v1.kindArch = v2.kindArch;<br>
-      v1.kindValue = v2.kindValue;<br>
-      v1.targetIndex = (v2.targetIndex == NativeReferenceIvarsV2::noTarget) ?<br>
-          (uint16_t)NativeReferenceIvarsV1::noTarget : v2.targetIndex;<br>
-      v1.addendIndex = this->getAddendIndex(v2.addend);<br>
-      _referencesV1.push_back(v1);<br>
-    }<br>
-    _referencesV2.clear();<br>
-  }<br>
-<br>
-  bool canConvertReferenceToV1(const NativeReferenceIvarsV2 &ref) {<br>
-    bool validOffset = (ref.offsetInAtom == NativeReferenceIvarsV2::noTarget) ||<br>
-        ref.offsetInAtom < NativeReferenceIvarsV1::noTarget;<br>
-    return validOffset && ref.targetIndex < UINT16_MAX;<br>
-  }<br>
-<br>
-  // Convert vector of NativeReferenceIvarsV2 to NativeReferenceIvarsV1 if<br>
-  // possible.<br>
-  void maybeConvertReferencesToV1() {<br>
-    std::set<int64_t> addends;<br>
-    for (const NativeReferenceIvarsV2 &ref : _referencesV2) {<br>
-      if (!canConvertReferenceToV1(ref))<br>
-        return;<br>
-      addends.insert(ref.addend);<br>
-      if (addends.size() >= UINT16_MAX)<br>
-        return;<br>
-    }<br>
-    convertReferencesToV1();<br>
-  }<br>
-<br>
-  // fill out native file header and chunk directory<br>
-  void makeHeader() {<br>
-    const bool hasDefines = !_definedAtomIvars.empty();<br>
-    const bool hasUndefines = !_undefinedAtomIvars.empty();<br>
-    const bool hasSharedLibraries = !_sharedLibraryAtomIvars.empty();<br>
-    const bool hasAbsolutes = !_absoluteAtomIvars.empty();<br>
-    const bool hasReferencesV1 = !_referencesV1.empty();<br>
-    const bool hasReferencesV2 = !_referencesV2.empty();<br>
-    const bool hasTargetsTable = !_targetsTableIndex.empty();<br>
-    const bool hasAddendTable = !_addendsTableIndex.empty();<br>
-    const bool hasContent = !_contentPool.empty();<br>
-<br>
-    int chunkCount = 1; // always have string pool chunk<br>
-    if ( hasDefines ) chunkCount += 2;<br>
-    if ( hasUndefines ) ++chunkCount;<br>
-    if ( hasSharedLibraries ) ++chunkCount;<br>
-    if ( hasAbsolutes ) chunkCount += 2;<br>
-    if ( hasReferencesV1 ) ++chunkCount;<br>
-    if ( hasReferencesV2 ) ++chunkCount;<br>
-    if ( hasTargetsTable ) ++chunkCount;<br>
-    if ( hasAddendTable ) ++chunkCount;<br>
-    if ( hasContent ) ++chunkCount;<br>
-<br>
-    _headerBufferSize = sizeof(NativeFileHeader)<br>
-                         + chunkCount*sizeof(NativeChunk);<br>
-    _headerBuffer = reinterpret_cast<NativeFileHeader*><br>
-                               (operator new(_headerBufferSize, std::nothrow));<br>
-    NativeChunk *chunks =<br>
-      reinterpret_cast<NativeChunk*>(reinterpret_cast<char*>(_headerBuffer)<br>
-                                     + sizeof(NativeFileHeader));<br>
-    memcpy(_headerBuffer->magic, NATIVE_FILE_HEADER_MAGIC,<br>
-           sizeof(_headerBuffer->magic));<br>
-    _headerBuffer->endian = NFH_LittleEndian;<br>
-    _headerBuffer->architecture = 0;<br>
-    _headerBuffer->fileSize = 0;<br>
-    _headerBuffer->chunkCount = chunkCount;<br>
-<br>
-    // create chunk for defined atom ivar array<br>
-    int nextIndex = 0;<br>
-    uint32_t nextFileOffset = _headerBufferSize;<br>
-    if (hasDefines) {<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset, _definedAtomIvars,<br>
-                      NCS_DefinedAtomsV1);<br>
-<br>
-      // create chunk for attributes<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset, _attributes,<br>
-                      NCS_AttributesArrayV1);<br>
-    }<br>
-<br>
-    // create chunk for undefined atom array<br>
-    if (hasUndefines)<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset, _undefinedAtomIvars,<br>
-                      NCS_UndefinedAtomsV1);<br>
-<br>
-    // create chunk for shared library atom array<br>
-    if (hasSharedLibraries)<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset,<br>
-                      _sharedLibraryAtomIvars, NCS_SharedLibraryAtomsV1);<br>
-<br>
-     // create chunk for shared library atom array<br>
-    if (hasAbsolutes) {<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset, _absoluteAtomIvars,<br>
-                      NCS_AbsoluteAtomsV1);<br>
-<br>
-      // create chunk for attributes<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset, _absAttributes,<br>
-                      NCS_AbsoluteAttributesV1);<br>
-    }<br>
-<br>
-    // create chunk for symbol strings<br>
-    // pad end of string pool to 4-bytes<br>
-    while ((_stringPool.size() % 4) != 0)<br>
-      _stringPool.push_back('\0');<br>
-    fillChunkHeader(chunks[nextIndex++], nextFileOffset, _stringPool,<br>
-                    NCS_Strings);<br>
-<br>
-    // create chunk for referencesV2<br>
-    if (hasReferencesV1)<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset, _referencesV1,<br>
-                      NCS_ReferencesArrayV1);<br>
-<br>
-    // create chunk for referencesV2<br>
-    if (hasReferencesV2)<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset, _referencesV2,<br>
-                      NCS_ReferencesArrayV2);<br>
-<br>
-    // create chunk for target table<br>
-    if (hasTargetsTable) {<br>
-      NativeChunk& cht = chunks[nextIndex++];<br>
-      cht.signature = NCS_TargetsTable;<br>
-      cht.fileOffset = nextFileOffset;<br>
-      cht.fileSize = _targetsTableIndex.size() * sizeof(uint32_t);<br>
-      cht.elementCount = _targetsTableIndex.size();<br>
-      nextFileOffset = cht.fileOffset + cht.fileSize;<br>
-    }<br>
-<br>
-    // create chunk for addend table<br>
-    if (hasAddendTable) {<br>
-      NativeChunk& chad = chunks[nextIndex++];<br>
-      chad.signature = NCS_AddendsTable;<br>
-      chad.fileOffset = nextFileOffset;<br>
-      chad.fileSize = _addendsTableIndex.size() * sizeof(Reference::Addend);<br>
-      chad.elementCount = _addendsTableIndex.size();<br>
-      nextFileOffset = chad.fileOffset + chad.fileSize;<br>
-    }<br>
-<br>
-    // create chunk for content<br>
-    if (hasContent)<br>
-      fillChunkHeader(chunks[nextIndex++], nextFileOffset, _contentPool,<br>
-                      NCS_Content);<br>
-<br>
-    _headerBuffer->fileSize = nextFileOffset;<br>
-  }<br>
-<br>
-  template<class T><br>
-  void fillChunkHeader(NativeChunk &chunk, uint32_t &nextFileOffset,<br>
-                       const std::vector<T> &data, uint32_t signature) {<br>
-    chunk.signature = signature;<br>
-    chunk.fileOffset = nextFileOffset;<br>
-    chunk.fileSize = data.size() * sizeof(T);<br>
-    chunk.elementCount = data.size();<br>
-    nextFileOffset = chunk.fileOffset + chunk.fileSize;<br>
-  }<br>
-<br>
-  // scan header to find particular chunk<br>
-  NativeChunk& findChunk(uint32_t signature) {<br>
-    const uint32_t chunkCount = _headerBuffer->chunkCount;<br>
-    NativeChunk* chunks =<br>
-      reinterpret_cast<NativeChunk*>(reinterpret_cast<char*>(_headerBuffer)<br>
-                                     + sizeof(NativeFileHeader));<br>
-    for (uint32_t i=0; i < chunkCount; ++i) {<br>
-      if ( chunks[i].signature == signature )<br>
-        return chunks[i];<br>
-    }<br>
-    llvm_unreachable("findChunk() signature not found");<br>
-  }<br>
-<br>
-  // append atom name to string pool and return offset<br>
-  uint32_t getNameOffset(const Atom& atom) {<br>
-    return this->getNameOffset(<a href="http://atom.name" target="_blank">atom.name</a>());<br>
-  }<br>
-<br>
-  // check if name is already in pool or append and return offset<br>
-  uint32_t getSharedLibraryNameOffset(StringRef name) {<br>
-    assert(!name.empty());<br>
-    // look to see if this library name was used by another atom<br>
-    for (auto &it : _sharedLibraryNames)<br>
-      if (name.equals(it.first))<br>
-        return it.second;<br>
-    // first use of this library name<br>
-    uint32_t result = this->getNameOffset(name);<br>
-    _sharedLibraryNames.push_back(std::make_pair(name, result));<br>
-    return result;<br>
-  }<br>
-<br>
-  // append atom name to string pool and return offset<br>
-  uint32_t getNameOffset(StringRef name) {<br>
-    if ( name.empty() )<br>
-      return 0;<br>
-    uint32_t result = _stringPool.size();<br>
-    _stringPool.insert(_stringPool.end(), name.begin(), name.end());<br>
-    _stringPool.push_back(0);<br>
-    return result;<br>
-  }<br>
-<br>
-  // append atom cotent to content pool and return offset<br>
-  uint32_t getContentOffset(const DefinedAtom& atom) {<br>
-    if (!atom.occupiesDiskSpace())<br>
-      return 0;<br>
-    uint32_t result = _contentPool.size();<br>
-    ArrayRef<uint8_t> cont = atom.rawContent();<br>
-    _contentPool.insert(_contentPool.end(), cont.begin(), cont.end());<br>
-    return result;<br>
-  }<br>
-<br>
-  // reuse existing attributes entry or create a new one and return offet<br>
-  uint32_t getAttributeOffset(const DefinedAtom& atom) {<br>
-    NativeAtomAttributesV1 attrs = computeAttributesV1(atom);<br>
-    return getOrPushAttribute(_attributes, attrs);<br>
-  }<br>
-<br>
-  uint32_t getAttributeOffset(const AbsoluteAtom& atom) {<br>
-    NativeAtomAttributesV1 attrs = computeAbsoluteAttributes(atom);<br>
-    return getOrPushAttribute(_absAttributes, attrs);<br>
-  }<br>
-<br>
-  uint32_t getOrPushAttribute(std::vector<NativeAtomAttributesV1> &dest,<br>
-                              const NativeAtomAttributesV1 &attrs) {<br>
-    for (size_t i = 0, e = dest.size(); i < e; ++i) {<br>
-      if (!memcmp(&dest[i], &attrs, sizeof(attrs))) {<br>
-        // found that this set of attributes already used, so re-use<br>
-        return i * sizeof(attrs);<br>
-      }<br>
-    }<br>
-    // append new attribute set to end<br>
-    uint32_t result = dest.size() * sizeof(attrs);<br>
-    dest.push_back(attrs);<br>
-    return result;<br>
-  }<br>
-<br>
-  uint32_t sectionNameOffset(const DefinedAtom& atom) {<br>
-    // if section based on content, then no custom section name available<br>
-    if (atom.sectionChoice() == DefinedAtom::sectionBasedOnContent)<br>
-      return 0;<br>
-    StringRef name = atom.customSectionName();<br>
-    assert(!name.empty());<br>
-    // look to see if this section name was used by another atom<br>
-    for (auto &it : _sectionNames)<br>
-      if (name.equals(it.first))<br>
-        return it.second;<br>
-    // first use of this section name<br>
-    uint32_t result = this->getNameOffset(name);<br>
-    _sectionNames.push_back(std::make_pair(name, result));<br>
-    return result;<br>
-  }<br>
-<br>
-  NativeAtomAttributesV1 computeAttributesV1(const DefinedAtom& atom) {<br>
-    NativeAtomAttributesV1 attrs;<br>
-    attrs.sectionNameOffset = sectionNameOffset(atom);<br>
-    attrs.align             = atom.alignment().value;<br>
-    attrs.alignModulus      = atom.alignment().modulus;<br>
-    attrs.scope             = atom.scope();<br>
-    attrs.interposable      = atom.interposable();<br>
-    attrs.merge             = atom.merge();<br>
-    attrs.contentType       = atom.contentType();<br>
-    attrs.sectionChoice     = atom.sectionChoice();<br>
-    attrs.deadStrip         = atom.deadStrip();<br>
-    attrs.dynamicExport     = atom.dynamicExport();<br>
-    attrs.codeModel         = atom.codeModel();<br>
-    attrs.permissions       = atom.permissions();<br>
-    return attrs;<br>
-  }<br>
-<br>
-  NativeAtomAttributesV1 computeAbsoluteAttributes(const AbsoluteAtom& atom) {<br>
-    NativeAtomAttributesV1 attrs;<br>
-    attrs.scope = atom.scope();<br>
-    return attrs;<br>
-  }<br>
-<br>
-  // add references for this atom in a contiguous block in NCS_ReferencesArrayV2<br>
-  uint32_t getReferencesIndex(const DefinedAtom& atom, unsigned& refsCount) {<br>
-    size_t startRefSize = _referencesV2.size();<br>
-    uint32_t result = startRefSize;<br>
-    for (const Reference *ref : atom) {<br>
-      NativeReferenceIvarsV2 nref;<br>
-      nref.offsetInAtom = ref->offsetInAtom();<br>
-      nref.kindNamespace = (uint8_t)ref->kindNamespace();<br>
-      nref.kindArch = (uint8_t)ref->kindArch();<br>
-      nref.kindValue = ref->kindValue();<br>
-      nref.targetIndex = this->getTargetIndex(ref->target());<br>
-      nref.addend = ref->addend();<br>
-      nref.tag = ref->tag();<br>
-      _referencesV2.push_back(nref);<br>
-    }<br>
-    refsCount = _referencesV2.size() - startRefSize;<br>
-    return (refsCount == 0) ? 0 : result;<br>
-  }<br>
-<br>
-  uint32_t getTargetIndex(const Atom* target) {<br>
-    if ( target == nullptr )<br>
-      return NativeReferenceIvarsV2::noTarget;<br>
-    TargetToIndex::const_iterator pos = _targetsTableIndex.find(target);<br>
-    if ( pos != _targetsTableIndex.end() ) {<br>
-      return pos->second;<br>
-    }<br>
-    uint32_t result = _targetsTableIndex.size();<br>
-    _targetsTableIndex[target] = result;<br>
-    return result;<br>
-  }<br>
-<br>
-  void writeTargetTable(raw_ostream &out) {<br>
-    // Build table of target indexes<br>
-    uint32_t maxTargetIndex = _targetsTableIndex.size();<br>
-    assert(maxTargetIndex > 0);<br>
-    std::vector<uint32_t> targetIndexes(maxTargetIndex);<br>
-    for (auto &it : _targetsTableIndex) {<br>
-      const Atom* atom = it.first;<br>
-      uint32_t targetIndex = it.second;<br>
-      assert(targetIndex < maxTargetIndex);<br>
-<br>
-      TargetToIndex::iterator pos = _definedAtomIndex.find(atom);<br>
-      if (pos != _definedAtomIndex.end()) {<br>
-        targetIndexes[targetIndex] = pos->second;<br>
-        continue;<br>
-      }<br>
-      uint32_t base = _definedAtomIvars.size();<br>
-<br>
-      pos = _undefinedAtomIndex.find(atom);<br>
-      if (pos != _undefinedAtomIndex.end()) {<br>
-        targetIndexes[targetIndex] = pos->second + base;<br>
-        continue;<br>
-      }<br>
-      base += _undefinedAtomIndex.size();<br>
-<br>
-      pos = _sharedLibraryAtomIndex.find(atom);<br>
-      if (pos != _sharedLibraryAtomIndex.end()) {<br>
-        targetIndexes[targetIndex] = pos->second + base;<br>
-        continue;<br>
-      }<br>
-      base += _sharedLibraryAtomIndex.size();<br>
-<br>
-      pos = _absoluteAtomIndex.find(atom);<br>
-      assert(pos != _absoluteAtomIndex.end());<br>
-      targetIndexes[targetIndex] = pos->second + base;<br>
-    }<br>
-    // write table<br>
-    out.write((char*)&targetIndexes[0], maxTargetIndex * sizeof(uint32_t));<br>
-  }<br>
-<br>
-  uint32_t getAddendIndex(Reference::Addend addend) {<br>
-    if ( addend == 0 )<br>
-      return 0; // addend index zero is used to mean "no addend"<br>
-    AddendToIndex::const_iterator pos = _addendsTableIndex.find(addend);<br>
-    if ( pos != _addendsTableIndex.end() ) {<br>
-      return pos->second;<br>
-    }<br>
-    uint32_t result = _addendsTableIndex.size() + 1; // one-based index<br>
-    _addendsTableIndex[addend] = result;<br>
-    return result;<br>
-  }<br>
-<br>
-  void writeAddendTable(raw_ostream &out) {<br>
-    // Build table of addends<br>
-    uint32_t maxAddendIndex = _addendsTableIndex.size();<br>
-    std::vector<Reference::Addend> addends(maxAddendIndex);<br>
-    for (auto &it : _addendsTableIndex) {<br>
-      Reference::Addend addend = it.first;<br>
-      uint32_t index = it.second;<br>
-      assert(index <= maxAddendIndex);<br>
-      addends[index-1] = addend;<br>
-    }<br>
-    // write table<br>
-    out.write((char*)&addends[0], maxAddendIndex*sizeof(Reference::Addend));<br>
-  }<br>
-<br>
-  typedef std::vector<std::pair<StringRef, uint32_t>> NameToOffsetVector;<br>
-<br>
-  typedef llvm::DenseMap<const Atom*, uint32_t> TargetToIndex;<br>
-  typedef llvm::DenseMap<Reference::Addend, uint32_t> AddendToIndex;<br>
-<br>
-  NativeFileHeader*                       _headerBuffer;<br>
-  size_t                                  _headerBufferSize;<br>
-  std::vector<char>                       _stringPool;<br>
-  std::vector<uint8_t>                    _contentPool;<br>
-  std::vector<NativeDefinedAtomIvarsV1>   _definedAtomIvars;<br>
-  std::vector<NativeAtomAttributesV1>     _attributes;<br>
-  std::vector<NativeAtomAttributesV1>     _absAttributes;<br>
-  std::vector<NativeUndefinedAtomIvarsV1> _undefinedAtomIvars;<br>
-  std::vector<NativeSharedLibraryAtomIvarsV1> _sharedLibraryAtomIvars;<br>
-  std::vector<NativeAbsoluteAtomIvarsV1>  _absoluteAtomIvars;<br>
-  std::vector<NativeReferenceIvarsV1>     _referencesV1;<br>
-  std::vector<NativeReferenceIvarsV2>     _referencesV2;<br>
-  TargetToIndex                           _targetsTableIndex;<br>
-  TargetToIndex                           _definedAtomIndex;<br>
-  TargetToIndex                           _undefinedAtomIndex;<br>
-  TargetToIndex                           _sharedLibraryAtomIndex;<br>
-  TargetToIndex                           _absoluteAtomIndex;<br>
-  AddendToIndex                           _addendsTableIndex;<br>
-  NameToOffsetVector                      _sectionNames;<br>
-  NameToOffsetVector                      _sharedLibraryNames;<br>
-};<br>
-} // end namespace native<br>
-<br>
-std::unique_ptr<Writer> createWriterNative() {<br>
-  return std::unique_ptr<Writer>(new native::Writer());<br>
-}<br>
-} // end namespace lld<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Fri Apr 10 16:23:51 2015<br>
@@ -312,11 +312,10 @@ std::error_code FileCOFF::doParse() {<br>
<br>
   if (getMachineType() != llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN &&<br>
       getMachineType() != _ctx.getMachineType()) {<br>
-    llvm::errs() << "module machine type '"<br>
-                 << getMachineName(getMachineType())<br>
-                 << "' conflicts with target machine type '"<br>
-                 << getMachineName(_ctx.getMachineType()) << "'\n";<br>
-    return NativeReaderError::conflicting_target_machine;<br>
+    return make_dynamic_error_code(Twine("module machine type '") +<br>
+                                   getMachineName(getMachineType()) +<br>
+                                   "' conflicts with target machine type '" +<br>
+                                   getMachineName(_ctx.getMachineType()) + "'");<br>
   }<br>
<br>
   if (std::error_code ec = getReferenceArch(_referenceArch))<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp?rev=234641&r1=234640&r2=234641&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp?rev=234641&r1=234640&r2=234641&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp Fri Apr 10 16:23:51 2015<br>
@@ -257,7 +257,7 @@ public:<br>
<br>
     // Check if the total size is valid.<br>
     if (std::size_t(end - buf) != sizeof(COFF::ImportHeader) + dataSize)<br>
-      return make_error_code(NativeReaderError::unknown_file_format);<br>
+      return make_dynamic_error_code(StringRef("Broken import library"));<br>
<br>
     uint16_t hint = read16le(buf + offsetof(COFF::ImportHeader, OrdinalHint));<br>
     StringRef symbolName(buf + sizeof(COFF::ImportHeader));<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>