1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #ifndef _EXEC_H_
23 #define _EXEC_H_
24
25 #ifdef HAVE_STDINT_H
26 #include <stdint.h>
27 #endif
28
29 #include <sys/types.h>
30
31 #include USER_HEADER
32
33
34
35
36 #ifndef UINT64_MAX
37
38 typedef struct
39 {
40 uint32_t word1;
41 uint32_t word2;
42 } xint64_t;
43
44 #else
45 typedef uint64_t xint64_t;
46 #endif
47
48
49
50
51
52 struct elf_header_32
53 {
54 unsigned char e_ident[16];
55 uint16_t e_type;
56 uint16_t e_machine;
57 uint32_t e_version;
58 uint32_t e_entry;
59 uint32_t e_phoff;
60 uint32_t e_shoff;
61 uint32_t e_flags;
62 uint16_t e_ehsize;
63 uint16_t e_phentsize;
64 uint16_t e_phnum;
65 uint16_t e_shentsize;
66 uint16_t e_shnum;
67 uint16_t e_shstrndx;
68 };
69
70 struct program_header_32
71 {
72 uint32_t p_type;
73 uint32_t p_offset;
74 uint32_t p_vaddr;
75 uint32_t p_paddr;
76 uint32_t p_filesz;
77 uint32_t p_memsz;
78 uint32_t p_flags;
79 uint32_t p_align;
80 };
81
82 struct dt_entry_32
83 {
84 uint32_t d_tag;
85 uint32_t d_val;
86 };
87
88
89
90 struct elf_header_64
91 {
92 unsigned char e_ident[16];
93 uint16_t e_type;
94 uint16_t e_machine;
95 uint32_t e_version;
96 xint64_t e_entry;
97 xint64_t e_phoff;
98 xint64_t e_shoff;
99 uint32_t e_flags;
100 uint16_t e_ehsize;
101 uint16_t e_phentsize;
102 uint16_t e_phnum;
103 uint16_t e_shentsize;
104 uint16_t e_shnum;
105 uint16_t e_shstrndx;
106 };
107
108 struct program_header_64
109 {
110 uint32_t p_type;
111 uint32_t p_flags;
112 xint64_t p_offset;
113 xint64_t p_vaddr;
114 xint64_t p_paddr;
115 xint64_t p_filesz;
116 xint64_t p_memsz;
117 xint64_t p_align;
118 };
119
120 struct dt_entry_64
121 {
122 xint64_t d_tag;
123 xint64_t d_val;
124 };
125
126
127
128
129
130 #ifdef EXEC_64
131 typedef struct elf_header_64 elf_header;
132 typedef struct program_header_64 program_header;
133 typedef struct dt_entry_64 dt_entry;
134 #else
135 typedef struct elf_header_32 elf_header;
136 typedef struct program_header_32 program_header;
137 typedef struct dt_entry_32 dt_entry;
138 #endif
139
140
141
142
143
144
145
146 struct exec_tracee
147 {
148
149 struct exec_tracee *next;
150
151
152 pid_t pid;
153
154
155
156 bool waiting_for_syscall : 1;
157
158
159
160 bool new_child : 1;
161
162 #ifndef REENTRANT
163
164 char *exec_file;
165 #endif
166 };
167
168
169
170 #ifdef __aarch64__
171
172 extern int aarch64_get_regs (pid_t, USER_REGS_STRUCT *);
173 extern int aarch64_set_regs (pid_t, USER_REGS_STRUCT *, bool);
174
175 #endif
176
177
178
179 extern USER_WORD user_alloca (struct exec_tracee *, USER_REGS_STRUCT *,
180 USER_REGS_STRUCT *, USER_WORD);
181 extern int user_copy (struct exec_tracee *, const unsigned char *,
182 USER_WORD, USER_WORD);
183 extern void exec_init (const char *);
184
185
186
187 extern int tracing_execve (const char *, char *const *,
188 char *const *);
189 extern int after_fork (pid_t);
190 extern pid_t exec_waitpid (pid_t, int *, int);
191
192
193
194
195
196 extern char *exec_0 (char *, struct exec_tracee *,
197 size_t *, USER_REGS_STRUCT *);
198
199
200
201 #endif