OpenAMP Library  353
elf_loader.h File Reference

Go to the source code of this file.

Data Structures

struct  Elf32_Ehdr
 
struct  Elf64_Ehdr
 
struct  elf32_phdr
 
struct  elf64_phdr
 
struct  Elf32_Shdr
 
struct  Elf64_Shdr
 
struct  Elf32_Rel
 
struct  Elf64_Rel
 
struct  Elf32_Rela
 
struct  elf64_rela
 
struct  Elf32_Sym
 
struct  elf64_sym
 
struct  elf32_info
 
struct  elf64_info
 

Macros

#define EI_NIDENT   16
 
#define ET_NONE   0
 
#define ET_REL   1 /* Re-locatable file */
 
#define ET_EXEC   2 /* Executable file */
 
#define ET_DYN   3 /* Shared object file */
 
#define ET_CORE   4 /* Core file */
 
#define ET_LOOS   0xfe00 /* Operating system-specific */
 
#define ET_HIOS   0xfeff /* Operating system-specific */
 
#define ET_LOPROC   0xff00 /* remote_proc-specific */
 
#define ET_HIPROC   0xffff /* remote_proc-specific */
 
#define EM_ARM   40 /* ARM/Thumb Architecture */
 
#define EV_CURRENT   1 /* Current version */
 
#define EI_MAG0   0 /* File identification */
 
#define EI_MAG1   1 /* File identification */
 
#define EI_MAG2   2 /* File identification */
 
#define EI_MAG3   3 /* File identification */
 
#define EI_CLASS   4 /* File class */
 
#define EI_DATA   5 /* Data encoding */
 
#define EI_VERSION   6 /* File version */
 
#define EI_OSABI   7 /* Operating system/ABI identification */
 
#define EI_ABIVERSION   8 /* ABI version */
 
#define EI_PAD   9 /* Start of padding bytes */
 
#define EI_NIDENT   16 /* Size of e_ident[] */
 
#define ELFMAG0   0x7f /* e_ident[EI_MAG0] */
 
#define ELFMAG1   'E' /* e_ident[EI_MAG1] */
 
#define ELFMAG2   'L' /* e_ident[EI_MAG2] */
 
#define ELFMAG3   'F' /* e_ident[EI_MAG3] */
 
#define ELFMAG   "\177ELF"
 
#define SELFMAG   4
 
#define ELFCLASSNONE   0 /* Invalid class */
 
#define ELFCLASS32   1 /* 32-bit objects */
 
#define ELFCLASS64   2 /* 64-bit objects */
 
#define ELFDATANONE   0 /* Invalid data encoding */
 
#define ELFDATA2LSB   1 /* See Data encodings, below */
 
#define ELFDATA2MSB   2 /* See Data encodings, below */
 
#define ELFOSABI_NONE   0
 
#define PT_NULL   0
 
#define PT_LOAD   1
 
#define PT_DYNAMIC   2
 
#define PT_INTERP   3
 
#define PT_NOTE   4
 
#define PT_SHLIB   5
 
#define PT_PHDR   6
 
#define PT_TLS   7 /* Thread local storage segment */
 
#define PT_LOOS   0x60000000 /* OS-specific */
 
#define PT_HIOS   0x6fffffff /* OS-specific */
 
#define PT_LOPROC   0x70000000
 
#define PT_HIPROC   0x7fffffff
 
#define SHT_NULL   0
 
#define SHT_PROGBITS   1
 
#define SHT_SYMTAB   2
 
#define SHT_STRTAB   3
 
#define SHT_RELA   4
 
#define SHT_HASH   5
 
#define SHT_DYNAMIC   6
 
#define SHT_NOTE   7
 
#define SHT_NOBITS   8
 
#define SHT_REL   9
 
#define SHT_SHLIB   10
 
#define SHT_DYNSYM   11
 
#define SHT_INIT_ARRAY   14
 
#define SHT_FINI_ARRAY   15
 
#define SHT_PREINIT_ARRAY   16
 
#define SHT_GROUP   17
 
#define SHT_SYMTAB_SHNDX   18
 
#define SHT_LOOS   0x60000000
 
#define SHT_HIOS   0x6fffffff
 
#define SHT_LOPROC   0x70000000
 
#define SHT_HIPROC   0x7fffffff
 
