95#define SHT_LOPROC 0x70000000
96#define SHT_HIPROC 0x7fffffff
97#define SHT_LOUSER 0x80000000
98#define SHT_HIUSER 0xffffffff
112#define SHF_EXECINSTR 4
113#define SHF_MASKPROC 0xf0000000
125#define SHN_ABS 0xfff1
223#define ELF32_ST_BIND(info) ((info) >> 4)
232#define ELF32_ST_TYPE(info) ((info) & 0xf)
283#define ELF32_R_SYM(i) ((i) >> 8)
292#define ELF32_R_TYPE(i) ((uint8)(i))
304typedef struct elf_prog {
int elf_load(const char *fn, struct klibrary *shell, elf_prog_t *out)
Load an ELF binary.
void elf_free(elf_prog_t *prog)
Free a loaded ELF program.
unsigned short uint16
16-bit unsigned integer
Definition types.h:34
unsigned long uint32
32-bit unsigned integer
Definition types.h:33
long int32
32-bit signed integer
Definition types.h:37
uint32 ptr_t
Pointer arithmetic type.
Definition types.h:52
unsigned char uint8
8-bit unsigned integer
Definition types.h:35
ELF file header.
Definition elf.h:43
uint16 shnum
Section header entry count.
Definition elf.h:56
uint32 flags
Processor flags.
Definition elf.h:51
uint16 ehsize
ELF header size in bytes.
Definition elf.h:52
uint16 shentsize
Section header entry size.
Definition elf.h:55
uint16 type
ELF file type.
Definition elf.h:45
uint16 shstrndx
String table section index.
Definition elf.h:57
uint32 version
Object file version.
Definition elf.h:47
uint16 phnum
Program header entry count.
Definition elf.h:54
uint32 entry
Entry point.
Definition elf.h:48
uint32 phoff
Program header offset.
Definition elf.h:49
uint16 machine
ELF file architecture.
Definition elf.h:46
uint8 ident[16]
ELF identifier.
Definition elf.h:44
uint16 phentsize
Program header entry size.
Definition elf.h:53
uint32 shoff
Section header offset.
Definition elf.h:50
Kernel-specific definition of a loaded ELF binary.
Definition elf.h:304
ptr_t lib_get_name
Pointer to get_name() function.
Definition elf.h:309
ptr_t lib_close
Pointer to library's close function.
Definition elf.h:312
ptr_t lib_open
Pointer to library's open function.
Definition elf.h:311
void * data
Pointer to program in memory.
Definition elf.h:305
uint32 size
Memory image size (rounded up to page size)
Definition elf.h:306
ptr_t lib_get_version
Pointer to get_version() function.
Definition elf.h:310
ELF Relocation entry (without explicit addend).
Definition elf.h:258
uint32 info
Symbol and type.
Definition elf.h:260
uint32 offset
Offset within section.
Definition elf.h:259
ELF Relocation entry (with explicit addend).
Definition elf.h:243
int32 addend
Constant addend for the symbol.
Definition elf.h:246
uint32 info
Symbol and type.
Definition elf.h:245
uint32 offset
Offset within section.
Definition elf.h:244
ELF Section header.
Definition elf.h:135
uint32 name
Index into string table.
Definition elf.h:136
uint32 type
Section type.
Definition elf.h:137
uint32 link
Section header table index link.
Definition elf.h:142
uint32 addralign
Alignment constraints.
Definition elf.h:144
uint32 flags
Section flags.
Definition elf.h:138
uint32 addr
In-memory offset.
Definition elf.h:139
uint32 entsize
Fixed-size table entry sizes.
Definition elf.h:145
uint32 info
Section header extra info.
Definition elf.h:143
uint32 offset
On-disk offset.
Definition elf.h:140
uint32 size
Size (if SHT_NOBITS, amount of 0s needed)
Definition elf.h:141
Symbol table entry.
Definition elf.h:207
uint16 shndx
Section index.
Definition elf.h:213
uint8 other
0.
Definition elf.h:212
uint8 info
Symbol type and binding.
Definition elf.h:211
uint32 value
Value of the symbol.
Definition elf.h:209
uint32 size
Size of the symbol.
Definition elf.h:210
uint32 name
Index into file's string table.
Definition elf.h:208