[llvm] [DirectX] Add `extract-section` to `llvm-objcopy` and implement it for `DXContainer` (PR #154804)

Finn Plummer via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 8 08:46:21 PDT 2025


https://github.com/inbelic updated https://github.com/llvm/llvm-project/pull/154804

>From 350d36a62c3b03f9dd93ad72759879f4da0e4935 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 21 Aug 2025 10:13:18 -0700
Subject: [PATCH 01/19] add common option `extract-section`

---
 llvm/include/llvm/ObjCopy/CommonConfig.h   |  1 +
 llvm/lib/ObjCopy/ConfigManager.cpp         | 15 +++++++--------
 llvm/tools/llvm-objcopy/CommonOpts.td      |  5 +++++
 llvm/tools/llvm-objcopy/ObjcopyOptions.cpp |  8 ++++++++
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/llvm/include/llvm/ObjCopy/CommonConfig.h b/llvm/include/llvm/ObjCopy/CommonConfig.h
index faa7b0db757a3..bad4bfdeaa46e 100644
--- a/llvm/include/llvm/ObjCopy/CommonConfig.h
+++ b/llvm/include/llvm/ObjCopy/CommonConfig.h
@@ -233,6 +233,7 @@ struct CommonConfig {
   SmallVector<StringRef, 0> DumpSection;
   SmallVector<NewSectionInfo, 0> UpdateSection;
   SmallVector<SectionPatternAddressUpdate, 0> ChangeSectionAddress;
+  SmallVector<StringRef, 0> ExtractSection;
 
   // Section matchers
   NameMatcher KeepSection;
diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index 2b17d728aad3f..718c8e2c8cd6a 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -27,7 +27,7 @@ Expected<const COFFConfig &> ConfigManager::getCOFFConfig() const {
       Common.DiscardMode == DiscardType::Locals ||
       !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
       Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
-      !Common.ChangeSectionAddress.empty())
+      !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
     return createStringError(llvm::errc::invalid_argument,
                              "option is not supported for COFF");
 
@@ -48,7 +48,7 @@ Expected<const MachOConfig &> ConfigManager::getMachOConfig() const {
       Common.DiscardMode == DiscardType::Locals ||
       !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
       Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
-      !Common.ChangeSectionAddress.empty())
+      !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
     return createStringError(llvm::errc::invalid_argument,
                              "option is not supported for MachO");
 
@@ -69,7 +69,7 @@ Expected<const WasmConfig &> ConfigManager::getWasmConfig() const {
       !Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
       !Common.SymbolsToRename.empty() || Common.GapFill != 0 ||
       Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
-      !Common.ChangeSectionAddress.empty())
+      !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
     return createStringError(llvm::errc::invalid_argument,
                              "only flags for section dumping, removal, and "
                              "addition are supported");
@@ -99,7 +99,7 @@ Expected<const XCOFFConfig &> ConfigManager::getXCOFFConfig() const {
       Common.Weaken || Common.StripUnneeded || Common.DecompressDebugSections ||
       Common.GapFill != 0 || Common.PadTo != 0 ||
       Common.ChangeSectionLMAValAll != 0 ||
-      !Common.ChangeSectionAddress.empty()) {
+      !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
     return createStringError(
         llvm::errc::invalid_argument,
         "no flags are supported yet, only basic copying is allowed");
@@ -124,10 +124,9 @@ ConfigManager::getDXContainerConfig() const {
       Common.StripUnneeded || Common.DecompressDebugSections ||
       Common.GapFill != 0 || Common.PadTo != 0 ||
       Common.ChangeSectionLMAValAll != 0 ||
-      !Common.ChangeSectionAddress.empty()) {
-    return createStringError(
-        llvm::errc::invalid_argument,
-        "no flags are supported yet, only basic copying is allowed");
+      !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
+    return createStringError(llvm::errc::invalid_argument,
+                             "option is not supported for directx");
   }
   return DXContainer;
 }
diff --git a/llvm/tools/llvm-objcopy/CommonOpts.td b/llvm/tools/llvm-objcopy/CommonOpts.td
index c247c93f6e0f2..411e954f393c4 100644
--- a/llvm/tools/llvm-objcopy/CommonOpts.td
+++ b/llvm/tools/llvm-objcopy/CommonOpts.td
@@ -69,6 +69,11 @@ def strip_sections
     : Flag<["--"], "strip-sections">,
       HelpText<"Remove all section headers and all section data not within segments">;
 
+defm extract_section
+    : Eq<"extract-section",
+         "Extract section named <section> into standalone object in file <file>">,
+      MetaVarName<"section=file">;
+
 defm strip_symbol : Eq<"strip-symbol", "Strip <symbol>">,
                     MetaVarName<"symbol">;
 def N : JoinedOrSeparate<["-"], "N">,
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
index 175f77c894825..3d7f33cd64bf4 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ b/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -1082,6 +1082,14 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
           "bad format for --dump-section, expected section=file");
     Config.DumpSection.push_back(Value);
   }
+  for (auto *Arg : InputArgs.filtered(OBJCOPY_extract_section)) {
+    StringRef Value(Arg->getValue());
+    if (Value.split('=').second.empty())
+      return createStringError(
+          errc::invalid_argument,
+          "bad format for --extract-section, expected section=file");
+    Config.ExtractSection.push_back(Value);
+  }
   Config.StripAll = InputArgs.hasArg(OBJCOPY_strip_all);
   Config.StripAllGNU = InputArgs.hasArg(OBJCOPY_strip_all_gnu);
   Config.StripDebug = InputArgs.hasArg(OBJCOPY_strip_debug);

>From 86160db816c6c91e139f06b3093782304b5b26bd Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Tue, 12 Aug 2025 19:29:20 +0000
Subject: [PATCH 02/19] add support for `extract-section` for `dxcontainer`

---
 .../DXContainer/DXContainerObjcopy.cpp        | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp b/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
