[llvm] [ObjCopy][DX] Support for -dump-section flag (PR #159999)
Chris B via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 25 06:13:20 PDT 2025
================
@@ -42,7 +44,40 @@ static Error extractPartAsObject(StringRef PartName, StringRef OutFilename,
"part '%s' not found", PartName.str().c_str());
}
+static Error dumpPartToFile(StringRef PartName, StringRef Filename,
+ StringRef InputFilename, Object &Obj) {
+ for (const Part &P : Obj.Parts) {
+ if (P.Name == PartName) {
+ ArrayRef<uint8_t> Contents = P.Data;
+ // For parts containing llvm bitcode, don't dump the program headers so
+ // that we get a valid .bc file.
----------------
llvm-beanz wrote:
I added a comment here to explain better. The gist is that the DXContainer section descriptions are put in at the beginning of the section data as a header. For the bitcode sections, the headers have more data that is just replicated out of the bitcode. This allows runtime tools to avoid cracking open the bitcode to get basic information about of the program.
My goal is to make the objcopy tooling a bit more ergonomic by allowing it to pull out the bitcode into a file that other tools can directly work with. We should also be able to extend the libObject interface to inspect the bitcode and re-materialize the extra header information so that we could support generating a bitcode section and the associated headers from a bitcode file provided as input.
https://github.com/llvm/llvm-project/pull/159999
More information about the llvm-commits
mailing list