@@ -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)
@@ -2249,10 +2255,18 @@ Error Object::removeSections(
22492255
22502256 // Transfer removed sections into the Object RemovedSections container for use
22512257 // later.
2252- std::move (Iter, Sections.end (), std::back_inserter (RemovedSections));
2253- // Now finally get rid of them all together.
2254- Sections.erase (Iter, std::end (Sections));
2255- return Error::success ();
2258+ for (auto &KeepSec : make_range (std::begin (Sections) , Iter))
2259+ {
2260+
2261+ if (Error E = KeepSec->removeSectionReferences (
2262+ AllowBrokenLinks, [&RemoveSections](const SectionBase *Sec) {
2263+ return RemoveSections.find (Sec) != RemoveSections.end ();
2264+ }))
2265+ std::move (Iter, Sections.end (), std::back_inserter (RemovedSections));
2266+ dbgs ()<<" Sections Removed:" <<KeepSec->Name <<' \n ' ;
2267+ Sections.erase (Iter, std::end (Sections));
2268+ return Error::success ();
2269+ }
22562270}
22572271
22582272Error Object::replaceSections (
0 commit comments