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