Skip to content

Commit f668cd1

Browse files
committed
arm64: ELF definitions
This patch adds definitions for the ELF format, including personality personality setting and EXEC_PAGESIZE. The are only two hwcap definitions for 64-bit applications - HWCAP_FP and HWCAP_ASIMD. Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Tony Lindgren <tony@atomide.com> Acked-by: Nicolas Pitre <nico@linaro.org> Acked-by: Olof Johansson <olof@lixom.net> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Acked-by: Arnd Bergmann <arnd@arndb.de>
1 parent 08e875c commit f668cd1

5 files changed

Lines changed: 305 additions & 0 deletions

File tree

‎arch/arm64/include/asm/auxvec.h‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (C) 2012 ARM Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
#ifndef __ASM_AUXVEC_H
17+
#define __ASM_AUXVEC_H
18+
19+
/* vDSO location */
20+
#define AT_SYSINFO_EHDR 33
21+
22+
#endif

‎arch/arm64/include/asm/elf.h‎

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
/*
2+
* Copyright (C) 2012 ARM Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
#ifndef __ASM_ELF_H
17+
#define __ASM_ELF_H
18+
19+
#include <asm/hwcap.h>
20+
21+
/*
22+
* ELF register definitions..
23+
*/
24+
#include <asm/ptrace.h>
25+
#include <asm/user.h>
26+
27+
typedef unsigned long elf_greg_t;
28+
typedef unsigned long elf_freg_t[3];
29+
30+
#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
31+
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
32+
33+
typedef struct user_fp elf_fpregset_t;
34+
35+
#define EM_AARCH64 183
36+
37+
/*
38+
* AArch64 static relocation types.
39+
*/
40+
41+
/* Miscellaneous. */
42+
#define R_ARM_NONE 0
43+
#define R_AARCH64_NONE 256
44+
45+
/* Data. */
46+
#define R_AARCH64_ABS64 257
47+
#define R_AARCH64_ABS32 258
48+
#define R_AARCH64_ABS16 259
49+
#define R_AARCH64_PREL64 260
50+
#define R_AARCH64_PREL32 261
51+
#define R_AARCH64_PREL16 262
52+
53+
/* Instructions. */
54+
#define R_AARCH64_MOVW_UABS_G0 263
55+
#define R_AARCH64_MOVW_UABS_G0_NC 264
56+
#define R_AARCH64_MOVW_UABS_G1 265
57+
#define R_AARCH64_MOVW_UABS_G1_NC 266
58+
#define R_AARCH64_MOVW_UABS_G2 267
59+
#define R_AARCH64_MOVW_UABS_G2_NC 268
60+
#define R_AARCH64_MOVW_UABS_G3 269
61+
62+
#define R_AARCH64_MOVW_SABS_G0 270
63+
#define R_AARCH64_MOVW_SABS_G1 271
64+
#define R_AARCH64_MOVW_SABS_G2 272
65+
66+
#define R_AARCH64_LD_PREL_LO19 273
67+
#define R_AARCH64_ADR_PREL_LO21 274
68+
#define R_AARCH64_ADR_PREL_PG_HI21 275
69+
#define R_AARCH64_ADR_PREL_PG_HI21_NC 276
70+
#define R_AARCH64_ADD_ABS_LO12_NC 277
71+
#define R_AARCH64_LDST8_ABS_LO12_NC 278
72+
73+
#define R_AARCH64_TSTBR14 279
74+
#define R_AARCH64_CONDBR19 280
75+
#define R_AARCH64_JUMP26 282
76+
#define R_AARCH64_CALL26 283
77+
#define R_AARCH64_LDST16_ABS_LO12_NC 284
78+
#define R_AARCH64_LDST32_ABS_LO12_NC 285
79+
#define R_AARCH64_LDST64_ABS_LO12_NC 286
80+
#define R_AARCH64_LDST128_ABS_LO12_NC 299
81+
82+
#define R_AARCH64_MOVW_PREL_G0 287
83+
#define R_AARCH64_MOVW_PREL_G0_NC 288
84+
#define R_AARCH64_MOVW_PREL_G1 289
85+
#define R_AARCH64_MOVW_PREL_G1_NC 290
86+
#define R_AARCH64_MOVW_PREL_G2 291
87+
#define R_AARCH64_MOVW_PREL_G2_NC 292
88+
#define R_AARCH64_MOVW_PREL_G3 293
89+
90+
91+
/*
92+
* These are used to set parameters in the core dumps.
93+
*/
94+
#define ELF_CLASS ELFCLASS64
95+
#define ELF_DATA ELFDATA2LSB
96+
#define ELF_ARCH EM_AARCH64
97+
98+
#define ELF_PLATFORM_SIZE 16
99+
#define ELF_PLATFORM ("aarch64")
100+
101+
/*
102+
* This is used to ensure we don't load something for the wrong architecture.
103+
*/
104+
#define elf_check_arch(x) ((x)->e_machine == EM_AARCH64)
105+
106+
#define elf_read_implies_exec(ex,stk) (stk != EXSTACK_DISABLE_X)
107+
108+
#define CORE_DUMP_USE_REGSET
109+
#define ELF_EXEC_PAGESIZE PAGE_SIZE
110+
111+
/*
112+
* This is the location that an ET_DYN program is loaded if exec'ed. Typical
113+
* use of this is to invoke "./ld.so someprog" to test out a new version of
114+
* the loader. We need to make sure that it is out of the way of the program
115+
* that it will "exec", and that there is sufficient room for the brk.
116+
*/
117+
extern unsigned long randomize_et_dyn(unsigned long base);
118+
#define ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_64 / 3))
119+
120+
/*
121+
* When the program starts, a1 contains a pointer to a function to be
122+
* registered with atexit, as per the SVR4 ABI. A value of 0 means we have no
123+
* such handler.
124+
*/
125+
#define ELF_PLAT_INIT(_r, load_addr) (_r)->regs[0] = 0
126+
127+
#define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT);
128+
129+
#define ARCH_DLINFO \
130+
do { \
131+
NEW_AUX_ENT(AT_SYSINFO_EHDR, \
132+
(elf_addr_t)current->mm->context.vdso); \
133+
} while (0)
134+
135+
#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
136+
struct linux_binprm;
137+
extern int arch_setup_additional_pages(struct linux_binprm *bprm,
138+
int uses_interp);
139+
140+
/* 1GB of VA */
141+
#ifdef CONFIG_COMPAT
142+
#define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \
143+
0x7ff >> (PAGE_SHIFT - 12) : \
144+
0x3ffff >> (PAGE_SHIFT - 12))
145+
#else
146+
#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12))
147+
#endif
148+
149+
struct mm_struct;
150+
extern unsigned long arch_randomize_brk(struct mm_struct *mm);
151+
#define arch_randomize_brk arch_randomize_brk
152+
153+
#ifdef CONFIG_COMPAT
154+
#define EM_ARM 40
155+
#define COMPAT_ELF_PLATFORM ("v8l")
156+
157+
#define COMPAT_ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_32 / 3))
158+
159+
/* AArch32 registers. */
160+
#define COMPAT_ELF_NGREG 18
161+
typedef unsigned int compat_elf_greg_t;
162+
typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
163+
164+
/* AArch32 EABI. */
165+
#define EF_ARM_EABI_MASK 0xff000000
166+
#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
167+
((x)->e_flags & EF_ARM_EABI_MASK))
168+
169+
#define compat_start_thread compat_start_thread
170+
#define COMPAT_SET_PERSONALITY(ex) set_thread_flag(TIF_32BIT);
171+
#define COMPAT_ARCH_DLINFO
172+
extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
173+
int uses_interp);
174+
#define compat_arch_setup_additional_pages \
175+
aarch32_setup_vectors_page
176+
177+
#endif /* CONFIG_COMPAT */
178+
179+
#endif

