Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions llvm/lib/ObjCopy/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,28 @@ Expected<const XCOFFConfig &> ConfigManager::getXCOFFConfig() const {

Expected<const DXContainerConfig &>
ConfigManager::getDXContainerConfig() const {
if (!Common.AddGnuDebugLink.empty() || Common.ExtractPartition ||
!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
!Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||
// If a flag is listed below, then it may be implemented in the future. All
// other flags are not applicable and will be silently ignored for the
// DXContainer object file
if (!Common.AddGnuDebugLink.empty() || !Common.SplitDWO.empty() ||
!Common.AllocSectionsPrefix.empty() ||
Common.DiscardMode != DiscardType::None || !Common.AddSection.empty() ||
!Common.DumpSection.empty() || !Common.SymbolsToAdd.empty() ||
!Common.KeepSection.empty() || !Common.OnlySection.empty() ||
!Common.ToRemove.empty() || !Common.SymbolsToGlobalize.empty() ||
!Common.SymbolsToKeep.empty() || !Common.SymbolsToLocalize.empty() ||
!Common.SymbolsToRemove.empty() ||
!Common.UnneededSymbolsToRemove.empty() ||
!Common.SymbolsToWeaken.empty() || !Common.SymbolsToKeepGlobal.empty() ||
!Common.DumpSection.empty() || !Common.KeepSection.empty() ||
!Common.OnlySection.empty() || !Common.ToRemove.empty() ||
!Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||
!Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
!Common.SymbolsToRename.empty() || Common.ExtractDWO ||
Common.ExtractMainPartition || Common.OnlyKeepDebug ||
Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
Common.Weaken || Common.StripUnneeded || Common.DecompressDebugSections ||
Common.GapFill != 0 || Common.PadTo != 0 ||
Common.ChangeSectionLMAValAll != 0 ||
Common.ExtractDWO || Common.OnlyKeepDebug || Common.StripAllGNU ||
Common.StripDWO || Common.StripDebug || Common.StripNonAlloc ||
Common.StripSections || 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");
}

// If a flag is listed here, then it has support for DXContainer:
// Common.PreserveDates
return DXContainer;
}
5 changes: 2 additions & 3 deletions llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
//===----------------------------------------------------------------------===//

#include "llvm/ObjCopy/DXContainer/DXContainerObjcopy.h"
#include "llvm/ObjCopy/CommonConfig.h"
#include "llvm/ObjCopy/DXContainer/DXContainerConfig.h"

#include "DXContainerReader.h"
#include "DXContainerWriter.h"
#include "llvm/ObjCopy/CommonConfig.h"
#include "llvm/ObjCopy/DXContainer/DXContainerConfig.h"

namespace llvm {
namespace objcopy {
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/ObjCopy/DXContainer/DXContainerObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_OBJCOPY_DXContainer_DXContainerOBJECT_H
#define LLVM_LIB_OBJCOPY_DXContainer_DXContainerOBJECT_H
#ifndef LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H
#define LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -44,4 +44,4 @@ struct Object {
} // end namespace objcopy
} // end namespace llvm

#endif // LLVM_LIB_OBJCOPY_DXContainer_DXContainerOBJECT_H
#endif // LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H
5 changes: 2 additions & 3 deletions llvm/lib/ObjCopy/DXContainer/DXContainerReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ Expected<std::unique_ptr<Object>> DXContainerReader::create() const {
DataRefImpl PartDRI = Part.getRawDataRefImpl();
Expected<StringRef> Name = DXContainerObj.getSectionName(PartDRI);
if (auto E = Name.takeError())
return createStringError(inconvertibleErrorCode(), "Missing Part Name");
return E;
assert(Name->size() == 4 &&
"Valid DXIL Part name consists of 4 characters");
Expected<ArrayRef<uint8_t>> Data =
DXContainerObj.getSectionContents(PartDRI);
if (auto E = Data.takeError())
return createStringError(inconvertibleErrorCode(),
"Missing Part Contents");
return E;
Obj->Parts.push_back({*Name, *Data});
}
return std::move(Obj);
Expand Down
18 changes: 10 additions & 8 deletions llvm/test/tools/llvm-objcopy/DXContainer/basic-copy.test
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
## Tests that the copied DXContainer is identical to the original

# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy %t %t.out
# RUN: cmp %t %t.out

# The following DXContainer to copied was generated with:
## The DXContainer described below was generated with:

# `clang-dxc -T cs_6_7 test.hlsl /Fo temp.dxo`
# `obj2yaml temp.dxo`
## `clang-dxc -T cs_6_7 test.hlsl /Fo temp.dxo`
## `obj2yaml temp.dxo`

# ``` test.hlsl
# [RootSignature("")]
# [numthreads(1,1,1)]
# void main() {}
# ```
## ``` test.hlsl
## [RootSignature("")]
## [numthreads(1,1,1)]
## void main() {}
## ```

--- !dxcontainer
Header:
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/tools/llvm-objcopy/DXContainer/headers-copy.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Tests that the copied DXContainer is identical to the original, ensuring all
## the different headers are correctly handled

# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy %t %t.out
# RUN: cmp %t %t.out
Expand Down