mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 15:19:33 +00:00
[COFF] Remove a duplicate import_directory_table_entry definition
We had import_directory_table_entry and coff_import_directory_table_entry, remove one. Also, factor out the logic which determins if a descriptor is a terminator. llvm-svn: 277296
This commit is contained in:
parent
5937e5d842
commit
94420225fa
@ -161,14 +161,6 @@ struct data_directory {
|
||||
support::ulittle32_t Size;
|
||||
};
|
||||
|
||||
struct import_directory_table_entry {
|
||||
support::ulittle32_t ImportLookupTableRVA;
|
||||
support::ulittle32_t TimeDateStamp;
|
||||
support::ulittle32_t ForwarderChain;
|
||||
support::ulittle32_t NameRVA;
|
||||
support::ulittle32_t ImportAddressTableRVA;
|
||||
};
|
||||
|
||||
struct debug_directory {
|
||||
support::ulittle32_t Characteristics;
|
||||
support::ulittle32_t TimeDateStamp;
|
||||
@ -534,6 +526,10 @@ struct coff_import_directory_table_entry {
|
||||
support::ulittle32_t ForwarderChain;
|
||||
support::ulittle32_t NameRVA;
|
||||
support::ulittle32_t ImportAddressTableRVA;
|
||||
bool isNull() const {
|
||||
return ImportLookupTableRVA == 0 && TimeDateStamp == 0 &&
|
||||
ForwarderChain == 0 && NameRVA == 0 && ImportAddressTableRVA == 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename IntTy>
|
||||
@ -633,7 +629,7 @@ private:
|
||||
const coff_symbol32 *SymbolTable32;
|
||||
const char *StringTable;
|
||||
uint32_t StringTableSize;
|
||||
const import_directory_table_entry *ImportDirectory;
|
||||
const coff_import_directory_table_entry *ImportDirectory;
|
||||
const delay_import_directory_table_entry *DelayImportDirectory;
|
||||
uint32_t NumberOfDelayImportDirectory;
|
||||
const export_directory_table_entry *ExportDirectory;
|
||||
@ -892,8 +888,8 @@ public:
|
||||
class ImportDirectoryEntryRef {
|
||||
public:
|
||||
ImportDirectoryEntryRef() : OwningObject(nullptr) {}
|
||||
ImportDirectoryEntryRef(const import_directory_table_entry *Table, uint32_t I,
|
||||
const COFFObjectFile *Owner)
|
||||
ImportDirectoryEntryRef(const coff_import_directory_table_entry *Table,
|
||||
uint32_t I, const COFFObjectFile *Owner)
|
||||
: ImportTable(Table), Index(I), OwningObject(Owner) {}
|
||||
|
||||
bool operator==(const ImportDirectoryEntryRef &Other) const;
|
||||
@ -908,10 +904,10 @@ public:
|
||||
std::error_code getImportAddressTableRVA(uint32_t &Result) const;
|
||||
|
||||
std::error_code
|
||||
getImportTableEntry(const import_directory_table_entry *&Result) const;
|
||||
getImportTableEntry(const coff_import_directory_table_entry *&Result) const;
|
||||
|
||||
private:
|
||||
const import_directory_table_entry *ImportTable;
|
||||
const coff_import_directory_table_entry *ImportTable;
|
||||
uint32_t Index;
|
||||
const COFFObjectFile *OwningObject;
|
||||
};
|
||||
|
@ -538,7 +538,7 @@ std::error_code COFFObjectFile::initImportTablePtr() {
|
||||
if (std::error_code EC = checkOffset(Data, IntPtr, DataEntry->Size))
|
||||
return EC;
|
||||
ImportDirectory = reinterpret_cast<
|
||||
const import_directory_table_entry *>(IntPtr);
|
||||
const coff_import_directory_table_entry *>(IntPtr);
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
@ -772,7 +772,7 @@ basic_symbol_iterator COFFObjectFile::symbol_end_impl() const {
|
||||
import_directory_iterator COFFObjectFile::import_directory_begin() const {
|
||||
if (!ImportDirectory)
|
||||
return import_directory_end();
|
||||
if (ImportDirectory[0].ImportLookupTableRVA == 0)
|
||||
if (ImportDirectory->isNull())
|
||||
return import_directory_end();
|
||||
return import_directory_iterator(
|
||||
ImportDirectoryEntryRef(ImportDirectory, 0, this));
|
||||
@ -1201,14 +1201,14 @@ operator==(const ImportDirectoryEntryRef &Other) const {
|
||||
|
||||
void ImportDirectoryEntryRef::moveNext() {
|
||||
++Index;
|
||||
if (ImportTable[Index].ImportLookupTableRVA == 0) {
|
||||
if (ImportTable[Index].isNull()) {
|
||||
Index = -1;
|
||||
ImportTable = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::error_code ImportDirectoryEntryRef::getImportTableEntry(
|
||||
const import_directory_table_entry *&Result) const {
|
||||
const coff_import_directory_table_entry *&Result) const {
|
||||
return getObject(Result, OwningObject->Data, ImportTable + Index);
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ static void printImportTables(const COFFObjectFile *Obj) {
|
||||
return;
|
||||
outs() << "The Import Tables:\n";
|
||||
for (const ImportDirectoryEntryRef &DirRef : Obj->import_directories()) {
|
||||
const import_directory_table_entry *Dir;
|
||||
const coff_import_directory_table_entry *Dir;
|
||||
StringRef Name;
|
||||
if (DirRef.getImportTableEntry(Dir)) return;
|
||||
if (DirRef.getName(Name)) return;
|
||||
|
Loading…
Reference in New Issue
Block a user