-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[DirectX] Add support for remove-section
of DXContainer
for llvm-objcopy
#153246
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
base: users/inbelic/pr-153079
Are you sure you want to change the base?
Changes from all commits
d450f5e
09a5ebe
d8bc47e
325809d
b821448
15632c8
01b1e0a
74ca962
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//===- DXContainerObject.cpp ----------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "DXContainerObject.h" | ||
|
||
namespace llvm { | ||
namespace objcopy { | ||
namespace dxbc { | ||
|
||
Error Object::removeParts(PartPred ToRemove) { | ||
erase_if(Parts, ToRemove); | ||
return Error::success(); | ||
} | ||
|
||
void Object::recomputeHeader() { | ||
Header.FileSize = headerSize(); | ||
Header.PartCount = Parts.size(); | ||
for (const Part &P : Parts) | ||
Header.FileSize += P.size(); | ||
} | ||
|
||
} // end namespace dxbc | ||
} // end namespace objcopy | ||
} // end namespace llvm |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## Tests that the copied DXContainer correctly has the specified headers | ||
## removed. | ||
|
||
# RUN: yaml2obj %s -o %t | ||
# RUN: llvm-objcopy --remove-section=FKE1 --remove-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 = 1996 - 8 (FKE1 content) - 1688 (FKE4 content) | ||
## - 8 (2 part offsets) - 16 (2 part headers) | ||
## = 276 | ||
# CHECK: FileSize: 276 | ||
FileSize: 1996 | ||
# CHECK: PartCount: 5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can any of these be |
||
PartCount: 7 | ||
# CHECK: PartOffsets: [ 52, 68, 84, 212, 240 ] | ||
PartOffsets: [ 60, 76, 92, 108, 236, 1932, 1960 ] | ||
Parts: | ||
# CHECK-NOT: FKE1 | ||
# CHECK-NOT: FKE4 | ||
Comment on lines
+25
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you aware that this just means FKE1 and FKE4 can't appear from this point onwards? I'd be tempted to put a |
||
- 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, ] | ||
... |
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.
Why is this different if the remove section arg wasn't passed to llvm-objcopy?
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.
Whoops, this commit was meant to be pushed to #153079.
In any case, the yaml here incorrectly specified the FileSize as 3548 instead of 1996. Since we now invoke
recomputeHeader
as part ofremoveParts
it was failing this test case, because the (correctly) computed size was different than the original specified.