[Core] Move Resolver and SymbolTable over to TargetInfo.

No functionality change.

llvm-svn: 173192
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 7e0d2e2..f53152b 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -9,17 +9,18 @@
 
 #include "lld/Core/Atom.h"
 #include "lld/Core/File.h"
-#include "lld/Core/LLVM.h"
 #include "lld/Core/InputFiles.h"
+#include "lld/Core/LinkerOptions.h"
 #include "lld/Core/LLVM.h"
 #include "lld/Core/Resolver.h"
 #include "lld/Core/SymbolTable.h"
+#include "lld/Core/TargetInfo.h"
 #include "lld/Core/UndefinedAtom.h"
 
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/ErrorHandling.h"
 
 #include <algorithm>
 #include <cassert>
@@ -113,7 +114,7 @@
   // tell symbol table 
   _symbolTable.add(atom);
 
-  if (_options.deadCodeStripping()) {
+  if (_targetInfo.getLinkerOptions()._deadStrip) {
     // add to set of dead-strip-roots, all symbols that
     // the compiler marks as don't strip
     if (atom.deadStrip() == DefinedAtom::deadStripNever)
@@ -166,10 +167,10 @@
 // ask symbol table if any definitionUndefined atoms still exist
 // if so, keep searching libraries until no more atoms being added
 void Resolver::resolveUndefines() {
-  const bool searchArchives =
-    _options.searchArchivesToOverrideTentativeDefinitions();
-  const bool searchSharedLibs =
-    _options.searchSharedLibrariesToOverrideTentativeDefinitions();
+  const bool searchArchives = _targetInfo.getLinkerOptions().
+      _searchArchivesToOverrideTentativeDefinitions;
+  const bool searchSharedLibs = _targetInfo.getLinkerOptions().
+      _searchSharedLibrariesToOverrideTentativeDefinitions;
 
   // keep looping until no more undefines were added in last loop
   unsigned int undefineGenCount = 0xFFFFFFFF;
@@ -243,14 +244,14 @@
 // remove all atoms not actually used
 void Resolver::deadStripOptimize() {
   // only do this optimization with -dead_strip
-  if (!_options.deadCodeStripping())
+  if (!_targetInfo.getLinkerOptions()._deadStrip)
     return;
 
   // clear liveness on all atoms
   _liveAtoms.clear();
 
   // By default, shared libraries are built with all globals as dead strip roots
-  if ( _options.allGlobalsAreDeadStripRoots() ) {
+  if (_targetInfo.getLinkerOptions()._globalsAreDeadStripRoots) {
     for ( const Atom *atom : _atoms ) {
       const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(atom);
       if (defAtom == nullptr)
@@ -261,8 +262,7 @@
   }
 
   // Or, use list of names that are dead stip roots.
-  const std::vector<StringRef> &names = _options.deadStripRootNames();
-  for ( const StringRef &name : names ) {
+  for (const StringRef &name : _targetInfo.getLinkerOptions()._deadStripRoots) {
     const Atom *symAtom = _symbolTable.findByName(name);
     assert(symAtom->definition() != Atom::definitionUndefined);
     _deadStripRoots.insert(symAtom);
@@ -288,7 +288,7 @@
   // build vector of remaining undefined symbols
   std::vector<const Atom *> undefinedAtoms;
   _symbolTable.undefines(undefinedAtoms);
-  if (_options.deadCodeStripping()) {
+  if (_targetInfo.getLinkerOptions()._deadStrip) {
     // When dead code stripping, we don't care if dead atoms are undefined.
     undefinedAtoms.erase(std::remove_if(
                            undefinedAtoms.begin(), undefinedAtoms.end(),
@@ -296,7 +296,9 @@
   }
 
   // error message about missing symbols
-  if ( (undefinedAtoms.size() != 0) && _options.undefinesAreErrors() ) {
+  if (!undefinedAtoms.empty() &&
+      (!_targetInfo.getLinkerOptions()._noInhibitExec ||
+       _targetInfo.getLinkerOptions()._outputKind == OutputKind::Relocatable)) {
     // FIXME: need diagonstics interface for writing error messages
     llvm::errs() << "Undefined symbols:\n";
     for ( const Atom *undefAtom : undefinedAtoms ) {
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp
index 1c7ea99f..7a35ed9 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -8,14 +8,16 @@
 //===----------------------------------------------------------------------===//
 
 #include "lld/Core/SymbolTable.h"
-#include "lld/Core/Atom.h"
 #include "lld/Core/AbsoluteAtom.h"
+#include "lld/Core/Atom.h"
 #include "lld/Core/DefinedAtom.h"
 #include "lld/Core/File.h"
 #include "lld/Core/InputFiles.h"
+#include "lld/Core/LinkerOptions.h"
 #include "lld/Core/LLVM.h"
 #include "lld/Core/Resolver.h"
 #include "lld/Core/SharedLibraryAtom.h"
+#include "lld/Core/TargetInfo.h"
 #include "lld/Core/UndefinedAtom.h"
 
 #include "llvm/ADT/ArrayRef.h"
@@ -29,9 +31,7 @@
 #include <vector>
 
 namespace lld {
-SymbolTable::SymbolTable(ResolverOptions &opts)
-  : _options(opts) {
-}
+SymbolTable::SymbolTable(const TargetInfo &ti) : _targetInfo(ti) {}
 
 void SymbolTable::add(const UndefinedAtom &atom) {
   this->addByName(atom);
@@ -183,7 +183,8 @@
             useNew = false;
           }
           else {
-            if ( _options.warnIfCoalesableAtomsHaveDifferentCanBeNull() ) {
+            if (_targetInfo.getLinkerOptions().
+                    _warnIfCoalesableAtomsHaveDifferentCanBeNull) {
               // FIXME: need diagonstics interface for writing warning messages
               llvm::errs() << "lld warning: undefined symbol "
                            << existingUndef->name()
@@ -208,7 +209,8 @@
           bool sameName = curShLib->loadName().equals(newShLib->loadName());
           if ( !sameName ) {
             useNew = false;
-            if ( _options.warnIfCoalesableAtomsHaveDifferentLoadName() ) {
+            if (_targetInfo.getLinkerOptions().
+                  _warnIfCoalesableAtomsHaveDifferentLoadName) {
               // FIXME: need diagonstics interface for writing warning messages
               llvm::errs() << "lld warning: shared library symbol "
                            << curShLib->name()
@@ -220,7 +222,8 @@
           }
           else if ( ! sameNullness ) {
             useNew = false;
-            if ( _options.warnIfCoalesableAtomsHaveDifferentCanBeNull() ) {
+            if (_targetInfo.getLinkerOptions().
+                    _warnIfCoalesableAtomsHaveDifferentCanBeNull) {
               // FIXME: need diagonstics interface for writing warning messages
               llvm::errs() << "lld warning: shared library symbol "
                            << curShLib->name()