18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __ASMSPARC_ELF_H
38c2ecf20Sopenharmony_ci#define __ASMSPARC_ELF_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci * ELF register definitions..
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/*
128c2ecf20Sopenharmony_ci * Sparc section types
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci#define STT_REGISTER		13
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/*
178c2ecf20Sopenharmony_ci * Sparc ELF relocation types
188c2ecf20Sopenharmony_ci */
198c2ecf20Sopenharmony_ci#define	R_SPARC_NONE		0
208c2ecf20Sopenharmony_ci#define	R_SPARC_8		1
218c2ecf20Sopenharmony_ci#define	R_SPARC_16		2
228c2ecf20Sopenharmony_ci#define	R_SPARC_32		3
238c2ecf20Sopenharmony_ci#define	R_SPARC_DISP8		4
248c2ecf20Sopenharmony_ci#define	R_SPARC_DISP16		5
258c2ecf20Sopenharmony_ci#define	R_SPARC_DISP32		6
268c2ecf20Sopenharmony_ci#define	R_SPARC_WDISP30		7
278c2ecf20Sopenharmony_ci#define	R_SPARC_WDISP22		8
288c2ecf20Sopenharmony_ci#define	R_SPARC_HI22		9
298c2ecf20Sopenharmony_ci#define	R_SPARC_22		10
308c2ecf20Sopenharmony_ci#define	R_SPARC_13		11
318c2ecf20Sopenharmony_ci#define	R_SPARC_LO10		12
328c2ecf20Sopenharmony_ci#define	R_SPARC_GOT10		13
338c2ecf20Sopenharmony_ci#define	R_SPARC_GOT13		14
348c2ecf20Sopenharmony_ci#define	R_SPARC_GOT22		15
358c2ecf20Sopenharmony_ci#define	R_SPARC_PC10		16
368c2ecf20Sopenharmony_ci#define	R_SPARC_PC22		17
378c2ecf20Sopenharmony_ci#define	R_SPARC_WPLT30		18
388c2ecf20Sopenharmony_ci#define	R_SPARC_COPY		19
398c2ecf20Sopenharmony_ci#define	R_SPARC_GLOB_DAT	20
408c2ecf20Sopenharmony_ci#define	R_SPARC_JMP_SLOT	21
418c2ecf20Sopenharmony_ci#define	R_SPARC_RELATIVE	22
428c2ecf20Sopenharmony_ci#define	R_SPARC_UA32		23
438c2ecf20Sopenharmony_ci#define R_SPARC_PLT32		24
448c2ecf20Sopenharmony_ci#define R_SPARC_HIPLT22		25
458c2ecf20Sopenharmony_ci#define R_SPARC_LOPLT10		26
468c2ecf20Sopenharmony_ci#define R_SPARC_PCPLT32		27
478c2ecf20Sopenharmony_ci#define R_SPARC_PCPLT22		28
488c2ecf20Sopenharmony_ci#define R_SPARC_PCPLT10		29
498c2ecf20Sopenharmony_ci#define R_SPARC_10		30
508c2ecf20Sopenharmony_ci#define R_SPARC_11		31
518c2ecf20Sopenharmony_ci#define R_SPARC_64		32
528c2ecf20Sopenharmony_ci#define R_SPARC_OLO10		33
538c2ecf20Sopenharmony_ci#define R_SPARC_WDISP16		40
548c2ecf20Sopenharmony_ci#define R_SPARC_WDISP19		41
558c2ecf20Sopenharmony_ci#define R_SPARC_7		43
568c2ecf20Sopenharmony_ci#define R_SPARC_5		44
578c2ecf20Sopenharmony_ci#define R_SPARC_6		45
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* Bits present in AT_HWCAP, primarily for Sparc32.  */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define HWCAP_SPARC_FLUSH       1    /* CPU supports flush instruction. */
628c2ecf20Sopenharmony_ci#define HWCAP_SPARC_STBAR       2
638c2ecf20Sopenharmony_ci#define HWCAP_SPARC_SWAP        4
648c2ecf20Sopenharmony_ci#define HWCAP_SPARC_MULDIV      8
658c2ecf20Sopenharmony_ci#define HWCAP_SPARC_V9		16
668c2ecf20Sopenharmony_ci#define HWCAP_SPARC_ULTRA3	32
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define CORE_DUMP_USE_REGSET
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/* Format is:
718c2ecf20Sopenharmony_ci * 	G0 --> G7
728c2ecf20Sopenharmony_ci *	O0 --> O7
738c2ecf20Sopenharmony_ci *	L0 --> L7
748c2ecf20Sopenharmony_ci *	I0 --> I7
758c2ecf20Sopenharmony_ci *	PSR, PC, nPC, Y, WIM, TBR
768c2ecf20Sopenharmony_ci */
778c2ecf20Sopenharmony_citypedef unsigned long elf_greg_t;
788c2ecf20Sopenharmony_ci#define ELF_NGREG 38
798c2ecf20Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG];
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_citypedef struct {
828c2ecf20Sopenharmony_ci	union {
838c2ecf20Sopenharmony_ci		unsigned long	pr_regs[32];
848c2ecf20Sopenharmony_ci		double		pr_dregs[16];
858c2ecf20Sopenharmony_ci	} pr_fr;
868c2ecf20Sopenharmony_ci	unsigned long __unused;
878c2ecf20Sopenharmony_ci	unsigned long	pr_fsr;
888c2ecf20Sopenharmony_ci	unsigned char	pr_qcnt;
898c2ecf20Sopenharmony_ci	unsigned char	pr_q_entrysize;
908c2ecf20Sopenharmony_ci	unsigned char	pr_en;
918c2ecf20Sopenharmony_ci	unsigned int	pr_q[64];
928c2ecf20Sopenharmony_ci} elf_fpregset_t;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#include <asm/mbus.h>
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci/*
978c2ecf20Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture.
988c2ecf20Sopenharmony_ci */
998c2ecf20Sopenharmony_ci#define elf_check_arch(x) ((x)->e_machine == EM_SPARC)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/*
1028c2ecf20Sopenharmony_ci * These are used to set parameters in the core dumps.
1038c2ecf20Sopenharmony_ci */
1048c2ecf20Sopenharmony_ci#define ELF_ARCH	EM_SPARC
1058c2ecf20Sopenharmony_ci#define ELF_CLASS	ELFCLASS32
1068c2ecf20Sopenharmony_ci#define ELF_DATA	ELFDATA2MSB
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#define ELF_EXEC_PAGESIZE	4096
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
1128c2ecf20Sopenharmony_ci   use of this is to invoke "./ld.so someprog" to test out a new version of
1138c2ecf20Sopenharmony_ci   the loader.  We need to make sure that it is out of the way of the program
1148c2ecf20Sopenharmony_ci   that it will "exec", and that there is sufficient room for the brk.  */
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define ELF_ET_DYN_BASE         (TASK_UNMAPPED_BASE)
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/* This yields a mask that user programs can use to figure out what
1198c2ecf20Sopenharmony_ci   instruction set this cpu supports.  This can NOT be done in userspace
1208c2ecf20Sopenharmony_ci   on Sparc.  */
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci/* Most sun4m's have them all.  */
1238c2ecf20Sopenharmony_ci#define ELF_HWCAP	(HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \
1248c2ecf20Sopenharmony_ci			 HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV)
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci/* This yields a string that ld.so will use to load implementation
1278c2ecf20Sopenharmony_ci   specific libraries for optimization.  This is more specific in
1288c2ecf20Sopenharmony_ci   intent than poking at uname or /proc/cpuinfo. */
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#define ELF_PLATFORM	(NULL)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#endif /* !(__ASMSPARC_ELF_H) */
133