forked from OSchip/llvm-project
[ifs] Add option to hide undefined symbols
This change add an option to llvm-ifs to hide undefined symbols from its output. Differential Revision: https://reviews.llvm.org/D108428
This commit is contained in:
parent
ed367b9dff
commit
31e61c58b0
|
@ -51,6 +51,9 @@ Error validateIFSTarget(IFSStub &Stub, bool ParseTriple);
|
|||
void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch,
|
||||
bool StripEndianness, bool StripBitWidth);
|
||||
|
||||
/// Strips symbols from IFS symbol table that are undefined.
|
||||
void stripIFSUndefinedSymbols(IFSStub &Stub);
|
||||
|
||||
/// Parse llvm triple string into a IFSTarget struct.
|
||||
IFSTarget parseTriple(StringRef TripleStr);
|
||||
|
||||
|
|
|
@ -327,3 +327,13 @@ void ifs::stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch,
|
|||
Stub.Target.ObjectFormat.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void ifs::stripIFSUndefinedSymbols(IFSStub &Stub) {
|
||||
for (auto Iter = Stub.Symbols.begin(); Iter != Stub.Symbols.end();) {
|
||||
if (Iter->Undefined) {
|
||||
Iter = Stub.Symbols.erase(Iter);
|
||||
} else {
|
||||
Iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# RUN: llvm-ifs --input-format=ELF --strip-undefined --output-format=IFS --output=- %p/Inputs/gnu_hash.so | FileCheck %s
|
||||
|
||||
# CHECK: --- !ifs-v1
|
||||
# CHECK-NEXT: IfsVersion: 3.0
|
||||
# CHECK-NEXT: SoName: libsomething.so
|
||||
# CHECK-NEXT: Target: { ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 }
|
||||
# CHECK-NEXT: NeededLibs:
|
||||
# CHECK-NEXT: - libm.so.6
|
||||
# CHECK-NEXT: - libc.so.6
|
||||
# CHECK-NEXT: - ld-linux-x86-64.so.2
|
||||
# CHECK-NEXT: Symbols:
|
||||
# CHECK-NEXT: - { Name: AGlobalInteger, Type: Object, Size: 4 }
|
||||
# CHECK-NEXT: - { Name: AThreadLocalLongInteger, Type: TLS, Size: 8 }
|
||||
# CHECK-NEXT: - { Name: _Z11rotateArrayPii, Type: Func }
|
||||
# CHECK-NEXT: - { Name: _fini, Type: Func }
|
||||
# CHECK-NEXT: - { Name: _init, Type: Func }
|
||||
# CHECK-NEXT: ...
|
|
@ -99,6 +99,11 @@ cl::opt<bool> StripIFSTarget(
|
|||
"strip-ifs-target",
|
||||
cl::desc("Strip all target information away from IFS output"),
|
||||
cl::cat(IfsCategory));
|
||||
cl::opt<bool>
|
||||
StripUndefined("strip-undefined",
|
||||
cl::desc("Strip undefined symbols from IFS output"),
|
||||
cl::cat(IfsCategory));
|
||||
|
||||
cl::opt<std::string>
|
||||
SoName("soname",
|
||||
cl::desc("Manually set the DT_SONAME entry of any emitted files"),
|
||||
|
@ -443,6 +448,8 @@ int main(int argc, char *argv[]) {
|
|||
stripIFSTarget(Stub, StripIFSTarget, StripIFSArch,
|
||||
StripIFSEndiannessWidth, StripIFSBitWidth);
|
||||
}
|
||||
if (StripUndefined)
|
||||
stripIFSUndefinedSymbols(Stub);
|
||||
Error IFSWriteError = writeIFS(OutputFilePath.getValue(), Stub);
|
||||
if (IFSWriteError)
|
||||
fatalError(std::move(IFSWriteError));
|
||||
|
|
Loading…
Reference in New Issue