summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2013-01-22 20:49:42 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2013-01-22 20:49:42 +0000
commit4586fbcbadbb7b4240de056aacc659c4aea2e861 (patch)
treef9b18def7c6a2c4ad6d513286246aad8a1b6f0b7 /lld/lib/Core
parent0c0c02c479cf6f3959d895c1b49ee91b726849aa (diff)
downloadbcm5719-llvm-4586fbcbadbb7b4240de056aacc659c4aea2e861.tar.gz
bcm5719-llvm-4586fbcbadbb7b4240de056aacc659c4aea2e861.zip
[Core] Move Resolver and SymbolTable over to TargetInfo.
No functionality change. llvm-svn: 173192
Diffstat (limited to 'lld/lib/Core')
-rw-r--r--lld/lib/Core/Resolver.cpp28
-rw-r--r--lld/lib/Core/SymbolTable.cpp17
2 files changed, 25 insertions, 20 deletions
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 7e0d2e2895b..f53152b2ec9 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 @@ void Resolver::doDefinedAtom(const DefinedAtom &atom) {
// 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 @@ void Resolver::addAtoms(const std::vector<const DefinedAtom*>& newAtoms) {
// 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 @@ void Resolver::markLive(const Atom &atom) {
// 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 @@ void Resolver::deadStripOptimize() {
}
// 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 @@ void Resolver::checkUndefines(bool final) {
// 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 @@ void Resolver::checkUndefines(bool final) {
}
// 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 1c7ea99ff05..7a35ed90144 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 @@ void SymbolTable::addByName(const Atom & newAtom) {
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 @@ void SymbolTable::addByName(const Atom & newAtom) {
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 @@ void SymbolTable::addByName(const Atom & newAtom) {
}
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()
OpenPOWER on IntegriCloud