18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
48c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
58c2ecf20Sopenharmony_ci * for more details.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Much of this is taken from binutils and GNU libc ...
88c2ecf20Sopenharmony_ci * Copyright (C) 2020 Loongson Technology Co., Ltd.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci#ifndef _ASM_ELF_H
118c2ecf20Sopenharmony_ci#define _ASM_ELF_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/auxvec.h>
148c2ecf20Sopenharmony_ci#include <linux/fs.h>
158c2ecf20Sopenharmony_ci#include <uapi/linux/elf.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <asm/current.h>
188c2ecf20Sopenharmony_ci#include <asm/vdso.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* The ABI of a file. */
218c2ecf20Sopenharmony_ci#define EF_LOONGARCH_ABI_LP64_SOFT_FLOAT	0x1
228c2ecf20Sopenharmony_ci#define EF_LOONGARCH_ABI_LP64_SINGLE_FLOAT	0x2
238c2ecf20Sopenharmony_ci#define EF_LOONGARCH_ABI_LP64_DOUBLE_FLOAT	0x3
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define EF_LOONGARCH_ABI_ILP32_SOFT_FLOAT	0x5
268c2ecf20Sopenharmony_ci#define EF_LOONGARCH_ABI_ILP32_SINGLE_FLOAT	0x6
278c2ecf20Sopenharmony_ci#define EF_LOONGARCH_ABI_ILP32_DOUBLE_FLOAT	0x7
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* LoongArch relocation types used by the dynamic linker */
308c2ecf20Sopenharmony_ci#define R_LARCH_NONE				0
318c2ecf20Sopenharmony_ci#define R_LARCH_32				1
328c2ecf20Sopenharmony_ci#define R_LARCH_64				2
338c2ecf20Sopenharmony_ci#define R_LARCH_RELATIVE			3
348c2ecf20Sopenharmony_ci#define R_LARCH_COPY				4
358c2ecf20Sopenharmony_ci#define R_LARCH_JUMP_SLOT			5
368c2ecf20Sopenharmony_ci#define R_LARCH_TLS_DTPMOD32			6
378c2ecf20Sopenharmony_ci#define R_LARCH_TLS_DTPMOD64			7
388c2ecf20Sopenharmony_ci#define R_LARCH_TLS_DTPREL32			8
398c2ecf20Sopenharmony_ci#define R_LARCH_TLS_DTPREL64			9
408c2ecf20Sopenharmony_ci#define R_LARCH_TLS_TPREL32			10
418c2ecf20Sopenharmony_ci#define R_LARCH_TLS_TPREL64			11
428c2ecf20Sopenharmony_ci#define R_LARCH_IRELATIVE			12
438c2ecf20Sopenharmony_ci#define R_LARCH_MARK_LA				20
448c2ecf20Sopenharmony_ci#define R_LARCH_MARK_PCREL			21
458c2ecf20Sopenharmony_ci#define R_LARCH_SOP_PUSH_PCREL			22
468c2ecf20Sopenharmony_ci#define R_LARCH_SOP_PUSH_ABSOLUTE		23
478c2ecf20Sopenharmony_ci#define R_LARCH_SOP_PUSH_DUP			24
488c2ecf20Sopenharmony_ci#define R_LARCH_SOP_PUSH_GPREL			25
498c2ecf20Sopenharmony_ci#define R_LARCH_SOP_PUSH_TLS_TPREL		26
508c2ecf20Sopenharmony_ci#define R_LARCH_SOP_PUSH_TLS_GOT		27
518c2ecf20Sopenharmony_ci#define R_LARCH_SOP_PUSH_TLS_GD			28
528c2ecf20Sopenharmony_ci#define R_LARCH_SOP_PUSH_PLT_PCREL		29
538c2ecf20Sopenharmony_ci#define R_LARCH_SOP_ASSERT			30
548c2ecf20Sopenharmony_ci#define R_LARCH_SOP_NOT				31
558c2ecf20Sopenharmony_ci#define R_LARCH_SOP_SUB				32
568c2ecf20Sopenharmony_ci#define R_LARCH_SOP_SL				33
578c2ecf20Sopenharmony_ci#define R_LARCH_SOP_SR				34
588c2ecf20Sopenharmony_ci#define R_LARCH_SOP_ADD				35
598c2ecf20Sopenharmony_ci#define R_LARCH_SOP_AND				36
608c2ecf20Sopenharmony_ci#define R_LARCH_SOP_IF_ELSE			37
618c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_S_10_5		38
628c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_U_10_12		39
638c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_S_10_12		40
648c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_S_10_16		41
658c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_S_10_16_S2		42
668c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_S_5_20		43
678c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_S_0_5_10_16_S2	44
688c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_S_0_10_10_16_S2	45
698c2ecf20Sopenharmony_ci#define R_LARCH_SOP_POP_32_U			46
708c2ecf20Sopenharmony_ci#define R_LARCH_ADD8				47
718c2ecf20Sopenharmony_ci#define R_LARCH_ADD16				48
728c2ecf20Sopenharmony_ci#define R_LARCH_ADD24				49
738c2ecf20Sopenharmony_ci#define R_LARCH_ADD32				50
748c2ecf20Sopenharmony_ci#define R_LARCH_ADD64				51
758c2ecf20Sopenharmony_ci#define R_LARCH_SUB8				52
768c2ecf20Sopenharmony_ci#define R_LARCH_SUB16				53
778c2ecf20Sopenharmony_ci#define R_LARCH_SUB24				54
788c2ecf20Sopenharmony_ci#define R_LARCH_SUB32				55
798c2ecf20Sopenharmony_ci#define R_LARCH_SUB64				56
808c2ecf20Sopenharmony_ci#define R_LARCH_GNU_VTINHERIT			57
818c2ecf20Sopenharmony_ci#define R_LARCH_GNU_VTENTRY			58
828c2ecf20Sopenharmony_ci#define R_LARCH_B16				64
838c2ecf20Sopenharmony_ci#define R_LARCH_B21				65
848c2ecf20Sopenharmony_ci#define R_LARCH_B26				66
858c2ecf20Sopenharmony_ci#define R_LARCH_ABS_HI20			67
868c2ecf20Sopenharmony_ci#define R_LARCH_ABS_LO12			68
878c2ecf20Sopenharmony_ci#define R_LARCH_ABS64_LO20			69
888c2ecf20Sopenharmony_ci#define R_LARCH_ABS64_HI12			70
898c2ecf20Sopenharmony_ci#define R_LARCH_PCALA_HI20			71
908c2ecf20Sopenharmony_ci#define R_LARCH_PCALA_LO12			72
918c2ecf20Sopenharmony_ci#define R_LARCH_PCALA64_LO20			73
928c2ecf20Sopenharmony_ci#define R_LARCH_PCALA64_HI12			74
938c2ecf20Sopenharmony_ci#define R_LARCH_GOT_PC_HI20			75
948c2ecf20Sopenharmony_ci#define R_LARCH_GOT_PC_LO12			76
958c2ecf20Sopenharmony_ci#define R_LARCH_GOT64_PC_LO20			77
968c2ecf20Sopenharmony_ci#define R_LARCH_GOT64_PC_HI12			78
978c2ecf20Sopenharmony_ci#define R_LARCH_GOT_HI20			79
988c2ecf20Sopenharmony_ci#define R_LARCH_GOT_LO12			80
998c2ecf20Sopenharmony_ci#define R_LARCH_GOT64_LO20			81
1008c2ecf20Sopenharmony_ci#define R_LARCH_GOT64_HI12			82
1018c2ecf20Sopenharmony_ci#define R_LARCH_TLS_LE_HI20			83
1028c2ecf20Sopenharmony_ci#define R_LARCH_TLS_LE_LO12			84
1038c2ecf20Sopenharmony_ci#define R_LARCH_TLS_LE64_LO20			85
1048c2ecf20Sopenharmony_ci#define R_LARCH_TLS_LE64_HI12			86
1058c2ecf20Sopenharmony_ci#define R_LARCH_TLS_IE_PC_HI20			87
1068c2ecf20Sopenharmony_ci#define R_LARCH_TLS_IE_PC_LO12			88
1078c2ecf20Sopenharmony_ci#define R_LARCH_TLS_IE64_PC_LO20		89
1088c2ecf20Sopenharmony_ci#define R_LARCH_TLS_IE64_PC_HI12		90
1098c2ecf20Sopenharmony_ci#define R_LARCH_TLS_IE_HI20			91
1108c2ecf20Sopenharmony_ci#define R_LARCH_TLS_IE_LO12			92
1118c2ecf20Sopenharmony_ci#define R_LARCH_TLS_IE64_LO20			93
1128c2ecf20Sopenharmony_ci#define R_LARCH_TLS_IE64_HI12			94
1138c2ecf20Sopenharmony_ci#define R_LARCH_TLS_LD_PC_HI20			95
1148c2ecf20Sopenharmony_ci#define R_LARCH_TLS_LD_HI20			96
1158c2ecf20Sopenharmony_ci#define R_LARCH_TLS_GD_PC_HI20			97
1168c2ecf20Sopenharmony_ci#define R_LARCH_TLS_GD_HI20			98
1178c2ecf20Sopenharmony_ci#define R_LARCH_32_PCREL			99
1188c2ecf20Sopenharmony_ci#define R_LARCH_RELAX				100
1198c2ecf20Sopenharmony_ci#define R_LARCH_DELETE				101
1208c2ecf20Sopenharmony_ci#define R_LARCH_ALIGN				102
1218c2ecf20Sopenharmony_ci#define R_LARCH_PCREL20_S2			103
1228c2ecf20Sopenharmony_ci#define R_LARCH_CFA				104
1238c2ecf20Sopenharmony_ci#define R_LARCH_ADD6				105
1248c2ecf20Sopenharmony_ci#define R_LARCH_SUB6				106
1258c2ecf20Sopenharmony_ci#define R_LARCH_ADD_ULEB128			107
1268c2ecf20Sopenharmony_ci#define R_LARCH_SUB_ULEB128			108
1278c2ecf20Sopenharmony_ci#define R_LARCH_64_PCREL			109
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#ifndef ELF_ARCH
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/* ELF register definitions */
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci/*
1348c2ecf20Sopenharmony_ci * General purpose have the following registers:
1358c2ecf20Sopenharmony_ci * 	Register	Number
1368c2ecf20Sopenharmony_ci * 	GPRs		  32
1378c2ecf20Sopenharmony_ci *	ORIG_A0		  1
1388c2ecf20Sopenharmony_ci * 	ERA		  1
1398c2ecf20Sopenharmony_ci *	BADVADDR	  1
1408c2ecf20Sopenharmony_ci *	CRMD		  1
1418c2ecf20Sopenharmony_ci *	PRMD		  1
1428c2ecf20Sopenharmony_ci *	EUEN		  1
1438c2ecf20Sopenharmony_ci *	ECFG		  1
1448c2ecf20Sopenharmony_ci *	ESTAT		  1
1458c2ecf20Sopenharmony_ci *	Reserved	  5
1468c2ecf20Sopenharmony_ci */
1478c2ecf20Sopenharmony_ci#define ELF_NGREG	45
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci/*
1508c2ecf20Sopenharmony_ci * Floating point have the following registers:
1518c2ecf20Sopenharmony_ci * 	Register	Number
1528c2ecf20Sopenharmony_ci * 	  FPR		  32
1538c2ecf20Sopenharmony_ci * 	  FCC		  1
1548c2ecf20Sopenharmony_ci * 	  FCSR		  1
1558c2ecf20Sopenharmony_ci */
1568c2ecf20Sopenharmony_ci#define ELF_NFPREG	34
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_citypedef unsigned long elf_greg_t;
1598c2ecf20Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG];
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_citypedef double elf_fpreg_t;
1628c2ecf20Sopenharmony_citypedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_civoid loongarch_dump_regs64(u64 *uregs, const struct pt_regs *regs);
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci#ifdef CONFIG_32BIT
1678c2ecf20Sopenharmony_ci/*
1688c2ecf20Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture.
1698c2ecf20Sopenharmony_ci */
1708c2ecf20Sopenharmony_ci#define elf_check_arch elf32_check_arch
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci/*
1738c2ecf20Sopenharmony_ci * These are used to set parameters in the core dumps.
1748c2ecf20Sopenharmony_ci */
1758c2ecf20Sopenharmony_ci#define ELF_CLASS	ELFCLASS32
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci#define ELF_CORE_COPY_REGS(dest, regs) \
1788c2ecf20Sopenharmony_ci	loongarch_dump_regs32((u32 *)&(dest), (regs));
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci#endif /* CONFIG_32BIT */
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
1838c2ecf20Sopenharmony_ci/*
1848c2ecf20Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture.
1858c2ecf20Sopenharmony_ci */
1868c2ecf20Sopenharmony_ci#define elf_check_arch elf64_check_arch
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/*
1898c2ecf20Sopenharmony_ci * These are used to set parameters in the core dumps.
1908c2ecf20Sopenharmony_ci */
1918c2ecf20Sopenharmony_ci#define ELF_CLASS	ELFCLASS64
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci#define ELF_CORE_COPY_REGS(dest, regs) \
1948c2ecf20Sopenharmony_ci	loongarch_dump_regs64((u64 *)&(dest), (regs));
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci/*
1998c2ecf20Sopenharmony_ci * These are used to set parameters in the core dumps.
2008c2ecf20Sopenharmony_ci */
2018c2ecf20Sopenharmony_ci#define ELF_DATA	ELFDATA2LSB
2028c2ecf20Sopenharmony_ci#define ELF_ARCH	EM_LOONGARCH
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci#endif /* !defined(ELF_ARCH) */
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci#define loongarch_elf_check_machine(x) ((x)->e_machine == EM_LOONGARCH)
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci#define vmcore_elf32_check_arch loongarch_elf_check_machine
2098c2ecf20Sopenharmony_ci#define vmcore_elf64_check_arch loongarch_elf_check_machine
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci/*
2128c2ecf20Sopenharmony_ci * Return non-zero if HDR identifies an 32bit ELF binary.
2138c2ecf20Sopenharmony_ci */
2148c2ecf20Sopenharmony_ci#define elf32_check_arch(hdr)						\
2158c2ecf20Sopenharmony_ci({									\
2168c2ecf20Sopenharmony_ci	int __res = 1;							\
2178c2ecf20Sopenharmony_ci	struct elfhdr *__h = (hdr);					\
2188c2ecf20Sopenharmony_ci									\
2198c2ecf20Sopenharmony_ci	if (!loongarch_elf_check_machine(__h))				\
2208c2ecf20Sopenharmony_ci		__res = 0;						\
2218c2ecf20Sopenharmony_ci	if (__h->e_ident[EI_CLASS] != ELFCLASS32)			\
2228c2ecf20Sopenharmony_ci		__res = 0;						\
2238c2ecf20Sopenharmony_ci									\
2248c2ecf20Sopenharmony_ci	__res;								\
2258c2ecf20Sopenharmony_ci})
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci/*
2288c2ecf20Sopenharmony_ci * Return non-zero if HDR identifies an 64bit ELF binary.
2298c2ecf20Sopenharmony_ci */
2308c2ecf20Sopenharmony_ci#define elf64_check_arch(hdr)						\
2318c2ecf20Sopenharmony_ci({									\
2328c2ecf20Sopenharmony_ci	int __res = 1;							\
2338c2ecf20Sopenharmony_ci	struct elfhdr *__h = (hdr);					\
2348c2ecf20Sopenharmony_ci									\
2358c2ecf20Sopenharmony_ci	if (!loongarch_elf_check_machine(__h))				\
2368c2ecf20Sopenharmony_ci		__res = 0;						\
2378c2ecf20Sopenharmony_ci	if (__h->e_ident[EI_CLASS] != ELFCLASS64)			\
2388c2ecf20Sopenharmony_ci		__res = 0;						\
2398c2ecf20Sopenharmony_ci									\
2408c2ecf20Sopenharmony_ci	__res;								\
2418c2ecf20Sopenharmony_ci})
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci#ifdef CONFIG_32BIT
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci#define SET_PERSONALITY2(ex, state)					\
2468c2ecf20Sopenharmony_cido {									\
2478c2ecf20Sopenharmony_ci	current->thread.vdso = &vdso_info;				\
2488c2ecf20Sopenharmony_ci									\
2498c2ecf20Sopenharmony_ci	if (personality(current->personality) != PER_LINUX)		\
2508c2ecf20Sopenharmony_ci		set_personality(PER_LINUX);				\
2518c2ecf20Sopenharmony_ci} while (0)
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci#endif /* CONFIG_32BIT */
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci#define SET_PERSONALITY2(ex, state)					\
2588c2ecf20Sopenharmony_cido {									\
2598c2ecf20Sopenharmony_ci	unsigned int p;							\
2608c2ecf20Sopenharmony_ci									\
2618c2ecf20Sopenharmony_ci	clear_thread_flag(TIF_32BIT_REGS);				\
2628c2ecf20Sopenharmony_ci	clear_thread_flag(TIF_32BIT_ADDR);				\
2638c2ecf20Sopenharmony_ci									\
2648c2ecf20Sopenharmony_ci	current->thread.vdso = &vdso_info;				\
2658c2ecf20Sopenharmony_ci									\
2668c2ecf20Sopenharmony_ci	p = personality(current->personality);				\
2678c2ecf20Sopenharmony_ci	if (p != PER_LINUX32 && p != PER_LINUX)				\
2688c2ecf20Sopenharmony_ci		set_personality(PER_LINUX);				\
2698c2ecf20Sopenharmony_ci} while (0)
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci#define CORE_DUMP_USE_REGSET
2748c2ecf20Sopenharmony_ci#define ELF_EXEC_PAGESIZE	PAGE_SIZE
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci/* This yields a mask that user programs can use to figure out what
2778c2ecf20Sopenharmony_ci   instruction set this cpu supports.  This could be done in userspace,
2788c2ecf20Sopenharmony_ci   but it's not easy, and we've already done it here.  */
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci#define ELF_HWCAP	(elf_hwcap)
2818c2ecf20Sopenharmony_ciextern unsigned int elf_hwcap;
2828c2ecf20Sopenharmony_ci#include <asm/hwcap.h>
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci/*
2858c2ecf20Sopenharmony_ci * This yields a string that ld.so will use to load implementation
2868c2ecf20Sopenharmony_ci * specific libraries for optimization.	 This is more specific in
2878c2ecf20Sopenharmony_ci * intent than poking at uname or /proc/cpuinfo.
2888c2ecf20Sopenharmony_ci */
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci#define ELF_PLATFORM  __elf_platform
2918c2ecf20Sopenharmony_ciextern const char *__elf_platform;
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci#define ELF_PLAT_INIT(_r, load_addr)	do { \
2948c2ecf20Sopenharmony_ci	_r->regs[1] = _r->regs[2] = _r->regs[3] = _r->regs[4] = 0;	\
2958c2ecf20Sopenharmony_ci	_r->regs[5] = _r->regs[6] = _r->regs[7] = _r->regs[8] = 0;	\
2968c2ecf20Sopenharmony_ci	_r->regs[9] = _r->regs[10] /* syscall n */ = _r->regs[12] = 0;	\
2978c2ecf20Sopenharmony_ci	_r->regs[13] = _r->regs[14] = _r->regs[15] = _r->regs[16] = 0;	\
2988c2ecf20Sopenharmony_ci	_r->regs[17] = _r->regs[18] = _r->regs[19] = _r->regs[20] = 0;	\
2998c2ecf20Sopenharmony_ci	_r->regs[21] = _r->regs[22] = _r->regs[23] = _r->regs[24] = 0;	\
3008c2ecf20Sopenharmony_ci	_r->regs[25] = _r->regs[26] = _r->regs[27] = _r->regs[28] = 0;	\
3018c2ecf20Sopenharmony_ci	_r->regs[29] = _r->regs[30] = _r->regs[31] = 0;			\
3028c2ecf20Sopenharmony_ci} while (0)
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
3058c2ecf20Sopenharmony_ci   use of this is to invoke "./ld.so someprog" to test out a new version of
3068c2ecf20Sopenharmony_ci   the loader.	We need to make sure that it is out of the way of the program
3078c2ecf20Sopenharmony_ci   that it will "exec", and that there is sufficient room for the brk.	*/
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci#define ELF_ET_DYN_BASE		(TASK_SIZE / 3 * 2)
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
3128c2ecf20Sopenharmony_ci#define ARCH_DLINFO							\
3138c2ecf20Sopenharmony_cido {									\
3148c2ecf20Sopenharmony_ci	NEW_AUX_ENT(AT_SYSINFO_EHDR,					\
3158c2ecf20Sopenharmony_ci		    (unsigned long)current->mm->context.vdso);		\
3168c2ecf20Sopenharmony_ci} while (0)
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
3198c2ecf20Sopenharmony_cistruct linux_binprm;
3208c2ecf20Sopenharmony_ciextern int arch_setup_additional_pages(struct linux_binprm *bprm,
3218c2ecf20Sopenharmony_ci				       int uses_interp);
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_cistruct arch_elf_state {
3248c2ecf20Sopenharmony_ci	int fp_abi;
3258c2ecf20Sopenharmony_ci	int interp_fp_abi;
3268c2ecf20Sopenharmony_ci};
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci#define LOONGARCH_ABI_FP_ANY	(0)
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci#define INIT_ARCH_ELF_STATE {			\
3318c2ecf20Sopenharmony_ci	.fp_abi = LOONGARCH_ABI_FP_ANY,		\
3328c2ecf20Sopenharmony_ci	.interp_fp_abi = LOONGARCH_ABI_FP_ANY,	\
3338c2ecf20Sopenharmony_ci}
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci#define elf_read_implies_exec(ex, exec_stk) (exec_stk == EXSTACK_DEFAULT)
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ciextern int arch_elf_pt_proc(void *ehdr, void *phdr, struct file *elf,
3388c2ecf20Sopenharmony_ci			    bool is_interp, struct arch_elf_state *state);
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ciextern int arch_check_elf(void *ehdr, bool has_interpreter, void *interp_ehdr,
3418c2ecf20Sopenharmony_ci			  struct arch_elf_state *state);
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci#endif /* _ASM_ELF_H */
344