LLVM-OFFLOAD-BINARY(1)
π llvm-offload-binary π
LLVM-OFFLOAD-BINARY(1) β yes bestie, that's the manual name, folded in right here at the top π«Ά
πΈ NAME πΈ
llvm-offload-binary β LLVM Offload Binary Packager. That's the whole main-character job description, no cap π
β¨ SYNOPSIS β¨
llvm-offload-binary [options] [input files...]
π¦ DESCRIPTION π¦
okay so llvm-offload-binary is a utility for bundling multiple device object files into a single binary container. The resulting binary can then be embedded into the host section table to form a fat binary containing offloading code for different targets. Conversely, it can also extract previously bundled device images from offload binaries. It's giving "pack and unpack, but make it LLVM" β¨
When extracting images, if no --image filters are specified, all offload images are automatically extracted with descriptive filenames. When --image filters are provided, only matching images are extracted. Lowkey the cleanest vibe check ever π
The tool supports nested OffloadBinary format, where device images can be wrapped in an inner OffloadBinary container. When extracting, the tool automatically detects and unwraps nested OffloadBinary images, making the format transparent to users. Obsessed with the transparency, fr fr π«Ά
The binary format begins with the magic bytes 0x10FF10AD, followed by a version and size. Each binary contains its own header, allowing tools to locate offloading sections even when merged by a linker. Each offload entry includes metadata such as the device image kind, producer kind, and key-value string metadata. Multiple offloading images are concatenated to form a fat binary. That's the tea β
π EXAMPLE π
# Package multiple device images into a fat binary:
$ llvm-offload-binary -o out.bin \
--image=file=input.o,triple=nvptx64,arch=sm_70
# Extract all offload images from an executable (no filters):
$ llvm-offload-binary in.bin
# Output:
# Extracted: in-nvptx64-nvidia-cuda-sm_70.0.bc
# Extracted: in-spirv64-intel-unknown.0.spv
# Extract only SPIR-V images using filters:
$ llvm-offload-binary in.bin --image=triple=spirv64-intel
# Output:
# Extracted: in-spirv64-intel-unknown.0.spv
# Extract filtered images to a specific file:
$ llvm-offload-binary in.bin --image=file=output.bc,arch=sm_70
# Extract filtered images to an archive:
$ llvm-offload-binary in.bin --image=file=output.a,triple=nvptx64 --archive
π OPTIONS π
--archiveβ when extracting from an input binary, write all extracted images into a static archive instead of separate files. Archive girlie behavior, and honestly? Iconic π§--image=<<key>=<value>,...>β specify a set of arbitrary key-value arguments describing an image. Commonly used optional keys includearch(e.g.sm_70for CUDA) andtriple(e.g.nvptx64-nvidia-cuda).
When bundling, this option specifies images to include in the output binary. When extracting, this option acts as a filter: only images matching the specified keys are extracted. If no --image options are provided during extraction, all images are automatically extracted with descriptive filenames.
When extracting from a static archive, the member key restricts the output to a single archive member for cases when --archive is insufficient, e.g. --image=member=foo.o,triple=nvptx64,arch=sm_70,file=out.o. Slay that precise member selection β¨
-o <file>β write output to<file>. When bundling, this specifies the fat binary filename. When extracting, this specifies the archive or output file destination. One flag, two moods, both valid π--help,-hβ display available options. Use--help-hiddento show hidden options. The peek-behind-the-curtain feature, iykyk π₯--help-listβ display a list of all options. Use--help-list-hiddento show hidden ones. A whole list of options? Not me being fed information ππ--versionβ display the version of thellvm-offload-binaryexecutable. Version check, but make it cute β@<FILE>β read command-line options from response file<FILE>. Response-file realness, periodt π
π BINARY FORMAT π
The binary format is marked by the magic bytes 0x10FF10AD, followed by a version number. Each created binary contains its own header. This allows tools to locate offloading sections even after linker operations such as relocatable linking. Conceptually, this binary format is a serialization of a string map and an image buffer. No cap, that's the whole structural vibe π¦
π Offloading Binary Header π
uint8_tmagicβ the magic bytes for the binary format (0x10FF10AD) β¨uint32_tversionβ version of this format (currently version1) πuint64_tsizeβ size of this binary in bytes πuint64_tentry offsetβ absolute offset of the offload entries in bytes π¦uint64_tentry sizeβ size of the offload entries in bytes πΈ
Each offload entry describes a bundled image along with its associated metadata. Main character metadata energy, honestly π
π Offloading Entry Table π
uint16_timage kindβ the kind of the device image (e.g.bc,cubin) β¨uint16_toffload kindβ the producer of the image (e.g.openmp,cuda) π₯uint32_tflagsβ generic flags for the image πuint64_tstring offsetβ absolute offset of the string metadata table πuint64_tnum stringsβ number of string entries in the table πΈuint64_timage offsetβ absolute offset of the device image in bytes π¦uint64_timage sizeβ size of the device image in bytes π
The entry table refers to both a string table and the raw device image itself. The string table provides arbitrary key-value metadata. It's giving "strings and image, holding hands" π«Ά
π Offloading String Entry π
uint64_tkey offsetβ absolute byte offset of the key in the string table β¨uint64_tvalue offsetβ absolute byte offset of the value in the string table π
The string table is a collection of null-terminated strings stored in the image. Offsets allow string entries to be interpreted as key-value pairs, enabling flexible metadata such as architecture or target triple. Literally the metadata glow-up we deserve π
The enumerated values for image kind and offload kind are:
π« Image Kind π«
okay so every image in there has a kind, and it's giving "what even is this file, bestie?" energy. here's the whole roster:
IMG_Noneβ0x00β literally no image information provided. it's giving empty vibes π«₯IMG_Objectβ0x01β the image is a generic object fileIMG_Bitcodeβ0x02β the image is an LLVM-IR bitcode fileIMG_Cubinβ0x03β the image is a CUDA object fileIMG_Fatbinaryβ0x04β the image is a CUDA fatbinary fileIMG_PTXβ0x05β the image is a CUDA PTX file
π¦ Offload Kind π¦
and this one tells you which producer made the image β like, who's the parent, yk? π
OFK_Noneβ0x00β no offloading information providedOFK_OpenMPβ0x01β the producer was OpenMP offloadingOFK_CUDAβ0x02β the producer was CUDAOFK_HIPβ0x03β the producer was HIPOFK_SYCLβ0x04β the producer was SYCL
πΈ COMMON WORKFLOWS πΈ
bestie this is the part you actually came for, fr fr. six little recipes, pick your fighter π
β¨ Workflow 1: Explore Executable Contents
extract all the embedded offload images so you can peek at what's inside (nosy girl behavior, and honestly? valid π):
$ clang++ -fopenmp -fopenmp-targets=nvptx64,spirv64-intel app.cpp -o myapp
$ llvm-offload-binary myapp
# Output:
# Extracted: myapp-nvptx64-nvidia-cuda-sm_70.0.bc
# Extracted: myapp-spirv64-intel-unknown.1.spv
β¨ Workflow 2: Extract Specific Target
only want one target's images? filter it, periodt:
$ llvm-offload-binary myapp --image=triple=spirv64-intel
# Output:
# Extracted: myapp-spirv64-intel-unknown.0.spv
β¨ Workflow 3: Create Device Image Archive
grab your filtered images and yeet 'em into a static archive π:
$ llvm-offload-binary myapp --image=file=nvptx.a,triple=nvptx64 --archive
$ ar t nvptx.a
# Shows extracted CUDA images
β¨ Workflow 4: Validate SPIR-V
extract, then validate, then disassemble β the full glow-up routine β¨:
$ llvm-offload-binary myapp --image=triple=spirv64-intel
$ spirv-val myapp-spirv64-intel-unknown.0.spv
$ spirv-dis myapp-spirv64-intel-unknown.0.spv -o kernel.spvasm
β¨ Workflow 5: Bundle Multiple Targets
build a fat binary out of a bunch of device images because why choose πββοΈ:
$ clang++ -fopenmp -fopenmp-targets=nvptx64 --offload-device-only kernel.cpp -o kernel_nvptx.bc
$ clang++ -fopenmp -fopenmp-targets=spirv64-intel --offload-device-only kernel.cpp -o kernel_spirv.bc
$ llvm-offload-binary -o bundle.bin \
--image=file=kernel_nvptx.bc,triple=nvptx64,arch=sm_70 \
--image=file=kernel_spirv.bc,triple=spirv64-intel
β¨ Workflow 6: Extract and Rebundle
take the images out of one binary and rebundle them with your own edits β remix culture π§:
$ llvm-offload-binary old_app
$ llvm-offload-binary -o new_bundle.bin \
--image=file=old_app-nvptx64-nvidia-cuda-sm_70.0.bc,triple=nvptx64,arch=sm_70 \
--image=file=new_kernel.bc,triple=nvptx64,arch=sm_80
π SEE ALSO π
go read these next, they're iconic and they're literally right there:
clang(1)(clang.html)llvm-objdump(1)(llvm-objdump.html)spirv-val(1)(spirv-val.html)spirv-dis(1)(spirv-dis.html)
π Author π
maintained by the LLVM Team (https://llvm.org/) β they're the main characters of this whole saga, no cap π«Ά
π Copyright π
2003-2026, LLVM Project
okay that's the whole page, bestie!! now go extract something slay π β¨
and hmm one last lil thing β if you're squinting at the footer wondering where this came from: it's from page 23, dated 2026-10-20, filed under LLVM-OFFLOAD-BINARY(1). iconic of the manpage to have a birthday tbh ππ bye bestie, mwah π
π¦ where this page comes from
- arch rolling: llvm 23.1.4-1 Β· Apache-2.0 WITH LLVM-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms