xref: /openbmc/linux/arch/riscv/include/asm/elf.h (revision 9726bfcd)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
4  * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
5  * Copyright (C) 2012 Regents of the University of California
6  */
7 
8 #ifndef _ASM_RISCV_ELF_H
9 #define _ASM_RISCV_ELF_H
10 
11 #include <uapi/asm/elf.h>
12 #include <asm/auxvec.h>
13 #include <asm/byteorder.h>
14 
15 /*
16  * These are used to set parameters in the core dumps.
17  */
18 #define ELF_ARCH	EM_RISCV
19 
20 #ifdef CONFIG_64BIT
21 #define ELF_CLASS	ELFCLASS64
22 #else
23 #define ELF_CLASS	ELFCLASS32
24 #endif
25 
26 #define ELF_DATA	ELFDATA2LSB
27 
28 /*
29  * This is used to ensure we don't load something for the wrong architecture.
30  */
31 #define elf_check_arch(x) ((x)->e_machine == EM_RISCV)
32 
33 #define CORE_DUMP_USE_REGSET
34 #define ELF_EXEC_PAGESIZE	(PAGE_SIZE)
35 
36 /*
37  * This is the location that an ET_DYN program is loaded if exec'ed.  Typical
38  * use of this is to invoke "./ld.so someprog" to test out a new version of
39  * the loader.  We need to make sure that it is out of the way of the program
40  * that it will "exec", and that there is sufficient room for the brk.
41  */
42 #define ELF_ET_DYN_BASE		((TASK_SIZE / 3) * 2)
43 
44 /*
45  * This yields a mask that user programs can use to figure out what
46  * instruction set this CPU supports.  This could be done in user space,
47  * but it's not easy, and we've already done it here.
48  */
49 #define ELF_HWCAP	(elf_hwcap)
50 extern unsigned long elf_hwcap;
51 
52 /*
53  * This yields a string that ld.so will use to load implementation
54  * specific libraries for optimization.  This is more specific in
55  * intent than poking at uname or /proc/cpuinfo.
56  */
57 #define ELF_PLATFORM	(NULL)
58 
59 #define ARCH_DLINFO						\
60 do {								\
61 	NEW_AUX_ENT(AT_SYSINFO_EHDR,				\
62 		(elf_addr_t)current->mm->context.vdso);		\
63 } while (0)
64 
65 
66 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
67 struct linux_binprm;
68 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
69 	int uses_interp);
70 
71 #endif /* _ASM_RISCV_ELF_H */
72