[llvm] Extend llvm objdump fatbin (PR #114834)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 28 17:55:52 PST 2025
================
@@ -96,6 +103,48 @@ Error extractFromObject(const ObjectFile &Obj,
return Error::success();
}
+// Extract an Offload bundle (usually a Offload Bundle) from a fat_bin
+// section
+Error extractOffloadBundle(MemoryBufferRef Contents, uint64_t SectionOffset,
+ StringRef fileName,
+ SmallVectorImpl<OffloadBundleFatBin> &Bundles) {
+
+ uint64_t Offset = 0;
+ int64_t nextbundleStart = 0;
+
+ // There could be multiple offloading bundles stored at this section.
+ while (nextbundleStart >= 0) {
+
+ std::unique_ptr<MemoryBuffer> Buffer =
+ MemoryBuffer::getMemBuffer(Contents.getBuffer().drop_front(Offset), "",
+ /*RequiresNullTerminator*/ false);
+
+ // Create the FatBinBindle object. This will also create the Bundle Entry
+ // list info.
+ auto FatBundleOrErr =
+ OffloadBundleFatBin::create(*Buffer, SectionOffset + Offset, fileName);
+ if (!FatBundleOrErr)
+ return FatBundleOrErr.takeError();
+ OffloadBundleFatBin &Bundle = **FatBundleOrErr;
+
+ // add current Bundle to list.
----------------
jhuber6 wrote:
Commends all need to be properly capitalized.
https://github.com/llvm/llvm-project/pull/114834
More information about the llvm-commits
mailing list