blob: 5c725e1df58bd2cf5a987bc704b001c006f29ba2 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001/* SPDX-License-Identifier: GPL-2.0-or-later */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
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
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00006 */
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>
Olivier Deprez157378f2022-04-04 15:47:50 +020014#include <asm/cacheinfo.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000015
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000016/*
17 * These are used to set parameters in the core dumps.
18 */
19#define ELF_ARCH EM_RISCV
20
21#ifdef CONFIG_64BIT
22#define ELF_CLASS ELFCLASS64
23#else
24#define ELF_CLASS ELFCLASS32
25#endif
26
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000027#define ELF_DATA ELFDATA2LSB
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028
29/*
30 * This is used to ensure we don't load something for the wrong architecture.
31 */
32#define elf_check_arch(x) ((x)->e_machine == EM_RISCV)
33
34#define CORE_DUMP_USE_REGSET
35#define ELF_EXEC_PAGESIZE (PAGE_SIZE)
36
37/*
38 * This is the location that an ET_DYN program is loaded if exec'ed. Typical
39 * use of this is to invoke "./ld.so someprog" to test out a new version of
40 * the loader. We need to make sure that it is out of the way of the program
41 * that it will "exec", and that there is sufficient room for the brk.
42 */
43#define ELF_ET_DYN_BASE ((TASK_SIZE / 3) * 2)
44
45/*
46 * This yields a mask that user programs can use to figure out what
47 * instruction set this CPU supports. This could be done in user space,
48 * but it's not easy, and we've already done it here.
49 */
50#define ELF_HWCAP (elf_hwcap)
51extern unsigned long elf_hwcap;
52
53/*
54 * This yields a string that ld.so will use to load implementation
55 * specific libraries for optimization. This is more specific in
56 * intent than poking at uname or /proc/cpuinfo.
57 */
58#define ELF_PLATFORM (NULL)
59
Olivier Deprez157378f2022-04-04 15:47:50 +020060#ifdef CONFIG_MMU
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000061#define ARCH_DLINFO \
62do { \
63 NEW_AUX_ENT(AT_SYSINFO_EHDR, \
64 (elf_addr_t)current->mm->context.vdso); \
Olivier Deprez157378f2022-04-04 15:47:50 +020065 NEW_AUX_ENT(AT_L1I_CACHESIZE, \
66 get_cache_size(1, CACHE_TYPE_INST)); \
67 NEW_AUX_ENT(AT_L1I_CACHEGEOMETRY, \
68 get_cache_geometry(1, CACHE_TYPE_INST)); \
69 NEW_AUX_ENT(AT_L1D_CACHESIZE, \
70 get_cache_size(1, CACHE_TYPE_DATA)); \
71 NEW_AUX_ENT(AT_L1D_CACHEGEOMETRY, \
72 get_cache_geometry(1, CACHE_TYPE_DATA)); \
73 NEW_AUX_ENT(AT_L2_CACHESIZE, \
74 get_cache_size(2, CACHE_TYPE_UNIFIED)); \
75 NEW_AUX_ENT(AT_L2_CACHEGEOMETRY, \
76 get_cache_geometry(2, CACHE_TYPE_UNIFIED)); \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000077} while (0)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000078#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
79struct linux_binprm;
80extern int arch_setup_additional_pages(struct linux_binprm *bprm,
81 int uses_interp);
Olivier Deprez157378f2022-04-04 15:47:50 +020082#endif /* CONFIG_MMU */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000083
84#endif /* _ASM_RISCV_ELF_H */