mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +00:00
Object: Add range iterators for COFF import/export table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219383 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e6d97094b7
commit
f02f03c21a
@ -600,6 +600,11 @@ public:
|
||||
export_directory_iterator export_directory_begin() const;
|
||||
export_directory_iterator export_directory_end() const;
|
||||
|
||||
iterator_range<import_directory_iterator> import_directories() const;
|
||||
iterator_range<delay_import_directory_iterator>
|
||||
delay_import_directories() const;
|
||||
iterator_range<export_directory_iterator> export_directories() const;
|
||||
|
||||
std::error_code getPE32Header(const pe32_header *&Res) const;
|
||||
std::error_code getPE32PlusHeader(const pe32plus_header *&Res) const;
|
||||
std::error_code getDataDirectory(uint32_t index,
|
||||
@ -676,6 +681,7 @@ public:
|
||||
|
||||
imported_symbol_iterator imported_symbol_begin() const;
|
||||
imported_symbol_iterator imported_symbol_end() const;
|
||||
iterator_range<imported_symbol_iterator> imported_symbols() const;
|
||||
|
||||
std::error_code getName(StringRef &Result) const;
|
||||
std::error_code getImportLookupTableRVA(uint32_t &Result) const;
|
||||
@ -705,6 +711,7 @@ public:
|
||||
|
||||
imported_symbol_iterator imported_symbol_begin() const;
|
||||
imported_symbol_iterator imported_symbol_end() const;
|
||||
iterator_range<imported_symbol_iterator> imported_symbols() const;
|
||||
|
||||
std::error_code getName(StringRef &Result) const;
|
||||
std::error_code getDelayImportTable(
|
||||
|
@ -730,6 +730,22 @@ unsigned COFFObjectFile::getArch() const {
|
||||
}
|
||||
}
|
||||
|
||||
iterator_range<import_directory_iterator>
|
||||
COFFObjectFile::import_directories() const {
|
||||
return make_range(import_directory_begin(), import_directory_end());
|
||||
}
|
||||
|
||||
iterator_range<delay_import_directory_iterator>
|
||||
COFFObjectFile::delay_import_directories() const {
|
||||
return make_range(delay_import_directory_begin(),
|
||||
delay_import_directory_end());
|
||||
}
|
||||
|
||||
iterator_range<export_directory_iterator>
|
||||
COFFObjectFile::export_directories() const {
|
||||
return make_range(export_directory_begin(), export_directory_end());
|
||||
}
|
||||
|
||||
std::error_code COFFObjectFile::getPE32Header(const pe32_header *&Res) const {
|
||||
Res = PE32Header;
|
||||
return object_error::success;
|
||||
@ -1094,6 +1110,11 @@ ImportDirectoryEntryRef::imported_symbol_end() const {
|
||||
OwningObject);
|
||||
}
|
||||
|
||||
iterator_range<imported_symbol_iterator>
|
||||
ImportDirectoryEntryRef::imported_symbols() const {
|
||||
return make_range(imported_symbol_begin(), imported_symbol_end());
|
||||
}
|
||||
|
||||
std::error_code ImportDirectoryEntryRef::getName(StringRef &Result) const {
|
||||
uintptr_t IntPtr = 0;
|
||||
if (std::error_code EC =
|
||||
@ -1146,6 +1167,11 @@ DelayImportDirectoryEntryRef::imported_symbol_end() const {
|
||||
OwningObject);
|
||||
}
|
||||
|
||||
iterator_range<imported_symbol_iterator>
|
||||
DelayImportDirectoryEntryRef::imported_symbols() const {
|
||||
return make_range(imported_symbol_begin(), imported_symbol_end());
|
||||
}
|
||||
|
||||
std::error_code DelayImportDirectoryEntryRef::getName(StringRef &Result) const {
|
||||
uintptr_t IntPtr = 0;
|
||||
if (std::error_code EC = OwningObject->getRvaPtr(Table[Index].Name, IntPtr))
|
||||
|
@ -75,9 +75,7 @@ private:
|
||||
SymbolRef &Sym);
|
||||
std::error_code resolveSymbolName(const coff_section *Section,
|
||||
uint64_t Offset, StringRef &Name);
|
||||
|
||||
void printImportedSymbols(imported_symbol_iterator I,
|
||||
imported_symbol_iterator E);
|
||||
void printImportedSymbols(iterator_range<imported_symbol_iterator> Range);
|
||||
|
||||
typedef DenseMap<const coff_section*, std::vector<RelocationRef> > RelocMapTy;
|
||||
|
||||
@ -886,50 +884,47 @@ void COFFDumper::printUnwindInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
void COFFDumper::printImportedSymbols(imported_symbol_iterator I,
|
||||
imported_symbol_iterator E) {
|
||||
for (; I != E; ++I) {
|
||||
void COFFDumper::printImportedSymbols(
|
||||
iterator_range<imported_symbol_iterator> Range) {
|
||||
for (const ImportedSymbolRef &I : Range) {
|
||||
StringRef Sym;
|
||||
if (error(I->getSymbolName(Sym))) return;
|
||||
if (error(I.getSymbolName(Sym))) return;
|
||||
uint16_t Ordinal;
|
||||
if (error(I->getOrdinal(Ordinal))) return;
|
||||
if (error(I.getOrdinal(Ordinal))) return;
|
||||
W.printNumber("Symbol", Sym, Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
void COFFDumper::printCOFFImports() {
|
||||
// Regular imports
|
||||
for (auto I = Obj->import_directory_begin(), E = Obj->import_directory_end();
|
||||
I != E; ++I) {
|
||||
for (const ImportDirectoryEntryRef &I : Obj->import_directories()) {
|
||||
DictScope Import(W, "Import");
|
||||
StringRef Name;
|
||||
if (error(I->getName(Name))) return;
|
||||
if (error(I.getName(Name))) return;
|
||||
W.printString("Name", Name);
|
||||
uint32_t Addr;
|
||||
if (error(I->getImportLookupTableRVA(Addr))) return;
|
||||
if (error(I.getImportLookupTableRVA(Addr))) return;
|
||||
W.printHex("ImportLookupTableRVA", Addr);
|
||||
if (error(I->getImportAddressTableRVA(Addr))) return;
|
||||
if (error(I.getImportAddressTableRVA(Addr))) return;
|
||||
W.printHex("ImportAddressTableRVA", Addr);
|
||||
printImportedSymbols(I->imported_symbol_begin(), I->imported_symbol_end());
|
||||
printImportedSymbols(I.imported_symbols());
|
||||
}
|
||||
|
||||
// Delay imports
|
||||
for (auto I = Obj->delay_import_directory_begin(),
|
||||
E = Obj->delay_import_directory_end();
|
||||
I != E; ++I) {
|
||||
for (const DelayImportDirectoryEntryRef &I : Obj->delay_import_directories()) {
|
||||
DictScope Import(W, "DelayImport");
|
||||
StringRef Name;
|
||||
if (error(I->getName(Name))) return;
|
||||
if (error(I.getName(Name))) return;
|
||||
W.printString("Name", Name);
|
||||
const delay_import_directory_table_entry *Table;
|
||||
if (error(I->getDelayImportTable(Table))) return;
|
||||
if (error(I.getDelayImportTable(Table))) return;
|
||||
W.printHex("Attributes", Table->Attributes);
|
||||
W.printHex("ModuleHandle", Table->ModuleHandle);
|
||||
W.printHex("ImportAddressTable", Table->DelayImportAddressTable);
|
||||
W.printHex("ImportNameTable", Table->DelayImportNameTable);
|
||||
W.printHex("BoundDelayImportTable", Table->BoundDelayImportTable);
|
||||
W.printHex("UnloadDelayImportTable", Table->UnloadDelayImportTable);
|
||||
printImportedSymbols(I->imported_symbol_begin(), I->imported_symbol_end());
|
||||
printImportedSymbols(I.imported_symbols());
|
||||
}
|
||||
}
|
||||
|
||||
@ -949,4 +944,3 @@ void COFFDumper::printCOFFDirectives() {
|
||||
W.printString("Directive(s)", Contents);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user