[PATCH] D108428: [ifs] Add option to hide undefined symbols
Haowei Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 24 13:29:30 PDT 2021
haowei updated this revision to Diff 368450.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108428/new/
https://reviews.llvm.org/D108428
Files:
llvm/include/llvm/InterfaceStub/IFSHandler.h
llvm/lib/InterfaceStub/IFSHandler.cpp
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
@@ -87,6 +87,9 @@
cl::opt<bool> StripIFSTarget(
"strip-ifs-target",
cl::desc("Strip all target information away from IFS output"));
+cl::opt<bool>
+ StripUndefinedSymbol("strip-undefined-symbol",
+ cl::desc("Strip undefined symbols from IFS output"));
cl::opt<std::string>
SoName("soname",
cl::desc("Manually set the DT_SONAME entry of any emitted files"),
@@ -428,6 +431,9 @@
stripIFSTarget(Stub, StripIFSTarget, StripIFSArch,
StripIFSEndiannessWidth, StripIFSBitWidth);
}
+ if (StripUndefinedSymbol) {
+ stripIFSSymbols(Stub, IFSSymbolType::Unknown, true, false);
+ }
Error IFSWriteError = writeIFS(OutputFilePath.getValue(), Stub);
if (IFSWriteError)
fatalError(std::move(IFSWriteError));
Index: llvm/lib/InterfaceStub/IFSHandler.cpp
===================================================================
--- llvm/lib/InterfaceStub/IFSHandler.cpp
+++ llvm/lib/InterfaceStub/IFSHandler.cpp
@@ -327,3 +327,16 @@
Stub.Target.ObjectFormat.reset();
}
}
+
+void ifs::stripIFSSymbols(IFSStub &Stub, IFSSymbolType Type, bool Undefined,
+ bool Weak) {
+ std::vector<IFSSymbol>::iterator it = Stub.Symbols.begin();
+ while (it != Stub.Symbols.end()) {
+ if ((Type != IFSSymbolType::Unknown && Type == it->Type) ||
+ (Undefined && it->Undefined) || (Weak && it->Weak)) {
+ Stub.Symbols.erase(it);
+ } else {
+ it++;
+ }
+ }
+}
Index: llvm/include/llvm/InterfaceStub/IFSHandler.h
===================================================================
--- llvm/include/llvm/InterfaceStub/IFSHandler.h
+++ llvm/include/llvm/InterfaceStub/IFSHandler.h
@@ -51,6 +51,10 @@
void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch,
bool StripEndianness, bool StripBitWidth);
+/// Strips symbols from IFS symbol table based on the type and attributes.
+void stripIFSSymbols(IFSStub &Stub, IFSSymbolType Type, bool Undefined,
+ bool Weak);
+
/// Parse llvm triple string into a IFSTarget struct.
IFSTarget parseTriple(StringRef TripleStr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108428.368450.patch
Type: text/x-patch
Size: 2339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210824/6256e1a3/attachment.bin>
More information about the llvm-commits
mailing list