18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __ASM_SPARC64_ELF_H 38c2ecf20Sopenharmony_ci#define __ASM_SPARC64_ELF_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * ELF register definitions.. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 108c2ecf20Sopenharmony_ci#include <asm/processor.h> 118c2ecf20Sopenharmony_ci#include <asm/extable_64.h> 128c2ecf20Sopenharmony_ci#include <asm/spitfire.h> 138c2ecf20Sopenharmony_ci#include <asm/adi.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci * Sparc section types 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci#define STT_REGISTER 13 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * Sparc ELF relocation types 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#define R_SPARC_NONE 0 248c2ecf20Sopenharmony_ci#define R_SPARC_8 1 258c2ecf20Sopenharmony_ci#define R_SPARC_16 2 268c2ecf20Sopenharmony_ci#define R_SPARC_32 3 278c2ecf20Sopenharmony_ci#define R_SPARC_DISP8 4 288c2ecf20Sopenharmony_ci#define R_SPARC_DISP16 5 298c2ecf20Sopenharmony_ci#define R_SPARC_DISP32 6 308c2ecf20Sopenharmony_ci#define R_SPARC_WDISP30 7 318c2ecf20Sopenharmony_ci#define R_SPARC_WDISP22 8 328c2ecf20Sopenharmony_ci#define R_SPARC_HI22 9 338c2ecf20Sopenharmony_ci#define R_SPARC_22 10 348c2ecf20Sopenharmony_ci#define R_SPARC_13 11 358c2ecf20Sopenharmony_ci#define R_SPARC_LO10 12 368c2ecf20Sopenharmony_ci#define R_SPARC_GOT10 13 378c2ecf20Sopenharmony_ci#define R_SPARC_GOT13 14 388c2ecf20Sopenharmony_ci#define R_SPARC_GOT22 15 398c2ecf20Sopenharmony_ci#define R_SPARC_PC10 16 408c2ecf20Sopenharmony_ci#define R_SPARC_PC22 17 418c2ecf20Sopenharmony_ci#define R_SPARC_WPLT30 18 428c2ecf20Sopenharmony_ci#define R_SPARC_COPY 19 438c2ecf20Sopenharmony_ci#define R_SPARC_GLOB_DAT 20 448c2ecf20Sopenharmony_ci#define R_SPARC_JMP_SLOT 21 458c2ecf20Sopenharmony_ci#define R_SPARC_RELATIVE 22 468c2ecf20Sopenharmony_ci#define R_SPARC_UA32 23 478c2ecf20Sopenharmony_ci#define R_SPARC_PLT32 24 488c2ecf20Sopenharmony_ci#define R_SPARC_HIPLT22 25 498c2ecf20Sopenharmony_ci#define R_SPARC_LOPLT10 26 508c2ecf20Sopenharmony_ci#define R_SPARC_PCPLT32 27 518c2ecf20Sopenharmony_ci#define R_SPARC_PCPLT22 28 528c2ecf20Sopenharmony_ci#define R_SPARC_PCPLT10 29 538c2ecf20Sopenharmony_ci#define R_SPARC_10 30 548c2ecf20Sopenharmony_ci#define R_SPARC_11 31 558c2ecf20Sopenharmony_ci#define R_SPARC_64 32 568c2ecf20Sopenharmony_ci#define R_SPARC_OLO10 33 578c2ecf20Sopenharmony_ci#define R_SPARC_WDISP16 40 588c2ecf20Sopenharmony_ci#define R_SPARC_WDISP19 41 598c2ecf20Sopenharmony_ci#define R_SPARC_7 43 608c2ecf20Sopenharmony_ci#define R_SPARC_5 44 618c2ecf20Sopenharmony_ci#define R_SPARC_6 45 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci/* Bits present in AT_HWCAP, primarily for Sparc32. */ 648c2ecf20Sopenharmony_ci#define HWCAP_SPARC_FLUSH 0x00000001 658c2ecf20Sopenharmony_ci#define HWCAP_SPARC_STBAR 0x00000002 668c2ecf20Sopenharmony_ci#define HWCAP_SPARC_SWAP 0x00000004 678c2ecf20Sopenharmony_ci#define HWCAP_SPARC_MULDIV 0x00000008 688c2ecf20Sopenharmony_ci#define HWCAP_SPARC_V9 0x00000010 698c2ecf20Sopenharmony_ci#define HWCAP_SPARC_ULTRA3 0x00000020 708c2ecf20Sopenharmony_ci#define HWCAP_SPARC_BLKINIT 0x00000040 718c2ecf20Sopenharmony_ci#define HWCAP_SPARC_N2 0x00000080 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* Solaris compatible AT_HWCAP bits. */ 748c2ecf20Sopenharmony_ci#define AV_SPARC_MUL32 0x00000100 /* 32x32 multiply is efficient */ 758c2ecf20Sopenharmony_ci#define AV_SPARC_DIV32 0x00000200 /* 32x32 divide is efficient */ 768c2ecf20Sopenharmony_ci#define AV_SPARC_FSMULD 0x00000400 /* 'fsmuld' is efficient */ 778c2ecf20Sopenharmony_ci#define AV_SPARC_V8PLUS 0x00000800 /* v9 insn available to 32bit */ 788c2ecf20Sopenharmony_ci#define AV_SPARC_POPC 0x00001000 /* 'popc' is efficient */ 798c2ecf20Sopenharmony_ci#define AV_SPARC_VIS 0x00002000 /* VIS insns available */ 808c2ecf20Sopenharmony_ci#define AV_SPARC_VIS2 0x00004000 /* VIS2 insns available */ 818c2ecf20Sopenharmony_ci#define AV_SPARC_ASI_BLK_INIT 0x00008000 /* block init ASIs available */ 828c2ecf20Sopenharmony_ci#define AV_SPARC_FMAF 0x00010000 /* fused multiply-add */ 838c2ecf20Sopenharmony_ci#define AV_SPARC_VIS3 0x00020000 /* VIS3 insns available */ 848c2ecf20Sopenharmony_ci#define AV_SPARC_HPC 0x00040000 /* HPC insns available */ 858c2ecf20Sopenharmony_ci#define AV_SPARC_RANDOM 0x00080000 /* 'random' insn available */ 868c2ecf20Sopenharmony_ci#define AV_SPARC_TRANS 0x00100000 /* transaction insns available */ 878c2ecf20Sopenharmony_ci#define AV_SPARC_FJFMAU 0x00200000 /* unfused multiply-add */ 888c2ecf20Sopenharmony_ci#define AV_SPARC_IMA 0x00400000 /* integer multiply-add */ 898c2ecf20Sopenharmony_ci#define AV_SPARC_ASI_CACHE_SPARING \ 908c2ecf20Sopenharmony_ci 0x00800000 /* cache sparing ASIs available */ 918c2ecf20Sopenharmony_ci#define AV_SPARC_PAUSE 0x01000000 /* PAUSE available */ 928c2ecf20Sopenharmony_ci#define AV_SPARC_CBCOND 0x02000000 /* CBCOND insns available */ 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* Solaris decided to enumerate every single crypto instruction type 958c2ecf20Sopenharmony_ci * in the AT_HWCAP bits. This is wasteful, since if crypto is present, 968c2ecf20Sopenharmony_ci * you still need to look in the CFR register to see if the opcode is 978c2ecf20Sopenharmony_ci * really available. So we simply advertise only "crypto" support. 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_ci#define HWCAP_SPARC_CRYPTO 0x04000000 /* CRYPTO insns available */ 1008c2ecf20Sopenharmony_ci#define HWCAP_SPARC_ADI 0x08000000 /* ADI available */ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define CORE_DUMP_USE_REGSET 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* 1058c2ecf20Sopenharmony_ci * These are used to set parameters in the core dumps. 1068c2ecf20Sopenharmony_ci */ 1078c2ecf20Sopenharmony_ci#define ELF_ARCH EM_SPARCV9 1088c2ecf20Sopenharmony_ci#define ELF_CLASS ELFCLASS64 1098c2ecf20Sopenharmony_ci#define ELF_DATA ELFDATA2MSB 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/* Format of 64-bit elf_gregset_t is: 1128c2ecf20Sopenharmony_ci * G0 --> G7 1138c2ecf20Sopenharmony_ci * O0 --> O7 1148c2ecf20Sopenharmony_ci * L0 --> L7 1158c2ecf20Sopenharmony_ci * I0 --> I7 1168c2ecf20Sopenharmony_ci * TSTATE 1178c2ecf20Sopenharmony_ci * TPC 1188c2ecf20Sopenharmony_ci * TNPC 1198c2ecf20Sopenharmony_ci * Y 1208c2ecf20Sopenharmony_ci */ 1218c2ecf20Sopenharmony_citypedef unsigned long elf_greg_t; 1228c2ecf20Sopenharmony_ci#define ELF_NGREG 36 1238c2ecf20Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG]; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_citypedef struct { 1268c2ecf20Sopenharmony_ci unsigned long pr_regs[32]; 1278c2ecf20Sopenharmony_ci unsigned long pr_fsr; 1288c2ecf20Sopenharmony_ci unsigned long pr_gsr; 1298c2ecf20Sopenharmony_ci unsigned long pr_fprs; 1308c2ecf20Sopenharmony_ci} elf_fpregset_t; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci/* Format of 32-bit elf_gregset_t is: 1338c2ecf20Sopenharmony_ci * G0 --> G7 1348c2ecf20Sopenharmony_ci * O0 --> O7 1358c2ecf20Sopenharmony_ci * L0 --> L7 1368c2ecf20Sopenharmony_ci * I0 --> I7 1378c2ecf20Sopenharmony_ci * PSR, PC, nPC, Y, WIM, TBR 1388c2ecf20Sopenharmony_ci */ 1398c2ecf20Sopenharmony_citypedef unsigned int compat_elf_greg_t; 1408c2ecf20Sopenharmony_ci#define COMPAT_ELF_NGREG 38 1418c2ecf20Sopenharmony_citypedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_citypedef struct { 1448c2ecf20Sopenharmony_ci union { 1458c2ecf20Sopenharmony_ci unsigned int pr_regs[32]; 1468c2ecf20Sopenharmony_ci unsigned long pr_dregs[16]; 1478c2ecf20Sopenharmony_ci } pr_fr; 1488c2ecf20Sopenharmony_ci unsigned int __unused; 1498c2ecf20Sopenharmony_ci unsigned int pr_fsr; 1508c2ecf20Sopenharmony_ci unsigned char pr_qcnt; 1518c2ecf20Sopenharmony_ci unsigned char pr_q_entrysize; 1528c2ecf20Sopenharmony_ci unsigned char pr_en; 1538c2ecf20Sopenharmony_ci unsigned int pr_q[64]; 1548c2ecf20Sopenharmony_ci} compat_elf_fpregset_t; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci/* UltraSparc extensions. Still unused, but will be eventually. */ 1578c2ecf20Sopenharmony_citypedef struct { 1588c2ecf20Sopenharmony_ci unsigned int pr_type; 1598c2ecf20Sopenharmony_ci unsigned int pr_align; 1608c2ecf20Sopenharmony_ci union { 1618c2ecf20Sopenharmony_ci struct { 1628c2ecf20Sopenharmony_ci union { 1638c2ecf20Sopenharmony_ci unsigned int pr_regs[32]; 1648c2ecf20Sopenharmony_ci unsigned long pr_dregs[16]; 1658c2ecf20Sopenharmony_ci long double pr_qregs[8]; 1668c2ecf20Sopenharmony_ci } pr_xfr; 1678c2ecf20Sopenharmony_ci } pr_v8p; 1688c2ecf20Sopenharmony_ci unsigned int pr_xfsr; 1698c2ecf20Sopenharmony_ci unsigned int pr_fprs; 1708c2ecf20Sopenharmony_ci unsigned int pr_xg[8]; 1718c2ecf20Sopenharmony_ci unsigned int pr_xo[8]; 1728c2ecf20Sopenharmony_ci unsigned long pr_tstate; 1738c2ecf20Sopenharmony_ci unsigned int pr_filler[8]; 1748c2ecf20Sopenharmony_ci } pr_un; 1758c2ecf20Sopenharmony_ci} elf_xregset_t; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci/* 1788c2ecf20Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture. 1798c2ecf20Sopenharmony_ci */ 1808c2ecf20Sopenharmony_ci#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) 1818c2ecf20Sopenharmony_ci#define compat_elf_check_arch(x) ((x)->e_machine == EM_SPARC || \ 1828c2ecf20Sopenharmony_ci (x)->e_machine == EM_SPARC32PLUS) 1838c2ecf20Sopenharmony_ci#define compat_start_thread start_thread32 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci#define ELF_EXEC_PAGESIZE PAGE_SIZE 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci/* This is the location that an ET_DYN program is loaded if exec'ed. Typical 1888c2ecf20Sopenharmony_ci use of this is to invoke "./ld.so someprog" to test out a new version of 1898c2ecf20Sopenharmony_ci the loader. We need to make sure that it is out of the way of the program 1908c2ecf20Sopenharmony_ci that it will "exec", and that there is sufficient room for the brk. */ 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci#define ELF_ET_DYN_BASE 0x0000010000000000UL 1938c2ecf20Sopenharmony_ci#define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ciextern unsigned long sparc64_elf_hwcap; 1968c2ecf20Sopenharmony_ci#define ELF_HWCAP sparc64_elf_hwcap 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci/* This yields a string that ld.so will use to load implementation 1998c2ecf20Sopenharmony_ci specific libraries for optimization. This is more specific in 2008c2ecf20Sopenharmony_ci intent than poking at uname or /proc/cpuinfo. */ 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci#define ELF_PLATFORM (NULL) 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci#define SET_PERSONALITY(ex) \ 2058c2ecf20Sopenharmony_cido { if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ 2068c2ecf20Sopenharmony_ci set_thread_flag(TIF_32BIT); \ 2078c2ecf20Sopenharmony_ci else \ 2088c2ecf20Sopenharmony_ci clear_thread_flag(TIF_32BIT); \ 2098c2ecf20Sopenharmony_ci /* flush_thread will update pgd cache */ \ 2108c2ecf20Sopenharmony_ci if (personality(current->personality) != PER_LINUX32) \ 2118c2ecf20Sopenharmony_ci set_personality(PER_LINUX | \ 2128c2ecf20Sopenharmony_ci (current->personality & (~PER_MASK))); \ 2138c2ecf20Sopenharmony_ci} while (0) 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ciextern unsigned int vdso_enabled; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci#define ARCH_DLINFO \ 2188c2ecf20Sopenharmony_cido { \ 2198c2ecf20Sopenharmony_ci extern struct adi_config adi_state; \ 2208c2ecf20Sopenharmony_ci if (vdso_enabled) \ 2218c2ecf20Sopenharmony_ci NEW_AUX_ENT(AT_SYSINFO_EHDR, \ 2228c2ecf20Sopenharmony_ci (unsigned long)current->mm->context.vdso); \ 2238c2ecf20Sopenharmony_ci NEW_AUX_ENT(AT_ADI_BLKSZ, adi_state.caps.blksz); \ 2248c2ecf20Sopenharmony_ci NEW_AUX_ENT(AT_ADI_NBITS, adi_state.caps.nbits); \ 2258c2ecf20Sopenharmony_ci NEW_AUX_ENT(AT_ADI_UEONADI, adi_state.caps.ue_on_adi); \ 2268c2ecf20Sopenharmony_ci} while (0) 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_cistruct linux_binprm; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 2318c2ecf20Sopenharmony_ciextern int arch_setup_additional_pages(struct linux_binprm *bprm, 2328c2ecf20Sopenharmony_ci int uses_interp); 2338c2ecf20Sopenharmony_ci#endif /* !(__ASM_SPARC64_ELF_H) */ 234