xref: /openbmc/linux/arch/nios2/include/asm/elf.h (revision 1ccea77e)
11ccea77eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
219f4c6b5SLey Foon Tan /*
319f4c6b5SLey Foon Tan  * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
419f4c6b5SLey Foon Tan  */
519f4c6b5SLey Foon Tan 
619f4c6b5SLey Foon Tan #ifndef _ASM_NIOS2_ELF_H
719f4c6b5SLey Foon Tan #define _ASM_NIOS2_ELF_H
819f4c6b5SLey Foon Tan 
919f4c6b5SLey Foon Tan #include <uapi/asm/elf.h>
1019f4c6b5SLey Foon Tan 
1119f4c6b5SLey Foon Tan /*
1219f4c6b5SLey Foon Tan  * This is used to ensure we don't load something for the wrong architecture.
1319f4c6b5SLey Foon Tan  */
1419f4c6b5SLey Foon Tan #define elf_check_arch(x) ((x)->e_machine == EM_ALTERA_NIOS2)
1519f4c6b5SLey Foon Tan 
1619f4c6b5SLey Foon Tan #define ELF_PLAT_INIT(_r, load_addr)
1719f4c6b5SLey Foon Tan 
1819f4c6b5SLey Foon Tan #define CORE_DUMP_USE_REGSET
1919f4c6b5SLey Foon Tan #define ELF_EXEC_PAGESIZE	4096
2019f4c6b5SLey Foon Tan 
2119f4c6b5SLey Foon Tan /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
2219f4c6b5SLey Foon Tan    use of this is to invoke "./ld.so someprog" to test out a new version of
2319f4c6b5SLey Foon Tan    the loader.  We need to make sure that it is out of the way of the program
2419f4c6b5SLey Foon Tan    that it will "exec", and that there is sufficient room for the brk.  */
2519f4c6b5SLey Foon Tan 
2619f4c6b5SLey Foon Tan #define ELF_ET_DYN_BASE		0xD0000000UL
2719f4c6b5SLey Foon Tan 
2819f4c6b5SLey Foon Tan /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
2919f4c6b5SLey Foon Tan    now struct_user_regs, they are different) */
3019f4c6b5SLey Foon Tan 
3119f4c6b5SLey Foon Tan #define ARCH_HAS_SETUP_ADDITIONAL_PAGES	1
3219f4c6b5SLey Foon Tan struct linux_binprm;
3319f4c6b5SLey Foon Tan extern int arch_setup_additional_pages(struct linux_binprm *bprm,
3419f4c6b5SLey Foon Tan 	int uses_interp);
3519f4c6b5SLey Foon Tan #define ELF_CORE_COPY_REGS(pr_reg, regs)				\
3619f4c6b5SLey Foon Tan { do {									\
3719f4c6b5SLey Foon Tan 	/* Bleech. */							\
3819f4c6b5SLey Foon Tan 	pr_reg[0]  = regs->r8;						\
3919f4c6b5SLey Foon Tan 	pr_reg[1]  = regs->r9;						\
4019f4c6b5SLey Foon Tan 	pr_reg[2]  = regs->r10;						\
4119f4c6b5SLey Foon Tan 	pr_reg[3]  = regs->r11;						\
4219f4c6b5SLey Foon Tan 	pr_reg[4]  = regs->r12;						\
4319f4c6b5SLey Foon Tan 	pr_reg[5]  = regs->r13;						\
4419f4c6b5SLey Foon Tan 	pr_reg[6]  = regs->r14;						\
4519f4c6b5SLey Foon Tan 	pr_reg[7]  = regs->r15;						\
4619f4c6b5SLey Foon Tan 	pr_reg[8]  = regs->r1;						\
4719f4c6b5SLey Foon Tan 	pr_reg[9]  = regs->r2;						\
4819f4c6b5SLey Foon Tan 	pr_reg[10] = regs->r3;						\
4919f4c6b5SLey Foon Tan 	pr_reg[11] = regs->r4;						\
5019f4c6b5SLey Foon Tan 	pr_reg[12] = regs->r5;						\
5119f4c6b5SLey Foon Tan 	pr_reg[13] = regs->r6;						\
5219f4c6b5SLey Foon Tan 	pr_reg[14] = regs->r7;						\
5319f4c6b5SLey Foon Tan 	pr_reg[15] = regs->orig_r2;					\
5419f4c6b5SLey Foon Tan 	pr_reg[16] = regs->ra;						\
5519f4c6b5SLey Foon Tan 	pr_reg[17] = regs->fp;						\
5619f4c6b5SLey Foon Tan 	pr_reg[18] = regs->sp;						\
5719f4c6b5SLey Foon Tan 	pr_reg[19] = regs->gp;						\
5819f4c6b5SLey Foon Tan 	pr_reg[20] = regs->estatus;					\
5919f4c6b5SLey Foon Tan 	pr_reg[21] = regs->ea;						\
6019f4c6b5SLey Foon Tan 	pr_reg[22] = regs->orig_r7;					\
6119f4c6b5SLey Foon Tan 	{								\
6219f4c6b5SLey Foon Tan 		struct switch_stack *sw = ((struct switch_stack *)regs) - 1; \
6319f4c6b5SLey Foon Tan 		pr_reg[23] = sw->r16;					\
6419f4c6b5SLey Foon Tan 		pr_reg[24] = sw->r17;					\
6519f4c6b5SLey Foon Tan 		pr_reg[25] = sw->r18;					\
6619f4c6b5SLey Foon Tan 		pr_reg[26] = sw->r19;					\
6719f4c6b5SLey Foon Tan 		pr_reg[27] = sw->r20;					\
6819f4c6b5SLey Foon Tan 		pr_reg[28] = sw->r21;					\
6919f4c6b5SLey Foon Tan 		pr_reg[29] = sw->r22;					\
7019f4c6b5SLey Foon Tan 		pr_reg[30] = sw->r23;					\
7119f4c6b5SLey Foon Tan 		pr_reg[31] = sw->fp;					\
7219f4c6b5SLey Foon Tan 		pr_reg[32] = sw->gp;					\
7319f4c6b5SLey Foon Tan 		pr_reg[33] = sw->ra;					\
7419f4c6b5SLey Foon Tan 	}								\
7519f4c6b5SLey Foon Tan } while (0); }
7619f4c6b5SLey Foon Tan 
7719f4c6b5SLey Foon Tan /* This yields a mask that user programs can use to figure out what
7819f4c6b5SLey Foon Tan    instruction set this cpu supports.  */
7919f4c6b5SLey Foon Tan 
8019f4c6b5SLey Foon Tan #define ELF_HWCAP	(0)
8119f4c6b5SLey Foon Tan 
8219f4c6b5SLey Foon Tan /* This yields a string that ld.so will use to load implementation
8319f4c6b5SLey Foon Tan    specific libraries for optimization.  This is more specific in
8419f4c6b5SLey Foon Tan    intent than poking at uname or /proc/cpuinfo.  */
8519f4c6b5SLey Foon Tan 
8619f4c6b5SLey Foon Tan #define ELF_PLATFORM  (NULL)
8719f4c6b5SLey Foon Tan 
8819f4c6b5SLey Foon Tan #endif /* _ASM_NIOS2_ELF_H */
89