#define SHT_LOUSER   0x80000000
 
#define SHT_HIUSER   0xffffffff
 
#define SHF_WRITE   0x1
 
#define SHF_ALLOC   0x2
 
#define SHF_EXECINSTR   0x4
 
#define SHF_MASKPROC   0xf0000000
 
#define ELF32_R_SYM(i)   ((i) >> 8)
 
#define ELF32_R_TYPE(i)   ((unsigned char)(i))
 
#define ELF64_R_SYM(i)   ((i) >> 32)
 
#define ELF64_R_TYPE(i)   ((i) & 0xffffffff)
 
#define R_ARM_GLOB_DAT   21 /* 0x15 */
 
#define R_ARM_JUMP_SLOT   22 /* 0x16 */
 
#define R_ARM_RELATIVE   23 /* 0x17 */
 
#define R_ARM_ABS32   2 /* 0x02 */
 
#define ELF_STATE_INIT   0x0L
 
#define ELF_STATE_WAIT_FOR_PHDRS   0x100L
 
#define ELF_STATE_WAIT_FOR_SHDRS   0x200L
 
#define ELF_STATE_WAIT_FOR_SHSTRTAB   0x400L
 
#define ELF_STATE_HDRS_COMPLETE   0x800L
 
#define ELF_STATE_MASK   0xFF00L
 
#define ELF_NEXT_SEGMENT_MASK   0x00FFL
 

Typedefs

typedef uint32_t Elf32_Addr
 
typedef uint16_t Elf32_Half
 
typedef uint32_t Elf32_Off
 
typedef int32_t Elf32_Sword
 
typedef uint32_t Elf32_Word
 
typedef uint64_t Elf64_Addr
 
typedef uint16_t Elf64_Half
 
typedef uint64_t Elf64_Off
 
typedef int32_t Elf64_Sword
 
typedef uint32_t Elf64_Word
 
typedef uint64_t Elf64_Xword
 
typedef int64_t Elf64_Sxword
 
typedef struct elf32_phdr Elf32_Phdr
 
typedef struct elf64_phdr Elf64_Phdr
 
typedef struct elf64_rela Elf64_Rela
 
typedef struct elf64_sym Elf64_Sym
 

Functions

int elf_identify (const void *img_data, size_t len)
 
int elf_load_header (const void *img_data, size_t offset, size_t len, void **img_info, int last_load_state, size_t *noffset, size_t *nlen)
 
int elf_load (struct remoteproc *rproc, const void *img_data, size_t offset, size_t len, void **img_info, int last_load_state, metal_phys_addr_t *da, size_t *noffset, size_t *nlen, unsigned char *padding, size_t *nmemsize)
 
void elf_release (void *img_info)
 
metal_phys_addr_t elf_get_entry (void *img_info)
 
int elf_locate_rsc_table (void *img_info, metal_phys_addr_t *da, size_t *offset, size_t *size)
 

Variables

const struct loader_ops elf_ops
 

Macro Definition Documentation

◆ EI_ABIVERSION

#define EI_ABIVERSION   8 /* ABI version */

◆ EI_CLASS

#define EI_CLASS   4 /* File class */

◆ EI_DATA

#define EI_DATA   5 /* Data encoding */

◆ EI_MAG0

#define EI_MAG0   0 /* File identification */

◆ EI_MAG1

#define EI_MAG1   1 /* File identification */

◆ EI_MAG2

#define EI_MAG2   2 /* File identification */

◆ EI_MAG3

#define EI_MAG3   3 /* File identification */

◆ EI_NIDENT [1/2]

#define EI_NIDENT   16

◆ EI_NIDENT [2/2]

#define EI_NIDENT   16 /* Size of e_ident[] */

◆ EI_OSABI

#define EI_OSABI   7 /* Operating system/ABI identification */

◆ EI_PAD

#define EI_PAD   9 /* Start of padding bytes */

◆ EI_VERSION

#define EI_VERSION   6 /* File version */

◆ ELF32_R_SYM

#define ELF32_R_SYM (   i)    ((i) >> 8)

◆ ELF32_R_TYPE

#define ELF32_R_TYPE (   i)    ((unsigned char)(i))

◆ ELF64_R_SYM

#define ELF64_R_SYM (   i)    ((i) >> 32)

◆ ELF64_R_TYPE

