From 1e26c748782b3e52215c0a994c435e87fff08d38 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 11 Dec 2013 08:40:40 +0000 Subject: [PATCH] [PECOFF] Remove code which is no longer needed because of r197016. llvm-svn: 197018 --- lld/lib/ReaderWriter/PECOFF/IdataPass.cpp | 41 +++-------------------- lld/lib/ReaderWriter/PECOFF/IdataPass.h | 25 +------------- 2 files changed, 6 insertions(+), 60 deletions(-) diff --git a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp index c73cae1675c4..c125cec95e9f 100644 --- a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp +++ b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp @@ -38,9 +38,6 @@ static void addDir32NBReloc(COFFBaseDefinedAtom *atom, const Atom *target, } namespace idata { -class DLLNameAtom; -class HintNameAtom; -class ImportTableEntryAtom; IdataAtom::IdataAtom(Context &context, std::vector data) : COFFLinkerInternalAtom(context.dummyFile, @@ -49,16 +46,12 @@ IdataAtom::IdataAtom(Context &context, std::vector data) } DLLNameAtom::DLLNameAtom(Context &context, StringRef name) - : IdataAtom(context, stringRefToVector(name)) { - context.dllNameAtoms.push_back(this); -} + : IdataAtom(context, stringRefToVector(name)) {} HintNameAtom::HintNameAtom(Context &context, uint16_t hint, StringRef importName) : IdataAtom(context, assembleRawContent(hint, importName)), - _importName(importName) { - context.hintNameAtoms.push_back(this); -} + _importName(importName) {} std::vector HintNameAtom::assembleRawContent(uint16_t hint, StringRef importName) { @@ -115,7 +108,8 @@ std::vector ImportDirectoryAtom::createImportTableAtoms( } else { // Import by name entry = new (_alloc) ImportTableEntryAtom(context, 0, sectionName); - HintNameAtom *hintName = createHintNameAtom(context, atom); + HintNameAtom *hintName = + new (_alloc) HintNameAtom(context, atom->hint(), atom->importName()); addDir32NBReloc(entry, hintName); } ret.push_back(entry); @@ -127,11 +121,6 @@ std::vector ImportDirectoryAtom::createImportTableAtoms( return ret; } -HintNameAtom *ImportDirectoryAtom::createHintNameAtom( - Context &context, const COFFSharedLibraryAtom *atom) const { - return new (_alloc) HintNameAtom(context, atom->hint(), atom->importName()); -} - } // namespace idata void IdataPass::perform(std::unique_ptr &file) { @@ -144,14 +133,13 @@ void IdataPass::perform(std::unique_ptr &file) { for (auto i : sharedAtoms) { StringRef loadName = i.first; std::vector &atoms = i.second; - createImportDirectory(context, loadName, atoms); + new (_alloc) idata::ImportDirectoryAtom(context, loadName, atoms); } // All atoms, including those of tyep NullImportDirectoryAtom, are added to // context.file in the IdataAtom's constructor. new (_alloc) idata::NullImportDirectoryAtom(context); - connectAtoms(context); replaceSharedLibraryAtoms(context); } @@ -169,25 +157,6 @@ IdataPass::groupByLoadName(MutableFile &file) { return ret; } -void IdataPass::createImportDirectory( - idata::Context &context, StringRef loadName, - std::vector &dllAtoms) { - new (_alloc) idata::ImportDirectoryAtom(context, loadName, dllAtoms); -} - -template -void IdataPass::appendAtoms(std::vector &vec1, - const std::vector &vec2) { - vec1.insert(vec1.end(), vec2.begin(), vec2.end()); -} - -void IdataPass::connectAtoms(idata::Context &context) { - std::vector atoms; - appendAtoms(atoms, context.dllNameAtoms); - appendAtoms(atoms, context.hintNameAtoms); - coff::connectAtomsWithLayoutEdge(atoms); -} - /// Transforms a reference to a COFFSharedLibraryAtom to a real reference. void IdataPass::replaceSharedLibraryAtoms(idata::Context &context) { for (const DefinedAtom *atom : context.file.defined()) { diff --git a/lld/lib/ReaderWriter/PECOFF/IdataPass.h b/lld/lib/ReaderWriter/PECOFF/IdataPass.h index b9fa689dfb61..e85bc5ec7e6c 100644 --- a/lld/lib/ReaderWriter/PECOFF/IdataPass.h +++ b/lld/lib/ReaderWriter/PECOFF/IdataPass.h @@ -49,19 +49,8 @@ class ImportTableEntryAtom; // A state object of this pass. struct Context { Context(MutableFile &f, IdataPassFile &g) : file(f), dummyFile(g) {} - MutableFile &file; IdataPassFile &dummyFile; - - // The object to accumulate idata atoms. Idata atoms need to be grouped by - // type and be continuous in the output file. To force such layout, we - // accumulate all atoms created in the pass in the following vectors, and add - // layout edges when finishing the pass. - std::vector importDirectories; - std::vector hintNameAtoms; - std::vector dllNameAtoms; - - std::map sharedToDefinedAtom; }; /// The root class of all idata atoms. @@ -126,7 +115,6 @@ public: const std::vector &sharedAtoms) : IdataAtom(context, std::vector(20, 0)) { addRelocations(context, loadName, sharedAtoms); - context.importDirectories.push_back(this); } virtual StringRef customSectionName() const { return ".idata.d"; } @@ -138,8 +126,6 @@ private: std::vector createImportTableAtoms( Context &context, const std::vector &sharedAtoms, bool shouldAddReference, StringRef sectionName) const; - HintNameAtom *createHintNameAtom(Context &context, - const COFFSharedLibraryAtom *atom) const; mutable llvm::BumpPtrAllocator _alloc; }; @@ -148,9 +134,7 @@ private: class NullImportDirectoryAtom : public IdataAtom { public: explicit NullImportDirectoryAtom(Context &context) - : IdataAtom(context, std::vector(20, 0)) { - context.importDirectories.push_back(this); - } + : IdataAtom(context, std::vector(20, 0)) {} virtual StringRef customSectionName() const { return ".idata.d"; } }; @@ -182,13 +166,6 @@ private: std::map > groupByLoadName(MutableFile &file); - void createImportDirectory(idata::Context &context, StringRef loadName, - std::vector &dllAtoms); - - template - void appendAtoms(std::vector &vec1, const std::vector &vec2); - - void connectAtoms(idata::Context &context); void replaceSharedLibraryAtoms(idata::Context &context); // A dummy file with which all the atoms created in the pass will be