[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:24 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.
----------------
dschuff wrote:

```suggestion
    // since that can invalidate the symbol table and relocation sections.
```

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


More information about the llvm-commits mailing list