Format:AMDGPU code object
| Vendor | AMD |
|---|---|
| Magic | 7F 45 4C 46, e_machine 0x00E0 |
| Extensions | .co, .hsaco, .bc |
| On this wiki | Facts · Code · Notes · Topics |
AMD GPU code (HIP/ROCm kernels, Vulkan/PAL and Mesa shaders) is an ELF with e_machine EM_AMDGPU (224) whose OS/ABI selects the runtime (64 HSA, 65 PAL, 66 Mesa3D), whose e_flags give the GPU (EF_AMDGPU_MACH), and whose notes carry MessagePack metadata.
Identification
From AMDGPUUsage.rst (llvm-project): e_machine EM_AMDGPU = 224 (0xe0) for all processors; e_ident[EI_OSABI] ELFOSABI_AMDGPU_HSA 64, ELFOSABI_AMDGPU_PAL 65, ELFOSABI_AMDGPU_MESA3D 66; e_ident[EI_ABIVERSION] for HSA: V2 = 0, V3 = 1, V4 = 2, V5 = 3, V6 = 4 (PAL and Mesa3D 0). The ABI version is the code object version.
GPU and features
The low bits of e_flags are EF_AMDGPU_MACH, a number per processor, for example gfx900 0x02c, gfx906 0x02f, gfx908 0x030, gfx1030 0x036, gfx1100 0x041. Code object V3 uses e_flags bits EF_AMDGPU_FEATURE_XNACK_V3 0x100 and EF_AMDGPU_FEATURE_SRAMECC_V3 0x200; V4 and later encode xnack and sramecc differently (see the document's tables).
Notes and metadata
Note records with vendor "AMDGPU": NT_AMDGPU_METADATA (type 32) holds metadata in MessagePack with the map amdhsa.kernels (one map per kernel: name, kernarg size, register counts, ...) for code object V3 and later; NT_AMDGPU_KFD_CORE_STATE (type 33) is used in core dumps. Unverified: each kernel also has a kernel descriptor symbol (name.kd) in .rodata that the hardware reads; the machine code is GCN/RDNA ISA in .text.
Reversing
llvm-objdump --offloading / llvm-readelf -n and llvm-objdump -d with the matching --mcpu disassemble the code; the notes give kernel argument layout. Unverified: command options 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