[mach-o] Fix stub generation to work for dylibs and bundles

Split up the CRuntimeFile into one part for output types that need an entry
point and another part for output types that use stubs.

Add file 'test/mach-o/Inputs/libSystem.yaml' for use by test cases that
use -dylib and therefore may now need the helper symbol in libSystem.dylib.

llvm-svn: 215602
diff --git a/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp b/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
index e12b881..f0788fa 100644
--- a/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
+++ b/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
@@ -25,30 +25,42 @@
 
 
 //
-// CRuntimeFile adds an UndefinedAtom for "_main" so that the Resolving
+// CEntryFile adds an UndefinedAtom for "_main" so that the Resolving
 // phase will fail if "_main" is undefined.
 //
-class CRuntimeFile : public SimpleFile {
+class CEntryFile : public SimpleFile {
 public:
-  CRuntimeFile(const MachOLinkingContext &context)
-      : SimpleFile("C runtime"), 
-       _undefMain(*this, context.entrySymbolName()),
-       _undefBinder(*this, context.binderSymbolName()) {
-      // only main executables need _main
-      if (context.outputMachOType() == llvm::MachO::MH_EXECUTE) {
-        this->addAtom(_undefMain);
-      }
-      // only dynamic binaries use stubs
-      if (context.needsStubsPass()) {
-        this->addAtom(_undefBinder);
-      }
-   }
+  CEntryFile(const MachOLinkingContext &context)
+      : SimpleFile("C entry"),
+       _undefMain(*this, context.entrySymbolName()) {
+    this->addAtom(_undefMain);
+  }
 
 private:
   SimpleUndefinedAtom   _undefMain;
+};
+
+
+//
+// StubHelperFile adds an UndefinedAtom for "dyld_stub_binder" so that
+// the Resolveing phase will fail if "dyld_stub_binder" is undefined.
+//
+class StubHelperFile : public SimpleFile {
+public:
+  StubHelperFile(const MachOLinkingContext &context)
+      : SimpleFile("stub runtime"),
+        _undefBinder(*this, context.binderSymbolName()) {
+    this->addAtom(_undefBinder);
+  }
+
+private:
   SimpleUndefinedAtom   _undefBinder;
 };
 
+
+
+
+
 } // namespace mach_o
 } // namespace lld