[llvm] r219228 - llvm-readobj: add support to dump (COFF) directives
Saleem Abdulrasool
compnerd at compnerd.org
Tue Oct 7 12:37:53 PDT 2014
Author: compnerd
Date: Tue Oct 7 14:37:52 2014
New Revision: 219228
URL: http://llvm.org/viewvc/llvm-project?rev=219228&view=rev
Log:
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.
Modified:
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
llvm/trunk/tools/llvm-readobj/ObjDumper.h
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=219228&r1=219227&r2=219228&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Tue Oct 7 14:37:52 2014
@@ -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);
+ }
+}
+
Modified: llvm/trunk/tools/llvm-readobj/ObjDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ObjDumper.h?rev=219228&r1=219227&r2=219228&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ObjDumper.h (original)
+++ llvm/trunk/tools/llvm-readobj/ObjDumper.h Tue Oct 7 14:37:52 2014
@@ -45,6 +45,7 @@ public:
// Only implemented for PE/COFF.
virtual void printCOFFImports() { }
+ virtual void printCOFFDirectives() { }
protected:
StreamWriter& W;
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=219228&r1=219227&r2=219228&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Tue Oct 7 14:37:52 2014
@@ -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
Dumper->printMipsPLTGOT();
if (opts::COFFImports)
Dumper->printCOFFImports();
+ if (opts::COFFDirectives)
+ Dumper->printCOFFDirectives();
}
More information about the llvm-commits
mailing list