[llvm] [ELFObject] Added dbgs() statement in removeSections() (PR #124692)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 00:24:06 PST 2025


================
@@ -2249,10 +2255,18 @@ Error Object::removeSections(
 
   // Transfer removed sections into the Object RemovedSections container for use
   // later.
-  std::move(Iter, Sections.end(), std::back_inserter(RemovedSections));
-  // Now finally get rid of them all together.
-  Sections.erase(Iter, std::end(Sections));
-  return Error::success();
+  for(auto &KeepSec : make_range(std::begin(Sections) , Iter))
+  {
+    
+    if (Error E = KeepSec->removeSectionReferences(
+            AllowBrokenLinks, [&RemoveSections](const SectionBase *Sec) {
+              return RemoveSections.find(Sec) != RemoveSections.end();
+            }))
+      std::move(Iter, Sections.end(), std::back_inserter(RemovedSections));
+      dbgs()<<"Sections Removed:"<<KeepSec->Name<<'\n';
----------------
jh7370 wrote:

I don't think you want this here. You want it where elements are added to `RemoveSections`, which is where sections that are to be removed are placed.

https://github.com/llvm/llvm-project/pull/124692


More information about the llvm-commits mailing list