[PATCH] D119907: [ifs] Add --strip-needed flag
Alex Brachet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 16 09:10:45 PST 2022
abrachet updated this revision to Diff 409291.
abrachet added a comment.
Apply clang-format suggestion
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119907/new/
https://reviews.llvm.org/D119907
Files:
llvm/include/llvm/InterfaceStub/IFSHandler.h
llvm/lib/InterfaceStub/IFSHandler.cpp
llvm/test/tools/llvm-ifs/strip-needed.test
llvm/tools/llvm-ifs/llvm-ifs.cpp
Index: llvm/tools/llvm-ifs/llvm-ifs.cpp
===================================================================
--- llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -103,6 +103,9 @@
StripUndefined("strip-undefined",
cl::desc("Strip undefined symbols from IFS output"),
cl::cat(IfsCategory));
+cl::opt<bool> StripIFSNeededLibs("strip-needed",
+ cl::desc("Strip needed libs from IFS output"),
+ cl::cat(IfsCategory));
cl::opt<std::string>
SoName("soname",
@@ -417,6 +420,9 @@
if (OverrideError)
fatalError(std::move(OverrideError));
+ if (StripIFSNeededLibs)
+ stripIFSNeededLibs(Stub);
+
if (OutputELFFilePath.getNumOccurrences() == 0 &&
OutputIFSFilePath.getNumOccurrences() == 0 &&
OutputTBDFilePath.getNumOccurrences() == 0) {
Index: llvm/test/tools/llvm-ifs/strip-needed.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ifs/strip-needed.test
@@ -0,0 +1,26 @@
+## Test --strip-needed flag
+
+# RUN: llvm-ifs --input-format=IFS --strip-needed --output-ifs=- %s | FileCheck %s
+
+# RUN: llvm-ifs --input-format=IFS --output-elf=- %s | \
+# RUN: obj2yaml | FileCheck %s --check-prefix=FROM-ELF
+
+# RUN: llvm-ifs --input-format=IFS --strip-needed --output-elf=- %s | \
+# RUN: obj2yaml | FileCheck %s --check-prefix=FROM-ELF-STRIP-NEEDED
+
+--- !ifs-v1
+IfsVersion: 3.0
+Target: { ObjectFormat: ELF, Arch: AArch64, Endianness: little, BitWidth: 64 }
+NeededLibs:
+ - ''
+Symbols: []
+...
+
+# CHECK: --- !ifs-v1
+# CHECK-NEXT: IfsVersion: {{[1-9]\d*\.(0|([1-9]\d*))}}
+# CHECK-NEXT: Target: { ObjectFormat: ELF, Arch: AArch64, Endianness: little, BitWidth: 64 }
+# CHECK-NEXT: Symbols: []
+# CHECK-NEXT: ...
+
+# FROM-ELF: DT_NEEDED
+# FROM-ELF-STRIP-NEEDED-NOT: DT_NEEDED
Index: llvm/lib/InterfaceStub/IFSHandler.cpp
===================================================================
--- llvm/lib/InterfaceStub/IFSHandler.cpp
+++ llvm/lib/InterfaceStub/IFSHandler.cpp
@@ -337,3 +337,5 @@
}
}
}
+
+void ifs::stripIFSNeededLibs(IFSStub &Stub) { Stub.NeededLibs.clear(); }
Index: llvm/include/llvm/InterfaceStub/IFSHandler.h
===================================================================
--- llvm/include/llvm/InterfaceStub/IFSHandler.h
+++ llvm/include/llvm/InterfaceStub/IFSHandler.h
@@ -54,6 +54,9 @@
/// Strips symbols from IFS symbol table that are undefined.
void stripIFSUndefinedSymbols(IFSStub &Stub);
+/// Strips all NeededLibs.
+void stripIFSNeededLibs(IFSStub &Stub);
+
/// Parse llvm triple string into a IFSTarget struct.
IFSTarget parseTriple(StringRef TripleStr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119907.409291.patch
Type: text/x-patch
Size: 2737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220216/ce4151ef/attachment.bin>
More information about the llvm-commits
mailing list