#define ELF64_R_TYPE (   i)    ((i) & 0xffffffff)

◆ ELF_NEXT_SEGMENT_MASK

#define ELF_NEXT_SEGMENT_MASK   0x00FFL

◆ ELF_STATE_HDRS_COMPLETE

#define ELF_STATE_HDRS_COMPLETE   0x800L

◆ ELF_STATE_INIT

#define ELF_STATE_INIT   0x0L

◆ ELF_STATE_MASK

#define ELF_STATE_MASK   0xFF00L

◆ ELF_STATE_WAIT_FOR_PHDRS

#define ELF_STATE_WAIT_FOR_PHDRS   0x100L

◆ ELF_STATE_WAIT_FOR_SHDRS

#define ELF_STATE_WAIT_FOR_SHDRS   0x200L

◆ ELF_STATE_WAIT_FOR_SHSTRTAB

#define ELF_STATE_WAIT_FOR_SHSTRTAB   0x400L

◆ ELFCLASS32

#define ELFCLASS32   1 /* 32-bit objects */

◆ ELFCLASS64

#define ELFCLASS64   2 /* 64-bit objects */

◆ ELFCLASSNONE

#define ELFCLASSNONE   0 /* Invalid class */

◆ ELFDATA2LSB

#define ELFDATA2LSB   1 /* See Data encodings, below */

◆ ELFDATA2MSB

#define ELFDATA2MSB   2 /* See Data encodings, below */

◆ ELFDATANONE

#define ELFDATANONE   0 /* Invalid data encoding */

◆ ELFMAG

#define ELFMAG   "\177ELF"

◆ ELFMAG0

#define ELFMAG0   0x7f /* e_ident[EI_MAG0] */

◆ ELFMAG1

#define ELFMAG1   'E' /* e_ident[EI_MAG1] */

◆ ELFMAG2

#define ELFMAG2   'L' /* e_ident[EI_MAG2] */

◆ ELFMAG3

#define ELFMAG3   'F' /* e_ident[EI_MAG3] */

◆ ELFOSABI_NONE

#define ELFOSABI_NONE   0

◆ EM_ARM

#define EM_ARM   40 /* ARM/Thumb Architecture */

◆ ET_CORE

#define ET_CORE   4 /* Core file */

◆ ET_DYN

#define ET_DYN   3 /* Shared object file */

◆ ET_EXEC

#define ET_EXEC   2 /* Executable file */

◆ ET_HIOS

#define ET_HIOS   0xfeff /* Operating system-specific */

◆ ET_HIPROC

#define ET_HIPROC   0xffff /* remote_proc-specific */

◆ ET_LOOS

#define ET_LOOS   0xfe00 /* Operating system-specific */

◆ ET_LOPROC

#define ET_LOPROC   0xff00 /* remote_proc-specific */

◆ ET_NONE

#define ET_NONE   0

◆ ET_REL

#define ET_REL   1 /* Re-locatable file */

◆ EV_CURRENT

#define EV_CURRENT   1 /* Current version */

◆ PT_DYNAMIC

#define PT_DYNAMIC   2

◆ PT_HIOS

#define PT_HIOS   0x6fffffff /* OS-specific */

◆ PT_HIPROC

#define PT_HIPROC   0x7fffffff

◆ PT_INTERP

#define PT_INTERP   3

◆ PT_LOAD

#define PT_LOAD   1

◆ PT_LOOS

#define PT_LOOS   0x60000000 /* OS-specific */

◆ PT_LOPROC

#define PT_LOPROC   0x70000000

◆ PT_NOTE

#define PT_NOTE   4

◆ PT_NULL

#define PT_NULL   0

◆ PT_PHDR

#define PT_PHDR   6

◆ PT_SHLIB

#define PT_SHLIB   5

◆ PT_TLS

#define PT_TLS   7 /* Thread local storage segment */

◆ R_ARM_ABS32

#define R_ARM_ABS32   2 /* 0x02 */

◆ R_ARM_GLOB_DAT

#define R_ARM_GLOB_DAT   21 /* 0x15 */

◆ R_ARM_JUMP_SLOT

#define R_ARM_JUMP_SLOT   22 /* 0x16 */

◆ R_ARM_RELATIVE

#define R_ARM_RELATIVE   23 /* 0x17 */

◆ SELFMAG

