[llvm] Add Offoading to llvm-readobj and llvm-objcopy (PR #141978)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu May 29 10:00:33 PDT 2025
================
@@ -230,4 +232,28 @@ void ObjDumper::printSectionsAsHex(const object::ObjectFile &Obj,
}
}
+// TODO: add proper error handling.
+void ObjDumper::printOffloading(const object::ObjectFile &Obj) {
+ // we can use an argument to let user select which offloading section they
+ // want to print. but for now, we're hardcoding ELF and "hip_fatbin".
+ assert((Obj.isELF() || Obj.isCOFF()) && "Invalid file type");
+
+ SmallVector<llvm::object::OffloadBundleFatBin> Bundles;
+ if (Error Err = llvm::object::extractOffloadBundleFatBinary(Obj, Bundles))
+ reportWarning(createError("Cannot extract Fatbin Binary from Object."),
+ Obj.getFileName());
+
+ // Print out all the FatBin Bundles that are contained in this buffer.
+ for (const auto &[Index, Bundle] : llvm::enumerate(Bundles)) {
+ Bundle.printEntriesAsURI();
+ }
+ /**SmallVectorImpl<llvm::object::OffloadBundleFatBin>::iterator it =
+ Bundles.begin();
+ for (uint64_t I = 0; I < Bundles.size(); I++) {
+ outs() << "Bundle " << I << "\n";
+ it->printEntriesAsURI();
+ ++it;
+ } **/
----------------
arsenm wrote:
Commented out code
https://github.com/llvm/llvm-project/pull/141978
More information about the llvm-commits
mailing list