llvm-project/llvm/lib/ObjCopy/DXContainer/DXContainerObject.h
Finn Plummer 87a1d42bed
[DirectX] Add support for remove-section of DXContainer for llvm-objcopy (#153246)
This pr implements the `remove-section` option for a `DXContainer`
object in `llvm-objcopy`.

It implements a base `removeParts` to the minimal `object`
representation of a `DXContainerObject`.

This is the second step to implement
https://github.com/llvm/llvm-project/issues/150275 as a compiler actions
that invokes llvm-objcopy for functionality.
2025-08-21 10:30:54 -07:00

53 lines
1.4 KiB
C++

//===- DXContainerObject.h --------------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H
#define LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/DXContainer.h"
#include <vector>
namespace llvm {
namespace objcopy {
namespace dxbc {
using namespace object;
struct Part {
StringRef Name;
ArrayRef<uint8_t> Data;
size_t size() const {
return sizeof(::llvm::dxbc::PartHeader) // base header
+ Data.size(); // contents size
}
};
using PartPred = llvm::function_ref<bool(const Part &)>;
struct Object {
::llvm::dxbc::Header Header;
SmallVector<Part> Parts;
size_t headerSize() const {
return sizeof(::llvm::dxbc::Header) // base header
+ sizeof(uint32_t) * Parts.size(); // part offset values
}
Error removeParts(PartPred ToRemove);
void recomputeHeader();
};
} // end namespace dxbc
} // end namespace objcopy
} // end namespace llvm
#endif // LLVM_LIB_OBJCOPY_DXCONTAINER_DXCONTAINEROBJECT_H