#define SELFMAG   4

◆ SHF_ALLOC

#define SHF_ALLOC   0x2

◆ SHF_EXECINSTR

#define SHF_EXECINSTR   0x4

◆ SHF_MASKPROC

#define SHF_MASKPROC   0xf0000000

◆ SHF_WRITE

#define SHF_WRITE   0x1

◆ SHT_DYNAMIC

#define SHT_DYNAMIC   6

◆ SHT_DYNSYM

#define SHT_DYNSYM   11

◆ SHT_FINI_ARRAY

#define SHT_FINI_ARRAY   15

◆ SHT_GROUP

#define SHT_GROUP   17

◆ SHT_HASH

#define SHT_HASH   5

◆ SHT_HIOS

#define SHT_HIOS   0x6fffffff

◆ SHT_HIPROC

#define SHT_HIPROC   0x7fffffff

◆ SHT_HIUSER

#define SHT_HIUSER   0xffffffff

◆ SHT_INIT_ARRAY

#define SHT_INIT_ARRAY   14

◆ SHT_LOOS

#define SHT_LOOS   0x60000000

◆ SHT_LOPROC

#define SHT_LOPROC   0x70000000

◆ SHT_LOUSER

#define SHT_LOUSER   0x80000000

◆ SHT_NOBITS

#define SHT_NOBITS   8

◆ SHT_NOTE

#define SHT_NOTE   7

◆ SHT_NULL

#define SHT_NULL   0

◆ SHT_PREINIT_ARRAY

#define SHT_PREINIT_ARRAY   16

◆ SHT_PROGBITS

#define SHT_PROGBITS   1

◆ SHT_REL

#define SHT_REL   9

◆ SHT_RELA

#define SHT_RELA   4

◆ SHT_SHLIB

#define SHT_SHLIB   10

◆ SHT_STRTAB

#define SHT_STRTAB   3

◆ SHT_SYMTAB

#define SHT_SYMTAB   2

◆ SHT_SYMTAB_SHNDX

#define SHT_SYMTAB_SHNDX   18

Typedef Documentation

◆ Elf32_Addr

typedef uint32_t Elf32_Addr

◆ Elf32_Half

typedef uint16_t Elf32_Half

◆ Elf32_Off

typedef uint32_t Elf32_Off

◆ Elf32_Phdr

typedef struct elf32_phdr Elf32_Phdr

◆ Elf32_Sword

typedef int32_t Elf32_Sword

◆ Elf32_Word

typedef uint32_t Elf32_Word

◆ Elf64_Addr

typedef uint64_t Elf64_Addr

◆ Elf64_Half

typedef uint16_t Elf64_Half

◆ Elf64_Off

typedef uint64_t Elf64_Off

◆ Elf64_Phdr

typedef struct elf64_phdr Elf64_Phdr

◆ Elf64_Rela

typedef struct elf64_rela Elf64_Rela

◆ Elf64_Sword

typedef int32_t Elf64_Sword

◆ Elf64_Sxword

typedef int64_t Elf64_Sxword

◆ Elf64_Sym

typedef struct elf64_sym Elf64_Sym

◆ Elf64_Word

typedef uint32_t Elf64_Word

◆ Elf64_Xword

typedef uint64_t Elf64_Xword

Function Documentation

◆ elf_get_entry()

metal_phys_addr_t elf_get_entry ( void *  img_info)

◆ elf_identify()

int elf_identify ( const void *  img_data,
size_t  len 
)

◆ elf_load()

int elf_load ( struct remoteproc rproc,
const void *  img_data,
size_t  offset,
size_t  len,
void **  img_info,
int  last_load_state,
metal_phys_addr_t *  da,
size_t *  noffset,
size_t *  nlen,
unsigned char *  padding,
size_t *  nmemsize 
)

◆ elf_load_header()

int elf_load_header ( const void *  img_data,
size_t  offset,
size_t  len,
void **  img_info,
int  last_load_state,
size_t *  noffset,
size_t *  nlen 
)

◆ elf_locate_rsc_table()

int elf_locate_rsc_table ( void *  img_info,
metal_phys_addr_t *  da,
size_t *  offset,
size_t *  size 
)

◆ elf_release()

void elf_release ( void *  img_info)

Variable Documentation

◆ elf_ops

const struct loader_ops elf_ops
extern