mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
llvm-readobj: print COFF imported symbols
This patch defines a new iterator for the imported symbols. Make a change to COFFDumper to use that iterator to print out imported symbols and its ordinals. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218915 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -26,8 +26,10 @@ template <typename T> class ArrayRef;
|
||||
namespace object {
|
||||
class ImportDirectoryEntryRef;
|
||||
class ExportDirectoryEntryRef;
|
||||
class ImportedSymbolRef;
|
||||
typedef content_iterator<ImportDirectoryEntryRef> import_directory_iterator;
|
||||
typedef content_iterator<ExportDirectoryEntryRef> export_directory_iterator;
|
||||
typedef content_iterator<ImportedSymbolRef> imported_symbol_iterator;
|
||||
|
||||
/// The DOS compatible header at the front of all PE/COFF executables.
|
||||
struct dos_header {
|
||||
@ -160,10 +162,11 @@ struct import_directory_table_entry {
|
||||
support::ulittle32_t ImportAddressTableRVA;
|
||||
};
|
||||
|
||||
struct import_lookup_table_entry32 {
|
||||
support::ulittle32_t data;
|
||||
template <typename IntTy>
|
||||
struct import_lookup_table_entry {
|
||||
IntTy data;
|
||||
|
||||
bool isOrdinal() const { return data & 0x80000000; }
|
||||
bool isOrdinal() const { return data < 0; }
|
||||
|
||||
uint16_t getOrdinal() const {
|
||||
assert(isOrdinal() && "ILT entry is not an ordinal!");
|
||||
@ -172,10 +175,15 @@ struct import_lookup_table_entry32 {
|
||||
|
||||
uint32_t getHintNameRVA() const {
|
||||
assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!");
|
||||
return data;
|
||||
return data & 0xFFFFFFFF;
|
||||
}
|
||||
};
|
||||
|
||||
typedef import_lookup_table_entry<support::little32_t>
|
||||
import_lookup_table_entry32;
|
||||
typedef import_lookup_table_entry<support::little64_t>
|
||||
import_lookup_table_entry64;
|
||||
|
||||
struct export_directory_table_entry {
|
||||
support::ulittle32_t ExportFlags;
|
||||
support::ulittle32_t TimeDateStamp;
|
||||
@ -650,6 +658,10 @@ public:
|
||||
|
||||
bool operator==(const ImportDirectoryEntryRef &Other) const;
|
||||
void moveNext();
|
||||
|
||||
imported_symbol_iterator imported_symbol_begin() const;
|
||||
imported_symbol_iterator imported_symbol_end() const;
|
||||
|
||||
std::error_code getName(StringRef &Result) const;
|
||||
std::error_code getImportLookupTableRVA(uint32_t &Result) const;
|
||||
std::error_code getImportAddressTableRVA(uint32_t &Result) const;
|
||||
@ -688,6 +700,29 @@ private:
|
||||
uint32_t Index;
|
||||
const COFFObjectFile *OwningObject;
|
||||
};
|
||||
|
||||
class ImportedSymbolRef {
|
||||
public:
|
||||
ImportedSymbolRef() : OwningObject(nullptr) {}
|
||||
ImportedSymbolRef(const import_lookup_table_entry32 *Entry, uint32_t I,
|
||||
const COFFObjectFile *Owner)
|
||||
: Entry32(Entry), Entry64(nullptr), Index(I), OwningObject(Owner) {}
|
||||
ImportedSymbolRef(const import_lookup_table_entry64 *Entry, uint32_t I,
|
||||
const COFFObjectFile *Owner)
|
||||
: Entry32(nullptr), Entry64(Entry), Index(I), OwningObject(Owner) {}
|
||||
|
||||
bool operator==(const ImportedSymbolRef &Other) const;
|
||||
void moveNext();
|
||||
|
||||
std::error_code getSymbolName(StringRef &Result) const;
|
||||
std::error_code getOrdinal(uint16_t &Result) const;
|
||||
|
||||
private:
|
||||
const import_lookup_table_entry32 *Entry32;
|
||||
const import_lookup_table_entry64 *Entry64;
|
||||
uint32_t Index;
|
||||
const COFFObjectFile *OwningObject;
|
||||
};
|
||||
} // end namespace object
|
||||
} // end namespace llvm
|
||||
|
||||
|
Reference in New Issue
Block a user