18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
38c2ecf20Sopenharmony_ci * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
48c2ecf20Sopenharmony_ci * Copyright (C) 2012 Regents of the University of California
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
78c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
88c2ecf20Sopenharmony_ci * the Free Software Foundation; either version 2 of the License, or
98c2ecf20Sopenharmony_ci * (at your option) any later version.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef _UAPI_ASM_RISCV_ELF_H
138c2ecf20Sopenharmony_ci#define _UAPI_ASM_RISCV_ELF_H
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* ELF register definitions */
188c2ecf20Sopenharmony_citypedef unsigned long elf_greg_t;
198c2ecf20Sopenharmony_citypedef struct user_regs_struct elf_gregset_t;
208c2ecf20Sopenharmony_ci#define ELF_NGREG (sizeof(elf_gregset_t) / sizeof(elf_greg_t))
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* We don't support f without d, or q.  */
238c2ecf20Sopenharmony_citypedef __u64 elf_fpreg_t;
248c2ecf20Sopenharmony_citypedef union __riscv_fp_state elf_fpregset_t;
258c2ecf20Sopenharmony_ci#define ELF_NFPREG (sizeof(struct __riscv_d_ext_state) / sizeof(elf_fpreg_t))
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#if __riscv_xlen == 64
288c2ecf20Sopenharmony_ci#define ELF_RISCV_R_SYM(r_info)		ELF64_R_SYM(r_info)
298c2ecf20Sopenharmony_ci#define ELF_RISCV_R_TYPE(r_info)	ELF64_R_TYPE(r_info)
308c2ecf20Sopenharmony_ci#else
318c2ecf20Sopenharmony_ci#define ELF_RISCV_R_SYM(r_info)		ELF32_R_SYM(r_info)
328c2ecf20Sopenharmony_ci#define ELF_RISCV_R_TYPE(r_info)	ELF32_R_TYPE(r_info)
338c2ecf20Sopenharmony_ci#endif
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/*
368c2ecf20Sopenharmony_ci * RISC-V relocation types
378c2ecf20Sopenharmony_ci */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* Relocation types used by the dynamic linker */
408c2ecf20Sopenharmony_ci#define R_RISCV_NONE		0
418c2ecf20Sopenharmony_ci#define R_RISCV_32		1
428c2ecf20Sopenharmony_ci#define R_RISCV_64		2
438c2ecf20Sopenharmony_ci#define R_RISCV_RELATIVE	3
448c2ecf20Sopenharmony_ci#define R_RISCV_COPY		4
458c2ecf20Sopenharmony_ci#define R_RISCV_JUMP_SLOT	5
468c2ecf20Sopenharmony_ci#define R_RISCV_TLS_DTPMOD32	6
478c2ecf20Sopenharmony_ci#define R_RISCV_TLS_DTPMOD64	7
488c2ecf20Sopenharmony_ci#define R_RISCV_TLS_DTPREL32	8
498c2ecf20Sopenharmony_ci#define R_RISCV_TLS_DTPREL64	9
508c2ecf20Sopenharmony_ci#define R_RISCV_TLS_TPREL32	10
518c2ecf20Sopenharmony_ci#define R_RISCV_TLS_TPREL64	11
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/* Relocation types not used by the dynamic linker */
548c2ecf20Sopenharmony_ci#define R_RISCV_BRANCH		16
558c2ecf20Sopenharmony_ci#define R_RISCV_JAL		17
568c2ecf20Sopenharmony_ci#define R_RISCV_CALL		18
578c2ecf20Sopenharmony_ci#define R_RISCV_CALL_PLT	19
588c2ecf20Sopenharmony_ci#define R_RISCV_GOT_HI20	20
598c2ecf20Sopenharmony_ci#define R_RISCV_TLS_GOT_HI20	21
608c2ecf20Sopenharmony_ci#define R_RISCV_TLS_GD_HI20	22
618c2ecf20Sopenharmony_ci#define R_RISCV_PCREL_HI20	23
628c2ecf20Sopenharmony_ci#define R_RISCV_PCREL_LO12_I	24
638c2ecf20Sopenharmony_ci#define R_RISCV_PCREL_LO12_S	25
648c2ecf20Sopenharmony_ci#define R_RISCV_HI20		26
658c2ecf20Sopenharmony_ci#define R_RISCV_LO12_I		27
668c2ecf20Sopenharmony_ci#define R_RISCV_LO12_S		28
678c2ecf20Sopenharmony_ci#define R_RISCV_TPREL_HI20	29
688c2ecf20Sopenharmony_ci#define R_RISCV_TPREL_LO12_I	30
698c2ecf20Sopenharmony_ci#define R_RISCV_TPREL_LO12_S	31
708c2ecf20Sopenharmony_ci#define R_RISCV_TPREL_ADD	32
718c2ecf20Sopenharmony_ci#define R_RISCV_ADD8		33
728c2ecf20Sopenharmony_ci#define R_RISCV_ADD16		34
738c2ecf20Sopenharmony_ci#define R_RISCV_ADD32		35
748c2ecf20Sopenharmony_ci#define R_RISCV_ADD64		36
758c2ecf20Sopenharmony_ci#define R_RISCV_SUB8		37
768c2ecf20Sopenharmony_ci#define R_RISCV_SUB16		38
778c2ecf20Sopenharmony_ci#define R_RISCV_SUB32		39
788c2ecf20Sopenharmony_ci#define R_RISCV_SUB64		40
798c2ecf20Sopenharmony_ci#define R_RISCV_GNU_VTINHERIT	41
808c2ecf20Sopenharmony_ci#define R_RISCV_GNU_VTENTRY	42
818c2ecf20Sopenharmony_ci#define R_RISCV_ALIGN		43
828c2ecf20Sopenharmony_ci#define R_RISCV_RVC_BRANCH	44
838c2ecf20Sopenharmony_ci#define R_RISCV_RVC_JUMP	45
848c2ecf20Sopenharmony_ci#define R_RISCV_LUI		46
858c2ecf20Sopenharmony_ci#define R_RISCV_GPREL_I		47
868c2ecf20Sopenharmony_ci#define R_RISCV_GPREL_S		48
878c2ecf20Sopenharmony_ci#define R_RISCV_TPREL_I		49
888c2ecf20Sopenharmony_ci#define R_RISCV_TPREL_S		50
898c2ecf20Sopenharmony_ci#define R_RISCV_RELAX		51
908c2ecf20Sopenharmony_ci#define R_RISCV_SUB6		52
918c2ecf20Sopenharmony_ci#define R_RISCV_SET6		53
928c2ecf20Sopenharmony_ci#define R_RISCV_SET8		54
938c2ecf20Sopenharmony_ci#define R_RISCV_SET16		55
948c2ecf20Sopenharmony_ci#define R_RISCV_SET32		56
958c2ecf20Sopenharmony_ci#define R_RISCV_32_PCREL	57
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#endif /* _UAPI_ASM_RISCV_ELF_H */
99