8#ifndef ZEPHYR_LLEXT_ELF_H
9#define ZEPHYR_LLEXT_ELF_H
202#define SHT_PROGBITS 0x1
203#define SHT_SYMTAB 0x2
204#define SHT_STRTAB 0x3
206#define SHT_NOBITS 0x8
208#define SHT_DYNSYM 0xB
209#define SHT_INIT_ARRAY 0xe
210#define SHT_FINI_ARRAY 0xf
211#define SHT_PREINIT_ARRAY 0x10
216#define SHF_EXECINSTR 0x4
217#define SHF_MASKOS 0x0ff00000
218#define SHF_LLEXT_HAS_RELOCS 0x00100000
220#define SHF_BASIC_TYPE_MASK (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR)
260#define SHN_LORESERVE 0xff00
261#define SHN_ABS 0xfff1
262#define SHN_COMMON 0xfff2
263#define SHN_HIRESERVE 0xffff
291#define ELF32_ST_BIND(i) ((i) >> 4)
298#define ELF32_ST_TYPE(i) ((i) & 0xf)
305#define ELF64_ST_BIND(i) ((i) >> 4)
313#define ELF64_ST_TYPE(i) ((i) & 0xf)
348#define ELF32_R_SYM(i) ((i) >> 8)
355#define ELF32_R_TYPE(i) ((i) & 0xff)
389#define ELF64_R_SYM(i) ((i) >> 32)
396#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
459#if defined(CONFIG_64BIT) || defined(__DOXYGEN__)
479#define ELF_R_SYM ELF64_R_SYM
481#define ELF_R_TYPE ELF64_R_TYPE
483#define ELF_ST_BIND ELF64_ST_BIND
485#define ELF_ST_TYPE ELF64_ST_TYPE
506#define ELF_R_SYM ELF32_R_SYM
508#define ELF_R_TYPE ELF32_R_TYPE
510#define ELF_ST_BIND ELF32_ST_BIND
512#define ELF_ST_TYPE ELF32_ST_TYPE
int32_t elf32_sword
Signed integer.
Definition elf.h:35
uint16_t elf32_half
Unsigned medium integer.
Definition elf.h:31
elf64_xword elf_word
Machine sized integer.
Definition elf.h:471
int32_t elf64_sword
Signed integer.
Definition elf.h:46
uint16_t elf64_half
Unsigned medium integer.
Definition elf.h:42
int64_t elf64_sxword
Signed long integer.
Definition elf.h:50
uint64_t elf64_addr
Unsigned program address.
Definition elf.h:40
uint32_t elf32_addr
Unsigned program address.
Definition elf.h:29
uint64_t elf64_xword
Unsigned long integer.
Definition elf.h:52
uint64_t elf64_off
Unsigned file offset.
Definition elf.h:44
elf64_addr elf_addr
Machine sized program address.
Definition elf.h:467
uint32_t elf64_word
Unsigned integer.
Definition elf.h:48
uint32_t elf32_off
Unsigned file offset.
Definition elf.h:33
uint32_t elf32_word
Unsigned integer.
Definition elf.h:37
elf64_half elf_half
Machine sized small integer.
Definition elf.h:469
struct elf64_phdr elf_phdr_t
Machine sized program header structure.
Definition elf.h:465
#define EI_NIDENT
ELF identifier block.
Definition elf.h:66
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT64_TYPE__ int64_t
Definition stdint.h:75
ELF Header(32-bit)
Definition elf.h:71
elf32_off e_shoff
Section header table offset.
Definition elf.h:85
elf32_half e_machine
Machine type.
Definition elf.h:77
elf32_half e_phentsize
Program header count.
Definition elf.h:91
elf32_word e_flags
Processor specific flags.
Definition elf.h:87
elf32_addr e_entry
Virtual address of entry.
Definition elf.h:81
elf32_half e_phnum
Program header count.
Definition elf.h:93
elf32_half e_shentsize
Section header size.
Definition elf.h:95
elf32_half e_ehsize
ELF header size.
Definition elf.h:89
elf32_half e_shstrndx
Section header containing section header string table.
Definition elf.h:99
elf32_word e_version
Object file version.
Definition elf.h:79
elf32_half e_shnum
Section header count.
Definition elf.h:97
unsigned char e_ident[16]
Magic string identifying ELF binary.
Definition elf.h:73
elf32_half e_type
Type of ELF.
Definition elf.h:75
elf32_off e_phoff
Program header table offset.
Definition elf.h:83
Relocation entry for 32-bit ELFs.
Definition elf.h:322
elf32_addr r_offset
Offset in the section to perform a relocation.
Definition elf.h:324
elf32_word r_info
Information about the relocation, related symbol and type.
Definition elf.h:326
Relocation entry for 32-bit ELFs with addend.
Definition elf.h:334
elf32_sword r_addend
Offset to be applied to the symbol address.
Definition elf.h:340
elf32_word r_info
Information about the relocation, related symbol and type.
Definition elf.h:338
elf32_addr r_offset
Offset in the section to perform a relocation.
Definition elf.h:336
Section Header(32-bit)
Definition elf.h:151
elf32_addr sh_addr
Address of section in the image.
Definition elf.h:159
elf32_word sh_name
Section header name index in section header string table.
Definition elf.h:153
elf32_word sh_type
Section type.
Definition elf.h:155
elf32_word sh_flags
Section header attributes.
Definition elf.h:157
elf32_word sh_size
Section size in bytes.
Definition elf.h:163
elf32_word sh_info
Section info, depends on section type.
Definition elf.h:167
elf32_word sh_addralign
Section address alignment.
Definition elf.h:169
elf32_off sh_offset
Location of section in the ELF binary in bytes.
Definition elf.h:161
elf32_word sh_entsize
Section contains table of fixed size entries sh_entsize bytes large.
Definition elf.h:171
elf32_word sh_link
Section header table link index, depends on section type.
Definition elf.h:165
Symbol table entry(32-bit)
Definition elf.h:225
elf32_half st_shndx
Symbols related section given by section header index.
Definition elf.h:237
elf32_word st_name
Name of the symbol as an index into the symbol string table.
Definition elf.h:227
elf32_addr st_value
Value or location of the symbol.
Definition elf.h:229
unsigned char st_other
Symbol visibility.
Definition elf.h:235
unsigned char st_info
Symbol binding and type information.
Definition elf.h:233
elf32_word st_size
Size of the symbol.
Definition elf.h:231
ELF Header(64-bit)
Definition elf.h:105
elf64_addr e_entry
Virtual address of entry.
Definition elf.h:115
elf64_off e_shoff
Section header table offset.
Definition elf.h:119
elf64_half e_shentsize
Section header size.
Definition elf.h:129
elf64_half e_phnum
Program header count.
Definition elf.h:127
elf64_half e_shstrndx
Section header containing section header string table.
Definition elf.h:133
elf64_half e_phentsize
Program header size.
Definition elf.h:125
elf64_word e_flags
Processor specific flags.
Definition elf.h:121
elf64_half e_ehsize
ELF header size.
Definition elf.h:123
elf64_word e_version
Object file version.
Definition elf.h:113
elf64_half e_type
Type of ELF.
Definition elf.h:109
elf64_off e_phoff
Program header table offset.
Definition elf.h:117
elf64_half e_machine
Machine type.
Definition elf.h:111
unsigned char e_ident[16]
Magic string identifying ELF binary.
Definition elf.h:107
elf64_half e_shnum
Section header count.
Definition elf.h:131
Relocation entry for 64-bit ELFs.
Definition elf.h:364
elf64_addr r_offset
Offset in the section to perform a relocation.
Definition elf.h:366
elf64_xword r_info
Information about the relocation, related symbol and type.
Definition elf.h:368
Relocation entry for 64-bit ELFs with addend.
Definition elf.h:376
elf64_sxword r_addend
Offset to be applied to the symbol address.
Definition elf.h:382
elf64_addr r_offset
Offset in the section to perform a relocation.
Definition elf.h:378
elf64_xword r_info
Information about the relocation, related symbol and type.
Definition elf.h:380
Section Header(64-bit)
Definition elf.h:177
elf64_xword sh_size
Section size in bytes.
Definition elf.h:189
elf64_xword sh_entsize
Section contains table of fixed size entries sh_entsize bytes large.
Definition elf.h:197
elf64_word sh_link
Section header table link index, depends on section type.
Definition elf.h:191
elf64_addr sh_addr
Address of section in the image.
Definition elf.h:185
elf64_off sh_offset
Location of section in the ELF binary in bytes.
Definition elf.h:187
elf64_xword sh_addralign
Section address alignment.
Definition elf.h:195
elf64_word sh_info
Section info, depends on section type.
Definition elf.h:193
elf64_xword sh_flags
Section header attributes.
Definition elf.h:183
elf64_word sh_type
Section type.
Definition elf.h:181
elf64_word sh_name
Section header name index in section header string table.
Definition elf.h:179
Symbol table entry(64-bit)
Definition elf.h:243
elf64_half st_shndx
Symbols related section given by section header index.
Definition elf.h:251
elf64_addr st_value
Value or location of the symbol.
Definition elf.h:253
unsigned char st_other
Symbol visibility.
Definition elf.h:249
unsigned char st_info
Symbol binding and type information.
Definition elf.h:247
elf64_xword st_size
Size of the symbol.
Definition elf.h:255
elf64_word st_name
Name of the symbol as an index into the symbol string table.
Definition elf.h:245