[llvm] r321498 - [llvm-readobj] Support -needed-libs option for COFF files
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 27 11:59:56 PST 2017
Author: phosek
Date: Wed Dec 27 11:59:56 2017
New Revision: 321498
URL: http://llvm.org/viewvc/llvm-project?rev=321498&view=rev
Log:
[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
Added:
llvm/trunk/test/tools/llvm-readobj/Inputs/needed-libs.obj.coff-am64
llvm/trunk/test/tools/llvm-readobj/coff-needed-libs.test
Modified:
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Added: llvm/trunk/test/tools/llvm-readobj/Inputs/needed-libs.obj.coff-am64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/Inputs/needed-libs.obj.coff-am64?rev=321498&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-readobj/Inputs/needed-libs.obj.coff-am64 (added) and llvm/trunk/test/tools/llvm-readobj/Inputs/needed-libs.obj.coff-am64 Wed Dec 27 11:59:56 2017 differ
Added: llvm/trunk/test/tools/llvm-readobj/coff-needed-libs.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/coff-needed-libs.test?rev=321498&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/coff-needed-libs.test (added)
+++ llvm/trunk/test/tools/llvm-readobj/coff-needed-libs.test Wed Dec 27 11:59:56 2017
@@ -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: ]
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=321498&r1=321497&r2=321498&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Wed Dec 27 11:59:56 2017
@@ -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) {
More information about the llvm-commits
mailing list