‎arch/arm64/include/asm/hwcap.h‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (C) 2012 ARM Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
#ifndef __ASM_HWCAP_H
17+
#define __ASM_HWCAP_H
18+
19+
/*
20+
* HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP
21+
*/
22+
#define HWCAP_FP (1 << 0)
23+
#define HWCAP_ASIMD (1 << 1)
24+
25+
#define COMPAT_HWCAP_HALF (1 << 1)
26+
#define COMPAT_HWCAP_THUMB (1 << 2)
27+
#define COMPAT_HWCAP_FAST_MULT (1 << 4)
28+
#define COMPAT_HWCAP_VFP (1 << 6)
29+
#define COMPAT_HWCAP_EDSP (1 << 7)
30+
#define COMPAT_HWCAP_NEON (1 << 12)
31+
#define COMPAT_HWCAP_VFPv3 (1 << 13)
32+
#define COMPAT_HWCAP_TLS (1 << 15)
33+
#define COMPAT_HWCAP_VFPv4 (1 << 16)
34+
#define COMPAT_HWCAP_IDIVA (1 << 17)
35+
#define COMPAT_HWCAP_IDIVT (1 << 18)
36+
#define COMPAT_HWCAP_IDIV (COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT)
37+
38+
#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
39+
/*
40+
* This yields a mask that user programs can use to figure out what
41+
* instruction set this cpu supports.
42+
*/
43+
#define ELF_HWCAP (elf_hwcap)
44+
#define COMPAT_ELF_HWCAP (COMPAT_HWCAP_HALF|COMPAT_HWCAP_THUMB|\
45+
COMPAT_HWCAP_FAST_MULT|COMPAT_HWCAP_EDSP|\
46+
COMPAT_HWCAP_TLS|COMPAT_HWCAP_VFP|\
47+
COMPAT_HWCAP_VFPv3|COMPAT_HWCAP_VFPv4|\
48+
COMPAT_HWCAP_NEON|COMPAT_HWCAP_IDIV)
49+
50+
extern unsigned int elf_hwcap;
51+
#endif
52+
53+
#endif

‎arch/arm64/include/asm/param.h‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (C) 2012 ARM Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
#ifndef __ASM_PARAM_H
17+
#define __ASM_PARAM_H
18+
19+
#define EXEC_PAGESIZE 65536
20+
21+
#include <asm-generic/param.h>
22+
23+
#endif

‎arch/arm64/include/asm/shmparam.h‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (C) 2012 ARM Ltd.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
#ifndef __ASM_SHMPARAM_H
17+
#define __ASM_SHMPARAM_H
18+
19+
/*
20+
* For IPC syscalls from compat tasks, we need to use the legacy 16k
21+
* alignment value. Since we don't have aliasing D-caches, the rest of
22+
* the time we can safely use PAGE_SIZE.
23+
*/
24+
#define COMPAT_SHMLBA 0x4000
25+
26+
#include <asm-generic/shmparam.h>
27+
28+
#endif /* __ASM_SHMPARAM_H */

0 commit comments

Comments
 (0)