llvm-project/llvm/test/tools/llvm-objcopy/DXContainer/extract-section-headers.test
Finn Plummer 2bdcfc7ab8
[DirectX] Add extract-section to llvm-objcopy and implement it for DXContainer (#154804)
This pr adds the `extract-section` option to `llvm-objcopy` as a common
option. It differs from `dump-section` as it will produce a standalone
object with just one section, as opposed to just the section contents.

For more context as to other options considered, see
https://github.com/llvm/llvm-project/pull/153265#issuecomment-3195696003.

This difference in behaviour is used for DXC compatibility with
`extract-rootsignature` and `/Frs`.

This pr then implements this functionality for `DXContainer` objects.

This is the second step of
https://github.com/llvm/llvm-project/issues/150277 to implement as a
compiler action that invokes `llvm-objcopy` for functionality.

This also completes the implementation of `extract-rootsignature` as
described in https://github.com/llvm/llvm-project/issues/149560.
2025-09-09 08:37:12 -06:00

54 lines
1.4 KiB
Plaintext

## 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 --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:
# 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 ]
Version:
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
Program:
MajorVersion: 6
MinorVersion: 5
ShaderKind: 5
Size: 8
DXILMajorVersion: 1
DXILMinorVersion: 5
DXILSize: 4
DXIL: [ 0x42, 0x43, 0xC0, 0xDE, ]
...