From c778aa4a302e68a5090ee4fcd64628df24b9beea Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 28 Feb 2016 16:27:08 +0000 Subject: [PATCH] Delete more COFF and ELF bits from the old linker. llvm-svn: 262184 --- lld/include/lld/Core/File.h | 8 ------- lld/include/lld/Core/Reader.h | 3 +-- lld/include/lld/Core/SharedLibraryFile.h | 3 +-- lld/include/lld/Core/UndefinedAtom.h | 8 ------- lld/include/lld/Core/Writer.h | 4 ++-- lld/lib/Core/Resolver.cpp | 11 ---------- lld/lib/Core/SymbolTable.cpp | 17 +-------------- lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp | 9 ++------ lld/test/core/undef-fallback.objtxt | 29 -------------------------- 9 files changed, 7 insertions(+), 85 deletions(-) delete mode 100644 lld/test/core/undef-fallback.objtxt diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h index 82d1796..71c03e0 100644 --- a/lld/include/lld/Core/File.h +++ b/lld/include/lld/Core/File.h @@ -146,14 +146,6 @@ public: std::error_code parse(); - // This function is called just before the core linker tries to use - // a file. Currently the PECOFF reader uses this to trigger the - // driver to parse .drectve section (which contains command line options). - // If you want to do something having side effects, don't do that in - // doParse() because a file could be pre-loaded speculatively. - // Use this hook instead. - virtual void beforeLink() {} - // Usually each file owns a std::unique_ptr. // However, there's one special case. If a file is an archive file, // the archive file and its children all shares the same memory buffer. diff --git a/lld/include/lld/Core/Reader.h b/lld/include/lld/Core/Reader.h index 03e2a9e..66df4380 100644 --- a/lld/include/lld/Core/Reader.h +++ b/lld/include/lld/Core/Reader.h @@ -34,8 +34,7 @@ class MachOLinkingContext; /// \brief An abstract class for reading object files, library files, and /// executable files. /// -/// Each file format (e.g. ELF, mach-o, PECOFF, etc) have a concrete -/// subclass of Reader. +/// Each file format (e.g. mach-o, etc) has a concrete subclass of Reader. class Reader { public: virtual ~Reader() {} diff --git a/lld/include/lld/Core/SharedLibraryFile.h b/lld/include/lld/Core/SharedLibraryFile.h index a290728..2e4771f 100644 --- a/lld/include/lld/Core/SharedLibraryFile.h +++ b/lld/include/lld/Core/SharedLibraryFile.h @@ -30,8 +30,7 @@ public: virtual const SharedLibraryAtom *exports(StringRef name, bool dataSymbolOnly) const = 0; - // Returns DSO name. It's the soname (ELF), the install name (MachO) or - // the import name (Windows). + // Returns the install name. virtual StringRef getDSOName() const = 0; const AtomVector &defined() const override { diff --git a/lld/include/lld/Core/UndefinedAtom.h b/lld/include/lld/Core/UndefinedAtom.h index 7a835a4..3e58f80 100644 --- a/lld/include/lld/Core/UndefinedAtom.h +++ b/lld/include/lld/Core/UndefinedAtom.h @@ -57,14 +57,6 @@ public: static bool classof(const UndefinedAtom *) { return true; } - /// Returns an undefined atom if this undefined symbol has a synonym. This is - /// mainly used in COFF. In COFF, an unresolved external symbol can have up to - /// one optional name (sym2) in addition to its regular name (sym1). If a - /// definition of sym1 exists, sym1 is resolved normally. Otherwise, all - /// references to sym1 refer to sym2 instead. In that case sym2 must be - /// resolved, or link will fail. - virtual const UndefinedAtom *fallback() const { return nullptr; } - protected: UndefinedAtom() : Atom(definitionUndefined) {} }; diff --git a/lld/include/lld/Core/Writer.h b/lld/include/lld/Core/Writer.h index 398be9e..38db0ff 100644 --- a/lld/include/lld/Core/Writer.h +++ b/lld/include/lld/Core/Writer.h @@ -20,8 +20,8 @@ class LinkingContext; class MachOLinkingContext; /// \brief The Writer is an abstract class for writing object files, shared -/// library files, and executable files. Each file format (e.g. ELF, mach-o, -/// PECOFF, etc) have a concrete subclass of Writer. +/// library files, and executable files. Each file format (e.g. mach-o, etc) +/// has a concrete subclass of Writer. class Writer { public: virtual ~Writer(); diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 840cbbe..de98fb8 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -98,7 +98,6 @@ ErrorOr Resolver::handleArchiveFile(File &file) { bool dataSymbolOnly)->ErrorOr { if (File *member = archiveFile->find(undefName, dataSymbolOnly)) { member->setOrdinal(_ctx.getNextOrdinalAndIncrement()); - member->beforeLink(); updatePreloadArchiveMap(); return handleFile(*member); } @@ -142,15 +141,6 @@ bool Resolver::doUndefinedAtom(const UndefinedAtom &atom) { if (newUndefAdded) _undefines.push_back(atom.name()); - // If the undefined symbol has an alternative name, try to resolve the - // symbol with the name to give it a second chance. This feature is used - // for COFF "weak external" symbol. - if (newUndefAdded || !_symbolTable.isDefined(atom.name())) { - if (const UndefinedAtom *fallbackAtom = atom.fallback()) { - doUndefinedAtom(*fallbackAtom); - _symbolTable.addReplacement(&atom, fallbackAtom); - } - } return newUndefAdded; } @@ -297,7 +287,6 @@ bool Resolver::resolveUndefines() { } DEBUG_WITH_TYPE("resolver", llvm::dbgs() << "Loaded file: " << file->path() << "\n"); - file->beforeLink(); updatePreloadArchiveMap(); switch (file->kind()) { case File::kindErrorObject: diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp index 9382db9..99e8547 100644 --- a/lld/lib/Core/SymbolTable.cpp +++ b/lld/lib/Core/SymbolTable.cpp @@ -196,23 +196,8 @@ bool SymbolTable::addByName(const Atom &newAtom) { << " and in " << newUndef->file().path() << "\n"; } - const UndefinedAtom *existingFallback = existingUndef->fallback(); - const UndefinedAtom *newFallback = newUndef->fallback(); - bool hasDifferentFallback = - (existingFallback && newFallback && - existingFallback->name() != newFallback->name()); - if (hasDifferentFallback) { - llvm::errs() << "lld warning: undefined symbol " - << existingUndef->name() << " has different fallback: " - << existingFallback->name() << " in " - << existingUndef->file().path() << " and " - << newFallback->name() << " in " - << newUndef->file().path() << "\n"; - } - - bool hasNewFallback = newUndef->fallback(); if (sameCanBeNull) - useNew = hasNewFallback; + useNew = false; else useNew = (newUndef->canBeNull() < existingUndef->canBeNull()); break; diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp index 151d204..550b30f 100644 --- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp +++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp @@ -940,12 +940,11 @@ template <> struct MappingTraits { class NormalizedAtom : public lld::UndefinedAtom { public: NormalizedAtom(IO &io) - : _file(fileFromContext(io)), _name(), _canBeNull(canBeNullNever), - _fallback(nullptr) {} + : _file(fileFromContext(io)), _name(), _canBeNull(canBeNullNever) {} NormalizedAtom(IO &io, const lld::UndefinedAtom *atom) : _file(fileFromContext(io)), _name(atom->name()), - _canBeNull(atom->canBeNull()), _fallback(atom->fallback()) {} + _canBeNull(atom->canBeNull()) {} const lld::UndefinedAtom *denormalize(IO &io) { YamlContext *info = reinterpret_cast(io.getContext()); @@ -973,12 +972,10 @@ template <> struct MappingTraits { const lld::File &file() const override { return _file; } StringRef name() const override { return _name; } CanBeNull canBeNull() const override { return _canBeNull; } - const UndefinedAtom *fallback() const override { return _fallback; } const lld::File &_file; StringRef _name; CanBeNull _canBeNull; - const UndefinedAtom *_fallback; }; static void mapping(IO &io, const lld::UndefinedAtom *&atom) { @@ -988,8 +985,6 @@ template <> struct MappingTraits { io.mapRequired("name", keys->_name); io.mapOptional("can-be-null", keys->_canBeNull, lld::UndefinedAtom::canBeNullNever); - io.mapOptional("fallback", keys->_fallback, - (const lld::UndefinedAtom *)nullptr); } }; diff --git a/lld/test/core/undef-fallback.objtxt b/lld/test/core/undef-fallback.objtxt deleted file mode 100644 index aef7b6d..0000000 --- a/lld/test/core/undef-fallback.objtxt +++ /dev/null @@ -1,29 +0,0 @@ -# RUN: lld -core %p/undef-fallback.objtxt %p/Inputs/undef-fallback.objtxt | FileCheck %s - -# Test that fallback atoms can be parsed by YAML reader and processed by the -# core linker. - ---- -defined-atoms: - - name: def1 - scope: global - -undefined-atoms: - - name: undef1 - fallback: - name: fallback1 - - name: undef2 - fallback: - name: fallback2 -... - -# CHECK: defined-atoms: -# CHECK-NEXT: - name: def1 -# CHECK-NEXT: scope: global -# CHECK-NEXT: - name: fallback1 -# CHECK-NEXT: ref-name: fallback1 -# CHECK-NEXT: undefined-atoms: -# CHECK-NEXT: - name: fallback1 -# CHECK-NEXT: - name: fallback2 - -# CHECK-NOT: - name: fallback3 -- 2.7.4