162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __ASMm68k_ELF_H
362306a36Sopenharmony_ci#define __ASMm68k_ELF_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/*
662306a36Sopenharmony_ci * ELF register definitions..
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <asm/ptrace.h>
1062306a36Sopenharmony_ci#include <asm/user.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci/*
1362306a36Sopenharmony_ci * 68k ELF relocation types
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci#define R_68K_NONE	0
1662306a36Sopenharmony_ci#define R_68K_32	1
1762306a36Sopenharmony_ci#define R_68K_16	2
1862306a36Sopenharmony_ci#define R_68K_8		3
1962306a36Sopenharmony_ci#define R_68K_PC32	4
2062306a36Sopenharmony_ci#define R_68K_PC16	5
2162306a36Sopenharmony_ci#define R_68K_PC8	6
2262306a36Sopenharmony_ci#define R_68K_GOT32	7
2362306a36Sopenharmony_ci#define R_68K_GOT16	8
2462306a36Sopenharmony_ci#define R_68K_GOT8	9
2562306a36Sopenharmony_ci#define R_68K_GOT32O	10
2662306a36Sopenharmony_ci#define R_68K_GOT16O	11
2762306a36Sopenharmony_ci#define R_68K_GOT8O	12
2862306a36Sopenharmony_ci#define R_68K_PLT32	13
2962306a36Sopenharmony_ci#define R_68K_PLT16	14
3062306a36Sopenharmony_ci#define R_68K_PLT8	15
3162306a36Sopenharmony_ci#define R_68K_PLT32O	16
3262306a36Sopenharmony_ci#define R_68K_PLT16O	17
3362306a36Sopenharmony_ci#define R_68K_PLT8O	18
3462306a36Sopenharmony_ci#define R_68K_COPY	19
3562306a36Sopenharmony_ci#define R_68K_GLOB_DAT	20
3662306a36Sopenharmony_ci#define R_68K_JMP_SLOT	21
3762306a36Sopenharmony_ci#define R_68K_RELATIVE	22
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_citypedef unsigned long elf_greg_t;
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
4262306a36Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG];
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_citypedef struct user_m68kfp_struct elf_fpregset_t;
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci/*
4762306a36Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture.
4862306a36Sopenharmony_ci */
4962306a36Sopenharmony_ci#define elf_check_arch(x) ((x)->e_machine == EM_68K)
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci/*
5262306a36Sopenharmony_ci * These are used to set parameters in the core dumps.
5362306a36Sopenharmony_ci */
5462306a36Sopenharmony_ci#define ELF_CLASS	ELFCLASS32
5562306a36Sopenharmony_ci#define ELF_DATA	ELFDATA2MSB
5662306a36Sopenharmony_ci#define ELF_ARCH	EM_68K
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* For SVR4/m68k the function pointer to be registered with `atexit' is
5962306a36Sopenharmony_ci   passed in %a1.  Although my copy of the ABI has no such statement, it
6062306a36Sopenharmony_ci   is actually used on ASV.  */
6162306a36Sopenharmony_ci#define ELF_PLAT_INIT(_r, load_addr)	_r->a1 = 0
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define ELF_FDPIC_PLAT_INIT(_r, _exec_map_addr, _interp_map_addr, dynamic_addr) \
6462306a36Sopenharmony_ci        do { \
6562306a36Sopenharmony_ci                (_r)->d3 = _exec_map_addr; \
6662306a36Sopenharmony_ci                (_r)->d4 = _interp_map_addr; \
6762306a36Sopenharmony_ci                (_r)->d5 = dynamic_addr; \
6862306a36Sopenharmony_ci        } while(0)
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci#if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE)
7162306a36Sopenharmony_ci#define ELF_EXEC_PAGESIZE	8192
7262306a36Sopenharmony_ci#else
7362306a36Sopenharmony_ci#define ELF_EXEC_PAGESIZE	4096
7462306a36Sopenharmony_ci#endif
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
7762306a36Sopenharmony_ci   use of this is to invoke "./ld.so someprog" to test out a new version of
7862306a36Sopenharmony_ci   the loader.  We need to make sure that it is out of the way of the program
7962306a36Sopenharmony_ci   that it will "exec", and that there is sufficient room for the brk.  */
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#ifndef CONFIG_SUN3
8262306a36Sopenharmony_ci#define ELF_ET_DYN_BASE         0xD0000000UL
8362306a36Sopenharmony_ci#else
8462306a36Sopenharmony_ci#define ELF_ET_DYN_BASE         0x0D800000UL
8562306a36Sopenharmony_ci#endif
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define ELF_CORE_COPY_REGS(pr_reg, regs)				\
8862306a36Sopenharmony_ci	/* Bleech. */							\
8962306a36Sopenharmony_ci	pr_reg[0] = regs->d1;						\
9062306a36Sopenharmony_ci	pr_reg[1] = regs->d2;						\
9162306a36Sopenharmony_ci	pr_reg[2] = regs->d3;						\
9262306a36Sopenharmony_ci	pr_reg[3] = regs->d4;						\
9362306a36Sopenharmony_ci	pr_reg[4] = regs->d5;						\
9462306a36Sopenharmony_ci	pr_reg[7] = regs->a0;						\
9562306a36Sopenharmony_ci	pr_reg[8] = regs->a1;						\
9662306a36Sopenharmony_ci	pr_reg[9] = regs->a2;						\
9762306a36Sopenharmony_ci	pr_reg[14] = regs->d0;						\
9862306a36Sopenharmony_ci	pr_reg[15] = rdusp();						\
9962306a36Sopenharmony_ci	pr_reg[16] = regs->orig_d0;					\
10062306a36Sopenharmony_ci	pr_reg[17] = regs->sr;						\
10162306a36Sopenharmony_ci	pr_reg[18] = regs->pc;						\
10262306a36Sopenharmony_ci	pr_reg[19] = (regs->format << 12) | regs->vector;		\
10362306a36Sopenharmony_ci	{								\
10462306a36Sopenharmony_ci	  struct switch_stack *sw = ((struct switch_stack *)regs) - 1;	\
10562306a36Sopenharmony_ci	  pr_reg[5] = sw->d6;						\
10662306a36Sopenharmony_ci	  pr_reg[6] = sw->d7;						\
10762306a36Sopenharmony_ci	  pr_reg[10] = sw->a3;						\
10862306a36Sopenharmony_ci	  pr_reg[11] = sw->a4;						\
10962306a36Sopenharmony_ci	  pr_reg[12] = sw->a5;						\
11062306a36Sopenharmony_ci	  pr_reg[13] = sw->a6;						\
11162306a36Sopenharmony_ci	}
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci/* This yields a mask that user programs can use to figure out what
11462306a36Sopenharmony_ci   instruction set this cpu supports.  */
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci#define ELF_HWCAP	(0)
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci/* This yields a string that ld.so will use to load implementation
11962306a36Sopenharmony_ci   specific libraries for optimization.  This is more specific in
12062306a36Sopenharmony_ci   intent than poking at uname or /proc/cpuinfo.  */
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci#define ELF_PLATFORM  (NULL)
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#define ELF_FDPIC_CORE_EFLAGS  0
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#endif
127