-
Notifications
You must be signed in to change notification settings - Fork 83
/
elf.h
71 lines (61 loc) · 1.21 KB
/
elf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* ps4-kexec - a kexec() implementation for Orbis OS / FreeBSD
*
* Copyright (C) 2015-2016 shuffle2 <godisgovernment@gmail.com>
* Copyright (C) 2015-2016 Hector Martin "marcan" <marcan@marcan.st>
*
* This code is licensed to you under the 2-clause BSD license. See the LICENSE
* file for more information.
*/
#ifndef ELF_H
#define ELF_H
#include "types.h"
#define EI_NIDENT 16
typedef struct {
u8 e_ident[EI_NIDENT];
u16 e_type;
u16 e_machine;
u32 e_version;
u64 e_entry;
u64 e_phoff;
u64 e_shoff;
u32 e_flags;
u16 e_ehsize;
u16 e_phentsize;
u16 e_phnum;
u16 e_shentsize;
u16 e_shnum;
u16 e_shtrndx;
} Elf64_Ehdr;
typedef struct {
u32 p_type;
u32 p_flags;
u64 p_offset;
void *p_vaddr;
u64 p_paddr;
u64 p_filesz;
u64 p_memsz;
u64 p_align;
} Elf64_Phdr;
#define PT_DYNAMIC 2
#define PT_PHDR 6
#define DT_NULL 0
#define DT_STRTAB 5
#define DT_SYMTAB 6
#define DT_STRSZ 10
typedef struct {
s64 d_tag;
union {
u64 d_val;
void *d_ptr;
} d_un;
} Elf64_Dyn;
typedef struct {
u32 st_name;
u8 st_info;
u8 st_other;
u16 st_shndx;
void *st_value;
u64 st_size;
} Elf64_Sym;
#endif