llvm.org GIT mirror llvm / db02fa5
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 Saleem Abdulrasool 5 years ago
3 changed file(s) with 27 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
5555 void printDynamicSymbols() override;
5656 void printUnwindInfo() override;
5757 void printCOFFImports() override;
58 void printCOFFDirectives() override;
5859
5960 private:
6061 void printSymbol(const SymbolRef &Sym);
931932 printImportedSymbols(I->imported_symbol_begin(), I->imported_symbol_end());
932933 }
933934 }
935
936 void COFFDumper::printCOFFDirectives() {
937 for (const SectionRef &Section : Obj->sections()) {
938 StringRef Contents;
939 StringRef Name;
940
941 if (error(Section.getName(Name)))
942 continue;
943 if (Name != ".drectve")
944 continue;
945
946 if (error(Section.getContents(Contents)))
947 return;
948
949 W.printString("Directive(s)", Contents);
950 }
951 }
952
4444
4545 // Only implemented for PE/COFF.
4646 virtual void printCOFFImports() { }
47 virtual void printCOFFDirectives() { }
4748
4849 protected:
4950 StreamWriter& W;
144144 // -coff-imports
145145 cl::opt
146146 COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
147
148 // -coff-directives
149 cl::opt
150 COFFDirectives("coff-directives",
151 cl::desc("Display the contents PE/COFF .drectve section"));
147152 } // namespace opts
148153
149154 static int ReturnValue = EXIT_SUCCESS;
271276 Dumper->printMipsPLTGOT();
272277 if (opts::COFFImports)
273278 Dumper->printCOFFImports();
279 if (opts::COFFDirectives)
280 Dumper->printCOFFDirectives();
274281 }
275282
276283