[lld] r219267 - [PECOFF] Move a function out of a class
Rui Ueyama
ruiu at google.com
Tue Oct 7 18:48:09 PDT 2014
Author: ruiu
Date: Tue Oct 7 20:48:08 2014
New Revision: 219267
URL: http://llvm.org/viewvc/llvm-project?rev=219267&view=rev
Log:
[PECOFF] Move a function out of a class
I'm going to use this function both for the import table and the
delay-import table.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h
Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp?rev=219267&r1=219266&r2=219267&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp Tue Oct 7 20:48:08 2014
@@ -63,6 +63,35 @@ ImportTableEntryAtom::assembleRawContent
return ret;
}
+static std::vector<ImportTableEntryAtom *>
+createImportTableAtoms(IdataContext &context,
+ const std::vector<COFFSharedLibraryAtom *> &sharedAtoms,
+ bool shouldAddReference, StringRef sectionName,
+ llvm::BumpPtrAllocator &alloc) {
+ std::vector<ImportTableEntryAtom *> ret;
+ for (COFFSharedLibraryAtom *atom : sharedAtoms) {
+ ImportTableEntryAtom *entry = nullptr;
+ if (atom->importName().empty()) {
+ // Import by ordinal
+ uint64_t hint = atom->hint();
+ hint |= context.ctx.is64Bit() ? (uint64_t(1) << 63) : (uint64_t(1) << 31);
+ entry = new (alloc) ImportTableEntryAtom(context, hint, sectionName);
+ } else {
+ // Import by name
+ entry = new (alloc) ImportTableEntryAtom(context, 0, sectionName);
+ HintNameAtom *hintName =
+ new (alloc) HintNameAtom(context, atom->hint(), atom->importName());
+ addDir32NBReloc(entry, hintName, context.ctx.getMachineType(), 0);
+ }
+ ret.push_back(entry);
+ if (shouldAddReference)
+ atom->setImportTableEntry(entry);
+ }
+ // Add the NULL entry.
+ ret.push_back(new (alloc) ImportTableEntryAtom(context, 0, sectionName));
+ return ret;
+}
+
// Creates atoms for an import lookup table. The import lookup table is an
// array of pointers to hint/name atoms. The array needs to be terminated with
// the NULL entry.
@@ -74,9 +103,9 @@ void ImportDirectoryAtom::addRelocations
// pointers to the referenced items after loading the executable into
// memory.
std::vector<ImportTableEntryAtom *> importLookupTables =
- createImportTableAtoms(context, sharedAtoms, false, ".idata.t");
+ createImportTableAtoms(context, sharedAtoms, false, ".idata.t", _alloc);
std::vector<ImportTableEntryAtom *> importAddressTables =
- createImportTableAtoms(context, sharedAtoms, true, ".idata.a");
+ createImportTableAtoms(context, sharedAtoms, true, ".idata.a", _alloc);
addDir32NBReloc(this, importLookupTables[0], context.ctx.getMachineType(),
offsetof(ImportDirectoryTableEntry, ImportLookupTableRVA));
@@ -90,34 +119,6 @@ void ImportDirectoryAtom::addRelocations
offsetof(ImportDirectoryTableEntry, NameRVA));
}
-std::vector<ImportTableEntryAtom *> ImportDirectoryAtom::createImportTableAtoms(
- IdataContext &context,
- const std::vector<COFFSharedLibraryAtom *> &sharedAtoms,
- bool shouldAddReference, StringRef sectionName) const {
- std::vector<ImportTableEntryAtom *> ret;
- for (COFFSharedLibraryAtom *atom : sharedAtoms) {
- ImportTableEntryAtom *entry = nullptr;
- if (atom->importName().empty()) {
- // Import by ordinal
- uint64_t hint = atom->hint();
- hint |= context.ctx.is64Bit() ? (uint64_t(1) << 63) : (uint64_t(1) << 31);
- entry = new (_alloc) ImportTableEntryAtom(context, hint, sectionName);
- } else {
- // Import by name
- entry = new (_alloc) ImportTableEntryAtom(context, 0, sectionName);
- HintNameAtom *hintName =
- new (_alloc) HintNameAtom(context, atom->hint(), atom->importName());
- addDir32NBReloc(entry, hintName, context.ctx.getMachineType(), 0);
- }
- ret.push_back(entry);
- if (shouldAddReference)
- atom->setImportTableEntry(entry);
- }
- // Add the NULL entry.
- ret.push_back(new (_alloc) ImportTableEntryAtom(context, 0, sectionName));
- return ret;
-}
-
} // namespace idata
void IdataPass::perform(std::unique_ptr<MutableFile> &file) {
Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h?rev=219267&r1=219266&r2=219267&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.h Tue Oct 7 20:48:08 2014
@@ -114,11 +114,6 @@ private:
void addRelocations(IdataContext &context, StringRef loadName,
const std::vector<COFFSharedLibraryAtom *> &sharedAtoms);
- std::vector<ImportTableEntryAtom *> createImportTableAtoms(
- IdataContext &context,
- const std::vector<COFFSharedLibraryAtom *> &sharedAtoms,
- bool shouldAddReference, StringRef sectionName) const;
-
mutable llvm::BumpPtrAllocator _alloc;
};
More information about the llvm-commits
mailing list