@@ -766,10 +766,11 @@ 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) {
769+ [& ](const SymPtr &Sym) {
770770 if (ToRemove (*Sym)) {
771- llvm::outs () << " Symbols Removed:" << Sym->Name << " \n " ;
772- return true ;
771+ if (VerboseOutput)
772+ outs () << " Symbols Removed:" << Sym->Name << " \n " ;
773+ return true ;
773774 }
774775 return false ;
775776 }));
@@ -779,7 +780,6 @@ Error SymbolTableSection::removeSymbols(
779780 if (Size < PrevSize)
780781 IndicesChanged = true ;
781782 assignIndices ();
782- return Error::success ();
783783}
784784
785785void SymbolTableSection::replaceSectionReferences (
@@ -2201,7 +2201,7 @@ Error Object::updateSectionData(SectionBase &S, ArrayRef<uint8_t> Data) {
22012201}
22022202
22032203Error Object::removeSections (
2204- bool AllowBrokenLinks, std::function<bool (const SectionBase &)> ToRemove) {
2204+ bool AllowBrokenLinks, std::function<bool (const SectionBase &)> ToRemove, bool VerboseOutput ) {
22052205
22062206 auto Iter = std::stable_partition (
22072207 std::begin (Sections), std::end (Sections), [=](const SecPtr &Sec) {
@@ -2236,8 +2236,8 @@ Error Object::removeSections(
22362236 for (auto &RemoveSec : make_range (Iter, std::end (Sections))) {
22372237 for (auto &Segment : Segments)
22382238 Segment->removeSection (RemoveSec.get ());
2239- if (isVerboseEnabled ) {
2240- llvm:: outs () << " Removed Section : " << (RemoveSec.get ()->Name );
2239+ if (VerboseOutput ) {
2240+ outs () << " removed section : " << (RemoveSec.get ()->Name );
22412241 }
22422242 RemoveSec->onRemove ();
22432243 RemoveSections.insert (RemoveSec.get ());
@@ -2282,21 +2282,20 @@ Error Object::replaceSections(
22822282
22832283 if (Error E = removeSections (
22842284 /* AllowBrokenLinks=*/ false ,
2285- [=](const SectionBase &Sec) { return FromTo.count (&Sec) > 0 ; }))
2285+ [=](const SectionBase &Sec) { return FromTo.count (&Sec) > 0 ; }, false ))
22862286 return E;
22872287 llvm::sort (Sections, SectionIndexLess);
22882288 return Error::success ();
22892289}
22902290
22912291Error Object::removeSymbols (function_ref<bool (const Symbol &)> ToRemove) {
2292- if (SymbolTable)
2293- for (const SecPtr &Sec : Sections)
2294- if (Error E = Sec->removeSymbols (ToRemove)){
2295- if (isVerboseEnabled){
2296- llvm::outs () << " Removed Symbols:" << Sec->Name ;
2297- }
2292+ if (SymbolTable){
2293+ for (const SecPtr &Sec : Sections){
2294+ if (Error E = Sec->removeSymbols (ToRemove))
22982295 return E;
2299- }
2296+ outs () << " removed symbols:" << Sec->Name ;
2297+ }
2298+ }
23002299 return Error::success ();
23012300}
23022301
@@ -2583,7 +2582,7 @@ static Error removeUnneededSections(Object &Obj) {
25832582 : Obj.SymbolTable ->getStrTab ();
25842583 return Obj.removeSections (false , [&](const SectionBase &Sec) {
25852584 return &Sec == Obj.SymbolTable || &Sec == StrTab;
2586- });
2585+ }, false );
25872586}
25882587
25892588template <class ELFT > Error ELFWriter<ELFT>::finalize() {
@@ -2637,7 +2636,7 @@ template <class ELFT> Error ELFWriter<ELFT>::finalize() {
26372636 if (Error E = Obj.removeSections (false /* AllowBrokenLinks*/ ,
26382637 [this ](const SectionBase &Sec) {
26392638 return &Sec == Obj.SectionIndexTable ;
2640- }))
2639+ }, false ))
26412640 return E;
26422641 }
26432642 }
0 commit comments