index 375e382ddb044..5546f991ae390 100644
--- a/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
+++ b/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
@@ -11,6 +11,7 @@
 #include "DXContainerWriter.h"
 #include "llvm/ObjCopy/CommonConfig.h"
 #include "llvm/ObjCopy/DXContainer/DXContainerConfig.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace llvm {
 namespace objcopy {
@@ -18,6 +19,29 @@ namespace dxbc {
 
 using namespace object;
 
+static Error extractPartAsObject(StringRef PartName, StringRef OutFilename,
+                               StringRef InputFilename, const Object &Obj) {
+  for (const Part &P : Obj.Parts)
+    if (P.Name == PartName) {
+      auto PartObj = std::make_unique<Object>();
+      PartObj->Header = Obj.Header;
+      PartObj->Parts.push_back({P.Name, P.Data});
+      PartObj->recomputeHeader();
+
+      auto Write = [&OutFilename, &PartObj](raw_ostream &Out) -> Error {
+        DXContainerWriter Writer(*PartObj, Out);
+        if (Error E = Writer.write())
+          return createFileError(OutFilename, std::move(E));
+        return Error::success();
+      };
+
+      return writeToOutput(OutFilename, Write);
+    }
+
+  return createFileError(InputFilename, object_error::parse_failed,
+                         "part '%s' not found", PartName.str().c_str());
+}
+
 static Error handleArgs(const CommonConfig &Config, Object &Obj) {
   std::function<bool(const Part &)> RemovePred = [](const Part &) {
     return false;
@@ -28,6 +52,15 @@ static Error handleArgs(const CommonConfig &Config, Object &Obj) {
       return Config.ToRemove.matches(P.Name);
     };
 
+  for (StringRef Flag : Config.ExtractSection) {
+    StringRef SectionName;
+    StringRef FileName;
+    std::tie(SectionName, FileName) = Flag.split('=');
+    if (Error E =
+            extractPartAsObject(SectionName, FileName, Config.InputFilename, Obj))
+      return E;
+  }
+
   if (auto E = Obj.removeParts(RemovePred))
     return E;
 

>From c4810e6afebd82e748bbf3bf0b8e254a3bcbd8de Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Tue, 12 Aug 2025 19:46:22 +0000
Subject: [PATCH 03/19] add basic test cases

---
 .../DXContainer/extract-basic.test            | 306 ++++++++++++++++++
 .../DXContainer/extract-headers.test          |  56 ++++
 2 files changed, 362 insertions(+)
 create mode 100644 llvm/test/tools/llvm-objcopy/DXContainer/extract-basic.test
 create mode 100644 llvm/test/tools/llvm-objcopy/DXContainer/extract-headers.test

diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-basic.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-basic.test
new file mode 100644
index 0000000000000..c4fbd5bd29845
--- /dev/null
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-basic.test
@@ -0,0 +1,306 @@
+## Tests that a separate DXContainer is created for the RTS0 (root signature)
+## part, specified with --extract-section specified
+
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy %t --extract-section=RTS0=%t.rts0.out
+# RUN: obj2yaml %t.rts0.out | FileCheck %s
+
+## The DXContainer described below was generated with:
+
+## `clang-dxc -T cs_6_7 test.hlsl /Fo temp.dxo`
+## `obj2yaml temp.dxo`
+
+## ``` test.hlsl
+## [RootSignature("")]
+## [numthreads(1,1,1)]
+## void main() {}
+## ```
+
+--- !dxcontainer
+Header:
+  Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+                     0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+  Version:
+    Major:           1
+    Minor:           0
+# CHECK: FileSize:       68
+  FileSize:        1984
+# CHECK-NEXT: PartCount:     1
+# CHECK-NEXT: PartOffsets:   [ 36 ]
+  PartCount:       7
+  PartOffsets:     [ 60, 1792, 1808, 1836, 1852, 1868, 1900 ]
+# CHECK-NEXT: Parts:
+Parts:
+# CHECK-NOT: DXIL
+# CHECK-NOT: SFI0
+# CHECK-NOT: HASH
+# CHECK-NOT: ISG1
+# CHECK-NOT: OSG1
+# CHECK: Name:            RTS0
+# CHECK-NOT: PSV0
+  - Name:            DXIL
+    Size:            1724
+    Program:
+      MajorVersion:    6
+      MinorVersion:    7
+      ShaderKind:      5
+      Size:            431
+      DXILMajorVersion: 1
+      DXILMinorVersion: 7
+      DXILSize:        1700
+      DXIL:            [ 0x42, 0x43, 0xC0, 0xDE, 0x21, 0xC, 0x0, 0x0, 0xA6,
+                         0x1, 0x0, 0x0, 0xB, 0x82, 0x20, 0x0, 0x2, 0x0,
+                         0x0, 0x0, 0x13, 0x0, 0x0, 0x0, 0x7, 0x81, 0x23,
+                         0x91, 0x41, 0xC8, 0x4, 0x49, 0x6, 0x10, 0x32,
+                         0x39, 0x92, 0x1, 0x84, 0xC, 0x25, 0x5, 0x8, 0x19,
+                         0x1E, 0x4, 0x8B, 0x62, 0x80, 0x10, 0x45, 0x2,
+                         0x42, 0x92, 0xB, 0x42, 0x84, 0x10, 0x32, 0x14,
+                         0x38, 0x8, 0x18, 0x4B, 0xA, 0x32, 0x42, 0x88,
+                         0x48, 0x90, 0x14, 0x20, 0x43, 0x46, 0x88, 0xA5,
+                         0x0, 0x19, 0x32, 0x42, 0xE4, 0x48, 0xE, 0x90,
+                         0x11, 0x22, 0xC4, 0x50, 0x41, 0x51, 0x81, 0x8C,
+                         0xE1, 0x83, 0xE5, 0x8A, 0x4, 0x21, 0x46, 0x6,
+                         0x51, 0x18, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1B,
+                         0x90, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0xC0,
+                         0x1, 0x24, 0x80, 0x2, 0x0, 0x0, 0x0, 0x49, 0x18,
+                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x13, 0x82, 0x0,
+                         0x0, 0x89, 0x20, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0,
+                         0x32, 0x22, 0x8, 0x9, 0x20, 0x64, 0x85, 0x4, 0x13,
+                         0x22, 0xA4, 0x84, 0x4, 0x13, 0x22, 0xE3, 0x84,
+                         0xA1, 0x90, 0x14, 0x12, 0x4C, 0x88, 0x8C, 0xB,
+                         0x84, 0x84, 0x4C, 0x10, 0x20, 0x73, 0x4, 0x8,
+                         0xC1, 0x65, 0xC3, 0x85, 0x2C, 0xE8, 0x3, 0x40,
+                         0x14, 0x91, 0x4E, 0xD1, 0x4A, 0x48, 0x44, 0x54,
+                         0x11, 0xC3, 0x9, 0x30, 0xC4, 0x18, 0x1, 0x30,
+                         0x2, 0x50, 0x82, 0x21, 0x1A, 0x8, 0x98, 0x23,
+                         0x0, 0x3, 0x0, 0x13, 0x14, 0x72, 0xC0, 0x87, 0x74,
+                         0x60, 0x87, 0x36, 0x68, 0x87, 0x79, 0x68, 0x3,
+                         0x72, 0xC0, 0x87, 0xD, 0xAE, 0x50, 0xE, 0x6D,
+                         0xD0, 0xE, 0x7A, 0x50, 0xE, 0x6D, 0x0, 0xF, 0x7A,
+                         0x30, 0x7, 0x72, 0xA0, 0x7, 0x73, 0x20, 0x7, 0x6D,
+                         0x90, 0xE, 0x71, 0xA0, 0x7, 0x73, 0x20, 0x7, 0x6D,
+                         0x90, 0xE, 0x78, 0xA0, 0x7, 0x78, 0xD0, 0x6, 0xE9,
+                         0x10, 0x7, 0x76, 0xA0, 0x7, 0x71, 0x60, 0x7, 0x6D,
+                         0x90, 0xE, 0x73, 0x20, 0x7, 0x7A, 0x30, 0x7, 0x72,
+                         0xD0, 0x6, 0xE9, 0x60, 0x7, 0x74, 0xA0, 0x7, 0x76,
+                         0x40, 0x7, 0x6D, 0x60, 0xE, 0x71, 0x60, 0x7, 0x7A,
+                         0x10, 0x7, 0x76, 0xD0, 0x6, 0xE6, 0x30, 0x7, 0x72,
+                         0xA0, 0x7, 0x73, 0x20, 0x7, 0x6D, 0x60, 0xE, 0x76,
+                         0x40, 0x7, 0x7A, 0x60, 0x7, 0x74, 0xD0, 0x6, 0xEE,
+                         0x80, 0x7, 0x7A, 0x10, 0x7, 0x76, 0xA0, 0x7, 0x73,
+                         0x20, 0x7, 0x7A, 0x60, 0x7, 0x74, 0x30, 0xE4,
+                         0x21, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x2, 0x0,
+                         0x0, 0x0, 0x20, 0xB, 0x4, 0x7, 0x0, 0x0, 0x0,
+                         0x32, 0x1E, 0x98, 0xC, 0x19, 0x11, 0x4C, 0x90,
+                         0x8C, 0x9, 0x26, 0x47, 0xC6, 0x4, 0x43, 0xBA,
+                         0x12, 0x28, 0x88, 0x62, 0x28, 0x87, 0x42, 0x28,
+                         0x2, 0x0, 0x0, 0x0, 0x79, 0x18, 0x0, 0x0, 0xE2,
+                         0x0, 0x0, 0x0, 0x33, 0x8, 0x80, 0x1C, 0xC4, 0xE1,
+                         0x1C, 0x66, 0x14, 0x1, 0x3D, 0x88, 0x43, 0x38,
+                         0x84, 0xC3, 0x8C, 0x42, 0x80, 0x7, 0x79, 0x78,
+                         0x7, 0x73, 0x98, 0x71, 0xC, 0xE6, 0x0, 0xF, 0xED,
+                         0x10, 0xE, 0xF4, 0x80, 0xE, 0x33, 0xC, 0x42, 0x1E,
+                         0xC2, 0xC1, 0x1D, 0xCE, 0xA1, 0x1C, 0x66, 0x30,
+                         0x5, 0x3D, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1B,
+                         0xCC, 0x3, 0x3D, 0xC8, 0x43, 0x3D, 0x8C, 0x3,
+                         0x3D, 0xCC, 0x78, 0x8C, 0x74, 0x70, 0x7, 0x7B,
+                         0x8, 0x7, 0x79, 0x48, 0x87, 0x70, 0x70, 0x7, 0x7A,
+                         0x70, 0x3, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87,
+                         0x19, 0xCC, 0x11, 0xE, 0xEC, 0x90, 0xE, 0xE1,
+                         0x30, 0xF, 0x6E, 0x30, 0xF, 0xE3, 0xF0, 0xE, 0xF0,
+                         0x50, 0xE, 0x33, 0x10, 0xC4, 0x1D, 0xDE, 0x21,
+                         0x1C, 0xD8, 0x21, 0x1D, 0xC2, 0x61, 0x1E, 0x66,
+                         0x30, 0x89, 0x3B, 0xBC, 0x83, 0x3B, 0xD0, 0x43,
+                         0x39, 0xB4, 0x3, 0x3C, 0xBC, 0x83, 0x3C, 0x84,
+                         0x3, 0x3B, 0xCC, 0xF0, 0x14, 0x76, 0x60, 0x7,
+                         0x7B, 0x68, 0x7, 0x37, 0x68, 0x87, 0x72, 0x68,
+                         0x7, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70,
+                         0x60, 0x7, 0x76, 0x28, 0x7, 0x76, 0xF8, 0x5, 0x76,
+                         0x78, 0x87, 0x77, 0x80, 0x87, 0x5F, 0x8, 0x87,
+                         0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98,
+                         0x81, 0x2C, 0xEE, 0xF0, 0xE, 0xEE, 0xE0, 0xE,
+                         0xF5, 0xC0, 0xE, 0xEC, 0x30, 0x3, 0x62, 0xC8,
+                         0xA1, 0x1C, 0xE4, 0xA1, 0x1C, 0xCC, 0xA1, 0x1C,
+                         0xE4, 0xA1, 0x1C, 0xDC, 0x61, 0x1C, 0xCA, 0x21,
+                         0x1C, 0xC4, 0x81, 0x1D, 0xCA, 0x61, 0x6, 0xD6,
+                         0x90, 0x43, 0x39, 0xC8, 0x43, 0x39, 0x98, 0x43,
+                         0x39, 0xC8, 0x43, 0x39, 0xB8, 0xC3, 0x38, 0x94,
+                         0x43, 0x38, 0x88, 0x3, 0x3B, 0x94, 0xC3, 0x2F,
+                         0xBC, 0x83, 0x3C, 0xFC, 0x82, 0x3B, 0xD4, 0x3,
+                         0x3B, 0xB0, 0xC3, 0xC, 0xC7, 0x69, 0x87, 0x70,
+                         0x58, 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x7,
+                         0x78, 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xA0,
+                         0x87, 0x19, 0xCE, 0x53, 0xF, 0xEE, 0x0, 0xF, 0xF2,
+                         0x50, 0xE, 0xE4, 0x90, 0xE, 0xE3, 0x40, 0xF, 0xE1,
+                         0x20, 0xE, 0xEC, 0x50, 0xE, 0x33, 0x20, 0x28,
+                         0x1D, 0xDC, 0xC1, 0x1E, 0xC2, 0x41, 0x1E, 0xD2,
+                         0x21, 0x1C, 0xDC, 0x81, 0x1E, 0xDC, 0xE0, 0x1C,
+                         0xE4, 0xE1, 0x1D, 0xEA, 0x1, 0x1E, 0x66, 0x18,
+                         0x51, 0x38, 0xB0, 0x43, 0x3A, 0x9C, 0x83, 0x3B,
+                         0xCC, 0x50, 0x24, 0x76, 0x60, 0x7, 0x7B, 0x68,
+                         0x7, 0x37, 0x60, 0x87, 0x77, 0x78, 0x7, 0x78,
+                         0x98, 0x51, 0x4C, 0xF4, 0x90, 0xF, 0xF0, 0x50,
+                         0xE, 0x33, 0x1E, 0x6A, 0x1E, 0xCA, 0x61, 0x1C,
+                         0xE8, 0x21, 0x1D, 0xDE, 0xC1, 0x1D, 0x7E, 0x1,
+                         0x1E, 0xE4, 0xA1, 0x1C, 0xCC, 0x21, 0x1D, 0xF0,
+                         0x61, 0x6, 0x54, 0x85, 0x83, 0x38, 0xCC, 0xC3,
+                         0x3B, 0xB0, 0x43, 0x3D, 0xD0, 0x43, 0x39, 0xFC,
+                         0xC2, 0x3C, 0xE4, 0x43, 0x3B, 0x88, 0xC3, 0x3B,
+                         0xB0, 0xC3, 0x8C, 0xC5, 0xA, 0x87, 0x79, 0x98,
+                         0x87, 0x77, 0x18, 0x87, 0x74, 0x8, 0x7, 0x7A,
+                         0x28, 0x7, 0x72, 0x98, 0x81, 0x5C, 0xE3, 0x10,
+                         0xE, 0xEC, 0xC0, 0xE, 0xE5, 0x50, 0xE, 0xF3, 0x30,
+                         0x23, 0xC1, 0xD2, 0x41, 0x1E, 0xE4, 0xE1, 0x17,
+                         0xD8, 0xE1, 0x1D, 0xDE, 0x1, 0x1E, 0x66, 0x48,
+                         0x19, 0x3B, 0xB0, 0x83, 0x3D, 0xB4, 0x83, 0x1B,
+                         0x84, 0xC3, 0x38, 0x8C, 0x43, 0x39, 0xCC, 0xC3,
+                         0x3C, 0xB8, 0xC1, 0x39, 0xC8, 0xC3, 0x3B, 0xD4,
+                         0x3, 0x3C, 0xCC, 0x48, 0xB4, 0x71, 0x8, 0x7, 0x76,
+                         0x60, 0x7, 0x71, 0x8, 0x87, 0x71, 0x58, 0x87,
+                         0x19, 0xDB, 0xC6, 0xE, 0xEC, 0x60, 0xF, 0xED,
+                         0xE0, 0x6, 0xF0, 0x20, 0xF, 0xE5, 0x30, 0xF, 0xE5,
+                         0x20, 0xF, 0xF6, 0x50, 0xE, 0x6E, 0x10, 0xE, 0xE3,
+                         0x30, 0xE, 0xE5, 0x30, 0xF, 0xF3, 0xE0, 0x6, 0xE9,
+                         0xE0, 0xE, 0xE4, 0x50, 0xE, 0xF8, 0x30, 0x23,
+                         0xE2, 0xEC, 0x61, 0x1C, 0xC2, 0x81, 0x1D, 0xD8,
+                         0xE1, 0x17, 0xEC, 0x21, 0x1D, 0xE6, 0x21, 0x1D,
+                         0xC4, 0x21, 0x1D, 0xD8, 0x21, 0x1D, 0xE8, 0x21,
+                         0x1F, 0x66, 0x20, 0x9D, 0x3B, 0xBC, 0x43, 0x3D,
+                         0xB8, 0x3, 0x39, 0x94, 0x83, 0x39, 0xCC, 0x58,
+                         0xBC, 0x70, 0x70, 0x7, 0x77, 0x78, 0x7, 0x7A,
+                         0x8, 0x7, 0x7A, 0x48, 0x87, 0x77, 0x70, 0x87,
+                         0x19, 0xCB, 0xE7, 0xE, 0xEF, 0x30, 0xF, 0xE1,
+                         0xE0, 0xE, 0xE9, 0x40, 0xF, 0xE9, 0xA0, 0xF, 0xE5,
+                         0x30, 0xC3, 0x1, 0x3, 0x73, 0xA8, 0x7, 0x77, 0x18,
+                         0x87, 0x5F, 0x98, 0x87, 0x70, 0x70, 0x87, 0x74,
+                         0xA0, 0x87, 0x74, 0xD0, 0x87, 0x72, 0x98, 0x81,
+                         0x84, 0x41, 0x39, 0xE0, 0xC3, 0x38, 0xB0, 0x43,
+                         0x3D, 0x90, 0x43, 0x39, 0xCC, 0x40, 0xC4, 0xA0,
+                         0x1D, 0xCA, 0xA1, 0x1D, 0xE0, 0x41, 0x1E, 0xDE,
+                         0xC1, 0x1C, 0x66, 0x24, 0x63, 0x30, 0xE, 0xE1,
+                         0xC0, 0xE, 0xEC, 0x30, 0xF, 0xE9, 0x40, 0xF, 0xE5,
+                         0x30, 0x43, 0x21, 0x83, 0x75, 0x18, 0x7, 0x73,
+                         0x48, 0x87, 0x5F, 0xA0, 0x87, 0x7C, 0x80, 0x87,
+                         0x72, 0x98, 0xB1, 0x94, 0x1, 0x3C, 0x8C, 0xC3,
+                         0x3C, 0x94, 0xC3, 0x38, 0xD0, 0x43, 0x3A, 0xBC,
+                         0x83, 0x3B, 0xCC, 0xC3, 0x8C, 0xC5, 0xC, 0x48,
+                         0x21, 0x15, 0x42, 0x61, 0x1E, 0xE6, 0x21, 0x1D,
+                         0xCE, 0xC1, 0x1D, 0x52, 0x81, 0x14, 0x66, 0x4C,
+                         0x67, 0x30, 0xE, 0xEF, 0x20, 0xF, 0xEF, 0xE0,
+                         0x6, 0xEF, 0x50, 0xF, 0xF4, 0x30, 0xF, 0xE9, 0x40,
+                         0xE, 0xE5, 0xE0, 0x6, 0xE6, 0x20, 0xF, 0xE1, 0xD0,
+                         0xE, 0xE5, 0x30, 0xA3, 0x40, 0x83, 0x76, 0x68,
+                         0x7, 0x79, 0x8, 0x87, 0x19, 0x52, 0x1A, 0xB8,
+                         0xC3, 0x3B, 0x84, 0x3, 0x3B, 0xA4, 0x43, 0x38,
+                         0xCC, 0x83, 0x1B, 0x84, 0x3, 0x39, 0x90, 0x83,
+                         0x3C, 0xCC, 0x3, 0x3C, 0x84, 0xC3, 0x38, 0x94,
+                         0xC3, 0xC, 0x46, 0xD, 0xC6, 0x21, 0x1C, 0xD8,
+                         0x81, 0x1D, 0xCA, 0xA1, 0x1C, 0x7E, 0x81, 0x1E,
+                         0xF2, 0x1, 0x1E, 0xCA, 0x61, 0x86, 0xB3, 0x6,
+                         0xE4, 0x80, 0xF, 0x6E, 0xE0, 0xE, 0xEF, 0xE0,
+                         0xE, 0xF5, 0xE0, 0xE, 0xE9, 0x60, 0xE, 0xEF, 0x20,
+                         0xF, 0xED, 0x30, 0xA3, 0x62, 0x3, 0x72, 0xC0,
+                         0x7, 0x37, 0x18, 0x87, 0x77, 0x70, 0x7, 0x7A,
+                         0x90, 0x87, 0x77, 0x60, 0x7, 0x73, 0x60, 0x87,
+                         0x77, 0xB8, 0x7, 0x37, 0x40, 0x87, 0x74, 0x70,
+                         0x7, 0x7A, 0x98, 0x87, 0x19, 0x4B, 0x1B, 0x90,
+                         0x3, 0x3E, 0xB8, 0x1, 0x3C, 0xC8, 0x43, 0x39,
+                         0x8C, 0x43, 0x3A, 0xCC, 0x43, 0x39, 0x0, 0x0,
+                         0x79, 0x28, 0x0, 0x0, 0x53, 0x0, 0x0, 0x0, 0xC2,
+                         0x3C, 0x90, 0x40, 0x86, 0x10, 0x19, 0x32, 0xE2,
+                         0x64, 0x90, 0x40, 0x46, 0x2, 0x19, 0x23, 0x23,
+                         0x46, 0x2, 0x13, 0x24, 0xC6, 0x0, 0x13, 0x74,
+                         0xD4, 0x61, 0x8C, 0x2D, 0xCC, 0xED, 0xC, 0xC4,
+                         0xAE, 0x4C, 0x6E, 0x2E, 0xED, 0xCD, 0xD, 0x44,
+                         0x46, 0xC6, 0x5, 0xC6, 0x5, 0xE6, 0x2C, 0x8D,
+                         0xE, 0x4, 0xE5, 0x2C, 0x8D, 0xE, 0xE8, 0x2C, 0x8D,
+                         0xE, 0xAD, 0x4E, 0xCC, 0x65, 0xEC, 0xAD, 0x4D,
+                         0x27, 0xCD, 0x4D, 0xAC, 0x8C, 0x2D, 0x6D, 0xEC,
+                         0x85, 0x8D, 0xCD, 0xAE, 0xAD, 0x5, 0x4E, 0xEE,
+                         0x4D, 0xAD, 0x6C, 0x8C, 0xCE, 0xE5, 0x2C, 0x8D,
+                         0xE, 0x84, 0x86, 0xC6, 0xCC, 0xC6, 0x86, 0x4C,
+                         0xC, 0x87, 0x6C, 0xEC, 0x26, 0x67, 0x46, 0x26,
+                         0x67, 0x6C, 0xA6, 0xCC, 0x66, 0x8C, 0xC6, 0x2C,
+                         0xEC, 0x26, 0xC, 0x26, 0x2C, 0xEC, 0x26, 0xCC,
+                         0xCC, 0x86, 0x6, 0xE6, 0x6, 0x26, 0xE7, 0x86,
+                         0xE6, 0x26, 0xE5, 0x8, 0x63, 0x73, 0x87, 0x68,
+                         0xB, 0x4B, 0x73, 0x3B, 0xCA, 0xDD, 0x18, 0x5A,
+                         0x98, 0xDC, 0xD7, 0x5C, 0x9A, 0x5E, 0xD9, 0x69,
+                         0xCC, 0xE4, 0xC2, 0xDA, 0xCA, 0x5A, 0xE0, 0xDE,
+                         0xD2, 0xDC, 0xE8, 0xCA, 0xE4, 0x86, 0x20, 0x1C,
+                         0xC1, 0x10, 0x84, 0x43, 0x18, 0x82, 0x70, 0xC,
+                         0x43, 0x10, 0xE, 0x62, 0x8, 0x42, 0x1, 0xC, 0x41,
+                         0x38, 0x8A, 0x21, 0x8, 0x87, 0x31, 0x6, 0xC1,
+                         0x38, 0xC6, 0x10, 0x4, 0x63, 0x18, 0x4, 0x24,
+                         0x19, 0x83, 0x60, 0x24, 0x63, 0x18, 0xC, 0xC3,
+                         0x18, 0x83, 0xB0, 0x44, 0x63, 0x28, 0x94, 0x1,
+                         0x0, 0xA4, 0x31, 0xC, 0x6, 0xB1, 0x8C, 0x61, 0x60,
+                         0xA, 0xC6, 0x24, 0x64, 0x78, 0x2E, 0x76, 0x61,
+                         0x6C, 0x76, 0x65, 0x72, 0x43, 0x9, 0x18, 0xA3,
+                         0xB0, 0xB1, 0xD9, 0xB5, 0xB9, 0xA4, 0x91, 0x95,
+                         0xB9, 0xD1, 0xD, 0x25, 0x68, 0x8C, 0x43, 0x86,
+                         0xE7, 0x32, 0x87, 0x16, 0x46, 0x56, 0x26, 0xD7,
+                         0xF4, 0x46, 0x56, 0xC6, 0x36, 0x94, 0xC0, 0x31,
+                         0xA, 0x19, 0x9E, 0x8B, 0x5D, 0x99, 0xDC, 0x5C,
+                         0xDA, 0x9B, 0xDB, 0x50, 0x82, 0xC7, 0x38, 0x64,
+                         0x78, 0x2E, 0x65, 0x6E, 0x74, 0x72, 0x79, 0x50,
+                         0x6F, 0x69, 0x6E, 0x74, 0x73, 0x43, 0x9, 0x24,
+                         0x13, 0xB1, 0xB1, 0xD9, 0xB5, 0xB9, 0xB4, 0xBD,
+                         0x91, 0xD5, 0xB1, 0x95, 0xB9, 0x98, 0xB1, 0x85,
+                         0x9D, 0xCD, 0xD, 0x45, 0x98, 0x28, 0x0, 0x0, 0x71,
+                         0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x6, 0x40,
+                         0x30, 0x0, 0xD2, 0x0, 0x0, 0x0, 0x61, 0x20, 0x0,
+                         0x0, 0x6, 0x0, 0x0, 0x0, 0x13, 0x4, 0x1, 0x86,
+                         0x3, 0x1, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x7, 0x50,
+                         0x10, 0xCD, 0x14, 0x61, 0x0, 0x0, 0x0, 0x0, 0x0,
+                         0x0, 0x0, 0x0, 0x0, 0x0 ]
+  - Name:            SFI0
+    Size:            8
+  - Name:            HASH
+    Size:            20
+    Hash:
+      IncludesSource:  false
+      Digest:          [ 0x9F, 0xD1, 0xD9, 0xE2, 0x49, 0xFB, 0x3A, 0x6C,
+                         0x8C, 0x14, 0x8A, 0x96, 0x1C, 0x7D, 0x85, 0xA9 ]
+  - Name:            ISG1
+    Size:            8
+    Signature:
+      Parameters:      []
+  - Name:            OSG1
+    Size:            8
+    Signature:
+      Parameters:      []
+  - Name:            RTS0
+    Size:            24
+    RootSignature:
+      Version:         2
+      NumRootParameters: 0
+      RootParametersOffset: 24
+      NumStaticSamplers: 0
+      StaticSamplersOffset: 0
+      Parameters:      []
+  - Name:            PSV0
+    Size:            76
+    PSVInfo:
+      Version:         3
+      ShaderStage:     5
+      MinimumWaveLaneCount: 0
+      MaximumWaveLaneCount: 4294967295
+      UsesViewID:      0
+      SigInputVectors: 0
+      SigOutputVectors: [ 0, 0, 0, 0 ]
+      NumThreadsX:     1
+      NumThreadsY:     1
+      NumThreadsZ:     1
+      EntryName:       main
+      ResourceStride:  24
+      Resources:       []
+      SigInputElements: []
+      SigOutputElements: []
+      SigPatchOrPrimElements: []
+      InputOutputMap:
+        - [  ]
+        - [  ]
+        - [  ]
+        - [  ]
+...
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-headers.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-headers.test
new file mode 100644
index 0000000000000..9af1a2bca749e
--- /dev/null
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-headers.test
@@ -0,0 +1,56 @@
+## Tests that a separate DXContainer is created with only the specified section
+## for each --extract-section specified
+
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy %t --extract-section=FKE1=%t.fke1.out --extract-section=FKE4=%t.fke4.out
+# RUN: obj2yaml %t.fke1.out | FileCheck %s --check-prefixes=CHECK,FKE1
+# RUN: obj2yaml %t.fke4.out | FileCheck %s --check-prefixes=CHECK,FKE4
+
+--- !dxcontainer
+Header:
+  Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+                     0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+  Version:
+    Major:           1
+    Minor:           0
+## FKE1: FileSize:       52
+## FKE4: FileSize:       1732
+  FileSize:        1996
+# CHECK: PartCount:     1
+# CHECK-NEXT: PartOffsets:   [ 36 ]
+  PartCount:       7
+  PartOffsets:     [ 60, 76, 92, 108, 236, 1932, 1960 ]
+# CHECK-NEXT: Parts:
+Parts:
+# CHECK-NOT: FKE0
+# FKE1: Name:            FKE1
+# FKE4-NOT: FKE1
+# CHECK-NOT: FKE2
+# CHECK-NOT: FKE3
+# FKE1-NOT: FKE4
+# FKE4: Name:            FKE4
+# CHECK-NOT: FKE5
+  - Name:            FKE0
+    Size:            8
+  - Name:            FKE1
+    Size:            8
+  - Name:            FKE2
+    Size:            8
+  - Name:            FKE3
+    Size:            120
+  - Name:            FKE4
+    Size:            1688
+  - Name:            FKE5
+    Size:            20
+  - Name:            DXIL
+    Size:            28
+    Program:
+      MajorVersion:    6
+      MinorVersion:    5
+      ShaderKind:      5
+      Size:            8
+      DXILMajorVersion: 1
+      DXILMinorVersion: 5
+      DXILSize:        4
+      DXIL:            [ 0x42, 0x43, 0xC0, 0xDE, ]
+...

>From 8b733cc59843817754ee490fb5672f6dd3eba449 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 21 Aug 2025 10:23:32 -0700
Subject: [PATCH 04/19] comment touch up

---
 llvm/lib/ObjCopy/ConfigManager.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index 718c8e2c8cd6a..446266cfbeecb 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -126,7 +126,7 @@ ConfigManager::getDXContainerConfig() const {
       Common.ChangeSectionLMAValAll != 0 ||
       !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
     return createStringError(llvm::errc::invalid_argument,
-                             "option is not supported for directx");
+                             "option is not supported for DXContainer");
   }
   return DXContainer;
 }

>From 2129aed6398fd7cfc48d660759a3fa99ad2b59a6 Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Thu, 14 Aug 2025 17:13:48 +0000
Subject: [PATCH 05/19] add failure testcase

---
 .../DXContainer/extract-errs.test             | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 llvm/test/tools/llvm-objcopy/DXContainer/extract-errs.test

diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-errs.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-errs.test
new file mode 100644
index 0000000000000..03f99b5192d36
--- /dev/null
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-errs.test
@@ -0,0 +1,21 @@
+## Check that llvm-objcopy reports a suitable error when it
+## can't find the section to extract
+
+## We can't have multiple DXIL parts.
+# RUN: yaml2obj %s --docnum=1 -o %t1
+# RUN: not llvm-objcopy %t1 --extract-section=UNKNOWN=%t.unknown.out 2>&1 | FileCheck %s -DFILE=%t1 --check-prefix=ERROR1
+
+# ERROR1: error: '[[FILE]]': part 'UNKNOWN' not found
+
+--- !dxcontainer
+Header:
+  Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+                     0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+  Version:
+    Major:           1
+    Minor:           0
+  PartCount:       1
+Parts:
+  - Name:            FKE0
+    Size:            8
+...

>From fcf53164fd15afda47de9d584cc4c9693a20e1b6 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 21 Aug 2025 10:28:24 -0700
Subject: [PATCH 06/19] actually enable option for DXContainer

---
 llvm/lib/ObjCopy/ConfigManager.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index 446266cfbeecb..bd9af30e3e003 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -124,7 +124,7 @@ ConfigManager::getDXContainerConfig() const {
       Common.StripUnneeded || Common.DecompressDebugSections ||
       Common.GapFill != 0 || Common.PadTo != 0 ||
       Common.ChangeSectionLMAValAll != 0 ||
-      !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
+      !Common.ChangeSectionAddress.empty()) {
     return createStringError(llvm::errc::invalid_argument,
                              "option is not supported for DXContainer");
   }

>From a6bf6cca2aa2743bdfa76d89a5758cb6bc0f7237 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 21 Aug 2025 10:48:58 -0700
Subject: [PATCH 07/19] self-review: no need to alloc

---
 llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp b/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
index 5546f991ae390..66ebe0016965e 100644
--- a/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
+++ b/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
@@ -23,13 +23,13 @@ static Error extractPartAsObject(StringRef PartName, StringRef OutFilename,
                                StringRef InputFilename, const Object &Obj) {
   for (const Part &P : Obj.Parts)
     if (P.Name == PartName) {
-      auto PartObj = std::make_unique<Object>();
-      PartObj->Header = Obj.Header;
-      PartObj->Parts.push_back({P.Name, P.Data});
-      PartObj->recomputeHeader();
+      Object PartObj;
+      PartObj.Header = Obj.Header;
+      PartObj.Parts.push_back({P.Name, P.Data});
+      PartObj.recomputeHeader();
 
       auto Write = [&OutFilename, &PartObj](raw_ostream &Out) -> Error {
-        DXContainerWriter Writer(*PartObj, Out);
+        DXContainerWriter Writer(PartObj, Out);
         if (Error E = Writer.write())
           return createFileError(OutFilename, std::move(E));
         return Error::success();

>From 7baf785b77623e30f6aad53c31d7c865b1fce90b Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 21 Aug 2025 10:58:43 -0700
Subject: [PATCH 08/19] clang-format

---
 llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp b/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
index 66ebe0016965e..4e0fd9d6f2fe8 100644
--- a/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
+++ b/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
@@ -20,7 +20,7 @@ namespace dxbc {
 using namespace object;
 
 static Error extractPartAsObject(StringRef PartName, StringRef OutFilename,
-                               StringRef InputFilename, const Object &Obj) {
+                                 StringRef InputFilename, const Object &Obj) {
   for (const Part &P : Obj.Parts)
     if (P.Name == PartName) {
       Object PartObj;
@@ -56,8 +56,8 @@ static Error handleArgs(const CommonConfig &Config, Object &Obj) {
     StringRef SectionName;
     StringRef FileName;
     std::tie(SectionName, FileName) = Flag.split('=');
-    if (Error E =
-            extractPartAsObject(SectionName, FileName, Config.InputFilename, Obj))
+    if (Error E = extractPartAsObject(SectionName, FileName,
+                                      Config.InputFilename, Obj))
       return E;
   }
 

>From 40d7e575d21a3923f0d565fc5540cadf85f7ad63 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Mon, 1 Sep 2025 14:25:36 -0700
Subject: [PATCH 09/19] review: alphabetical order

---
 llvm/tools/llvm-objcopy/CommonOpts.td | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/llvm/tools/llvm-objcopy/CommonOpts.td b/llvm/tools/llvm-objcopy/CommonOpts.td
index 411e954f393c4..7359e628582d2 100644
--- a/llvm/tools/llvm-objcopy/CommonOpts.td
+++ b/llvm/tools/llvm-objcopy/CommonOpts.td
@@ -23,6 +23,12 @@ def enable_deterministic_archives
     : Flag<["--"], "enable-deterministic-archives">,
       HelpText<"Enable deterministic mode when operating on archives (use "
                "zero for UIDs, GIDs, and timestamps).">;
+
+defm extract_section
+    : Eq<"extract-section",
+         "Extract section named <section> into standalone object in file <file>">,
+      MetaVarName<"section=file">;
+
 def D : Flag<["-"], "D">,
         Alias<enable_deterministic_archives>,
         HelpText<"Alias for --enable-deterministic-archives">;
@@ -69,11 +75,6 @@ def strip_sections
     : Flag<["--"], "strip-sections">,
       HelpText<"Remove all section headers and all section data not within segments">;
 
-defm extract_section
-    : Eq<"extract-section",
-         "Extract section named <section> into standalone object in file <file>">,
-      MetaVarName<"section=file">;
-
 defm strip_symbol : Eq<"strip-symbol", "Strip <symbol>">,
                     MetaVarName<"symbol">;
 def N : JoinedOrSeparate<["-"], "N">,

>From 6d92ea48d5c0e38d7e1331fff6592d42fd7fc2d9 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Mon, 1 Sep 2025 14:28:47 -0700
Subject: [PATCH 10/19] review: add ELF block to denote unhandled option

---
 llvm/include/llvm/ObjCopy/ConfigManager.h | 2 +-
 llvm/lib/ObjCopy/ConfigManager.cpp        | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ObjCopy/ConfigManager.h b/llvm/include/llvm/ObjCopy/ConfigManager.h
index 4b596c604ea3a..27fbd96fc486c 100644
--- a/llvm/include/llvm/ObjCopy/ConfigManager.h
+++ b/llvm/include/llvm/ObjCopy/ConfigManager.h
@@ -27,7 +27,7 @@ struct LLVM_ABI ConfigManager : public MultiFormatConfig {
 
   const CommonConfig &getCommonConfig() const override { return Common; }
 
-  Expected<const ELFConfig &> getELFConfig() const override { return ELF; }
+  Expected<const ELFConfig &> getELFConfig() const override;
 
   Expected<const COFFConfig &> getCOFFConfig() const override;
 
diff --git a/llvm/lib/ObjCopy/ConfigManager.cpp b/llvm/lib/ObjCopy/ConfigManager.cpp
index bd9af30e3e003..f1b036c8675d1 100644
--- a/llvm/lib/ObjCopy/ConfigManager.cpp
+++ b/llvm/lib/ObjCopy/ConfigManager.cpp
@@ -13,6 +13,13 @@
 using namespace llvm;
 using namespace llvm::objcopy;
 
+Expected<const ELFConfig &> ConfigManager::getELFConfig() const {
+  if (!Common.ExtractSection.empty())
+    return createStringError(llvm::errc::invalid_argument,
+                             "option is not supported for ELF");
+  return ELF;
+}
+
 Expected<const COFFConfig &> ConfigManager::getCOFFConfig() const {
   if (!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
       !Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||

>From a795ac70b96a42a8da54e3d63d79d37c9e1a249d Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Mon, 1 Sep 2025 14:28:54 -0700
Subject: [PATCH 11/19] review: add option docs

---
 llvm/docs/CommandGuide/llvm-objcopy.rst | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/llvm/docs/CommandGuide/llvm-objcopy.rst b/llvm/docs/CommandGuide/llvm-objcopy.rst
index 35d907fbe44d4..d8ce147c5eedf 100644
--- a/llvm/docs/CommandGuide/llvm-objcopy.rst
+++ b/llvm/docs/CommandGuide/llvm-objcopy.rst
@@ -79,6 +79,18 @@ multiple file formats.
  Enable deterministic mode when copying archives, i.e. use 0 for archive member
  header UIDs, GIDs and timestamp fields. On by default.
 
+.. option:: --extract-section <section>=<file>
+
+ Extract the specified section ``<section>`` into the file ``<file>`` as a
+ seperate object. Can be specified multiple times to extract multiple sections.
+ ``<file>`` is unrelated to the input and output files provided to
+ :program:`llvm-objcopy` and as such the normal copying and editing
+ operations will still be performed. No operations are performed on the sections
+ prior to dumping them.
+
+ For MachO objects, ``<section>`` must be formatted as
+ ``<segment name>,<section name>``.
+
 .. option:: --globalize-symbol <symbol>
 
  Mark any defined symbols named ``<symbol>`` as global symbols in the output.

>From 2792bd050447e1e63aa7449fded5922efb3ddf9a Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Mon, 1 Sep 2025 14:35:09 -0700
Subject: [PATCH 12/19] review: rename tests

---
 .../{extract-basic.test => extract-section-basic.test}            | 0
 .../DXContainer/{extract-errs.test => extract-section-errs.test}  | 0
 .../{extract-headers.test => extract-section-headers.test}        | 0
 3 files changed, 0 insertions(+), 0 deletions(-)
 rename llvm/test/tools/llvm-objcopy/DXContainer/{extract-basic.test => extract-section-basic.test} (100%)
 rename llvm/test/tools/llvm-objcopy/DXContainer/{extract-errs.test => extract-section-errs.test} (100%)
 rename llvm/test/tools/llvm-objcopy/DXContainer/{extract-headers.test => extract-section-headers.test} (100%)

diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-basic.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
similarity index 100%
rename from llvm/test/tools/llvm-objcopy/DXContainer/extract-basic.test
rename to llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-errs.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
similarity index 100%
rename from llvm/test/tools/llvm-objcopy/DXContainer/extract-errs.test
rename to llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-headers.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
similarity index 100%
rename from llvm/test/tools/llvm-objcopy/DXContainer/extract-headers.test
rename to llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test

>From bb336c929600956c0a251cc44070b2c264f9bee2 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Mon, 1 Sep 2025 14:38:06 -0700
Subject: [PATCH 13/19] self-review: misc

- update static sampler offset now that it is computed correctly
- update test comment
---
 .../tools/llvm-objcopy/DXContainer/extract-section-basic.test   | 2 +-
 .../tools/llvm-objcopy/DXContainer/extract-section-errs.test    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
index c4fbd5bd29845..9c02fac2ec0ec 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
@@ -277,7 +277,7 @@ Parts:
       NumRootParameters: 0
       RootParametersOffset: 24
       NumStaticSamplers: 0
-      StaticSamplersOffset: 0
+      StaticSamplersOffset: 24
       Parameters:      []
   - Name:            PSV0
     Size:            76
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
index 03f99b5192d36..41b257f7940a7 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
@@ -1,7 +1,7 @@
 ## Check that llvm-objcopy reports a suitable error when it
 ## can't find the section to extract
 
-## We can't have multiple DXIL parts.
+## We can't extract a part that doesn't exist
 # RUN: yaml2obj %s --docnum=1 -o %t1
 # RUN: not llvm-objcopy %t1 --extract-section=UNKNOWN=%t.unknown.out 2>&1 | FileCheck %s -DFILE=%t1 --check-prefix=ERROR1
 

>From 9197d823cf1846ebc91b685bd2dae675a706c973 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 4 Sep 2025 10:55:58 -0700
Subject: [PATCH 14/19] review: fix up comments

---
 llvm/docs/CommandGuide/llvm-objcopy.rst                     | 3 ---
 .../llvm-objcopy/DXContainer/extract-section-basic.test     | 2 +-
 .../llvm-objcopy/DXContainer/extract-section-errs.test      | 6 +++---
 .../llvm-objcopy/DXContainer/extract-section-headers.test   | 2 +-
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/llvm/docs/CommandGuide/llvm-objcopy.rst b/llvm/docs/CommandGuide/llvm-objcopy.rst
index d8ce147c5eedf..343e1d8dbac90 100644
--- a/llvm/docs/CommandGuide/llvm-objcopy.rst
+++ b/llvm/docs/CommandGuide/llvm-objcopy.rst
@@ -88,9 +88,6 @@ multiple file formats.
  operations will still be performed. No operations are performed on the sections
  prior to dumping them.
 
- For MachO objects, ``<section>`` must be formatted as
- ``<segment name>,<section name>``.
-
 .. option:: --globalize-symbol <symbol>
 
  Mark any defined symbols named ``<symbol>`` as global symbols in the output.
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
index 9c02fac2ec0ec..d88205382e6c0 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
@@ -1,5 +1,5 @@
 ## Tests that a separate DXContainer is created for the RTS0 (root signature)
-## part, specified with --extract-section specified
+## part, when--extract-section is specified.
 
 # RUN: yaml2obj %s -o %t
 # RUN: llvm-objcopy %t --extract-section=RTS0=%t.rts0.out
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
index 41b257f7940a7..f0f12e2d7e371 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
@@ -1,7 +1,7 @@
-## Check that llvm-objcopy reports a suitable error when it
-## can't find the section to extract
+## Check that llvm-objcopy reports a suitable error when it can't find the
+## section to extract.
 
-## We can't extract a part that doesn't exist
+## We can't extract a part that doesn't exist.
 # RUN: yaml2obj %s --docnum=1 -o %t1
 # RUN: not llvm-objcopy %t1 --extract-section=UNKNOWN=%t.unknown.out 2>&1 | FileCheck %s -DFILE=%t1 --check-prefix=ERROR1
 
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
index 9af1a2bca749e..9fc199334265f 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
@@ -1,5 +1,5 @@
 ## Tests that a separate DXContainer is created with only the specified section
-## for each --extract-section specified
+## for each --extract-section specified.
 
 # RUN: yaml2obj %s -o %t
 # RUN: llvm-objcopy %t --extract-section=FKE1=%t.fke1.out --extract-section=FKE4=%t.fke4.out

>From 2bc14504f7e94f3e4d26d657b70e84fd647a1110 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 4 Sep 2025 10:56:24 -0700
Subject: [PATCH 15/19] review: improve testing readability and strictness

---
 .../DXContainer/extract-section-basic.test    | 36 +++++++++++++------
 .../DXContainer/extract-section-headers.test  | 29 ++++++++-------
 2 files changed, 41 insertions(+), 24 deletions(-)

diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
index d88205382e6c0..e6ea105fab3a7 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
@@ -16,6 +16,31 @@
 ## void main() {}
 ## ```
 
+# CHECK:      Header:
+# CHECK-NEXT:   Hash:
+# CHECK:        Version:
+# CHECK-NEXT:      Major:           1
+# CHECK-NEXT:      Minor:           0
+# CHECK-NEXT:   FileSize:       68
+# CHECK-NEXT:   PartCount:     1
+# CHECK-NEXT:   PartOffsets:   [ 36 ]
+# CHECK-NEXT:   Parts:
+# CHECK-NOT: DXIL
+# CHECK-NOT: SFI0
+# CHECK-NOT: HASH
+# CHECK-NOT: ISG1
+# CHECK-NOT: OSG1
+# CHECK:        Name:            RTS0
+# CHECK-NEXT    Size:            24
+# CHECK-NEXT    RootSignature:
+# CHECK-NEXT      Version:         2
+# CHECK-NEXT      NumRootParameters: 0
+# CHECK-NEXT      RootParametersOffset: 24
+# CHECK-NEXT      NumStaticSamplers: 0
+# CHECK-NEXT      StaticSamplersOffset: 24
+# CHECK-NEXT      Parameters:      []
+# CHECK-NOT: PSV0
+
 --- !dxcontainer
 Header:
   Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
@@ -23,21 +48,10 @@ Header:
   Version:
     Major:           1
     Minor:           0
-# CHECK: FileSize:       68
   FileSize:        1984
-# CHECK-NEXT: PartCount:     1
-# CHECK-NEXT: PartOffsets:   [ 36 ]
   PartCount:       7
   PartOffsets:     [ 60, 1792, 1808, 1836, 1852, 1868, 1900 ]
-# CHECK-NEXT: Parts:
 Parts:
-# CHECK-NOT: DXIL
-# CHECK-NOT: SFI0
-# CHECK-NOT: HASH
-# CHECK-NOT: ISG1
-# CHECK-NOT: OSG1
-# CHECK: Name:            RTS0
-# CHECK-NOT: PSV0
   - Name:            DXIL
     Size:            1724
     Program:
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
index 9fc199334265f..47f9011cc89c8 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
@@ -6,6 +6,22 @@
 # RUN: obj2yaml %t.fke1.out | FileCheck %s --check-prefixes=CHECK,FKE1
 # RUN: obj2yaml %t.fke4.out | FileCheck %s --check-prefixes=CHECK,FKE4
 
+# FKE1:       FileSize:       52
+# FKE4:       FileSize:       1732
+# CHECK-NEXT: PartCount:     1
+# CHECK-NEXT: PartOffsets:   [ 36 ]
+# CHECK-NEXT: Parts:
+
+# CHECK-NOT: FKE0
+# FKE1: Name:            FKE1
+# FKE4-NOT: FKE1
+# CHECK-NOT: FKE2
+# CHECK-NOT: FKE3
+# FKE1-NOT: FKE4
+# FKE4: Name:            FKE4
+# CHECK-NOT: FKE5
+# CHECK-NOT: DXIL
+
 --- !dxcontainer
 Header:
   Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
@@ -13,23 +29,10 @@ Header:
   Version:
     Major:           1
     Minor:           0
-## FKE1: FileSize:       52
-## FKE4: FileSize:       1732
   FileSize:        1996
-# CHECK: PartCount:     1
-# CHECK-NEXT: PartOffsets:   [ 36 ]
   PartCount:       7
   PartOffsets:     [ 60, 76, 92, 108, 236, 1932, 1960 ]
-# CHECK-NEXT: Parts:
 Parts:
-# CHECK-NOT: FKE0
-# FKE1: Name:            FKE1
-# FKE4-NOT: FKE1
-# CHECK-NOT: FKE2
-# CHECK-NOT: FKE3
-# FKE1-NOT: FKE4
-# FKE4: Name:            FKE4
-# CHECK-NOT: FKE5
   - Name:            FKE0
     Size:            8
   - Name:            FKE1

>From be61cae6acb04b3df90a84e8c84b252eb4ba19b8 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 4 Sep 2025 10:57:31 -0700
Subject: [PATCH 16/19] review: hande extract before any removal

---
 .../DXContainer/DXContainerObjcopy.cpp        | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp b/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
index 4e0fd9d6f2fe8..3797e6b41cf66 100644
--- a/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
+++ b/llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
@@ -43,15 +43,7 @@ static Error extractPartAsObject(StringRef PartName, StringRef OutFilename,
 }
 
 static Error handleArgs(const CommonConfig &Config, Object &Obj) {
-  std::function<bool(const Part &)> RemovePred = [](const Part &) {
-    return false;
-  };
-
-  if (!Config.ToRemove.empty())
-    RemovePred = [&Config](const Part &P) {
-      return Config.ToRemove.matches(P.Name);
-    };
-
+  // Extract all sections before any modifications.
   for (StringRef Flag : Config.ExtractSection) {
     StringRef SectionName;
     StringRef FileName;
@@ -61,6 +53,15 @@ static Error handleArgs(const CommonConfig &Config, Object &Obj) {
       return E;
   }
 
+  std::function<bool(const Part &)> RemovePred = [](const Part &) {
+    return false;
+  };
+
+  if (!Config.ToRemove.empty())
+    RemovePred = [&Config](const Part &P) {
+      return Config.ToRemove.matches(P.Name);
+    };
+
   if (auto E = Obj.removeParts(RemovePred))
     return E;
 

>From b9f6e08a90653f782ce01a83e44dae2f1d371c98 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 4 Sep 2025 11:03:55 -0700
Subject: [PATCH 17/19] review: add test for invalid format err

---
 .../DXContainer/extract-section-errs.test     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
index f0f12e2d7e371..59b3d274315b2 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
@@ -19,3 +19,22 @@ Parts:
   - Name:            FKE0
     Size:            8
 ...
+
+## We can't extract a part that is specified incorrectly.
+# RUN: yaml2obj %s --docnum=2 -o %t2
+# RUN: not llvm-objcopy %t2 --extract-section=FKE0,%t.fke0.out 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=ERROR2
+
+# ERROR2: error: bad format for --extract-section, expected section=file
+
+--- !dxcontainer
+Header:
+  Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+                     0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+  Version:
+    Major:           1
+    Minor:           0
+  PartCount:       1
+Parts:
+  - Name:            FKE0
+    Size:            8
+...

>From f3ce155f9b34c5af648a179a424539fe3b6edf36 Mon Sep 17 00:00:00 2001
From: Finn Plummer <mail at inbelic.dev>
Date: Thu, 4 Sep 2025 14:30:18 -0700
Subject: [PATCH 18/19] review: improve test readability and flexibility

---
 .../DXContainer/extract-section-basic.test    | 221 +-----------------
 .../DXContainer/extract-section-headers.test  |   8 +-
 2 files changed, 11 insertions(+), 218 deletions(-)

diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
index e6ea105fab3a7..02496c6f84ca4 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
@@ -10,6 +10,8 @@
 ## `clang-dxc -T cs_6_7 test.hlsl /Fo temp.dxo`
 ## `obj2yaml temp.dxo`
 
+## and has the DXIL section trimmed for readability.
+
 ## ``` test.hlsl
 ## [RootSignature("")]
 ## [numthreads(1,1,1)]
@@ -25,11 +27,7 @@
 # CHECK-NEXT:   PartCount:     1
 # CHECK-NEXT:   PartOffsets:   [ 36 ]
 # CHECK-NEXT:   Parts:
-# CHECK-NOT: DXIL
-# CHECK-NOT: SFI0
-# CHECK-NOT: HASH
-# CHECK-NOT: ISG1
-# CHECK-NOT: OSG1
+# CHECK-NOT:  - Name: {{DXIL|SFI0|HASH|ISG1|OSG1|PSV0}}
 # CHECK:        Name:            RTS0
 # CHECK-NEXT    Size:            24
 # CHECK-NEXT    RootSignature:
@@ -39,7 +37,7 @@
 # CHECK-NEXT      NumStaticSamplers: 0
 # CHECK-NEXT      StaticSamplersOffset: 24
 # CHECK-NEXT      Parameters:      []
-# CHECK-NOT: PSV0
+# CHECK-NOT:  - Name: {{DXIL|SFI0|HASH|ISG1|OSG1|PSV0}}
 
 --- !dxcontainer
 Header:
@@ -58,216 +56,11 @@ Parts:
       MajorVersion:    6
       MinorVersion:    7
       ShaderKind:      5
-      Size:            431
+      Size:            28
       DXILMajorVersion: 1
       DXILMinorVersion: 7
-      DXILSize:        1700
-      DXIL:            [ 0x42, 0x43, 0xC0, 0xDE, 0x21, 0xC, 0x0, 0x0, 0xA6,
-                         0x1, 0x0, 0x0, 0xB, 0x82, 0x20, 0x0, 0x2, 0x0,
-                         0x0, 0x0, 0x13, 0x0, 0x0, 0x0, 0x7, 0x81, 0x23,
-                         0x91, 0x41, 0xC8, 0x4, 0x49, 0x6, 0x10, 0x32,
-                         0x39, 0x92, 0x1, 0x84, 0xC, 0x25, 0x5, 0x8, 0x19,
-                         0x1E, 0x4, 0x8B, 0x62, 0x80, 0x10, 0x45, 0x2,
-                         0x42, 0x92, 0xB, 0x42, 0x84, 0x10, 0x32, 0x14,
-                         0x38, 0x8, 0x18, 0x4B, 0xA, 0x32, 0x42, 0x88,
-                         0x48, 0x90, 0x14, 0x20, 0x43, 0x46, 0x88, 0xA5,
-                         0x0, 0x19, 0x32, 0x42, 0xE4, 0x48, 0xE, 0x90,
-                         0x11, 0x22, 0xC4, 0x50, 0x41, 0x51, 0x81, 0x8C,
-                         0xE1, 0x83, 0xE5, 0x8A, 0x4, 0x21, 0x46, 0x6,
-                         0x51, 0x18, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1B,
-                         0x90, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0xC0,
-                         0x1, 0x24, 0x80, 0x2, 0x0, 0x0, 0x0, 0x49, 0x18,
-                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x13, 0x82, 0x0,
-                         0x0, 0x89, 0x20, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0,
-                         0x32, 0x22, 0x8, 0x9, 0x20, 0x64, 0x85, 0x4, 0x13,
-                         0x22, 0xA4, 0x84, 0x4, 0x13, 0x22, 0xE3, 0x84,
-                         0xA1, 0x90, 0x14, 0x12, 0x4C, 0x88, 0x8C, 0xB,
-                         0x84, 0x84, 0x4C, 0x10, 0x20, 0x73, 0x4, 0x8,
-                         0xC1, 0x65, 0xC3, 0x85, 0x2C, 0xE8, 0x3, 0x40,
-                         0x14, 0x91, 0x4E, 0xD1, 0x4A, 0x48, 0x44, 0x54,
-                         0x11, 0xC3, 0x9, 0x30, 0xC4, 0x18, 0x1, 0x30,
-                         0x2, 0x50, 0x82, 0x21, 0x1A, 0x8, 0x98, 0x23,
-                         0x0, 0x3, 0x0, 0x13, 0x14, 0x72, 0xC0, 0x87, 0x74,
-                         0x60, 0x87, 0x36, 0x68, 0x87, 0x79, 0x68, 0x3,
-                         0x72, 0xC0, 0x87, 0xD, 0xAE, 0x50, 0xE, 0x6D,
-                         0xD0, 0xE, 0x7A, 0x50, 0xE, 0x6D, 0x0, 0xF, 0x7A,
-                         0x30, 0x7, 0x72, 0xA0, 0x7, 0x73, 0x20, 0x7, 0x6D,
-                         0x90, 0xE, 0x71, 0xA0, 0x7, 0x73, 0x20, 0x7, 0x6D,
-                         0x90, 0xE, 0x78, 0xA0, 0x7, 0x78, 0xD0, 0x6, 0xE9,
-                         0x10, 0x7, 0x76, 0xA0, 0x7, 0x71, 0x60, 0x7, 0x6D,
-                         0x90, 0xE, 0x73, 0x20, 0x7, 0x7A, 0x30, 0x7, 0x72,
-                         0xD0, 0x6, 0xE9, 0x60, 0x7, 0x74, 0xA0, 0x7, 0x76,
-                         0x40, 0x7, 0x6D, 0x60, 0xE, 0x71, 0x60, 0x7, 0x7A,
-                         0x10, 0x7, 0x76, 0xD0, 0x6, 0xE6, 0x30, 0x7, 0x72,
-                         0xA0, 0x7, 0x73, 0x20, 0x7, 0x6D, 0x60, 0xE, 0x76,
-                         0x40, 0x7, 0x7A, 0x60, 0x7, 0x74, 0xD0, 0x6, 0xEE,
-                         0x80, 0x7, 0x7A, 0x10, 0x7, 0x76, 0xA0, 0x7, 0x73,
-                         0x20, 0x7, 0x7A, 0x60, 0x7, 0x74, 0x30, 0xE4,
-                         0x21, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x2, 0x0,
-                         0x0, 0x0, 0x20, 0xB, 0x4, 0x7, 0x0, 0x0, 0x0,
-                         0x32, 0x1E, 0x98, 0xC, 0x19, 0x11, 0x4C, 0x90,
-                         0x8C, 0x9, 0x26, 0x47, 0xC6, 0x4, 0x43, 0xBA,
-                         0x12, 0x28, 0x88, 0x62, 0x28, 0x87, 0x42, 0x28,
-                         0x2, 0x0, 0x0, 0x0, 0x79, 0x18, 0x0, 0x0, 0xE2,
-                         0x0, 0x0, 0x0, 0x33, 0x8, 0x80, 0x1C, 0xC4, 0xE1,
-                         0x1C, 0x66, 0x14, 0x1, 0x3D, 0x88, 0x43, 0x38,
-                         0x84, 0xC3, 0x8C, 0x42, 0x80, 0x7, 0x79, 0x78,
-                         0x7, 0x73, 0x98, 0x71, 0xC, 0xE6, 0x0, 0xF, 0xED,
-                         0x10, 0xE, 0xF4, 0x80, 0xE, 0x33, 0xC, 0x42, 0x1E,
-                         0xC2, 0xC1, 0x1D, 0xCE, 0xA1, 0x1C, 0x66, 0x30,
-                         0x5, 0x3D, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1B,
-                         0xCC, 0x3, 0x3D, 0xC8, 0x43, 0x3D, 0x8C, 0x3,
-                         0x3D, 0xCC, 0x78, 0x8C, 0x74, 0x70, 0x7, 0x7B,
-                         0x8, 0x7, 0x79, 0x48, 0x87, 0x70, 0x70, 0x7, 0x7A,
-                         0x70, 0x3, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87,
-                         0x19, 0xCC, 0x11, 0xE, 0xEC, 0x90, 0xE, 0xE1,
-                         0x30, 0xF, 0x6E, 0x30, 0xF, 0xE3, 0xF0, 0xE, 0xF0,
-                         0x50, 0xE, 0x33, 0x10, 0xC4, 0x1D, 0xDE, 0x21,
-                         0x1C, 0xD8, 0x21, 0x1D, 0xC2, 0x61, 0x1E, 0x66,
-                         0x30, 0x89, 0x3B, 0xBC, 0x83, 0x3B, 0xD0, 0x43,
-                         0x39, 0xB4, 0x3, 0x3C, 0xBC, 0x83, 0x3C, 0x84,
-                         0x3, 0x3B, 0xCC, 0xF0, 0x14, 0x76, 0x60, 0x7,
-                         0x7B, 0x68, 0x7, 0x37, 0x68, 0x87, 0x72, 0x68,
-                         0x7, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70,
-                         0x60, 0x7, 0x76, 0x28, 0x7, 0x76, 0xF8, 0x5, 0x76,
-                         0x78, 0x87, 0x77, 0x80, 0x87, 0x5F, 0x8, 0x87,
-                         0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98,
-                         0x81, 0x2C, 0xEE, 0xF0, 0xE, 0xEE, 0xE0, 0xE,
-                         0xF5, 0xC0, 0xE, 0xEC, 0x30, 0x3, 0x62, 0xC8,
-                         0xA1, 0x1C, 0xE4, 0xA1, 0x1C, 0xCC, 0xA1, 0x1C,
-                         0xE4, 0xA1, 0x1C, 0xDC, 0x61, 0x1C, 0xCA, 0x21,
-                         0x1C, 0xC4, 0x81, 0x1D, 0xCA, 0x61, 0x6, 0xD6,
-                         0x90, 0x43, 0x39, 0xC8, 0x43, 0x39, 0x98, 0x43,
-                         0x39, 0xC8, 0x43, 0x39, 0xB8, 0xC3, 0x38, 0x94,
-                         0x43, 0x38, 0x88, 0x3, 0x3B, 0x94, 0xC3, 0x2F,
-                         0xBC, 0x83, 0x3C, 0xFC, 0x82, 0x3B, 0xD4, 0x3,
-                         0x3B, 0xB0, 0xC3, 0xC, 0xC7, 0x69, 0x87, 0x70,
-                         0x58, 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x7,
-                         0x78, 0x60, 0x87, 0x74, 0x18, 0x87, 0x74, 0xA0,
-                         0x87, 0x19, 0xCE, 0x53, 0xF, 0xEE, 0x0, 0xF, 0xF2,
-                         0x50, 0xE, 0xE4, 0x90, 0xE, 0xE3, 0x40, 0xF, 0xE1,
-                         0x20, 0xE, 0xEC, 0x50, 0xE, 0x33, 0x20, 0x28,
-                         0x1D, 0xDC, 0xC1, 0x1E, 0xC2, 0x41, 0x1E, 0xD2,
-                         0x21, 0x1C, 0xDC, 0x81, 0x1E, 0xDC, 0xE0, 0x1C,
-                         0xE4, 0xE1, 0x1D, 0xEA, 0x1, 0x1E, 0x66, 0x18,
-                         0x51, 0x38, 0xB0, 0x43, 0x3A, 0x9C, 0x83, 0x3B,
-                         0xCC, 0x50, 0x24, 0x76, 0x60, 0x7, 0x7B, 0x68,
-                         0x7, 0x37, 0x60, 0x87, 0x77, 0x78, 0x7, 0x78,
-                         0x98, 0x51, 0x4C, 0xF4, 0x90, 0xF, 0xF0, 0x50,
-                         0xE, 0x33, 0x1E, 0x6A, 0x1E, 0xCA, 0x61, 0x1C,
-                         0xE8, 0x21, 0x1D, 0xDE, 0xC1, 0x1D, 0x7E, 0x1,
-                         0x1E, 0xE4, 0xA1, 0x1C, 0xCC, 0x21, 0x1D, 0xF0,
-                         0x61, 0x6, 0x54, 0x85, 0x83, 0x38, 0xCC, 0xC3,
-                         0x3B, 0xB0, 0x43, 0x3D, 0xD0, 0x43, 0x39, 0xFC,
-                         0xC2, 0x3C, 0xE4, 0x43, 0x3B, 0x88, 0xC3, 0x3B,
-                         0xB0, 0xC3, 0x8C, 0xC5, 0xA, 0x87, 0x79, 0x98,
-                         0x87, 0x77, 0x18, 0x87, 0x74, 0x8, 0x7, 0x7A,
-                         0x28, 0x7, 0x72, 0x98, 0x81, 0x5C, 0xE3, 0x10,
-                         0xE, 0xEC, 0xC0, 0xE, 0xE5, 0x50, 0xE, 0xF3, 0x30,
-                         0x23, 0xC1, 0xD2, 0x41, 0x1E, 0xE4, 0xE1, 0x17,
-                         0xD8, 0xE1, 0x1D, 0xDE, 0x1, 0x1E, 0x66, 0x48,
-                         0x19, 0x3B, 0xB0, 0x83, 0x3D, 0xB4, 0x83, 0x1B,
-                         0x84, 0xC3, 0x38, 0x8C, 0x43, 0x39, 0xCC, 0xC3,
-                         0x3C, 0xB8, 0xC1, 0x39, 0xC8, 0xC3, 0x3B, 0xD4,
-                         0x3, 0x3C, 0xCC, 0x48, 0xB4, 0x71, 0x8, 0x7, 0x76,
-                         0x60, 0x7, 0x71, 0x8, 0x87, 0x71, 0x58, 0x87,
-                         0x19, 0xDB, 0xC6, 0xE, 0xEC, 0x60, 0xF, 0xED,
-                         0xE0, 0x6, 0xF0, 0x20, 0xF, 0xE5, 0x30, 0xF, 0xE5,
-                         0x20, 0xF, 0xF6, 0x50, 0xE, 0x6E, 0x10, 0xE, 0xE3,
-                         0x30, 0xE, 0xE5, 0x30, 0xF, 0xF3, 0xE0, 0x6, 0xE9,
-                         0xE0, 0xE, 0xE4, 0x50, 0xE, 0xF8, 0x30, 0x23,
-                         0xE2, 0xEC, 0x61, 0x1C, 0xC2, 0x81, 0x1D, 0xD8,
-                         0xE1, 0x17, 0xEC, 0x21, 0x1D, 0xE6, 0x21, 0x1D,
-                         0xC4, 0x21, 0x1D, 0xD8, 0x21, 0x1D, 0xE8, 0x21,
-                         0x1F, 0x66, 0x20, 0x9D, 0x3B, 0xBC, 0x43, 0x3D,
-                         0xB8, 0x3, 0x39, 0x94, 0x83, 0x39, 0xCC, 0x58,
-                         0xBC, 0x70, 0x70, 0x7, 0x77, 0x78, 0x7, 0x7A,
-                         0x8, 0x7, 0x7A, 0x48, 0x87, 0x77, 0x70, 0x87,
-                         0x19, 0xCB, 0xE7, 0xE, 0xEF, 0x30, 0xF, 0xE1,
-                         0xE0, 0xE, 0xE9, 0x40, 0xF, 0xE9, 0xA0, 0xF, 0xE5,
-                         0x30, 0xC3, 0x1, 0x3, 0x73, 0xA8, 0x7, 0x77, 0x18,
-                         0x87, 0x5F, 0x98, 0x87, 0x70, 0x70, 0x87, 0x74,
-                         0xA0, 0x87, 0x74, 0xD0, 0x87, 0x72, 0x98, 0x81,
-                         0x84, 0x41, 0x39, 0xE0, 0xC3, 0x38, 0xB0, 0x43,
-                         0x3D, 0x90, 0x43, 0x39, 0xCC, 0x40, 0xC4, 0xA0,
-                         0x1D, 0xCA, 0xA1, 0x1D, 0xE0, 0x41, 0x1E, 0xDE,
-                         0xC1, 0x1C, 0x66, 0x24, 0x63, 0x30, 0xE, 0xE1,
-                         0xC0, 0xE, 0xEC, 0x30, 0xF, 0xE9, 0x40, 0xF, 0xE5,
-                         0x30, 0x43, 0x21, 0x83, 0x75, 0x18, 0x7, 0x73,
-                         0x48, 0x87, 0x5F, 0xA0, 0x87, 0x7C, 0x80, 0x87,
-                         0x72, 0x98, 0xB1, 0x94, 0x1, 0x3C, 0x8C, 0xC3,
-                         0x3C, 0x94, 0xC3, 0x38, 0xD0, 0x43, 0x3A, 0xBC,
-                         0x83, 0x3B, 0xCC, 0xC3, 0x8C, 0xC5, 0xC, 0x48,
-                         0x21, 0x15, 0x42, 0x61, 0x1E, 0xE6, 0x21, 0x1D,
-                         0xCE, 0xC1, 0x1D, 0x52, 0x81, 0x14, 0x66, 0x4C,
-                         0x67, 0x30, 0xE, 0xEF, 0x20, 0xF, 0xEF, 0xE0,
-                         0x6, 0xEF, 0x50, 0xF, 0xF4, 0x30, 0xF, 0xE9, 0x40,
-                         0xE, 0xE5, 0xE0, 0x6, 0xE6, 0x20, 0xF, 0xE1, 0xD0,
-                         0xE, 0xE5, 0x30, 0xA3, 0x40, 0x83, 0x76, 0x68,
-                         0x7, 0x79, 0x8, 0x87, 0x19, 0x52, 0x1A, 0xB8,
-                         0xC3, 0x3B, 0x84, 0x3, 0x3B, 0xA4, 0x43, 0x38,
-                         0xCC, 0x83, 0x1B, 0x84, 0x3, 0x39, 0x90, 0x83,
-                         0x3C, 0xCC, 0x3, 0x3C, 0x84, 0xC3, 0x38, 0x94,
-                         0xC3, 0xC, 0x46, 0xD, 0xC6, 0x21, 0x1C, 0xD8,
-                         0x81, 0x1D, 0xCA, 0xA1, 0x1C, 0x7E, 0x81, 0x1E,
-                         0xF2, 0x1, 0x1E, 0xCA, 0x61, 0x86, 0xB3, 0x6,
-                         0xE4, 0x80, 0xF, 0x6E, 0xE0, 0xE, 0xEF, 0xE0,
-                         0xE, 0xF5, 0xE0, 0xE, 0xE9, 0x60, 0xE, 0xEF, 0x20,
-                         0xF, 0xED, 0x30, 0xA3, 0x62, 0x3, 0x72, 0xC0,
-                         0x7, 0x37, 0x18, 0x87, 0x77, 0x70, 0x7, 0x7A,
-                         0x90, 0x87, 0x77, 0x60, 0x7, 0x73, 0x60, 0x87,
-                         0x77, 0xB8, 0x7, 0x37, 0x40, 0x87, 0x74, 0x70,
-                         0x7, 0x7A, 0x98, 0x87, 0x19, 0x4B, 0x1B, 0x90,
-                         0x3, 0x3E, 0xB8, 0x1, 0x3C, 0xC8, 0x43, 0x39,
-                         0x8C, 0x43, 0x3A, 0xCC, 0x43, 0x39, 0x0, 0x0,
-                         0x79, 0x28, 0x0, 0x0, 0x53, 0x0, 0x0, 0x0, 0xC2,
-                         0x3C, 0x90, 0x40, 0x86, 0x10, 0x19, 0x32, 0xE2,
-                         0x64, 0x90, 0x40, 0x46, 0x2, 0x19, 0x23, 0x23,
-                         0x46, 0x2, 0x13, 0x24, 0xC6, 0x0, 0x13, 0x74,
-                         0xD4, 0x61, 0x8C, 0x2D, 0xCC, 0xED, 0xC, 0xC4,
-                         0xAE, 0x4C, 0x6E, 0x2E, 0xED, 0xCD, 0xD, 0x44,
-                         0x46, 0xC6, 0x5, 0xC6, 0x5, 0xE6, 0x2C, 0x8D,
-                         0xE, 0x4, 0xE5, 0x2C, 0x8D, 0xE, 0xE8, 0x2C, 0x8D,
-                         0xE, 0xAD, 0x4E, 0xCC, 0x65, 0xEC, 0xAD, 0x4D,
-                         0x27, 0xCD, 0x4D, 0xAC, 0x8C, 0x2D, 0x6D, 0xEC,
-                         0x85, 0x8D, 0xCD, 0xAE, 0xAD, 0x5, 0x4E, 0xEE,
-                         0x4D, 0xAD, 0x6C, 0x8C, 0xCE, 0xE5, 0x2C, 0x8D,
-                         0xE, 0x84, 0x86, 0xC6, 0xCC, 0xC6, 0x86, 0x4C,
-                         0xC, 0x87, 0x6C, 0xEC, 0x26, 0x67, 0x46, 0x26,
-                         0x67, 0x6C, 0xA6, 0xCC, 0x66, 0x8C, 0xC6, 0x2C,
-                         0xEC, 0x26, 0xC, 0x26, 0x2C, 0xEC, 0x26, 0xCC,
-                         0xCC, 0x86, 0x6, 0xE6, 0x6, 0x26, 0xE7, 0x86,
-                         0xE6, 0x26, 0xE5, 0x8, 0x63, 0x73, 0x87, 0x68,
-                         0xB, 0x4B, 0x73, 0x3B, 0xCA, 0xDD, 0x18, 0x5A,
-                         0x98, 0xDC, 0xD7, 0x5C, 0x9A, 0x5E, 0xD9, 0x69,
-                         0xCC, 0xE4, 0xC2, 0xDA, 0xCA, 0x5A, 0xE0, 0xDE,
-                         0xD2, 0xDC, 0xE8, 0xCA, 0xE4, 0x86, 0x20, 0x1C,
-                         0xC1, 0x10, 0x84, 0x43, 0x18, 0x82, 0x70, 0xC,
-                         0x43, 0x10, 0xE, 0x62, 0x8, 0x42, 0x1, 0xC, 0x41,
-                         0x38, 0x8A, 0x21, 0x8, 0x87, 0x31, 0x6, 0xC1,
-                         0x38, 0xC6, 0x10, 0x4, 0x63, 0x18, 0x4, 0x24,
-                         0x19, 0x83, 0x60, 0x24, 0x63, 0x18, 0xC, 0xC3,
-                         0x18, 0x83, 0xB0, 0x44, 0x63, 0x28, 0x94, 0x1,
-                         0x0, 0xA4, 0x31, 0xC, 0x6, 0xB1, 0x8C, 0x61, 0x60,
-                         0xA, 0xC6, 0x24, 0x64, 0x78, 0x2E, 0x76, 0x61,
-                         0x6C, 0x76, 0x65, 0x72, 0x43, 0x9, 0x18, 0xA3,
-                         0xB0, 0xB1, 0xD9, 0xB5, 0xB9, 0xA4, 0x91, 0x95,
-                         0xB9, 0xD1, 0xD, 0x25, 0x68, 0x8C, 0x43, 0x86,
-                         0xE7, 0x32, 0x87, 0x16, 0x46, 0x56, 0x26, 0xD7,
-                         0xF4, 0x46, 0x56, 0xC6, 0x36, 0x94, 0xC0, 0x31,
-                         0xA, 0x19, 0x9E, 0x8B, 0x5D, 0x99, 0xDC, 0x5C,
-                         0xDA, 0x9B, 0xDB, 0x50, 0x82, 0xC7, 0x38, 0x64,
-                         0x78, 0x2E, 0x65, 0x6E, 0x74, 0x72, 0x79, 0x50,
-                         0x6F, 0x69, 0x6E, 0x74, 0x73, 0x43, 0x9, 0x24,
-                         0x13, 0xB1, 0xB1, 0xD9, 0xB5, 0xB9, 0xB4, 0xBD,
-                         0x91, 0xD5, 0xB1, 0x95, 0xB9, 0x98, 0xB1, 0x85,
-                         0x9D, 0xCD, 0xD, 0x45, 0x98, 0x28, 0x0, 0x0, 0x71,
-                         0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x6, 0x40,
-                         0x30, 0x0, 0xD2, 0x0, 0x0, 0x0, 0x61, 0x20, 0x0,
-                         0x0, 0x6, 0x0, 0x0, 0x0, 0x13, 0x4, 0x1, 0x86,
-                         0x3, 0x1, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x7, 0x50,
-                         0x10, 0xCD, 0x14, 0x61, 0x0, 0x0, 0x0, 0x0, 0x0,
-                         0x0, 0x0, 0x0, 0x0, 0x0 ]
+      DXILSize:        4
+      DXIL:            [ 0x42, 0x43, 0xC0, 0xDE, ]
   - Name:            SFI0
     Size:            8
   - Name:            HASH
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
index 47f9011cc89c8..671b43ba6f2de 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
@@ -13,12 +13,12 @@
 # CHECK-NEXT: Parts:
 
 # CHECK-NOT: FKE0
-# FKE1: Name:            FKE1
-# FKE4-NOT: FKE1
+# FKE1:      Name: FKE1
+# FKE4-NOT:  FKE1
 # CHECK-NOT: FKE2
 # CHECK-NOT: FKE3
-# FKE1-NOT: FKE4
-# FKE4: Name:            FKE4
+# FKE1-NOT:  FKE4
+# FKE4:      Name: FKE4
 # CHECK-NOT: FKE5
 # CHECK-NOT: DXIL
 

>From 00627a4f2e86cd97dd7a7f55818754e5c4bb6adb Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Fri, 5 Sep 2025 16:49:17 +0000
Subject: [PATCH 19/19] review: clean up test cases

- makes key value spacing uniform and minimal of yaml objects
- simplify the tests by using --implicit-check-not and CHECK-NEXT for
the valid parts
---
 .../DXContainer/extract-section-basic.test    |  6 +-
 .../DXContainer/extract-section-errs.test     | 28 ++++----
 .../DXContainer/extract-section-headers.test  | 72 +++++++++----------
 3 files changed, 49 insertions(+), 57 deletions(-)

diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
index 02496c6f84ca4..fc16e51e8b78e 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-basic.test
@@ -3,7 +3,7 @@
 
 # RUN: yaml2obj %s -o %t
 # RUN: llvm-objcopy %t --extract-section=RTS0=%t.rts0.out
-# RUN: obj2yaml %t.rts0.out | FileCheck %s
+# RUN: obj2yaml %t.rts0.out | FileCheck %s --implicit-check-not=Name:
 
 ## The DXContainer described below was generated with:
 
@@ -27,8 +27,7 @@
 # CHECK-NEXT:   PartCount:     1
 # CHECK-NEXT:   PartOffsets:   [ 36 ]
 # CHECK-NEXT:   Parts:
-# CHECK-NOT:  - Name: {{DXIL|SFI0|HASH|ISG1|OSG1|PSV0}}
-# CHECK:        Name:            RTS0
+# CHECK-NEXT:   Name:            RTS0
 # CHECK-NEXT    Size:            24
 # CHECK-NEXT    RootSignature:
 # CHECK-NEXT      Version:         2
@@ -37,7 +36,6 @@
 # CHECK-NEXT      NumStaticSamplers: 0
 # CHECK-NEXT      StaticSamplersOffset: 24
 # CHECK-NEXT      Parameters:      []
-# CHECK-NOT:  - Name: {{DXIL|SFI0|HASH|ISG1|OSG1|PSV0}}
 
 --- !dxcontainer
 Header:
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
index 59b3d274315b2..2156b62cb2b7c 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-errs.test
@@ -9,15 +9,15 @@
 
 --- !dxcontainer
 Header:
-  Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-                     0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+  Hash:      [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+               0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
   Version:
-    Major:           1
-    Minor:           0
-  PartCount:       1
+    Major:   1
+    Minor:   0
+  PartCount: 1
 Parts:
-  - Name:            FKE0
-    Size:            8
+  - Name:    FKE0
+    Size:    8
 ...
 
 ## We can't extract a part that is specified incorrectly.
@@ -28,13 +28,13 @@ Parts:
 
 --- !dxcontainer
 Header:
-  Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-                     0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+  Hash:      [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+               0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
   Version:
-    Major:           1
-    Minor:           0
-  PartCount:       1
+    Major:   1
+    Minor:   0
+  PartCount: 1
 Parts:
-  - Name:            FKE0
-    Size:            8
+  - Name:    FKE0
+    Size:    8
 ...
diff --git a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
index 671b43ba6f2de..53818178b95cb 100644
--- a/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
+++ b/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
@@ -3,57 +3,51 @@
 
 # RUN: yaml2obj %s -o %t
 # RUN: llvm-objcopy %t --extract-section=FKE1=%t.fke1.out --extract-section=FKE4=%t.fke4.out
-# RUN: obj2yaml %t.fke1.out | FileCheck %s --check-prefixes=CHECK,FKE1
-# RUN: obj2yaml %t.fke4.out | FileCheck %s --check-prefixes=CHECK,FKE4
+# RUN: obj2yaml %t.fke1.out | FileCheck %s --check-prefixes=CHECK,FKE1 --implicit-check-not=Name:
+# RUN: obj2yaml %t.fke4.out | FileCheck %s --check-prefixes=CHECK,FKE4 --implicit-check-not=Name:
 
 # FKE1:       FileSize:       52
 # FKE4:       FileSize:       1732
 # CHECK-NEXT: PartCount:     1
 # CHECK-NEXT: PartOffsets:   [ 36 ]
 # CHECK-NEXT: Parts:
-
-# CHECK-NOT: FKE0
-# FKE1:      Name: FKE1
-# FKE4-NOT:  FKE1
-# CHECK-NOT: FKE2
-# CHECK-NOT: FKE3
-# FKE1-NOT:  FKE4
-# FKE4:      Name: FKE4
-# CHECK-NOT: FKE5
-# CHECK-NOT: DXIL
+# FKE1-NEXT:    Name: FKE1
+# FKE1-NEXT:    Size: 8
+# FKE4-NEXT:    Name: FKE4
+# FKE4-NEXT:    Size: 1688
 
 --- !dxcontainer
 Header:
-  Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-                     0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+  Hash:        [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+                 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
   Version:
-    Major:           1
-    Minor:           0
-  FileSize:        1996
-  PartCount:       7
-  PartOffsets:     [ 60, 76, 92, 108, 236, 1932, 1960 ]
+    Major:     1
+    Minor:     0
+  FileSize:    1996
+  PartCount:   7
+  PartOffsets: [ 60, 76, 92, 108, 236, 1932, 1960 ]
 Parts:
-  - Name:            FKE0
-    Size:            8
-  - Name:            FKE1
-    Size:            8
-  - Name:            FKE2
-    Size:            8
-  - Name:            FKE3
-    Size:            120
-  - Name:            FKE4
-    Size:            1688
-  - Name:            FKE5
-    Size:            20
-  - Name:            DXIL
-    Size:            28
+  - Name: FKE0
+    Size: 8
+  - Name: FKE1
+    Size: 8
+  - Name: FKE2
+    Size: 8
+  - Name: FKE3
+    Size: 120
+  - Name: FKE4
+    Size: 1688
+  - Name: FKE5
+    Size: 20
+  - Name: DXIL
+    Size: 28
     Program:
-      MajorVersion:    6
-      MinorVersion:    5
-      ShaderKind:      5
-      Size:            8
+      MajorVersion:     6
+      MinorVersion:     5
+      ShaderKind:       5
+      Size:             8
       DXILMajorVersion: 1
       DXILMinorVersion: 5
-      DXILSize:        4
-      DXIL:            [ 0x42, 0x43, 0xC0, 0xDE, ]
+      DXILSize:         4
+      DXIL:             [ 0x42, 0x43, 0xC0, 0xDE, ]
 ...



More information about the llvm-commits mailing list