Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __ASM_SPARC64_ELF_H
0003 #define __ASM_SPARC64_ELF_H
0004 
0005 /*
0006  * ELF register definitions..
0007  */
0008 
0009 #include <asm/ptrace.h>
0010 #include <asm/processor.h>
0011 #include <asm/spitfire.h>
0012 #include <asm/adi.h>
0013 
0014 /*
0015  * Sparc section types
0016  */
0017 #define STT_REGISTER        13
0018 
0019 /*
0020  * Sparc ELF relocation types
0021  */
0022 #define R_SPARC_NONE        0
0023 #define R_SPARC_8       1
0024 #define R_SPARC_16      2
0025 #define R_SPARC_32      3
0026 #define R_SPARC_DISP8       4
0027 #define R_SPARC_DISP16      5
0028 #define R_SPARC_DISP32      6
0029 #define R_SPARC_WDISP30     7
0030 #define R_SPARC_WDISP22     8
0031 #define R_SPARC_HI22        9
0032 #define R_SPARC_22      10
0033 #define R_SPARC_13      11
0034 #define R_SPARC_LO10        12
0035 #define R_SPARC_GOT10       13
0036 #define R_SPARC_GOT13       14
0037 #define R_SPARC_GOT22       15
0038 #define R_SPARC_PC10        16
0039 #define R_SPARC_PC22        17
0040 #define R_SPARC_WPLT30      18
0041 #define R_SPARC_COPY        19
0042 #define R_SPARC_GLOB_DAT    20
0043 #define R_SPARC_JMP_SLOT    21
0044 #define R_SPARC_RELATIVE    22
0045 #define R_SPARC_UA32        23
0046 #define R_SPARC_PLT32       24
0047 #define R_SPARC_HIPLT22     25
0048 #define R_SPARC_LOPLT10     26
0049 #define R_SPARC_PCPLT32     27
0050 #define R_SPARC_PCPLT22     28
0051 #define R_SPARC_PCPLT10     29
0052 #define R_SPARC_10      30
0053 #define R_SPARC_11      31
0054 #define R_SPARC_64      32
0055 #define R_SPARC_OLO10       33
0056 #define R_SPARC_WDISP16     40
0057 #define R_SPARC_WDISP19     41
0058 #define R_SPARC_7       43
0059 #define R_SPARC_5       44
0060 #define R_SPARC_6       45
0061 
0062 /* Bits present in AT_HWCAP, primarily for Sparc32.  */
0063 #define HWCAP_SPARC_FLUSH       0x00000001
0064 #define HWCAP_SPARC_STBAR       0x00000002
0065 #define HWCAP_SPARC_SWAP        0x00000004
0066 #define HWCAP_SPARC_MULDIV      0x00000008
0067 #define HWCAP_SPARC_V9      0x00000010
0068 #define HWCAP_SPARC_ULTRA3  0x00000020
0069 #define HWCAP_SPARC_BLKINIT 0x00000040
0070 #define HWCAP_SPARC_N2      0x00000080
0071 
0072 /* Solaris compatible AT_HWCAP bits. */
0073 #define AV_SPARC_MUL32      0x00000100 /* 32x32 multiply is efficient */
0074 #define AV_SPARC_DIV32      0x00000200 /* 32x32 divide is efficient */
0075 #define AV_SPARC_FSMULD     0x00000400 /* 'fsmuld' is efficient */
0076 #define AV_SPARC_V8PLUS     0x00000800 /* v9 insn available to 32bit */
0077 #define AV_SPARC_POPC       0x00001000 /* 'popc' is efficient */
0078 #define AV_SPARC_VIS        0x00002000 /* VIS insns available */
0079 #define AV_SPARC_VIS2       0x00004000 /* VIS2 insns available */
0080 #define AV_SPARC_ASI_BLK_INIT   0x00008000 /* block init ASIs available */
0081 #define AV_SPARC_FMAF       0x00010000 /* fused multiply-add */
0082 #define AV_SPARC_VIS3       0x00020000 /* VIS3 insns available */
0083 #define AV_SPARC_HPC        0x00040000 /* HPC insns available */
0084 #define AV_SPARC_RANDOM     0x00080000 /* 'random' insn available */
0085 #define AV_SPARC_TRANS      0x00100000 /* transaction insns available */
0086 #define AV_SPARC_FJFMAU     0x00200000 /* unfused multiply-add */
0087 #define AV_SPARC_IMA        0x00400000 /* integer multiply-add */
0088 #define AV_SPARC_ASI_CACHE_SPARING \
0089                 0x00800000 /* cache sparing ASIs available */
0090 #define AV_SPARC_PAUSE      0x01000000 /* PAUSE available */
0091 #define AV_SPARC_CBCOND     0x02000000 /* CBCOND insns available */
0092 
0093 /* Solaris decided to enumerate every single crypto instruction type
0094  * in the AT_HWCAP bits.  This is wasteful, since if crypto is present,
0095  * you still need to look in the CFR register to see if the opcode is
0096  * really available.  So we simply advertise only "crypto" support.
0097  */
0098 #define HWCAP_SPARC_CRYPTO  0x04000000 /* CRYPTO insns available */
0099 #define HWCAP_SPARC_ADI     0x08000000 /* ADI available */
0100 
0101 #define CORE_DUMP_USE_REGSET
0102 
0103 /*
0104  * These are used to set parameters in the core dumps.
0105  */
0106 #define ELF_ARCH        EM_SPARCV9
0107 #define ELF_CLASS       ELFCLASS64
0108 #define ELF_DATA        ELFDATA2MSB
0109 
0110 /* Format of 64-bit elf_gregset_t is:
0111  *  G0 --> G7
0112  *  O0 --> O7
0113  *  L0 --> L7
0114  *  I0 --> I7
0115  *  TSTATE
0116  *  TPC
0117  *  TNPC
0118  *  Y
0119  */
0120 typedef unsigned long elf_greg_t;
0121 #define ELF_NGREG 36
0122 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
0123 
0124 typedef struct {
0125     unsigned long   pr_regs[32];
0126     unsigned long   pr_fsr;
0127     unsigned long   pr_gsr;
0128     unsigned long   pr_fprs;
0129 } elf_fpregset_t;
0130 
0131 /* Format of 32-bit elf_gregset_t is:
0132  *  G0 --> G7
0133  *  O0 --> O7
0134  *  L0 --> L7
0135  *  I0 --> I7
0136  *  PSR, PC, nPC, Y, WIM, TBR
0137  */
0138 typedef unsigned int compat_elf_greg_t;
0139 #define COMPAT_ELF_NGREG 38
0140 typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
0141 
0142 typedef struct {
0143     union {
0144         unsigned int    pr_regs[32];
0145         unsigned long   pr_dregs[16];
0146     } pr_fr;
0147     unsigned int __unused;
0148     unsigned int    pr_fsr;
0149     unsigned char   pr_qcnt;
0150     unsigned char   pr_q_entrysize;
0151     unsigned char   pr_en;
0152     unsigned int    pr_q[64];
0153 } compat_elf_fpregset_t;
0154 
0155 /* UltraSparc extensions.  Still unused, but will be eventually.  */
0156 typedef struct {
0157     unsigned int pr_type;
0158     unsigned int pr_align;
0159     union {
0160         struct {
0161             union {
0162                 unsigned int    pr_regs[32];
0163                 unsigned long   pr_dregs[16];
0164                 long double pr_qregs[8];
0165             } pr_xfr;
0166         } pr_v8p;
0167         unsigned int    pr_xfsr;
0168         unsigned int    pr_fprs;
0169         unsigned int    pr_xg[8];
0170         unsigned int    pr_xo[8];
0171         unsigned long   pr_tstate;
0172         unsigned int    pr_filler[8];
0173     } pr_un;
0174 } elf_xregset_t;
0175 
0176 /*
0177  * This is used to ensure we don't load something for the wrong architecture.
0178  */
0179 #define elf_check_arch(x)       ((x)->e_machine == ELF_ARCH)
0180 #define compat_elf_check_arch(x)    ((x)->e_machine == EM_SPARC || \
0181                      (x)->e_machine == EM_SPARC32PLUS)
0182 #define compat_start_thread     start_thread32
0183 
0184 #define ELF_EXEC_PAGESIZE   PAGE_SIZE
0185 
0186 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
0187    use of this is to invoke "./ld.so someprog" to test out a new version of
0188    the loader.  We need to make sure that it is out of the way of the program
0189    that it will "exec", and that there is sufficient room for the brk.  */
0190 
0191 #define ELF_ET_DYN_BASE     0x0000010000000000UL
0192 #define COMPAT_ELF_ET_DYN_BASE  0x0000000070000000UL
0193 
0194 extern unsigned long sparc64_elf_hwcap;
0195 #define ELF_HWCAP   sparc64_elf_hwcap
0196 
0197 /* This yields a string that ld.so will use to load implementation
0198    specific libraries for optimization.  This is more specific in
0199    intent than poking at uname or /proc/cpuinfo.  */
0200 
0201 #define ELF_PLATFORM    (NULL)
0202 
0203 #define SET_PERSONALITY(ex)             \
0204 do {    if ((ex).e_ident[EI_CLASS] == ELFCLASS32)   \
0205         set_thread_flag(TIF_32BIT);     \
0206     else                        \
0207         clear_thread_flag(TIF_32BIT);       \
0208     /* flush_thread will update pgd cache */    \
0209     if (personality(current->personality) != PER_LINUX32)   \
0210         set_personality(PER_LINUX |     \
0211             (current->personality & (~PER_MASK)));  \
0212 } while (0)
0213 
0214 extern unsigned int vdso_enabled;
0215 
0216 #define ARCH_DLINFO                         \
0217 do {                                    \
0218     extern struct adi_config adi_state;             \
0219     if (vdso_enabled)                       \
0220         NEW_AUX_ENT(AT_SYSINFO_EHDR,                \
0221                 (unsigned long)current->mm->context.vdso);  \
0222     NEW_AUX_ENT(AT_ADI_BLKSZ, adi_state.caps.blksz);        \
0223     NEW_AUX_ENT(AT_ADI_NBITS, adi_state.caps.nbits);        \
0224     NEW_AUX_ENT(AT_ADI_UEONADI, adi_state.caps.ue_on_adi);      \
0225 } while (0)
0226 
0227 struct linux_binprm;
0228 
0229 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
0230 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
0231                     int uses_interp);
0232 #endif /* !(__ASM_SPARC64_ELF_H) */