[llvm] [DirectX] Add `only-section` to `llvm-objcopy` for `DXContainer` (PR #156372)

Finn Plummer via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 13:02:58 PDT 2025


================
@@ -28,6 +28,13 @@ static Error handleArgs(const CommonConfig &Config, Object &Obj) {
       return Config.ToRemove.matches(P.Name);
     };
 
+  if (!Config.OnlySection.empty())
+    RemovePred = [&Config](const Part &P) {
+      // Explicitly keep these sections regardless of previous removes and
+      // remove everything else.
----------------
inbelic wrote:

This follows the same behaviour as other objcopy implementations (for instance [`ELFObjcopy`](https://github.com/llvm/llvm-project/blob/9a3aedb093008b55fa2018396cebb9b4606a7453/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp#L506)) where `--only-section` should just overwrite any previous specification for it to be removed (without warning or error)

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


More information about the llvm-commits mailing list