From be5e0b07caa02a527681c6eb3bb64fcfcff862c3 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 28 Feb 2016 21:59:02 +0000 Subject: [PATCH] Remove dead code for ELF. llvm-svn: 262195 --- lld/include/lld/Core/LinkingContext.h | 53 --------------------------------- lld/include/lld/Core/Node.h | 6 +--- lld/include/lld/Core/Resolver.h | 2 +- lld/include/lld/Core/SymbolTable.h | 3 -- lld/lib/Core/LinkingContext.cpp | 5 +--- lld/lib/Core/SymbolTable.cpp | 56 +++++++---------------------------- 6 files changed, 13 insertions(+), 112 deletions(-) diff --git a/lld/include/lld/Core/LinkingContext.h b/lld/include/lld/Core/LinkingContext.h index acde577..ff1e352 100644 --- a/lld/include/lld/Core/LinkingContext.h +++ b/lld/include/lld/Core/LinkingContext.h @@ -111,35 +111,6 @@ public: /// whether core linking considers remaining undefines to be an error. bool allowRemainingUndefines() const { return _allowRemainingUndefines; } - /// In the lld model, a SharedLibraryAtom is a proxy atom for something - /// that will be found in a dynamic shared library when the program runs. - /// A SharedLibraryAtom optionally contains the name of the shared library - /// in which to find the symbol name at runtime. Core linking may merge - /// two SharedLibraryAtom with the same name. If this method returns true, - /// when merging core linking will also verify that they both have the same - /// loadName() and if not print a warning. - /// - /// \todo This should be a method core linking calls so that drivers can - /// format the warning as needed. - bool warnIfCoalesableAtomsHaveDifferentLoadName() const { - return _warnIfCoalesableAtomsHaveDifferentLoadName; - } - - /// In C/C++ you can mark a function's prototype with - /// __attribute__((weak_import)) or __attribute__((weak)) to say the function - /// may not be available at runtime and/or build time and in which case its - /// address will evaluate to NULL. In lld this is modeled using the - /// UndefinedAtom::canBeNull() method. During core linking, UndefinedAtom - /// with the same name are automatically merged. If this method returns - /// true, core link also verfies that the canBeNull() value for merged - /// UndefinedAtoms are the same and warns if not. - /// - /// \todo This should be a method core linking calls so that drivers can - /// format the warning as needed. - bool warnIfCoalesableAtomsHaveDifferentCanBeNull() const { - return _warnIfCoalesableAtomsHaveDifferentCanBeNull; - } - /// Normally, every UndefinedAtom must be replaced by a DefinedAtom or a /// SharedLibraryAtom for the link to be successful. This method controls /// whether core linking considers remaining undefines from the shared library @@ -173,7 +144,6 @@ public: } void setDeadStripping(bool enable) { _deadStrip = enable; } - void setAllowDuplicates(bool enable) { _allowDuplicates = enable; } void setGlobalsAreDeadStripRoots(bool v) { _globalsAreDeadStripRoots = v; } void setSearchArchivesToOverrideTentativeDefinitions(bool search) { _searchArchivesToOverrideTentativeDefinitions = search; @@ -181,12 +151,6 @@ public: void setSearchSharedLibrariesToOverrideTentativeDefinitions(bool search) { _searchSharedLibrariesToOverrideTentativeDefinitions = search; } - void setWarnIfCoalesableAtomsHaveDifferentCanBeNull(bool warn) { - _warnIfCoalesableAtomsHaveDifferentCanBeNull = warn; - } - void setWarnIfCoalesableAtomsHaveDifferentLoadName(bool warn) { - _warnIfCoalesableAtomsHaveDifferentLoadName = warn; - } void setPrintRemainingUndefines(bool print) { _printRemainingUndefines = print; } @@ -196,22 +160,11 @@ public: void setAllowShlibUndefines(bool allow) { _allowShlibUndefines = allow; } void setLogInputFiles(bool log) { _logInputFiles = log; } - // Returns true if multiple definitions should not be treated as a - // fatal error. - bool getAllowDuplicates() const { return _allowDuplicates; } - void appendLLVMOption(const char *opt) { _llvmOptions.push_back(opt); } std::vector> &getNodes() { return _nodes; } const std::vector> &getNodes() const { return _nodes; } - /// Notify the LinkingContext when the symbol table found a name collision. - /// The useNew parameter specifies which the symbol table plans to keep, - /// but that can be changed by the LinkingContext. This is also an - /// opportunity for flavor specific processing. - virtual void notifySymbolTableCoalesce(const Atom *existingAtom, - const Atom *newAtom, bool &useNew) {} - /// This method adds undefined symbols specified by the -u option to the to /// the list of undefined symbols known to the linker. This option essentially /// forces an undefined symbol to be created. You may also need to call @@ -323,18 +276,12 @@ protected: virtual std::unique_ptr createUndefinedSymbolFile() const; std::unique_ptr createUndefinedSymbolFile(StringRef filename) const; - /// Method to create an internal file for alias symbols - std::unique_ptr createAliasSymbolFile() const; - StringRef _outputPath; StringRef _entrySymbolName; bool _deadStrip; - bool _allowDuplicates; bool _globalsAreDeadStripRoots; bool _searchArchivesToOverrideTentativeDefinitions; bool _searchSharedLibrariesToOverrideTentativeDefinitions; - bool _warnIfCoalesableAtomsHaveDifferentCanBeNull; - bool _warnIfCoalesableAtomsHaveDifferentLoadName; bool _printRemainingUndefines; bool _allowRemainingUndefines; bool _logInputFiles; diff --git a/lld/include/lld/Core/Node.h b/lld/include/lld/Core/Node.h index cd38fbd..8de0ecd 100644 --- a/lld/include/lld/Core/Node.h +++ b/lld/include/lld/Core/Node.h @@ -57,7 +57,7 @@ private: class FileNode : public Node { public: explicit FileNode(std::unique_ptr f) - : Node(Node::Kind::File), _file(std::move(f)), _asNeeded(false) {} + : Node(Node::Kind::File), _file(std::move(f)) {} static bool classof(const Node *a) { return a->kind() == Node::Kind::File; @@ -65,12 +65,8 @@ public: File *getFile() { return _file.get(); } - void setAsNeeded(bool val) { _asNeeded = val; } - bool asNeeded() const { return _asNeeded; } - protected: std::unique_ptr _file; - bool _asNeeded; }; } // namespace lld diff --git a/lld/include/lld/Core/Resolver.h b/lld/include/lld/Core/Resolver.h index 0a37e79..cc82c5d 100644 --- a/lld/include/lld/Core/Resolver.h +++ b/lld/include/lld/Core/Resolver.h @@ -33,7 +33,7 @@ class LinkingContext; class Resolver { public: Resolver(LinkingContext &ctx) - : _ctx(ctx), _symbolTable(ctx), _result(new MergedFile()), + : _ctx(ctx), _symbolTable(), _result(new MergedFile()), _fileIndex(0) {} // InputFiles::Handler methods diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h index 4bde20d..db610ad 100644 --- a/lld/include/lld/Core/SymbolTable.h +++ b/lld/include/lld/Core/SymbolTable.h @@ -34,8 +34,6 @@ class UndefinedAtom; /// if an atom has been coalesced away. class SymbolTable { public: - explicit SymbolTable(LinkingContext &); - /// @brief add atom to symbol table bool add(const DefinedAtom &); @@ -98,7 +96,6 @@ private: bool addByName(const Atom &); bool addByContent(const DefinedAtom &); - LinkingContext &_ctx; AtomToAtom _replacedAtoms; NameToAtom _nameTable; AtomContentSet _contentTable; diff --git a/lld/lib/Core/LinkingContext.cpp b/lld/lib/Core/LinkingContext.cpp index 54d2c51..75baf7a 100644 --- a/lld/lib/Core/LinkingContext.cpp +++ b/lld/lib/Core/LinkingContext.cpp @@ -16,12 +16,9 @@ namespace lld { LinkingContext::LinkingContext() - : _deadStrip(false), _allowDuplicates(false), - _globalsAreDeadStripRoots(false), + : _deadStrip(false), _globalsAreDeadStripRoots(false), _searchArchivesToOverrideTentativeDefinitions(false), _searchSharedLibrariesToOverrideTentativeDefinitions(false), - _warnIfCoalesableAtomsHaveDifferentCanBeNull(false), - _warnIfCoalesableAtomsHaveDifferentLoadName(false), _printRemainingUndefines(true), _allowRemainingUndefines(false), _logInputFiles(false), _allowShlibUndefines(true), _outputFileType(OutputFileType::Default), _nextOrdinal(0) {} diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp index 99e8547..44631a5 100644 --- a/lld/lib/Core/SymbolTable.cpp +++ b/lld/lib/Core/SymbolTable.cpp @@ -28,8 +28,6 @@ #include namespace lld { -SymbolTable::SymbolTable(LinkingContext &context) : _ctx(context) {} - bool SymbolTable::add(const UndefinedAtom &atom) { return addByName(atom); } bool SymbolTable::add(const SharedLibraryAtom &atom) { return addByName(atom); } @@ -166,19 +164,16 @@ bool SymbolTable::addByName(const Atom &newAtom) { // fallthrough } case MCR_Error: - if (!_ctx.getAllowDuplicates()) { - llvm::errs() << "Duplicate symbols: " - << existing->name() - << ":" - << existing->file().path() - << " and " - << newAtom.name() - << ":" - << newAtom.file().path() - << "\n"; - llvm::report_fatal_error("duplicate symbol error"); - } - useNew = false; + llvm::errs() << "Duplicate symbols: " + << existing->name() + << ":" + << existing->file().path() + << " and " + << newAtom.name() + << ":" + << newAtom.file().path() + << "\n"; + llvm::report_fatal_error("duplicate symbol error"); break; } break; @@ -188,14 +183,6 @@ bool SymbolTable::addByName(const Atom &newAtom) { const UndefinedAtom* newUndef = cast(&newAtom); bool sameCanBeNull = (existingUndef->canBeNull() == newUndef->canBeNull()); - if (!sameCanBeNull && _ctx.warnIfCoalesableAtomsHaveDifferentCanBeNull()) { - llvm::errs() << "lld warning: undefined symbol " - << existingUndef->name() - << " has different weakness in " - << existingUndef->file().path() - << " and in " << newUndef->file().path() << "\n"; - } - if (sameCanBeNull) useNew = false; else @@ -203,26 +190,6 @@ bool SymbolTable::addByName(const Atom &newAtom) { break; } case NCR_DupShLib: { - const SharedLibraryAtom *curShLib = cast(existing); - const SharedLibraryAtom *newShLib = cast(&newAtom); - bool sameNullness = - (curShLib->canBeNullAtRuntime() == newShLib->canBeNullAtRuntime()); - bool sameName = curShLib->loadName().equals(newShLib->loadName()); - if (sameName && !sameNullness && - _ctx.warnIfCoalesableAtomsHaveDifferentCanBeNull()) { - // FIXME: need diagonstics interface for writing warning messages - llvm::errs() << "lld warning: shared library symbol " - << curShLib->name() << " has different weakness in " - << curShLib->file().path() << " and in " - << newShLib->file().path(); - } - if (!sameName && _ctx.warnIfCoalesableAtomsHaveDifferentLoadName()) { - // FIXME: need diagonstics interface for writing warning messages - llvm::errs() << "lld warning: shared library symbol " - << curShLib->name() << " has different load path in " - << curShLib->file().path() << " and in " - << newShLib->file().path(); - } useNew = false; break; } @@ -232,9 +199,6 @@ bool SymbolTable::addByName(const Atom &newAtom) { break; } - // Give context a chance to change which is kept. - _ctx.notifySymbolTableCoalesce(existing, &newAtom, useNew); - if (useNew) { // Update name table to use new atom. _nameTable[name] = &newAtom; -- 2.7.4