[lld] [llvm] [llvm-objcopy][WebAssembly] Allow --strip-debug to operate on relocatable files. (PR #102978)

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 15:24:23 PDT 2024


================
@@ -25,8 +25,23 @@ void Object::addSectionWithOwnedContents(
 }
 
 void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
-  // TODO: remove reloc sections for the removed section, handle symbols, etc.
-  llvm::erase_if(Sections, ToRemove);
+  if (isRelocatableObject) {
+    // For relocatable objects, avoid actually removing any sections,
+    // since that can invalidate the symbol table an relocation sections.
+    // TODO: Allow removal of sections by re-generating symbol table and
+    // relocation sections here instead.
+    for (auto &Sec : Sections) {
+      if (ToRemove(Sec)) {
+        //static std::vector<char> empty;
----------------
dschuff wrote:

remove?

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


More information about the llvm-commits mailing list