Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
elf.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Intel Corporation
3 * Copyright (c) 2024 Schneider Electric
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 */
8#ifndef ZEPHYR_LLEXT_ELF_H
9#define ZEPHYR_LLEXT_ELF_H
10
11#include <stdint.h>
12
23#ifdef __cplusplus
24extern "C" {
25#endif
26
37
52
53
65#define EI_NIDENT 16
66
70struct elf32_ehdr {
72 unsigned char e_ident[EI_NIDENT];
99};
100
106 unsigned char e_ident[EI_NIDENT];
133};
134
136#define ET_REL 1
137
139#define ET_EXEC 2
140
142#define ET_DYN 3
143
145#define ET_CORE 4
146
171};
172
197};
198
199#define SHT_PROGBITS 0x1
200#define SHT_SYMTAB 0x2
201#define SHT_STRTAB 0x3
202#define SHT_RELA 0x4
203#define SHT_NOBITS 0x8
204#define SHT_REL 0x9
205#define SHT_DYNSYM 0xB
206
207#define SHF_WRITE 0x1
208#define SHF_ALLOC 0x2
209#define SHF_EXECINSTR 0x4
210
214struct elf32_sym {
222 unsigned char st_info;
224 unsigned char st_other;
227};
228
232struct elf64_sym {
236 unsigned char st_info;
238 unsigned char st_other;
245};
246
247#define SHN_UNDEF 0
248#define SHN_ABS 0xfff1
249#define SHN_COMMON 0xfff2
250
251#define STT_NOTYPE 0
252#define STT_OBJECT 1
253#define STT_FUNC 2
254#define STT_SECTION 3
255#define STT_FILE 4
256#define STT_COMMON 5
257#define STT_LOOS 10
258#define STT_HIOS 12
259#define STT_LOPROC 13
260#define STT_HIPROC 15
261
262#define STB_LOCAL 0
263#define STB_GLOBAL 1
264#define STB_WEAK 2
265#define STB_LOOS 10
266#define STB_HIOS 12
267#define STB_LOPROC 13
268#define STB_HIPROC 15
269
275#define ELF32_ST_BIND(i) ((i) >> 4)
276
282#define ELF32_ST_TYPE(i) ((i) & 0xf)
283
289#define ELF64_ST_BIND(i) ((i) >> 4)
290
291
297#define ELF64_ST_TYPE(i) ((i) & 0xf)
298
302struct elf32_rel {
305
308};
309
314};
315
321#define ELF32_R_SYM(i) ((i) >> 8)
322
328#define ELF32_R_TYPE(i) ((i) & 0xff)
329
333struct elf64_rel {
338};
339
344};
345
350#define ELF64_R_SYM(i) ((i) >> 32)
351
357#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
358
359#define R_386_NONE 0
360#define R_386_32 1
361#define R_386_PC32 2
362#define R_386_GOT32 3
363#define R_386_PLT32 4
364#define R_386_COPY 5
365#define R_386_GLOB_DAT 6
366#define R_386_JMP_SLOT 7
367#define R_386_RELATIVE 8
368#define R_386_GOTOFF 9
369
370#define R_ARM_NONE 0
371#define R_ARM_PC24 1
372#define R_ARM_ABS32 2
373#define R_ARM_REL32 3
374#define R_ARM_COPY 20
375#define R_ARM_GLOB_DAT 21
376#define R_ARM_JUMP_SLOT 22
377#define R_ARM_RELATIVE 23
378#define R_ARM_CALL 28
379#define R_ARM_JUMP24 29
380#define R_ARM_TARGET1 38
381#define R_ARM_V4BX 40
382#define R_ARM_PREL31 42
383#define R_ARM_MOVW_ABS_NC 43
384#define R_ARM_MOVT_ABS 44
385#define R_ARM_MOVW_PREL_NC 45
386#define R_ARM_MOVT_PREL 46
387#define R_ARM_ALU_PC_G0_NC 57
388#define R_ARM_ALU_PC_G1_NC 59
389#define R_ARM_LDR_PC_G2 63
390
391#define R_ARM_THM_CALL 10
392#define R_ARM_THM_JUMP24 30
393#define R_ARM_THM_MOVW_ABS_NC 47
394#define R_ARM_THM_MOVT_ABS 48
395#define R_ARM_THM_MOVW_PREL_NC 49
396#define R_ARM_THM_MOVT_PREL 50
397
398#define R_XTENSA_NONE 0
399#define R_XTENSA_32 1
400#define R_XTENSA_SLOT0_OP 20
401
414};
415
428};
429
433#define PT_LOAD 1
434
438struct elf32_dyn {
440 union {
444};
445
449struct elf64_dyn {
451 union {
455};
456
457#if defined(CONFIG_64BIT) || defined(__DOXYGEN__)
459typedef struct elf64_ehdr elf_ehdr_t;
461typedef struct elf64_shdr elf_shdr_t;
463typedef struct elf64_phdr elf_phdr_t;
471typedef struct elf64_rel elf_rel_t;
472typedef struct elf64_rela elf_rela_t;
474typedef struct elf64_sym elf_sym_t;
476#define ELF_R_SYM ELF64_R_SYM
478#define ELF_R_TYPE ELF64_R_TYPE
480#define ELF_ST_BIND ELF64_ST_BIND
482#define ELF_ST_TYPE ELF64_ST_TYPE
483#else
485typedef struct elf32_ehdr elf_ehdr_t;
487typedef struct elf32_shdr elf_shdr_t;
489typedef struct elf32_phdr elf_phdr_t;
491typedef elf32_addr elf_addr;
493typedef elf32_half elf_half;
495typedef elf32_word elf_word;
497typedef struct elf32_rel elf_rel_t;
498typedef struct elf32_rela elf_rela_t;
500typedef struct elf32_sym elf_sym_t;
502#define ELF_R_SYM ELF32_R_SYM
504#define ELF_R_TYPE ELF32_R_TYPE
506#define ELF_ST_BIND ELF32_ST_BIND
508#define ELF_ST_TYPE ELF32_ST_TYPE
509#endif
510
511#ifdef __cplusplus
512}
513#endif
514
519#endif /* ZEPHYR_LLEXT_ELF_H */
int32_t elf32_sword
Signed integer.
Definition: elf.h:34
uint16_t elf32_half
Unsigned medium integer.
Definition: elf.h:30
elf64_xword elf_word
Machine sized integer.
Definition: elf.h:469
int32_t elf64_sword
Signed integer.
Definition: elf.h:45
uint16_t elf64_half
Unsigned medium integer.
Definition: elf.h:41
int64_t elf64_sxword
Signed long integer.
Definition: elf.h:49
uint64_t elf64_addr
Unsigned program address.
Definition: elf.h:39
uint32_t elf32_addr
Unsigned program address.
Definition: elf.h:28
uint64_t elf64_xword
Unsigned long integer.
Definition: elf.h:51
uint64_t elf64_off
Unsigned file offset.
Definition: elf.h:43
elf64_addr elf_addr
Machine sized program address.
Definition: elf.h:465
uint32_t elf64_word
Unsigned integer.
Definition: elf.h:47
uint32_t elf32_off
Unsigned file offset.
Definition: elf.h:32
uint32_t elf32_word
Unsigned integer.
Definition: elf.h:36
elf64_half elf_half
Machine sized small integer.
Definition: elf.h:467
#define EI_NIDENT
ELF identifier block.
Definition: elf.h:65
__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
Dynamic section entry(32-bit)
Definition: elf.h:438
elf32_sword d_tag
Definition: elf.h:439
elf32_addr d_ptr
Definition: elf.h:442
elf32_word d_val
Definition: elf.h:441
union elf32_dyn::@261 d_un
ELF Header(32-bit)
Definition: elf.h:70
elf32_off e_shoff
Section header table offset.
Definition: elf.h:84
elf32_half e_machine
Machine type.
Definition: elf.h:76
elf32_half e_phentsize
Program header count.
Definition: elf.h:90
elf32_word e_flags
Processor specific flags.
Definition: elf.h:86
elf32_addr e_entry
Virtual address of entry.
Definition: elf.h:80
elf32_half e_phnum
Program header count.
Definition: elf.h:92
elf32_half e_shentsize
Section header size.
Definition: elf.h:94
elf32_half e_ehsize
ELF header size.
Definition: elf.h:88
elf32_half e_shstrndx
Section header containing section header string table.
Definition: elf.h:98
elf32_word e_version
Object file version.
Definition: elf.h:78
elf32_half e_shnum
Section header count.
Definition: elf.h:96
unsigned char e_ident[16]
Magic string identifying ELF binary.
Definition: elf.h:72
elf32_half e_type
Type of ELF.
Definition: elf.h:74
elf32_off e_phoff
Program header table offset.
Definition: elf.h:82
Program header(32-bit)
Definition: elf.h:405
elf32_word p_flags
Definition: elf.h:412
elf32_addr p_paddr
Definition: elf.h:409
elf32_word p_memsz
Definition: elf.h:411
elf32_off p_offset
Definition: elf.h:407
elf32_addr p_vaddr
Definition: elf.h:408
elf32_word p_align
Definition: elf.h:413
elf32_word p_type
Definition: elf.h:406
elf32_word p_filesz
Definition: elf.h:410
Relocation entry for 32-bit ELFs.
Definition: elf.h:302
elf32_addr r_offset
Offset in the section to perform a relocation.
Definition: elf.h:304
elf32_word r_info
Information about the relocation, related symbol and type.
Definition: elf.h:307
Definition: elf.h:310
elf32_sword r_addend
Definition: elf.h:313
elf32_word r_info
Definition: elf.h:312
elf32_addr r_offset
Definition: elf.h:311
Section Header(32-bit)
Definition: elf.h:150
elf32_addr sh_addr
Address of section in the image.
Definition: elf.h:158
elf32_word sh_name
Section header name index in section header string table.
Definition: elf.h:152
elf32_word sh_type
Section type.
Definition: elf.h:154
elf32_word sh_flags
Section header attributes.
Definition: elf.h:156
elf32_word sh_size
Section size in bytes.
Definition: elf.h:162
elf32_word sh_info
Section info, depends on section type.
Definition: elf.h:166
elf32_word sh_addralign
Section address alignment.
Definition: elf.h:168
elf32_off sh_offset
Location of section in the ELF binary in bytes.
Definition: elf.h:160
elf32_word sh_entsize
Section contains table of fixed size entries sh_entsize bytes large.
Definition: elf.h:170
elf32_word sh_link
Section header table link index, depends on section type.
Definition: elf.h:164
Symbol table entry(32-bit)
Definition: elf.h:214
elf32_half st_shndx
Symbols related section given by section header index.
Definition: elf.h:226
elf32_word st_name
Name of the symbol as an index into the symbol string table.
Definition: elf.h:216
elf32_addr st_value
Value or location of the symbol.
Definition: elf.h:218
unsigned char st_other
Symbol visibility.
Definition: elf.h:224
unsigned char st_info
Symbol binding and type information.
Definition: elf.h:222
elf32_word st_size
Size of the symbol.
Definition: elf.h:220
Dynamic section entry(64-bit)
Definition: elf.h:449
elf64_sxword d_tag
Definition: elf.h:450
union elf64_dyn::@262 d_un
elf64_addr d_ptr
Definition: elf.h:453
elf64_xword d_val
Definition: elf.h:452
ELF Header(64-bit)
Definition: elf.h:104
elf64_addr e_entry
Virtual address of entry.
Definition: elf.h:114
elf64_off e_shoff
Section header table offset.
Definition: elf.h:118
elf64_half e_shentsize
Section header size.
Definition: elf.h:128
elf64_half e_phnum
Program header count.
Definition: elf.h:126
elf64_half e_shstrndx
Section header containing section header string table.
Definition: elf.h:132
elf64_half e_phentsize
Program header size.
Definition: elf.h:124
elf64_word e_flags
Processor specific flags.
Definition: elf.h:120
elf64_half e_ehsize
ELF header size.
Definition: elf.h:122
elf64_word e_version
Object file version.
Definition: elf.h:112
elf64_half e_type
Type of ELF.
Definition: elf.h:108
elf64_off e_phoff
Program header table offset.
Definition: elf.h:116
elf64_half e_machine
Machine type.
Definition: elf.h:110
unsigned char e_ident[16]
Magic string identifying ELF binary.
Definition: elf.h:106
elf64_half e_shnum
Section header count.
Definition: elf.h:130
Program header(64-bit)
Definition: elf.h:419
elf64_xword p_filesz
Definition: elf.h:424
elf64_addr p_vaddr
Definition: elf.h:422
elf64_word p_type
Definition: elf.h:420
elf64_addr p_paddr
Definition: elf.h:423
elf64_word p_flags
Definition: elf.h:426
elf64_xword p_align
Definition: elf.h:427
elf64_xword p_memsz
Definition: elf.h:425
elf64_off p_offset
Definition: elf.h:421
Relocation entry for 64-bit ELFs.
Definition: elf.h:333
elf64_addr r_offset
Offset in section to perform a relocation.
Definition: elf.h:335
elf64_xword r_info
Information about relocation, related symbol and type.
Definition: elf.h:337
Definition: elf.h:340
elf64_sxword r_addend
Definition: elf.h:343
elf64_addr r_offset
Definition: elf.h:341
elf64_xword r_info
Definition: elf.h:342
Section Header(64-bit)
Definition: elf.h:176
elf64_xword sh_size
Section size in bytes.
Definition: elf.h:188
elf64_xword sh_entsize
Section contains table of fixed size entries sh_entsize bytes large.
Definition: elf.h:196
elf64_word sh_link
Section header table link index, depends on section type.
Definition: elf.h:190
elf64_addr sh_addr
Address of section in the image.
Definition: elf.h:184
elf64_off sh_offset
Location of section in the ELF binary in bytes.
Definition: elf.h:186
elf64_xword sh_addralign
Section address alignment.
Definition: elf.h:194
elf64_word sh_info
Section info, depends on section type.
Definition: elf.h:192
elf64_xword sh_flags
Section header attributes.
Definition: elf.h:182
elf64_word sh_type
Section type.
Definition: elf.h:180
elf64_word sh_name
Section header name index in section header string table.
Definition: elf.h:178
Symbol table entry(64-bit)
Definition: elf.h:232
elf64_half st_shndx
Symbols related section given by section header index.
Definition: elf.h:240
elf64_addr st_value
Value or location of the symbol.
Definition: elf.h:242
unsigned char st_other
Symbol visibility.
Definition: elf.h:238
unsigned char st_info
Symbol binding and type information.
Definition: elf.h:236
elf64_xword st_size
Size of the symbol.
Definition: elf.h:244
elf64_word st_name
Name of the symbol as an index into the symbol string table.
Definition: elf.h:234