[clang] [llvm] [llvm][tools] Extend llvm-objdump to support nested OffloadBinaries (PR #185425)

Alex Duran via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 21 06:19:28 PDT 2026


================
@@ -0,0 +1,19 @@
+## Test that llvm-objdump can display nested OffloadBinary images.
+
+# RUN: yaml2obj %s -o %t.bin
+# RUN: llvm-objdump --offloading %t.bin 2>&1 | FileCheck -DFILENAME=%t.bin %s
+
+!Offload
+Members:
+  - ImageKind:      IMG_Object
+    OffloadKind:    OFK_OpenMP
+    String:
+    - Key:            "triple"
+      Value:          "x-y-z"
+    - Key:            "arch"
+      Value:          "none"
+    Content:        10ff10ad
+
+# CHECK: warning: '[[FILENAME]]': failed to extract nested OffloadBinary: Invalid data was encountered while parsing the file
+## Check no information about the nested image is printed
+# CHECK-NOT: OFFLOADING IMAGE [0.0]:
----------------
adurang wrote:

There's some output before (that of the root image) so it would look like this:

```
#      CHECK:OFFLOADING IMAGE [0]:
# CHECK-NEXT:kind            elf
# CHECK-NEXT:arch            none
# CHECK-NEXT:triple          x-y-z
# CHECK-NEXT:producer        openmp
# CHECK-NEXT:image size      {{[0-9]+}} bytes
# CHECK-NEXT:{{.*}}: warning: '[[FILENAME]]': failed to extract nested OffloadBinary: Invalid data was encountered while parsing the file
```
but it seems to methis would also be succeptible to fail to any slight change, so I opted to use your count version but with a non-zero count:

`# RUN: llvm-objdump --offloading %t.bin 2> %t.err | count 7`

which will only be required to be updated if the number of output lines change. I hope this is ok.

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


More information about the cfe-commits mailing list