mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-13 23:25:06 +00:00
llmv-objdump/COFF: Print export table contents.
This patch adds the capability to dump export table contents. An example output is this: Export Table: Ordinal RVA Name 5 0x2008 exportfn1 6 0x2010 exportfn2 By adding this feature to llvm-objdump, we will be able to use it to check export table contents in LLD's tests. Currently we are doing binary comparison in the tests, which is fragile and not readable to humans. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199358 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -271,6 +271,36 @@ static void printImportTables(const COFFObjectFile *Obj) {
|
||||
}
|
||||
}
|
||||
|
||||
// Prints export tables. The export table is a table containing the list of
|
||||
// exported symbol from the DLL.
|
||||
static void printExportTable(const COFFObjectFile *Obj) {
|
||||
outs() << "Export Table:\n";
|
||||
export_directory_iterator I = Obj->export_directory_begin();
|
||||
export_directory_iterator E = Obj->export_directory_end();
|
||||
if (I == E)
|
||||
return;
|
||||
outs() << " Ordinal RVA Name\n";
|
||||
error_code EC;
|
||||
for (; I != E; I = I.increment(EC)) {
|
||||
if (EC)
|
||||
return;
|
||||
uint32_t Ordinal;
|
||||
if (I->getOrdinal(Ordinal))
|
||||
return;
|
||||
uint32_t RVA;
|
||||
if (I->getExportRVA(RVA))
|
||||
return;
|
||||
outs() << format(" % 4d %# 8x", Ordinal, RVA);
|
||||
|
||||
StringRef Name;
|
||||
if (I->getName(Name))
|
||||
continue;
|
||||
if (!Name.empty())
|
||||
outs() << " " << Name;
|
||||
outs() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) {
|
||||
const coff_file_header *Header;
|
||||
if (error(Obj->getCOFFHeader(Header))) return;
|
||||
@@ -399,5 +429,7 @@ void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) {
|
||||
}
|
||||
|
||||
void llvm::printCOFFFileHeader(const object::ObjectFile *Obj) {
|
||||
printImportTables(dyn_cast<const COFFObjectFile>(Obj));
|
||||
const COFFObjectFile *file = dyn_cast<const COFFObjectFile>(Obj);
|
||||
printImportTables(file);
|
||||
printExportTable(file);
|
||||
}
|
||||
|
Reference in New Issue
Block a user