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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219228 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool
2014-10-07 19:37:52 +00:00
parent b3a0758832
commit db02fa5a11
3 changed files with 27 additions and 0 deletions

View File

@ -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);
}
}