18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __ASMPARISC_ELF_H
38c2ecf20Sopenharmony_ci#define __ASMPARISC_ELF_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci * ELF register definitions..
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/types.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define EM_PARISC 15
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* HPPA specific definitions.  */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/* Legal values for e_flags field of Elf32_Ehdr.  */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define EF_PARISC_TRAPNIL	0x00010000 /* Trap nil pointer dereference.  */
188c2ecf20Sopenharmony_ci#define EF_PARISC_EXT		0x00020000 /* Program uses arch. extensions. */
198c2ecf20Sopenharmony_ci#define EF_PARISC_LSB		0x00040000 /* Program expects little endian. */
208c2ecf20Sopenharmony_ci#define EF_PARISC_WIDE		0x00080000 /* Program expects wide mode.  */
218c2ecf20Sopenharmony_ci#define EF_PARISC_NO_KABP	0x00100000 /* No kernel assisted branch
228c2ecf20Sopenharmony_ci					      prediction.  */
238c2ecf20Sopenharmony_ci#define EF_PARISC_LAZYSWAP	0x00400000 /* Allow lazy swapping.  */
248c2ecf20Sopenharmony_ci#define EF_PARISC_ARCH		0x0000ffff /* Architecture version.  */
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* Defined values for `e_flags & EF_PARISC_ARCH' are:  */
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define EFA_PARISC_1_0		    0x020b /* PA-RISC 1.0 big-endian.  */
298c2ecf20Sopenharmony_ci#define EFA_PARISC_1_1		    0x0210 /* PA-RISC 1.1 big-endian.  */
308c2ecf20Sopenharmony_ci#define EFA_PARISC_2_0		    0x0214 /* PA-RISC 2.0 big-endian.  */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* Additional section indices.  */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define SHN_PARISC_ANSI_COMMON	0xff00	   /* Section for tenatively declared
358c2ecf20Sopenharmony_ci					      symbols in ANSI C.  */
368c2ecf20Sopenharmony_ci#define SHN_PARISC_HUGE_COMMON	0xff01	   /* Common blocks in huge model.  */
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* Legal values for sh_type field of Elf32_Shdr.  */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define SHT_PARISC_EXT		0x70000000 /* Contains product specific ext. */
418c2ecf20Sopenharmony_ci#define SHT_PARISC_UNWIND	0x70000001 /* Unwind information.  */
428c2ecf20Sopenharmony_ci#define SHT_PARISC_DOC		0x70000002 /* Debug info for optimized code. */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/* Legal values for sh_flags field of Elf32_Shdr.  */
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define SHF_PARISC_SHORT	0x20000000 /* Section with short addressing. */
478c2ecf20Sopenharmony_ci#define SHF_PARISC_HUGE		0x40000000 /* Section far from gp.  */
488c2ecf20Sopenharmony_ci#define SHF_PARISC_SBP		0x80000000 /* Static branch prediction code. */
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define STT_PARISC_MILLICODE	13	/* Millicode function entry point.  */
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define STT_HP_OPAQUE		(STT_LOOS + 0x1)
558c2ecf20Sopenharmony_ci#define STT_HP_STUB		(STT_LOOS + 0x2)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* HPPA relocs.  */
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define R_PARISC_NONE		0	/* No reloc.  */
608c2ecf20Sopenharmony_ci#define R_PARISC_DIR32		1	/* Direct 32-bit reference.  */
618c2ecf20Sopenharmony_ci#define R_PARISC_DIR21L		2	/* Left 21 bits of eff. address.  */
628c2ecf20Sopenharmony_ci#define R_PARISC_DIR17R		3	/* Right 17 bits of eff. address.  */
638c2ecf20Sopenharmony_ci#define R_PARISC_DIR17F		4	/* 17 bits of eff. address.  */
648c2ecf20Sopenharmony_ci#define R_PARISC_DIR14R		6	/* Right 14 bits of eff. address.  */
658c2ecf20Sopenharmony_ci#define R_PARISC_PCREL32	9	/* 32-bit rel. address.  */
668c2ecf20Sopenharmony_ci#define R_PARISC_PCREL21L	10	/* Left 21 bits of rel. address.  */
678c2ecf20Sopenharmony_ci#define R_PARISC_PCREL17R	11	/* Right 17 bits of rel. address.  */
688c2ecf20Sopenharmony_ci#define R_PARISC_PCREL17F	12	/* 17 bits of rel. address.  */
698c2ecf20Sopenharmony_ci#define R_PARISC_PCREL14R	14	/* Right 14 bits of rel. address.  */
708c2ecf20Sopenharmony_ci#define R_PARISC_DPREL21L	18	/* Left 21 bits of rel. address.  */
718c2ecf20Sopenharmony_ci#define R_PARISC_DPREL14R	22	/* Right 14 bits of rel. address.  */
728c2ecf20Sopenharmony_ci#define R_PARISC_GPREL21L	26	/* GP-relative, left 21 bits.  */
738c2ecf20Sopenharmony_ci#define R_PARISC_GPREL14R	30	/* GP-relative, right 14 bits.  */
748c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF21L	34	/* LT-relative, left 21 bits.  */
758c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF14R	38	/* LT-relative, right 14 bits.  */
768c2ecf20Sopenharmony_ci#define R_PARISC_SECREL32	41	/* 32 bits section rel. address.  */
778c2ecf20Sopenharmony_ci#define R_PARISC_SEGBASE	48	/* No relocation, set segment base.  */
788c2ecf20Sopenharmony_ci#define R_PARISC_SEGREL32	49	/* 32 bits segment rel. address.  */
798c2ecf20Sopenharmony_ci#define R_PARISC_PLTOFF21L	50	/* PLT rel. address, left 21 bits.  */
808c2ecf20Sopenharmony_ci#define R_PARISC_PLTOFF14R	54	/* PLT rel. address, right 14 bits.  */
818c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR32	57	/* 32 bits LT-rel. function pointer. */
828c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR21L	58	/* LT-rel. fct ptr, left 21 bits. */
838c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR14R	62	/* LT-rel. fct ptr, right 14 bits. */
848c2ecf20Sopenharmony_ci#define R_PARISC_FPTR64		64	/* 64 bits function address.  */
858c2ecf20Sopenharmony_ci#define R_PARISC_PLABEL32	65	/* 32 bits function address.  */
868c2ecf20Sopenharmony_ci#define R_PARISC_PCREL64	72	/* 64 bits PC-rel. address.  */
878c2ecf20Sopenharmony_ci#define R_PARISC_PCREL22F	74	/* 22 bits PC-rel. address.  */
888c2ecf20Sopenharmony_ci#define R_PARISC_PCREL14WR	75	/* PC-rel. address, right 14 bits.  */
898c2ecf20Sopenharmony_ci#define R_PARISC_PCREL14DR	76	/* PC rel. address, right 14 bits.  */
908c2ecf20Sopenharmony_ci#define R_PARISC_PCREL16F	77	/* 16 bits PC-rel. address.  */
918c2ecf20Sopenharmony_ci#define R_PARISC_PCREL16WF	78	/* 16 bits PC-rel. address.  */
928c2ecf20Sopenharmony_ci#define R_PARISC_PCREL16DF	79	/* 16 bits PC-rel. address.  */
938c2ecf20Sopenharmony_ci#define R_PARISC_DIR64		80	/* 64 bits of eff. address.  */
948c2ecf20Sopenharmony_ci#define R_PARISC_DIR14WR	83	/* 14 bits of eff. address.  */
958c2ecf20Sopenharmony_ci#define R_PARISC_DIR14DR	84	/* 14 bits of eff. address.  */
968c2ecf20Sopenharmony_ci#define R_PARISC_DIR16F		85	/* 16 bits of eff. address.  */
978c2ecf20Sopenharmony_ci#define R_PARISC_DIR16WF	86	/* 16 bits of eff. address.  */
988c2ecf20Sopenharmony_ci#define R_PARISC_DIR16DF	87	/* 16 bits of eff. address.  */
998c2ecf20Sopenharmony_ci#define R_PARISC_GPREL64	88	/* 64 bits of GP-rel. address.  */
1008c2ecf20Sopenharmony_ci#define R_PARISC_GPREL14WR	91	/* GP-rel. address, right 14 bits.  */
1018c2ecf20Sopenharmony_ci#define R_PARISC_GPREL14DR	92	/* GP-rel. address, right 14 bits.  */
1028c2ecf20Sopenharmony_ci#define R_PARISC_GPREL16F	93	/* 16 bits GP-rel. address.  */
1038c2ecf20Sopenharmony_ci#define R_PARISC_GPREL16WF	94	/* 16 bits GP-rel. address.  */
1048c2ecf20Sopenharmony_ci#define R_PARISC_GPREL16DF	95	/* 16 bits GP-rel. address.  */
1058c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF64	96	/* 64 bits LT-rel. address.  */
1068c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF14WR	99	/* LT-rel. address, right 14 bits.  */
1078c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF14DR	100	/* LT-rel. address, right 14 bits.  */
1088c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF16F	101	/* 16 bits LT-rel. address.  */
1098c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF16WF	102	/* 16 bits LT-rel. address.  */
1108c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF16DF	103	/* 16 bits LT-rel. address.  */
1118c2ecf20Sopenharmony_ci#define R_PARISC_SECREL64	104	/* 64 bits section rel. address.  */
1128c2ecf20Sopenharmony_ci#define R_PARISC_SEGREL64	112	/* 64 bits segment rel. address.  */
1138c2ecf20Sopenharmony_ci#define R_PARISC_PLTOFF14WR	115	/* PLT-rel. address, right 14 bits.  */
1148c2ecf20Sopenharmony_ci#define R_PARISC_PLTOFF14DR	116	/* PLT-rel. address, right 14 bits.  */
1158c2ecf20Sopenharmony_ci#define R_PARISC_PLTOFF16F	117	/* 16 bits LT-rel. address.  */
1168c2ecf20Sopenharmony_ci#define R_PARISC_PLTOFF16WF	118	/* 16 bits PLT-rel. address.  */
1178c2ecf20Sopenharmony_ci#define R_PARISC_PLTOFF16DF	119	/* 16 bits PLT-rel. address.  */
1188c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR64	120	/* 64 bits LT-rel. function ptr.  */
1198c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR14WR	123	/* LT-rel. fct. ptr., right 14 bits. */
1208c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR14DR	124	/* LT-rel. fct. ptr., right 14 bits. */
1218c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR16F	125	/* 16 bits LT-rel. function ptr.  */
1228c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR16WF	126	/* 16 bits LT-rel. function ptr.  */
1238c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_FPTR16DF	127	/* 16 bits LT-rel. function ptr.  */
1248c2ecf20Sopenharmony_ci#define R_PARISC_LORESERVE	128
1258c2ecf20Sopenharmony_ci#define R_PARISC_COPY		128	/* Copy relocation.  */
1268c2ecf20Sopenharmony_ci#define R_PARISC_IPLT		129	/* Dynamic reloc, imported PLT */
1278c2ecf20Sopenharmony_ci#define R_PARISC_EPLT		130	/* Dynamic reloc, exported PLT */
1288c2ecf20Sopenharmony_ci#define R_PARISC_TPREL32	153	/* 32 bits TP-rel. address.  */
1298c2ecf20Sopenharmony_ci#define R_PARISC_TPREL21L	154	/* TP-rel. address, left 21 bits.  */
1308c2ecf20Sopenharmony_ci#define R_PARISC_TPREL14R	158	/* TP-rel. address, right 14 bits.  */
1318c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP21L	162	/* LT-TP-rel. address, left 21 bits. */
1328c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP14R	166	/* LT-TP-rel. address, right 14 bits.*/
1338c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP14F	167	/* 14 bits LT-TP-rel. address.  */
1348c2ecf20Sopenharmony_ci#define R_PARISC_TPREL64	216	/* 64 bits TP-rel. address.  */
1358c2ecf20Sopenharmony_ci#define R_PARISC_TPREL14WR	219	/* TP-rel. address, right 14 bits.  */
1368c2ecf20Sopenharmony_ci#define R_PARISC_TPREL14DR	220	/* TP-rel. address, right 14 bits.  */
1378c2ecf20Sopenharmony_ci#define R_PARISC_TPREL16F	221	/* 16 bits TP-rel. address.  */
1388c2ecf20Sopenharmony_ci#define R_PARISC_TPREL16WF	222	/* 16 bits TP-rel. address.  */
1398c2ecf20Sopenharmony_ci#define R_PARISC_TPREL16DF	223	/* 16 bits TP-rel. address.  */
1408c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP64	224	/* 64 bits LT-TP-rel. address.  */
1418c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP14WR	227	/* LT-TP-rel. address, right 14 bits.*/
1428c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP14DR	228	/* LT-TP-rel. address, right 14 bits.*/
1438c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP16F	229	/* 16 bits LT-TP-rel. address.  */
1448c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP16WF	230	/* 16 bits LT-TP-rel. address.  */
1458c2ecf20Sopenharmony_ci#define R_PARISC_LTOFF_TP16DF	231	/* 16 bits LT-TP-rel. address.  */
1468c2ecf20Sopenharmony_ci#define R_PARISC_HIRESERVE	255
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci#define PA_PLABEL_FDESC		0x02	/* bit set if PLABEL points to
1498c2ecf20Sopenharmony_ci					 * a function descriptor, not
1508c2ecf20Sopenharmony_ci					 * an address */
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci/* The following are PA function descriptors
1538c2ecf20Sopenharmony_ci *
1548c2ecf20Sopenharmony_ci * addr:	the absolute address of the function
1558c2ecf20Sopenharmony_ci * gp:		either the data pointer (r27) for non-PIC code or
1568c2ecf20Sopenharmony_ci *		the PLT pointer (r19) for PIC code */
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci/* Format for the Elf32 Function descriptor */
1598c2ecf20Sopenharmony_citypedef struct elf32_fdesc {
1608c2ecf20Sopenharmony_ci	__u32	addr;
1618c2ecf20Sopenharmony_ci	__u32	gp;
1628c2ecf20Sopenharmony_ci} Elf32_Fdesc;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci/* Format for the Elf64 Function descriptor */
1658c2ecf20Sopenharmony_citypedef struct elf64_fdesc {
1668c2ecf20Sopenharmony_ci	__u64	dummy[2]; /* FIXME: nothing uses these, why waste
1678c2ecf20Sopenharmony_ci			   * the space */
1688c2ecf20Sopenharmony_ci	__u64	addr;
1698c2ecf20Sopenharmony_ci	__u64	gp;
1708c2ecf20Sopenharmony_ci} Elf64_Fdesc;
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
1738c2ecf20Sopenharmony_ci#define Elf_Fdesc	Elf64_Fdesc
1748c2ecf20Sopenharmony_ci#else
1758c2ecf20Sopenharmony_ci#define Elf_Fdesc	Elf32_Fdesc
1768c2ecf20Sopenharmony_ci#endif /*CONFIG_64BIT*/
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr.  */
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci#define PT_HP_TLS		(PT_LOOS + 0x0)
1818c2ecf20Sopenharmony_ci#define PT_HP_CORE_NONE		(PT_LOOS + 0x1)
1828c2ecf20Sopenharmony_ci#define PT_HP_CORE_VERSION	(PT_LOOS + 0x2)
1838c2ecf20Sopenharmony_ci#define PT_HP_CORE_KERNEL	(PT_LOOS + 0x3)
1848c2ecf20Sopenharmony_ci#define PT_HP_CORE_COMM		(PT_LOOS + 0x4)
1858c2ecf20Sopenharmony_ci#define PT_HP_CORE_PROC		(PT_LOOS + 0x5)
1868c2ecf20Sopenharmony_ci#define PT_HP_CORE_LOADABLE	(PT_LOOS + 0x6)
1878c2ecf20Sopenharmony_ci#define PT_HP_CORE_STACK	(PT_LOOS + 0x7)
1888c2ecf20Sopenharmony_ci#define PT_HP_CORE_SHM		(PT_LOOS + 0x8)
1898c2ecf20Sopenharmony_ci#define PT_HP_CORE_MMF		(PT_LOOS + 0x9)
1908c2ecf20Sopenharmony_ci#define PT_HP_PARALLEL		(PT_LOOS + 0x10)
1918c2ecf20Sopenharmony_ci#define PT_HP_FASTBIND		(PT_LOOS + 0x11)
1928c2ecf20Sopenharmony_ci#define PT_HP_OPT_ANNOT		(PT_LOOS + 0x12)
1938c2ecf20Sopenharmony_ci#define PT_HP_HSL_ANNOT		(PT_LOOS + 0x13)
1948c2ecf20Sopenharmony_ci#define PT_HP_STACK		(PT_LOOS + 0x14)
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci#define PT_PARISC_ARCHEXT	0x70000000
1978c2ecf20Sopenharmony_ci#define PT_PARISC_UNWIND	0x70000001
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr.  */
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci#define PF_PARISC_SBP		0x08000000
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci#define PF_HP_PAGE_SIZE		0x00100000
2048c2ecf20Sopenharmony_ci#define PF_HP_FAR_SHARED	0x00200000
2058c2ecf20Sopenharmony_ci#define PF_HP_NEAR_SHARED	0x00400000
2068c2ecf20Sopenharmony_ci#define PF_HP_CODE		0x01000000
2078c2ecf20Sopenharmony_ci#define PF_HP_MODIFY		0x02000000
2088c2ecf20Sopenharmony_ci#define PF_HP_LAZYSWAP		0x04000000
2098c2ecf20Sopenharmony_ci#define PF_HP_SBP		0x08000000
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci/*
2128c2ecf20Sopenharmony_ci * This yields a string that ld.so will use to load implementation
2138c2ecf20Sopenharmony_ci * specific libraries for optimization.  This is more specific in
2148c2ecf20Sopenharmony_ci * intent than poking at uname or /proc/cpuinfo.
2158c2ecf20Sopenharmony_ci */
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci#define ELF_PLATFORM  ("PARISC")
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci/*
2208c2ecf20Sopenharmony_ci * The following definitions are those for 32-bit ELF binaries on a 32-bit
2218c2ecf20Sopenharmony_ci * kernel and for 64-bit binaries on a 64-bit kernel.  To run 32-bit binaries
2228c2ecf20Sopenharmony_ci * on a 64-bit kernel, fs/compat_binfmt_elf.c defines ELF_CLASS and then
2238c2ecf20Sopenharmony_ci * #includes binfmt_elf.c, which then includes this file.
2248c2ecf20Sopenharmony_ci */
2258c2ecf20Sopenharmony_ci#ifndef ELF_CLASS
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
2288c2ecf20Sopenharmony_ci#define ELF_CLASS	ELFCLASS64
2298c2ecf20Sopenharmony_ci#else
2308c2ecf20Sopenharmony_ci#define ELF_CLASS	ELFCLASS32
2318c2ecf20Sopenharmony_ci#endif
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_citypedef unsigned long elf_greg_t;
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci#define SET_PERSONALITY(ex) \
2368c2ecf20Sopenharmony_ci({	\
2378c2ecf20Sopenharmony_ci	set_personality((current->personality & ~PER_MASK) | PER_LINUX); \
2388c2ecf20Sopenharmony_ci	clear_thread_flag(TIF_32BIT); \
2398c2ecf20Sopenharmony_ci	current->thread.map_base = DEFAULT_MAP_BASE; \
2408c2ecf20Sopenharmony_ci	current->thread.task_size = DEFAULT_TASK_SIZE; \
2418c2ecf20Sopenharmony_ci })
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci#endif /* ! ELF_CLASS */
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci#define COMPAT_SET_PERSONALITY(ex) \
2468c2ecf20Sopenharmony_ci({	\
2478c2ecf20Sopenharmony_ci	if ((ex).e_ident[EI_CLASS] == ELFCLASS32) { \
2488c2ecf20Sopenharmony_ci		set_thread_flag(TIF_32BIT); \
2498c2ecf20Sopenharmony_ci		current->thread.map_base = DEFAULT_MAP_BASE32; \
2508c2ecf20Sopenharmony_ci		current->thread.task_size = DEFAULT_TASK_SIZE32; \
2518c2ecf20Sopenharmony_ci	} else clear_thread_flag(TIF_32BIT); \
2528c2ecf20Sopenharmony_ci })
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci/*
2558c2ecf20Sopenharmony_ci * Fill in general registers in a core dump.  This saves pretty
2568c2ecf20Sopenharmony_ci * much the same registers as hp-ux, although in a different order.
2578c2ecf20Sopenharmony_ci * Registers marked # below are not currently saved in pt_regs, so
2588c2ecf20Sopenharmony_ci * we use their current values here.
2598c2ecf20Sopenharmony_ci *
2608c2ecf20Sopenharmony_ci * 	gr0..gr31
2618c2ecf20Sopenharmony_ci * 	sr0..sr7
2628c2ecf20Sopenharmony_ci * 	iaoq0..iaoq1
2638c2ecf20Sopenharmony_ci * 	iasq0..iasq1
2648c2ecf20Sopenharmony_ci * 	cr11 (sar)
2658c2ecf20Sopenharmony_ci * 	cr19 (iir)
2668c2ecf20Sopenharmony_ci * 	cr20 (isr)
2678c2ecf20Sopenharmony_ci * 	cr21 (ior)
2688c2ecf20Sopenharmony_ci *  #	cr22 (ipsw)
2698c2ecf20Sopenharmony_ci *  #	cr0 (recovery counter)
2708c2ecf20Sopenharmony_ci *  #	cr24..cr31 (temporary registers)
2718c2ecf20Sopenharmony_ci *  #	cr8,9,12,13 (protection IDs)
2728c2ecf20Sopenharmony_ci *  #	cr10 (scr/ccr)
2738c2ecf20Sopenharmony_ci *  #	cr15 (ext int enable mask)
2748c2ecf20Sopenharmony_ci *
2758c2ecf20Sopenharmony_ci */
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci#define ELF_CORE_COPY_REGS(dst, pt)	\
2788c2ecf20Sopenharmony_ci	memset(dst, 0, sizeof(dst));	/* don't leak any "random" bits */ \
2798c2ecf20Sopenharmony_ci	{	int i; \
2808c2ecf20Sopenharmony_ci		for (i = 0; i < 32; i++) dst[i] = pt->gr[i]; \
2818c2ecf20Sopenharmony_ci		for (i = 0; i < 8; i++) dst[32 + i] = pt->sr[i]; \
2828c2ecf20Sopenharmony_ci	} \
2838c2ecf20Sopenharmony_ci	dst[40] = pt->iaoq[0]; dst[41] = pt->iaoq[1]; \
2848c2ecf20Sopenharmony_ci	dst[42] = pt->iasq[0]; dst[43] = pt->iasq[1]; \
2858c2ecf20Sopenharmony_ci	dst[44] = pt->sar;   dst[45] = pt->iir; \
2868c2ecf20Sopenharmony_ci	dst[46] = pt->isr;   dst[47] = pt->ior; \
2878c2ecf20Sopenharmony_ci	dst[48] = mfctl(22); dst[49] = mfctl(0); \
2888c2ecf20Sopenharmony_ci	dst[50] = mfctl(24); dst[51] = mfctl(25); \
2898c2ecf20Sopenharmony_ci	dst[52] = mfctl(26); dst[53] = mfctl(27); \
2908c2ecf20Sopenharmony_ci	dst[54] = mfctl(28); dst[55] = mfctl(29); \
2918c2ecf20Sopenharmony_ci	dst[56] = mfctl(30); dst[57] = mfctl(31); \
2928c2ecf20Sopenharmony_ci	dst[58] = mfctl( 8); dst[59] = mfctl( 9); \
2938c2ecf20Sopenharmony_ci	dst[60] = mfctl(12); dst[61] = mfctl(13); \
2948c2ecf20Sopenharmony_ci	dst[62] = mfctl(10); dst[63] = mfctl(15);
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci#define CORE_DUMP_USE_REGSET
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci#define ELF_NGREG 80	/* We only need 64 at present, but leave space
2998c2ecf20Sopenharmony_ci			   for expansion. */
3008c2ecf20Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG];
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci#define ELF_NFPREG 32
3038c2ecf20Sopenharmony_citypedef double elf_fpreg_t;
3048c2ecf20Sopenharmony_citypedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_cistruct task_struct;
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cistruct pt_regs;	/* forward declaration... */
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci#define elf_check_arch(x)		\
3128c2ecf20Sopenharmony_ci	((x)->e_machine == EM_PARISC && (x)->e_ident[EI_CLASS] == ELF_CLASS)
3138c2ecf20Sopenharmony_ci#define compat_elf_check_arch(x)	\
3148c2ecf20Sopenharmony_ci	((x)->e_machine == EM_PARISC && (x)->e_ident[EI_CLASS] == ELFCLASS32)
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci/*
3178c2ecf20Sopenharmony_ci * These are used to set parameters in the core dumps.
3188c2ecf20Sopenharmony_ci */
3198c2ecf20Sopenharmony_ci#define ELF_DATA	ELFDATA2MSB
3208c2ecf20Sopenharmony_ci#define ELF_ARCH	EM_PARISC
3218c2ecf20Sopenharmony_ci#define ELF_OSABI 	ELFOSABI_LINUX
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci/* %r23 is set by ld.so to a pointer to a function which might be
3248c2ecf20Sopenharmony_ci   registered using atexit.  This provides a means for the dynamic
3258c2ecf20Sopenharmony_ci   linker to call DT_FINI functions for shared libraries that have
3268c2ecf20Sopenharmony_ci   been loaded before the code runs.
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci   So that we can use the same startup file with static executables,
3298c2ecf20Sopenharmony_ci   we start programs with a value of 0 to indicate that there is no
3308c2ecf20Sopenharmony_ci   such function.  */
3318c2ecf20Sopenharmony_ci#define ELF_PLAT_INIT(_r, load_addr)       _r->gr[23] = 0
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci#define ELF_EXEC_PAGESIZE	4096
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
3368c2ecf20Sopenharmony_ci   use of this is to invoke "./ld.so someprog" to test out a new version of
3378c2ecf20Sopenharmony_ci   the loader.  We need to make sure that it is out of the way of the program
3388c2ecf20Sopenharmony_ci   that it will "exec", and that there is sufficient room for the brk.
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci   (2 * TASK_SIZE / 3) turns into something undefined when run through a
3418c2ecf20Sopenharmony_ci   32 bit preprocessor and in some cases results in the kernel trying to map
3428c2ecf20Sopenharmony_ci   ld.so to the kernel virtual base. Use a sane value instead. /Jes
3438c2ecf20Sopenharmony_ci  */
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci#define ELF_ET_DYN_BASE         (TASK_UNMAPPED_BASE + 0x01000000)
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci/* This yields a mask that user programs can use to figure out what
3488c2ecf20Sopenharmony_ci   instruction set this CPU supports.  This could be done in user space,
3498c2ecf20Sopenharmony_ci   but it's not easy, and we've already done it here.  */
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci#define ELF_HWCAP	0
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci/* Masks for stack and mmap randomization */
3548c2ecf20Sopenharmony_ci#define BRK_RND_MASK	(is_32bit_task() ? 0x07ffUL : 0x3ffffUL)
3558c2ecf20Sopenharmony_ci#define MMAP_RND_MASK	(is_32bit_task() ? 0x1fffUL : 0x3ffffUL)
3568c2ecf20Sopenharmony_ci#define STACK_RND_MASK	MMAP_RND_MASK
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_cistruct mm_struct;
3598c2ecf20Sopenharmony_ciextern unsigned long arch_randomize_brk(struct mm_struct *);
3608c2ecf20Sopenharmony_ci#define arch_randomize_brk arch_randomize_brk
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci#endif
363