xref: /linux/arch/riscv/include/uapi/asm/elf.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1e2c0cdfbSPalmer Dabbelt /*
2e2c0cdfbSPalmer Dabbelt  * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
3e2c0cdfbSPalmer Dabbelt  * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
4e2c0cdfbSPalmer Dabbelt  * Copyright (C) 2012 Regents of the University of California
5e2c0cdfbSPalmer Dabbelt  *
6e2c0cdfbSPalmer Dabbelt  * This program is free software; you can redistribute it and/or modify
7e2c0cdfbSPalmer Dabbelt  * it under the terms of the GNU General Public License as published by
8e2c0cdfbSPalmer Dabbelt  * the Free Software Foundation; either version 2 of the License, or
9e2c0cdfbSPalmer Dabbelt  * (at your option) any later version.
10e2c0cdfbSPalmer Dabbelt  */
11e2c0cdfbSPalmer Dabbelt 
126b57ba8eSZong Li #ifndef _UAPI_ASM_RISCV_ELF_H
136b57ba8eSZong Li #define _UAPI_ASM_RISCV_ELF_H
14e2c0cdfbSPalmer Dabbelt 
15e2c0cdfbSPalmer Dabbelt #include <asm/ptrace.h>
16e2c0cdfbSPalmer Dabbelt 
17e2c0cdfbSPalmer Dabbelt /* ELF register definitions */
18e2c0cdfbSPalmer Dabbelt typedef unsigned long elf_greg_t;
19e2c0cdfbSPalmer Dabbelt typedef struct user_regs_struct elf_gregset_t;
20e2c0cdfbSPalmer Dabbelt #define ELF_NGREG (sizeof(elf_gregset_t) / sizeof(elf_greg_t))
21e2c0cdfbSPalmer Dabbelt 
22b8c8a959SJim Wilson /* We don't support f without d, or q.  */
23b8c8a959SJim Wilson typedef __u64 elf_fpreg_t;
24e2c0cdfbSPalmer Dabbelt typedef union __riscv_fp_state elf_fpregset_t;
25b8c8a959SJim Wilson #define ELF_NFPREG (sizeof(struct __riscv_d_ext_state) / sizeof(elf_fpreg_t))
26e2c0cdfbSPalmer Dabbelt 
27c480d891SZong Li #if __riscv_xlen == 64
28c480d891SZong Li #define ELF_RISCV_R_SYM(r_info)		ELF64_R_SYM(r_info)
29c480d891SZong Li #define ELF_RISCV_R_TYPE(r_info)	ELF64_R_TYPE(r_info)
30c480d891SZong Li #else
31c480d891SZong Li #define ELF_RISCV_R_SYM(r_info)		ELF32_R_SYM(r_info)
32c480d891SZong Li #define ELF_RISCV_R_TYPE(r_info)	ELF32_R_TYPE(r_info)
33c480d891SZong Li #endif
34e2c0cdfbSPalmer Dabbelt 
35e2c0cdfbSPalmer Dabbelt /*
36e2c0cdfbSPalmer Dabbelt  * RISC-V relocation types
37e2c0cdfbSPalmer Dabbelt  */
38e2c0cdfbSPalmer Dabbelt 
39e2c0cdfbSPalmer Dabbelt /* Relocation types used by the dynamic linker */
40e2c0cdfbSPalmer Dabbelt #define R_RISCV_NONE		0
41e2c0cdfbSPalmer Dabbelt #define R_RISCV_32		1
42e2c0cdfbSPalmer Dabbelt #define R_RISCV_64		2
43e2c0cdfbSPalmer Dabbelt #define R_RISCV_RELATIVE	3
44e2c0cdfbSPalmer Dabbelt #define R_RISCV_COPY		4
45e2c0cdfbSPalmer Dabbelt #define R_RISCV_JUMP_SLOT	5
46e2c0cdfbSPalmer Dabbelt #define R_RISCV_TLS_DTPMOD32	6
47e2c0cdfbSPalmer Dabbelt #define R_RISCV_TLS_DTPMOD64	7
48e2c0cdfbSPalmer Dabbelt #define R_RISCV_TLS_DTPREL32	8
49e2c0cdfbSPalmer Dabbelt #define R_RISCV_TLS_DTPREL64	9
50e2c0cdfbSPalmer Dabbelt #define R_RISCV_TLS_TPREL32	10
51e2c0cdfbSPalmer Dabbelt #define R_RISCV_TLS_TPREL64	11
52*8fd6c514SCharlie Jenkins #define R_RISCV_IRELATIVE	58
53e2c0cdfbSPalmer Dabbelt 
54e2c0cdfbSPalmer Dabbelt /* Relocation types not used by the dynamic linker */
55e2c0cdfbSPalmer Dabbelt #define R_RISCV_BRANCH		16
56e2c0cdfbSPalmer Dabbelt #define R_RISCV_JAL		17
57e2c0cdfbSPalmer Dabbelt #define R_RISCV_CALL		18
58e2c0cdfbSPalmer Dabbelt #define R_RISCV_CALL_PLT	19
59e2c0cdfbSPalmer Dabbelt #define R_RISCV_GOT_HI20	20
60e2c0cdfbSPalmer Dabbelt #define R_RISCV_TLS_GOT_HI20	21
61e2c0cdfbSPalmer Dabbelt #define R_RISCV_TLS_GD_HI20	22
62e2c0cdfbSPalmer Dabbelt #define R_RISCV_PCREL_HI20	23
63e2c0cdfbSPalmer Dabbelt #define R_RISCV_PCREL_LO12_I	24
64e2c0cdfbSPalmer Dabbelt #define R_RISCV_PCREL_LO12_S	25
65e2c0cdfbSPalmer Dabbelt #define R_RISCV_HI20		26
66e2c0cdfbSPalmer Dabbelt #define R_RISCV_LO12_I		27
67e2c0cdfbSPalmer Dabbelt #define R_RISCV_LO12_S		28
68e2c0cdfbSPalmer Dabbelt #define R_RISCV_TPREL_HI20	29
69e2c0cdfbSPalmer Dabbelt #define R_RISCV_TPREL_LO12_I	30
70e2c0cdfbSPalmer Dabbelt #define R_RISCV_TPREL_LO12_S	31
71e2c0cdfbSPalmer Dabbelt #define R_RISCV_TPREL_ADD	32
72e2c0cdfbSPalmer Dabbelt #define R_RISCV_ADD8		33
73e2c0cdfbSPalmer Dabbelt #define R_RISCV_ADD16		34
74e2c0cdfbSPalmer Dabbelt #define R_RISCV_ADD32		35
75e2c0cdfbSPalmer Dabbelt #define R_RISCV_ADD64		36
76e2c0cdfbSPalmer Dabbelt #define R_RISCV_SUB8		37
77e2c0cdfbSPalmer Dabbelt #define R_RISCV_SUB16		38
78e2c0cdfbSPalmer Dabbelt #define R_RISCV_SUB32		39
79e2c0cdfbSPalmer Dabbelt #define R_RISCV_SUB64		40
80e2c0cdfbSPalmer Dabbelt #define R_RISCV_GNU_VTINHERIT	41
81e2c0cdfbSPalmer Dabbelt #define R_RISCV_GNU_VTENTRY	42
82e2c0cdfbSPalmer Dabbelt #define R_RISCV_ALIGN		43
83e2c0cdfbSPalmer Dabbelt #define R_RISCV_RVC_BRANCH	44
84e2c0cdfbSPalmer Dabbelt #define R_RISCV_RVC_JUMP	45
85e2c0cdfbSPalmer Dabbelt #define R_RISCV_GPREL_I		47
86e2c0cdfbSPalmer Dabbelt #define R_RISCV_GPREL_S		48
87e2c0cdfbSPalmer Dabbelt #define R_RISCV_TPREL_I		49
88e2c0cdfbSPalmer Dabbelt #define R_RISCV_TPREL_S		50
89e2c0cdfbSPalmer Dabbelt #define R_RISCV_RELAX		51
90e21d5421SZong Li #define R_RISCV_SUB6		52
91e21d5421SZong Li #define R_RISCV_SET6		53
92e21d5421SZong Li #define R_RISCV_SET8		54
93e21d5421SZong Li #define R_RISCV_SET16		55
94e21d5421SZong Li #define R_RISCV_SET32		56
95e21d5421SZong Li #define R_RISCV_32_PCREL	57
96*8fd6c514SCharlie Jenkins #define R_RISCV_PLT32		59
97*8fd6c514SCharlie Jenkins #define R_RISCV_SET_ULEB128	60
98*8fd6c514SCharlie Jenkins #define R_RISCV_SUB_ULEB128	61
99e21d5421SZong Li 
100e2c0cdfbSPalmer Dabbelt 
1016b57ba8eSZong Li #endif /* _UAPI_ASM_RISCV_ELF_H */
102