88#ifndef _ASM_RISCV_ELF_H
99#define _ASM_RISCV_ELF_H
1010
11+ #include <uapi/linux/elf.h>
12+ #include <linux/compat.h>
1113#include <uapi/asm/elf.h>
1214#include <asm/auxvec.h>
1315#include <asm/byteorder.h>
1820 */
1921#define ELF_ARCH EM_RISCV
2022
23+ #ifndef ELF_CLASS
2124#ifdef CONFIG_64BIT
2225#define ELF_CLASS ELFCLASS64
2326#else
2427#define ELF_CLASS ELFCLASS32
2528#endif
29+ #endif
2630
2731#define ELF_DATA ELFDATA2LSB
2832
3135 */
3236#define elf_check_arch (x ) ((x)->e_machine == EM_RISCV)
3337
38+ #define compat_elf_check_arch (x ) ((x)->e_machine == EM_RISCV)
39+
3440#define CORE_DUMP_USE_REGSET
3541#define ELF_EXEC_PAGESIZE (PAGE_SIZE)
3642
4349#define ELF_ET_DYN_BASE ((TASK_SIZE / 3) * 2)
4450
4551#ifdef CONFIG_64BIT
52+ #ifdef CONFIG_COMPAT
53+ #define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \
54+ 0x7ff >> (PAGE_SHIFT - 12) : \
55+ 0x3ffff >> (PAGE_SHIFT - 12))
56+ #else
4657#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12))
4758#endif
59+ #endif
4860/*
4961 * This yields a mask that user programs can use to figure out what
5062 * instruction set this CPU supports. This could be done in user space,
@@ -60,11 +72,19 @@ extern unsigned long elf_hwcap;
6072 */
6173#define ELF_PLATFORM (NULL)
6274
75+ #define COMPAT_ELF_PLATFORM (NULL)
76+
6377#ifdef CONFIG_MMU
6478#define ARCH_DLINFO \
6579do { \
80+ /* \
81+ * Note that we add ulong after elf_addr_t because \
82+ * casting current->mm->context.vdso triggers a cast \
83+ * warning of cast from pointer to integer for \
84+ * COMPAT ELFCLASS32. \
85+ */ \
6686 NEW_AUX_ENT (AT_SYSINFO_EHDR , \
67- (elf_addr_t)current->mm->context.vdso); \
87+ (elf_addr_t )( ulong ) current -> mm -> context .vdso ); \
6888 NEW_AUX_ENT (AT_L1I_CACHESIZE , \
6989 get_cache_size (1 , CACHE_TYPE_INST )); \
7090 NEW_AUX_ENT (AT_L1I_CACHEGEOMETRY , \
@@ -90,4 +110,23 @@ do { \
90110 *(struct user_regs_struct *)regs; \
91111} while (0);
92112
113+ #ifdef CONFIG_COMPAT
114+
115+ #define SET_PERSONALITY (ex ) \
116+ do { if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
117+ set_thread_flag(TIF_32BIT); \
118+ else \
119+ clear_thread_flag(TIF_32BIT); \
120+ if (personality(current->personality) != PER_LINUX32) \
121+ set_personality(PER_LINUX | \
122+ (current->personality & (~PER_MASK))); \
123+ } while (0)
124+
125+ #define COMPAT_ELF_ET_DYN_BASE ((TASK_SIZE_32 / 3) * 2)
126+
127+ /* rv32 registers */
128+ typedef compat_ulong_t compat_elf_greg_t ;
129+ typedef compat_elf_greg_t compat_elf_gregset_t [ELF_NGREG ];
130+
131+ #endif /* CONFIG_COMPAT */
93132#endif /* _ASM_RISCV_ELF_H */
0 commit comments