cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

balidani
Adept I

OpenCL ELF binary format

Hello!

I've been looking at the generated ELF binaries for OpenCL kernels and I have a few questions.

Is there any documentation for the structure of these binaries out there?

That would answer most of my questions if there was one.

I attached an example ELF for a very simple kernel.

In this binary there is an inner ELF in the .text section and this inner ELF contains the GCN microcode.

When I run readelf to see the sections of this inner ELF I get this:

$ readelf -S sample_inner.bin

There are 6 section headers, starting at offset 0xd0:

Section Headers:

  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al

  [ 0]                   NULL            00000000 000000 000000 00      0   0  0

  [ 1] .shstrtab         STRTAB          00000000 0000a8 000028 00      0   0  0

  [ 2] .text             PROGBITS        00000000 0005dc 00007c 00      0   0  0

  [ 3] .data             PROGBITS        00000000 000658 001280 1280    0   0  0

  [ 4] .symtab           SYMTAB          00000000 0018d8 000010 10      5   1  0

  [ 5] .strtab           STRTAB          00000000 0018e8 000002 00      0   0  0

Key to Flags:

  (...)

The weird part is that there is data in the ELF that is not contained by any section.

For example, you can find a bunch of text that says "ATI CAL" in the binary but those aren't contained by sections.

Does anyone know what that part is?

Thanks in advance,

Daniel

0 Likes
2 Replies
kd2
Adept II

For the format if the inner elf, see Section B2 of http://developer.amd.com/wordpress/media/2012/10/AMD_CAL_Programming_Guide_v2.0.pdf.


For example (page B-5), the "ATI CAL" strings appear in each CALNoteHeader...


typedef struct {

     Elf32_Word namesz; /* size of the name field. Must be 8 */

     Elf32_Word descsz; /* size of the data payload */

     Elf32_Word type; /* type of the payload */

     char name[8]; /* note header string. Must be “ATI CAL” */

} CALNoteHeader;

realhet
Miniboss

Hi,

That part with ATI_CAL strings is the note section. There is one for the AMD_IL and another for the ISA binary. They contain parameters such as LDS size, and sizes of the constant buffers, etc. They are standard elf note sections (see elf documentation) and located in the program header, not in the section header.

There's no documentation on the latest AMD OpenCl ELF file format as I know.