forked from ish-app/ish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elf.h
109 lines (97 loc) · 1.91 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef ELF_H
#define ELF_H
#include "misc.h"
#define ELF_MAGIC "\177ELF"
#define ELF_32BIT 1
#define ELF_64BIT 2
#define ELF_LITTLEENDIAN 1
#define ELF_BIGENDIAN 2
#define ELF_LINUX_ABI 3
#define ELF_EXECUTABLE 2
#define ELF_DYNAMIC 3
#define ELF_X86 3
struct elf_header {
uint32_t magic;
byte_t bitness;
byte_t endian;
byte_t elfversion1;
byte_t abi;
byte_t abi_version;
byte_t padding[7];
uint16_t type; // library or executable or what
uint16_t machine;
uint32_t elfversion2;
dword_t entry_point;
dword_t prghead_off;
dword_t secthead_off;
uint32_t flags;
uint16_t header_size;
uint16_t phent_size;
uint16_t phent_count;
uint16_t shent_size;
uint16_t shent_count;
uint16_t sectname_index;
};
#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
#define PT_NUM 8
struct prg_header {
uint32_t type;
dword_t offset;
dword_t vaddr;
dword_t paddr;
dword_t filesize;
dword_t memsize;
uint32_t flags;
dword_t alignment; // must be power of 2
};
#define PH_R (1 << 2)
#define PH_W (1 << 1)
#define PH_X (1 << 0)
struct aux_ent {
uint32_t type;
uint32_t value;
};
#define AX_PHDR 3
#define AX_PHENT 4
#define AX_PHNUM 5
#define AX_PAGESZ 6
#define AX_BASE 7
#define AX_FLAGS 8
#define AX_ENTRY 9
#define AX_UID 11
#define AX_EUID 12
#define AX_GID 13
#define AX_EGID 14
#define AX_PLATFORM 15
#define AX_HWCAP 16
#define AX_CLKTCK 17
#define AX_SECURE 23
#define AX_RANDOM 25
#define AX_HWCAP2 26
#define AX_EXECFN 31
#define AX_SYSINFO 32
#define AX_SYSINFO_EHDR 33
struct dyn_ent {
dword_t tag;
dword_t val;
};
#define DT_NULL 0
#define DT_HASH 4
#define DT_STRTAB 5
#define DT_SYMTAB 6
struct elf_sym {
uint32_t name;
addr_t value;
dword_t size;
byte_t info;
byte_t other;
uint16_t shndx;
};
#endif