summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2015-12-20 09:54:34 +0000
committerDavide Italiano <davide@freebsd.org>2015-12-20 09:54:34 +0000
commitabe8418ff7e12a2ac07f0cfbc4900e30dc8db99c (patch)
treebfc5bf1e18ee7561d82b4161eda8d4f7b770f8e0 /tools
parent5a75233380a54999e932b68f3f04e3532e8b2912 (diff)
[llvm-objdump] Move COFF function to where it belongs.
Ideally much more stuff should be moved out of llvm-objdump.cpp, but that will happen later. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256118 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-objdump/COFFDump.cpp49
-rw-r--r--tools/llvm-objdump/llvm-objdump.cpp51
-rw-r--r--tools/llvm-objdump/llvm-objdump.h1
3 files changed, 51 insertions, 50 deletions
diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp
index 001e352c8d0..f286351614a 100644
--- a/tools/llvm-objdump/COFFDump.cpp
+++ b/tools/llvm-objdump/COFFDump.cpp
@@ -542,3 +542,52 @@ void llvm::printCOFFFileHeader(const object::ObjectFile *Obj) {
printImportTables(file);
printExportTable(file);
}
+
+void llvm::printCOFFSymbolTable(const COFFObjectFile *coff) {
+ for (unsigned SI = 0, SE = coff->getNumberOfSymbols(); SI != SE; ++SI) {
+ ErrorOr<COFFSymbolRef> Symbol = coff->getSymbol(SI);
+ StringRef Name;
+ error(Symbol.getError());
+ error(coff->getSymbolName(*Symbol, Name));
+
+ outs() << "[" << format("%2d", SI) << "]"
+ << "(sec " << format("%2d", int(Symbol->getSectionNumber())) << ")"
+ << "(fl 0x00)" // Flag bits, which COFF doesn't have.
+ << "(ty " << format("%3x", unsigned(Symbol->getType())) << ")"
+ << "(scl " << format("%3x", unsigned(Symbol->getStorageClass())) << ") "
+ << "(nx " << unsigned(Symbol->getNumberOfAuxSymbols()) << ") "
+ << "0x" << format("%08x", unsigned(Symbol->getValue())) << " "
+ << Name << "\n";
+
+ for (unsigned AI = 0, AE = Symbol->getNumberOfAuxSymbols(); AI < AE; ++AI, ++SI) {
+ if (Symbol->isSectionDefinition()) {
+ const coff_aux_section_definition *asd;
+ error(coff->getAuxSymbol<coff_aux_section_definition>(SI + 1, asd));
+
+ int32_t AuxNumber = asd->getNumber(Symbol->isBigObj());
+
+ outs() << "AUX "
+ << format("scnlen 0x%x nreloc %d nlnno %d checksum 0x%x "
+ , unsigned(asd->Length)
+ , unsigned(asd->NumberOfRelocations)
+ , unsigned(asd->NumberOfLinenumbers)
+ , unsigned(asd->CheckSum))
+ << format("assoc %d comdat %d\n"
+ , unsigned(AuxNumber)
+ , unsigned(asd->Selection));
+ } else if (Symbol->isFileRecord()) {
+ const char *FileName;
+ error(coff->getAuxSymbol<char>(SI + 1, FileName));
+
+ StringRef Name(FileName, Symbol->getNumberOfAuxSymbols() *
+ coff->getSymbolTableEntrySize());
+ outs() << "AUX " << Name.rtrim(StringRef("\0", 1)) << '\n';
+
+ SI = SI + Symbol->getNumberOfAuxSymbols();
+ break;
+ } else {
+ outs() << "AUX Unknown\n";
+ }
+ }
+ }
+}
diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp
index 3057a1d099e..e89243340cc 100644
--- a/tools/llvm-objdump/llvm-objdump.cpp
+++ b/tools/llvm-objdump/llvm-objdump.cpp
@@ -1247,60 +1247,11 @@ void llvm::PrintSectionContents(const ObjectFile *Obj) {
}
}
-static void PrintCOFFSymbolTable(const COFFObjectFile *coff) {
- for (unsigned SI = 0, SE = coff->getNumberOfSymbols(); SI != SE; ++SI) {
- ErrorOr<COFFSymbolRef> Symbol = coff->getSymbol(SI);
- StringRef Name;
- error(Symbol.getError());
- error(coff->getSymbolName(*Symbol, Name));
-
- outs() << "[" << format("%2d", SI) << "]"
- << "(sec " << format("%2d", int(Symbol->getSectionNumber())) << ")"
- << "(fl 0x00)" // Flag bits, which COFF doesn't have.
- << "(ty " << format("%3x", unsigned(Symbol->getType())) << ")"
- << "(scl " << format("%3x", unsigned(Symbol->getStorageClass())) << ") "
- << "(nx " << unsigned(Symbol->getNumberOfAuxSymbols()) << ") "
- << "0x" << format("%08x", unsigned(Symbol->getValue())) << " "
- << Name << "\n";
-
- for (unsigned AI = 0, AE = Symbol->getNumberOfAuxSymbols(); AI < AE; ++AI, ++SI) {
- if (Symbol->isSectionDefinition()) {
- const coff_aux_section_definition *asd;
- error(coff->getAuxSymbol<coff_aux_section_definition>(SI + 1, asd));
-
- int32_t AuxNumber = asd->getNumber(Symbol->isBigObj());
-
- outs() << "AUX "
- << format("scnlen 0x%x nreloc %d nlnno %d checksum 0x%x "
- , unsigned(asd->Length)
- , unsigned(asd->NumberOfRelocations)
- , unsigned(asd->NumberOfLinenumbers)
- , unsigned(asd->CheckSum))
- << format("assoc %d comdat %d\n"
- , unsigned(AuxNumber)
- , unsigned(asd->Selection));
- } else if (Symbol->isFileRecord()) {
- const char *FileName;
- error(coff->getAuxSymbol<char>(SI + 1, FileName));
-
- StringRef Name(FileName, Symbol->getNumberOfAuxSymbols() *
- coff->getSymbolTableEntrySize());
- outs() << "AUX " << Name.rtrim(StringRef("\0", 1)) << '\n';
-
- SI = SI + Symbol->getNumberOfAuxSymbols();
- break;
- } else {
- outs() << "AUX Unknown\n";
- }
- }
- }
-}
-
void llvm::PrintSymbolTable(const ObjectFile *o) {
outs() << "SYMBOL TABLE:\n";
if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o)) {
- PrintCOFFSymbolTable(coff);
+ printCOFFSymbolTable(coff);
return;
}
for (const SymbolRef &Symbol : o->symbols()) {
diff --git a/tools/llvm-objdump/llvm-objdump.h b/tools/llvm-objdump/llvm-objdump.h
index f74ed010d1d..e7c28f53abe 100644
--- a/tools/llvm-objdump/llvm-objdump.h
+++ b/tools/llvm-objdump/llvm-objdump.h
@@ -67,6 +67,7 @@ void printMachOLazyBindTable(const object::MachOObjectFile* o);
void printMachOWeakBindTable(const object::MachOObjectFile* o);
void printELFFileHeader(const object::ObjectFile *o);
void printCOFFFileHeader(const object::ObjectFile *o);
+void printCOFFSymbolTable(const object::COFFObjectFile *o);
void printMachOFileHeader(const object::ObjectFile *o);
void printExportsTrie(const object::ObjectFile *o);
void printRebaseTable(const object::ObjectFile *o);