[PECOFF] Remove code which is no longer needed because of r197016.

llvm-svn: 197018
This commit is contained in:
Rui Ueyama 2013-12-11 08:40:40 +00:00
parent b6d333fb09
commit 1e26c74878
2 changed files with 6 additions and 60 deletions

View File

@ -38,9 +38,6 @@ static void addDir32NBReloc(COFFBaseDefinedAtom *atom, const Atom *target,
} }
namespace idata { namespace idata {
class DLLNameAtom;
class HintNameAtom;
class ImportTableEntryAtom;
IdataAtom::IdataAtom(Context &context, std::vector<uint8_t> data) IdataAtom::IdataAtom(Context &context, std::vector<uint8_t> data)
: COFFLinkerInternalAtom(context.dummyFile, : COFFLinkerInternalAtom(context.dummyFile,
@ -49,16 +46,12 @@ IdataAtom::IdataAtom(Context &context, std::vector<uint8_t> data)
} }
DLLNameAtom::DLLNameAtom(Context &context, StringRef name) DLLNameAtom::DLLNameAtom(Context &context, StringRef name)
: IdataAtom(context, stringRefToVector(name)) { : IdataAtom(context, stringRefToVector(name)) {}
context.dllNameAtoms.push_back(this);
}
HintNameAtom::HintNameAtom(Context &context, uint16_t hint, HintNameAtom::HintNameAtom(Context &context, uint16_t hint,
StringRef importName) StringRef importName)
: IdataAtom(context, assembleRawContent(hint, importName)), : IdataAtom(context, assembleRawContent(hint, importName)),
_importName(importName) { _importName(importName) {}
context.hintNameAtoms.push_back(this);
}
std::vector<uint8_t> HintNameAtom::assembleRawContent(uint16_t hint, std::vector<uint8_t> HintNameAtom::assembleRawContent(uint16_t hint,
StringRef importName) { StringRef importName) {
@ -115,7 +108,8 @@ std::vector<ImportTableEntryAtom *> ImportDirectoryAtom::createImportTableAtoms(
} else { } else {
// Import by name // Import by name
entry = new (_alloc) ImportTableEntryAtom(context, 0, sectionName); 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); addDir32NBReloc(entry, hintName);
} }
ret.push_back(entry); ret.push_back(entry);
@ -127,11 +121,6 @@ std::vector<ImportTableEntryAtom *> ImportDirectoryAtom::createImportTableAtoms(
return ret; return ret;
} }
HintNameAtom *ImportDirectoryAtom::createHintNameAtom(
Context &context, const COFFSharedLibraryAtom *atom) const {
return new (_alloc) HintNameAtom(context, atom->hint(), atom->importName());
}
} // namespace idata } // namespace idata
void IdataPass::perform(std::unique_ptr<MutableFile> &file) { void IdataPass::perform(std::unique_ptr<MutableFile> &file) {
@ -144,14 +133,13 @@ void IdataPass::perform(std::unique_ptr<MutableFile> &file) {
for (auto i : sharedAtoms) { for (auto i : sharedAtoms) {
StringRef loadName = i.first; StringRef loadName = i.first;
std::vector<COFFSharedLibraryAtom *> &atoms = i.second; std::vector<COFFSharedLibraryAtom *> &atoms = i.second;
createImportDirectory(context, loadName, atoms); new (_alloc) idata::ImportDirectoryAtom(context, loadName, atoms);
} }
// All atoms, including those of tyep NullImportDirectoryAtom, are added to // All atoms, including those of tyep NullImportDirectoryAtom, are added to
// context.file in the IdataAtom's constructor. // context.file in the IdataAtom's constructor.
new (_alloc) idata::NullImportDirectoryAtom(context); new (_alloc) idata::NullImportDirectoryAtom(context);
connectAtoms(context);
replaceSharedLibraryAtoms(context); replaceSharedLibraryAtoms(context);
} }
@ -169,25 +157,6 @@ IdataPass::groupByLoadName(MutableFile &file) {
return ret; return ret;
} }
void IdataPass::createImportDirectory(
idata::Context &context, StringRef loadName,
std::vector<COFFSharedLibraryAtom *> &dllAtoms) {
new (_alloc) idata::ImportDirectoryAtom(context, loadName, dllAtoms);
}
template <typename T, typename U>
void IdataPass::appendAtoms(std::vector<T *> &vec1,
const std::vector<U *> &vec2) {
vec1.insert(vec1.end(), vec2.begin(), vec2.end());
}
void IdataPass::connectAtoms(idata::Context &context) {
std::vector<COFFBaseDefinedAtom *> atoms;
appendAtoms(atoms, context.dllNameAtoms);
appendAtoms(atoms, context.hintNameAtoms);
coff::connectAtomsWithLayoutEdge(atoms);
}
/// Transforms a reference to a COFFSharedLibraryAtom to a real reference. /// Transforms a reference to a COFFSharedLibraryAtom to a real reference.
void IdataPass::replaceSharedLibraryAtoms(idata::Context &context) { void IdataPass::replaceSharedLibraryAtoms(idata::Context &context) {
for (const DefinedAtom *atom : context.file.defined()) { for (const DefinedAtom *atom : context.file.defined()) {

View File

@ -49,19 +49,8 @@ class ImportTableEntryAtom;
// A state object of this pass. // A state object of this pass.
struct Context { struct Context {
Context(MutableFile &f, IdataPassFile &g) : file(f), dummyFile(g) {} Context(MutableFile &f, IdataPassFile &g) : file(f), dummyFile(g) {}
MutableFile &file; MutableFile &file;
IdataPassFile &dummyFile; 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<COFFBaseDefinedAtom *> importDirectories;
std::vector<HintNameAtom *> hintNameAtoms;
std::vector<DLLNameAtom *> dllNameAtoms;
std::map<StringRef, COFFBaseDefinedAtom *> sharedToDefinedAtom;
}; };
/// The root class of all idata atoms. /// The root class of all idata atoms.
@ -126,7 +115,6 @@ public:
const std::vector<COFFSharedLibraryAtom *> &sharedAtoms) const std::vector<COFFSharedLibraryAtom *> &sharedAtoms)
: IdataAtom(context, std::vector<uint8_t>(20, 0)) { : IdataAtom(context, std::vector<uint8_t>(20, 0)) {
addRelocations(context, loadName, sharedAtoms); addRelocations(context, loadName, sharedAtoms);
context.importDirectories.push_back(this);
} }
virtual StringRef customSectionName() const { return ".idata.d"; } virtual StringRef customSectionName() const { return ".idata.d"; }
@ -138,8 +126,6 @@ private:
std::vector<ImportTableEntryAtom *> createImportTableAtoms( std::vector<ImportTableEntryAtom *> createImportTableAtoms(
Context &context, const std::vector<COFFSharedLibraryAtom *> &sharedAtoms, Context &context, const std::vector<COFFSharedLibraryAtom *> &sharedAtoms,
bool shouldAddReference, StringRef sectionName) const; bool shouldAddReference, StringRef sectionName) const;
HintNameAtom *createHintNameAtom(Context &context,
const COFFSharedLibraryAtom *atom) const;
mutable llvm::BumpPtrAllocator _alloc; mutable llvm::BumpPtrAllocator _alloc;
}; };
@ -148,9 +134,7 @@ private:
class NullImportDirectoryAtom : public IdataAtom { class NullImportDirectoryAtom : public IdataAtom {
public: public:
explicit NullImportDirectoryAtom(Context &context) explicit NullImportDirectoryAtom(Context &context)
: IdataAtom(context, std::vector<uint8_t>(20, 0)) { : IdataAtom(context, std::vector<uint8_t>(20, 0)) {}
context.importDirectories.push_back(this);
}
virtual StringRef customSectionName() const { return ".idata.d"; } virtual StringRef customSectionName() const { return ".idata.d"; }
}; };
@ -182,13 +166,6 @@ private:
std::map<StringRef, std::vector<COFFSharedLibraryAtom *> > std::map<StringRef, std::vector<COFFSharedLibraryAtom *> >
groupByLoadName(MutableFile &file); groupByLoadName(MutableFile &file);
void createImportDirectory(idata::Context &context, StringRef loadName,
std::vector<COFFSharedLibraryAtom *> &dllAtoms);
template <typename T, typename U>
void appendAtoms(std::vector<T *> &vec1, const std::vector<U *> &vec2);
void connectAtoms(idata::Context &context);
void replaceSharedLibraryAtoms(idata::Context &context); void replaceSharedLibraryAtoms(idata::Context &context);
// A dummy file with which all the atoms created in the pass will be // A dummy file with which all the atoms created in the pass will be