mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 00:11:00 +00:00
llvm-readobj: add support to dump COFF export tables
This enhances llvm-readobj to print out the COFF export table, similar to the -coff-import option. This is useful for testing in lld. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225120 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
97f8f69a7f
commit
b19a485253
BIN
test/tools/llvm-readobj/Inputs/export-arm.dll
Executable file
BIN
test/tools/llvm-readobj/Inputs/export-arm.dll
Executable file
Binary file not shown.
BIN
test/tools/llvm-readobj/Inputs/export-x64.dll
Executable file
BIN
test/tools/llvm-readobj/Inputs/export-x64.dll
Executable file
Binary file not shown.
BIN
test/tools/llvm-readobj/Inputs/export-x86.dll
Executable file
BIN
test/tools/llvm-readobj/Inputs/export-x86.dll
Executable file
Binary file not shown.
11
test/tools/llvm-readobj/coff-exports.test
Normal file
11
test/tools/llvm-readobj/coff-exports.test
Normal file
@ -0,0 +1,11 @@
|
||||
RUN: llvm-readobj -coff-exports %p/Inputs/export-x86.dll | FileCheck %s -check-prefix CHECK -check-prefix CHECK-X86
|
||||
RUN: llvm-readobj -coff-exports %p/Inputs/export-x64.dll | FileCheck %s -check-prefix CHECK -check-prefix CHECK-X64
|
||||
RUN: llvm-readobj -coff-exports %p/Inputs/export-arm.dll | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM
|
||||
|
||||
CHECK: Export {
|
||||
CHECK: Ordinal: 1
|
||||
CHECK: Name: function
|
||||
CHECK-X86: RVA: 0x1000
|
||||
CHECK-X64: RVA: 0x1000
|
||||
CHECK-ARM: RVA: 0x1001
|
||||
CHECK: }
|
@ -57,6 +57,7 @@ public:
|
||||
void printDynamicSymbols() override;
|
||||
void printUnwindInfo() override;
|
||||
void printCOFFImports() override;
|
||||
void printCOFFExports() override;
|
||||
void printCOFFDirectives() override;
|
||||
void printCOFFBaseReloc() override;
|
||||
|
||||
@ -1062,6 +1063,26 @@ void COFFDumper::printCOFFImports() {
|
||||
}
|
||||
}
|
||||
|
||||
void COFFDumper::printCOFFExports() {
|
||||
for (const ExportDirectoryEntryRef &E : Obj->export_directories()) {
|
||||
DictScope Export(W, "Export");
|
||||
|
||||
StringRef Name;
|
||||
uint32_t Ordinal, RVA;
|
||||
|
||||
if (error(E.getSymbolName(Name)))
|
||||
continue;
|
||||
if (error(E.getOrdinal(Ordinal)))
|
||||
continue;
|
||||
if (error(E.getExportRVA(RVA)))
|
||||
continue;
|
||||
|
||||
W.printNumber("Ordinal", Ordinal);
|
||||
W.printString("Name", Name);
|
||||
W.printHex("RVA", RVA);
|
||||
}
|
||||
}
|
||||
|
||||
void COFFDumper::printCOFFDirectives() {
|
||||
for (const SectionRef &Section : Obj->sections()) {
|
||||
StringRef Contents;
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
|
||||
// Only implemented for PE/COFF.
|
||||
virtual void printCOFFImports() { }
|
||||
virtual void printCOFFExports() { }
|
||||
virtual void printCOFFDirectives() { }
|
||||
virtual void printCOFFBaseReloc() { }
|
||||
|
||||
|
@ -146,6 +146,10 @@ namespace opts {
|
||||
cl::opt<bool>
|
||||
COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
|
||||
|
||||
// -coff-exports
|
||||
cl::opt<bool>
|
||||
COFFExports("coff-exports", cl::desc("Display the PE/COFF export table"));
|
||||
|
||||
// -coff-directives
|
||||
cl::opt<bool>
|
||||
COFFDirectives("coff-directives",
|
||||
@ -282,6 +286,8 @@ static void dumpObject(const ObjectFile *Obj) {
|
||||
Dumper->printMipsPLTGOT();
|
||||
if (opts::COFFImports)
|
||||
Dumper->printCOFFImports();
|
||||
if (opts::COFFExports)
|
||||
Dumper->printCOFFExports();
|
||||
if (opts::COFFDirectives)
|
||||
Dumper->printCOFFDirectives();
|
||||
if (opts::COFFBaseRelocs)
|
||||
|
Loading…
Reference in New Issue
Block a user