Factor out core linking options from Platform in a new ResolverOptions
class.  Change Resolver to no longer use Platform.  Core linking
now issues errors directly.  We need to factor that out later.

Rework how Darwin executable writer finds "main" atom.  It now
adds to core linking an Atom  which has a Reference to "main".  

llvm-svn: 155060
diff --git a/lld/lib/Core/YamlWriter.cpp b/lld/lib/Core/YamlWriter.cpp
index c5f45c9..e056eb8 100644
--- a/lld/lib/Core/YamlWriter.cpp
+++ b/lld/lib/Core/YamlWriter.cpp
@@ -56,11 +56,12 @@
       // Find references to unnamed atoms and create ref-names for them.
       for (const Reference *ref : *atom) {
         // create refname for any unnamed reference target
-        if ( ref->target()->name().empty() ) {
+        const Atom *target = ref->target();
+        if ( (target != nullptr) && target->name().empty() ) {
           std::string Storage;
           llvm::raw_string_ostream Buffer(Storage);
           Buffer << llvm::format("L%03d", _unnamedCounter++);
-          _refNames[ref->target()] = Buffer.str();
+          _refNames[target] = Buffer.str();
         }
       }
     }