1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[llvm-readobj] Support -needed-libs option for COFF files

This implements the -needed-libs option in the COFF dumper.

Differential Revision: https://reviews.llvm.org/D41529

llvm-svn: 321498
This commit is contained in:
Petr Hosek 2017-12-27 19:59:56 +00:00
parent 84207a4f93
commit dc03f24781
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,5 @@
RUN: llvm-readobj -needed-libs %p/Inputs/needed-libs.obj.coff-am64 | FileCheck %s
CHECK: NeededLibraries [
CHECK-NEXT: KERNEL32.dll
CHECK-NEXT: ]

View File

@ -81,6 +81,9 @@ public:
void printSymbols() override;
void printDynamicSymbols() override;
void printUnwindInfo() override;
void printNeededLibraries() override;
void printCOFFImports() override;
void printCOFFExports() override;
void printCOFFDirectives() override;
@ -1522,6 +1525,25 @@ void COFFDumper::printUnwindInfo() {
}
}
void COFFDumper::printNeededLibraries() {
ListScope D(W, "NeededLibraries");
using LibsTy = std::vector<StringRef>;
LibsTy Libs;
for (const ImportDirectoryEntryRef &DirRef : Obj->import_directories()) {
StringRef Name;
if (!DirRef.getName(Name))
Libs.push_back(Name);
}
std::stable_sort(Libs.begin(), Libs.end());
for (const auto &L : Libs) {
outs() << " " << L << "\n";
}
}
void COFFDumper::printImportedSymbols(
iterator_range<imported_symbol_iterator> Range) {
for (const ImportedSymbolRef &I : Range) {