@@ -766,8 +766,14 @@ Error SymbolTableSection::removeSymbols(
766766 function_ref<bool (const Symbol &)> ToRemove) {
767767 Symbols.erase (
768768 std::remove_if (std::begin (Symbols) + 1 , std::end (Symbols),
769- [ToRemove](const SymPtr &Sym) { return ToRemove (*Sym); }),
770- std::end (Symbols));
769+ [ToRemove](const SymPtr &Sym) {
770+ if (ToRemove (*Sym)) {
771+ dbgs ()<<" Symbols Removed:" <<Sym->Name << " \n " ;
772+ return true ;
773+ }
774+ return false ;
775+ }));
776+
771777 auto PrevSize = Size;
772778 Size = Symbols.size () * EntrySize;
773779 if (Size < PrevSize)
@@ -2240,10 +2246,18 @@ Error Object::removeSections(
22402246
22412247 // Transfer removed sections into the Object RemovedSections container for use
22422248 // later.
2243- std::move (Iter, Sections.end (), std::back_inserter (RemovedSections));
2244- // Now finally get rid of them all together.
2245- Sections.erase (Iter, std::end (Sections));
2246- return Error::success ();
2249+ for (auto &KeepSec : make_range (std::begin (Sections) , Iter))
2250+ {
2251+
2252+ if (Error E = KeepSec->removeSectionReferences (
2253+ AllowBrokenLinks, [&RemoveSections](const SectionBase *Sec) {
2254+ return RemoveSections.find (Sec) != RemoveSections.end ();
2255+ }))
2256+ std::move (Iter, Sections.end (), std::back_inserter (RemovedSections));
2257+ dbgs ()<<" Sections Removed:" <<KeepSec->Name <<' \n ' ;
2258+ Sections.erase (Iter, std::end (Sections));
2259+ return Error::success ();
2260+ }
22472261}
22482262
22492263Error Object::replaceSections (
0 commit comments