[llvm] Add --dump-offload-bundle option to llvm-objcopy (PR #143347)

David Salinas via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 19 20:50:13 PDT 2025


================
@@ -210,6 +210,27 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
                          "section '%s' not found", SecName.str().c_str());
 }
 
+static Error dumpRawDataURIToFile(StringRef Filename, int64_t Offset,
+                                  int64_t Size, ObjectFile &Obj) {
+  SmallString<2048> NameBuf;
+  raw_svector_ostream OutputFileName(NameBuf);
+  OutputFileName << Obj.getFileName().str() << "-offset" << Offset << "-size"
+                 << Size << ".co";
+
+  Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
+      FileOutputBuffer::create(OutputFileName.str(), Size);
+
+  if (!BufferOrErr)
+    return BufferOrErr.takeError();
----------------
david-salinas wrote:

This function does not get called.  I must have left in from an earlier draft.  I'm going to remove it.  However ... in trying to test this error case, and realizing that we do call "extractOffloadBundleByURI" in the API source in OffloadBundler.cpp, I uncovered that the API function throws an exception/error that isn't handled.  So I'll fix that and add an error check (or two) in the test case "dump-offload-bundle.test".

https://github.com/llvm/llvm-project/pull/143347


More information about the llvm-commits mailing list