Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:CUDA fatbin and cubin

From ReverseEngineering.wiki
Format
Vendor NVIDIA
Magic 7F 45 4C 46 (cubin); fatbin header 0xBA55ED50; wrapper 0x466243B1
Extensions .cubin, .fatbin, .ptx
On this wiki Facts · Code · Notes · Topics

NVIDIA GPU code: a cubin is an ELF (e_machine EM_CUDA 190, OS/ABI 51, or 41 in newer toolchains) holding SASS machine code for one architecture; a fatbin bundles cubins and PTX for several architectures, embedded in host executables in a .nv_fatbin section and registered through a small wrapper struct with magic 0x466243B1.

Overview

CUDA host programs (nvcc, clang -x cuda) embed GPU code. At runtime __cudaRegisterFatBinary receives a wrapper that points at the fatbin blob. Reversing it means extracting the blob from the host binary, then listing its entries (cuobjdump / nvdisasm from the CUDA toolkit disassemble SASS; these are proprietary).

Host wrapper

In clang's CUDA code generator the wrapper is struct { int magic, int version, void *gpu_binary, void *unused } with magic 0x466243b1 (CudaFatMagic) and version 1; it is placed in the section .nvFatBinSegment (Mach-O __NV_CUDA,__fatbin) and the blob itself in .nv_fatbin (__NV_CUDA,__nv_fatbin). The comment in clang says NVIDIA's cuobjdump looks for fatbins in that section. The HIP counterpart uses magic 0x48495046 'HIPF'.

Fatbin blob

The blob starts with a header whose first dword is 0xBA55ED50 (little endian bytes 50 ED 55 BA) followed by version, header size and payload size, then entries each with a kind (PTX, ELF/cubin), target SM, flags, and possibly LZ4 or similar compression of the payload. Unverified: not read in a source this time; check the open tools that unpack fatbins before relying on field offsets.

Cubin

An ELF with e_machine EM_CUDA (190) and e_ident[EI_OSABI] ELFOSABI_CUDA (51 = 0x33) or ELFOSABI_CUDA_V2 (41 = 0x29), per LLVM's ELF.h. The SM version is in e_flags. Unverified: flag layout. Sections include .text.<kernel>, .nv.info.* (kernel attributes), .nv.constant0.<kernel> (kernel parameters and constants) and .nv.shared.* . Unverified: section names from memory.

See Format:ELF (Executable and Linkable Format), Technique:Compiled GPU shader formats.

Code & repositories

  • https://github.com/llvm/llvm-project @ 63ad0005f5eaac3e58289c05111ce5e5a20592b8 · license: Apache-2.0 WITH LLVM-exception (declared by the contributor; GitHub's detector did not recognize LICENSE.TXT)
    LLVM; AMDGPUUsage.rst documents the AMDGPU ELF code object, ELF.h lists EM_CUDA/EM_AMDGPU and OS ABIs, clang CGCUDANV.cpp shows the CUDA fatbin wrapper.
    Tested on: source read, not run: read only · checked 2026-10-19; last activity 2026-10-19; Note: the latest release ships binaries; the wiki links only the source, never the binaries