summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/Object.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/Object.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp
index 07b60367b9e..93487dc5bf6 100644
--- a/llvm/tools/llvm-objcopy/Object.cpp
+++ b/llvm/tools/llvm-objcopy/Object.cpp
@@ -194,12 +194,7 @@ void SymbolTableSection::removeSectionReferences(const SectionBase *Sec) {
" cannot be removed because it is referenced by the symbol table " +
this->Name);
}
- auto Iter =
- std::remove_if(std::begin(Symbols), std::end(Symbols),
- [=](const SymPtr &Sym) { return Sym->DefinedIn == Sec; });
- Size -= (std::end(Symbols) - Iter) * this->EntrySize;
- Symbols.erase(Iter, std::end(Symbols));
- assignIndices();
+ removeSymbols([Sec](const Symbol &Sym) { return Sym.DefinedIn == Sec; });
}
void SymbolTableSection::updateSymbols(function_ref<void(Symbol &)> Callable) {
@@ -211,6 +206,15 @@ void SymbolTableSection::updateSymbols(function_ref<void(Symbol &)> Callable) {
assignIndices();
}
+void SymbolTableSection::removeSymbols(function_ref<bool(Symbol &)> ToRemove) {
+ Symbols.erase(
+ std::remove_if(std::begin(Symbols), std::end(Symbols),
+ [ToRemove](const SymPtr &Sym) { return ToRemove(*Sym); }),
+ std::end(Symbols));
+ Size = Symbols.size() * EntrySize;
+ assignIndices();
+}
+
void SymbolTableSection::initialize(SectionTableRef SecTable) {
Size = 0;
setStrTab(SecTable.getSectionOfType<StringTableSection>(
OpenPOWER on IntegriCloud