forked from proot-me/proot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharch.h
More file actions
179 lines (135 loc) · 5 KB
/
Copy patharch.h
File metadata and controls
179 lines (135 loc) · 5 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* -*- c-set-style: "K&R"; c-basic-offset: 8 -*-
*
* This file is part of PRoot.
*
* Copyright (C) 2015 STMicroelectronics
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
#ifndef ARCH_H
#define ARCH_H
#ifndef NO_LIBC_HEADER
#include <sys/ptrace.h> /* linux.git:c0a3a20b */
#include <linux/audit.h> /* AUDIT_ARCH_*, */
#endif
typedef unsigned long word_t;
typedef unsigned char byte_t;
#define SYSCALL_AVOIDER ((word_t) -1)
#define SYSTRAP_NUM SYSARG_NUM
#define STACK_ALIGNMENT 16
#define OFFSETOF_STATX_UID 20
#define OFFSETOF_STATX_GID 24
#if !defined(ARCH_X86_64) && !defined(ARCH_ARM_EABI) && !defined(ARCH_X86) && !defined(ARCH_SH4)
# if defined(__x86_64__)
# define ARCH_X86_64 1
# elif defined(__ARM_EABI__)
# define ARCH_ARM_EABI 1
# elif defined(__aarch64__)
# define ARCH_ARM64 1
# elif defined(__arm__)
# error "Only EABI is currently supported for ARM"
# elif defined(__i386__)
# define ARCH_X86 1
# elif defined(__SH4__)
# define ARCH_SH4 1
# else
# error "Unsupported architecture"
# endif
#endif
/* Architecture specific definitions. */
#if defined(ARCH_X86_64)
#define SYSNUMS_HEADER1 "syscall/sysnums-x86_64.h"
#define SYSNUMS_HEADER2 "syscall/sysnums-i386.h"
#define SYSNUMS_HEADER3 "syscall/sysnums-x32.h"
#define SYSNUMS_ABI1 sysnums_x86_64
#define SYSNUMS_ABI2 sysnums_i386
#define SYSNUMS_ABI3 sysnums_x32
#undef SYSTRAP_NUM
#define SYSTRAP_NUM SYSARG_RESULT
#define SYSTRAP_SIZE 2
#define SECCOMP_ARCHS { \
{ .value = AUDIT_ARCH_X86_64, .nb_abis = 2, .abis = { ABI_DEFAULT, ABI_3 } }, \
{ .value = AUDIT_ARCH_I386, .nb_abis = 1, .abis = { ABI_2 } }, \
}
#define HOST_ELF_MACHINE {62, 3, 6, 0}
#define RED_ZONE_SIZE 128
#define OFFSETOF_STAT_UID_32 24
#define OFFSETOF_STAT_GID_32 28
#define LOADER_ADDRESS 0x600000000000
#define HAS_LOADER_32BIT true
#define EXEC_PIC_ADDRESS 0x500000000000
#define INTERP_PIC_ADDRESS 0x6f0000000000
#define EXEC_PIC_ADDRESS_32 0x0f000000
#define INTERP_PIC_ADDRESS_32 0xaf000000
#elif defined(ARCH_ARM_EABI)
#define SYSNUMS_HEADER1 "syscall/sysnums-arm.h"
#define SYSNUMS_ABI1 sysnums_arm
#define SYSTRAP_SIZE 4
#define SECCOMP_ARCHS { { .value = AUDIT_ARCH_ARM, .nb_abis = 1, .abis = { ABI_DEFAULT } } }
#define user_regs_struct user_regs
#define HOST_ELF_MACHINE {40, 0};
#define RED_ZONE_SIZE 0
#define OFFSETOF_STAT_UID_32 0
#define OFFSETOF_STAT_GID_32 0
#define EM_ARM 40
#define LOADER_ADDRESS 0x10000000
#define EXEC_PIC_ADDRESS 0x0f000000
#define INTERP_PIC_ADDRESS 0x1f000000
#elif defined(ARCH_ARM64)
#define SYSNUMS_HEADER1 "syscall/sysnums-arm64.h"
#define SYSNUMS_ABI1 sysnums_arm64
#define SYSTRAP_SIZE 4
#ifndef AUDIT_ARCH_AARCH64
#define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
#endif
#define SECCOMP_ARCHS { { .value = AUDIT_ARCH_AARCH64, .nb_abis = 1, .abis = { ABI_DEFAULT } } }
#define HOST_ELF_MACHINE {183, 0};
#define RED_ZONE_SIZE 0
#define OFFSETOF_STAT_UID_32 0
#define OFFSETOF_STAT_GID_32 0
#define LOADER_ADDRESS 0x2000000000
#define EXEC_PIC_ADDRESS 0x3000000000
#define INTERP_PIC_ADDRESS 0x3f00000000
#elif defined(ARCH_X86)
#define SYSNUMS_HEADER1 "syscall/sysnums-i386.h"
#define SYSNUMS_ABI1 sysnums_i386
#undef SYSTRAP_NUM
#define SYSTRAP_NUM SYSARG_RESULT
#define SYSTRAP_SIZE 2
#define SECCOMP_ARCHS { { .value = AUDIT_ARCH_I386, .nb_abis = 1, .abis = { ABI_DEFAULT } } }
#define HOST_ELF_MACHINE {3, 6, 0};
#define RED_ZONE_SIZE 0
#define OFFSETOF_STAT_UID_32 0
#define OFFSETOF_STAT_GID_32 0
#define LOADER_ADDRESS 0xa0000000
#define LOADER_ARCH_CFLAGS -mregparm=3
#define EXEC_PIC_ADDRESS 0x0f000000
#define INTERP_PIC_ADDRESS 0xaf000000
#elif defined(ARCH_SH4)
#define SYSNUMS_HEADER1 "syscall/sysnums-sh4.h"
#define SYSNUMS_ABI1 sysnums_sh4
#define SYSTRAP_SIZE 2
#define SECCOMP_ARCHS { }
#define user_regs_struct pt_regs
#define HOST_ELF_MACHINE {42, 0};
#define RED_ZONE_SIZE 0
#define OFFSETOF_STAT_UID_32 0
#define OFFSETOF_STAT_GID_32 0
#define NO_MISALIGNED_ACCESS 1
#else
#error "Unsupported architecture"
#endif
#endif /* ARCH_H */