-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DirectX] Add only-section to llvm-objcopy for DXContainer
#156372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
llvm/test/tools/llvm-objcopy/DXContainer/only-section-headers.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| ## Tests that the copied DXContainer correctly retains only the specified | ||
| ## headers. | ||
|
|
||
| # RUN: yaml2obj %s -o %t | ||
| # RUN: llvm-objcopy --only-section=FKE1 --only-section=FKE4 %t %t.out | ||
| # RUN: obj2yaml %t.out | FileCheck %s | ||
|
|
||
| --- !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 = 32 (header) | ||
| ## + 8 (FKE1 content) + 1688 (FKE4 content) | ||
| ## + 8 (2 part offsets) + 16 (2 part headers) | ||
| ## = 1752 | ||
| # CHECK: FileSize: 1752 | ||
jh7370 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| FileSize: 1996 | ||
| # CHECK-NEXT: PartCount: 2 | ||
| PartCount: 7 | ||
| # CHECK-NEXT: PartOffsets: [ 40, 56 ] | ||
| PartOffsets: [ 60, 76, 92, 108, 236, 1932, 1960 ] | ||
| Parts: | ||
| # CHECK-NEXT: Parts | ||
| # CHECK: FKE1 | ||
jh7370 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # CHECK-NOT: FKE2 | ||
| # CHECK-NOT: FKE3 | ||
| # CHECK: FKE4 | ||
| # CHECK-NOT: FKE5 | ||
| # CHECK-NOT: DXIL | ||
| - 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, ] | ||
| ... | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can/should we error if both
--remove-sectionand--only-sectionare specified together?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This follows the same behaviour as other objcopy implementations (for instance
ELFObjcopy) where--only-sectionshould just overwrite any previous specification for it to be removed (without warning or error). I think in general we want to match the behaviour as close as we can.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a fair bit of discussion back in Phabricator at some point when bringing up llvm-objcopy for ELF. In general, the conclusion was that explicit removals override implicit keeps, while explicit keeps override implicit removals (e.g. --keep-section=X would override the implicit removal of X from --only-section=Y).
Anyway, match what ELF does (which this does)!