summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-10-07 19:37:52 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-10-07 19:37:52 +0000
commitf95786324c233dcfa28da5fea929e62bc50b4083 (patch)
tree0fd3efdbc08a8068ee77cf2b3431d74348a5f7ab /llvm/tools/llvm-readobj
parent1419e9adb5f4586a4950bf99acd40b2ca46ef648 (diff)
downloadbcm5719-llvm-f95786324c233dcfa28da5fea929e62bc50b4083.tar.gz
bcm5719-llvm-f95786324c233dcfa28da5fea929e62bc50b4083.zip
llvm-readobj: add support to dump (COFF) directives
PE/COFF has a special section (.drectve) which can be used to pass options to the linker (similar to LC_LINKER_OPTION). Add support to llvm-readobj to print the contents of the section for tests. llvm-svn: 219228
Diffstat (limited to 'llvm/tools/llvm-readobj')
-rw-r--r--llvm/tools/llvm-readobj/COFFDumper.cpp19
-rw-r--r--llvm/tools/llvm-readobj/ObjDumper.h1
-rw-r--r--llvm/tools/llvm-readobj/llvm-readobj.cpp7
3 files changed, 27 insertions, 0 deletions
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 8e7fcc06c1b..84cd9a689e3 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -56,6 +56,7 @@ public:
void printDynamicSymbols() override;
void printUnwindInfo() override;
void printCOFFImports() override;
+ void printCOFFDirectives() override;
private:
void printSymbol(const SymbolRef &Sym);
@@ -932,3 +933,21 @@ void COFFDumper::printCOFFImports() {
printImportedSymbols(I->imported_symbol_begin(), I->imported_symbol_end());
}
}
+
+void COFFDumper::printCOFFDirectives() {
+ for (const SectionRef &Section : Obj->sections()) {
+ StringRef Contents;
+ StringRef Name;
+
+ if (error(Section.getName(Name)))
+ continue;
+ if (Name != ".drectve")
+ continue;
+
+ if (error(Section.getContents(Contents)))
+ return;
+
+ W.printString("Directive(s)", Contents);
+ }
+}
+
diff --git a/llvm/tools/llvm-readobj/ObjDumper.h b/llvm/tools/llvm-readobj/ObjDumper.h
index 8f0c171233e..b898224a44d 100644
--- a/llvm/tools/llvm-readobj/ObjDumper.h
+++ b/llvm/tools/llvm-readobj/ObjDumper.h
@@ -45,6 +45,7 @@ public:
// Only implemented for PE/COFF.
virtual void printCOFFImports() { }
+ virtual void printCOFFDirectives() { }
protected:
StreamWriter& W;
diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp
index 31a011d2b9e..55eadd887c7 100644
--- a/llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -145,6 +145,11 @@ namespace opts {
// -coff-imports
cl::opt<bool>
COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
+
+ // -coff-directives
+ cl::opt<bool>
+ COFFDirectives("coff-directives",
+ cl::desc("Display the contents PE/COFF .drectve section"));
} // namespace opts
static int ReturnValue = EXIT_SUCCESS;
@@ -272,6 +277,8 @@ static void dumpObject(const ObjectFile *Obj) {
Dumper->printMipsPLTGOT();
if (opts::COFFImports)
Dumper->printCOFFImports();
+ if (opts::COFFDirectives)
+ Dumper->printCOFFDirectives();
}
OpenPOWER on IntegriCloud