Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: elf.h,v 1.22 2000/07/12 01:27:08 davem Exp $ */ |
| 2 | #ifndef __ASMSPARC_ELF_H |
| 3 | #define __ASMSPARC_ELF_H |
| 4 | |
| 5 | /* |
| 6 | * ELF register definitions.. |
| 7 | */ |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <asm/ptrace.h> |
| 10 | |
| 11 | #ifdef __KERNEL__ |
| 12 | #include <asm/mbus.h> |
| 13 | #include <asm/uaccess.h> |
| 14 | #endif |
| 15 | |
| 16 | /* |
| 17 | * Sparc section types |
| 18 | */ |
| 19 | #define STT_REGISTER 13 |
| 20 | |
| 21 | /* |
| 22 | * Sparc ELF relocation types |
| 23 | */ |
| 24 | #define R_SPARC_NONE 0 |
| 25 | #define R_SPARC_8 1 |
| 26 | #define R_SPARC_16 2 |
| 27 | #define R_SPARC_32 3 |
| 28 | #define R_SPARC_DISP8 4 |
| 29 | #define R_SPARC_DISP16 5 |
| 30 | #define R_SPARC_DISP32 6 |
| 31 | #define R_SPARC_WDISP30 7 |
| 32 | #define R_SPARC_WDISP22 8 |
| 33 | #define R_SPARC_HI22 9 |
| 34 | #define R_SPARC_22 10 |
| 35 | #define R_SPARC_13 11 |
| 36 | #define R_SPARC_LO10 12 |
| 37 | #define R_SPARC_GOT10 13 |
| 38 | #define R_SPARC_GOT13 14 |
| 39 | #define R_SPARC_GOT22 15 |
| 40 | #define R_SPARC_PC10 16 |
| 41 | #define R_SPARC_PC22 17 |
| 42 | #define R_SPARC_WPLT30 18 |
| 43 | #define R_SPARC_COPY 19 |
| 44 | #define R_SPARC_GLOB_DAT 20 |
| 45 | #define R_SPARC_JMP_SLOT 21 |
| 46 | #define R_SPARC_RELATIVE 22 |
| 47 | #define R_SPARC_UA32 23 |
| 48 | #define R_SPARC_PLT32 24 |
| 49 | #define R_SPARC_HIPLT22 25 |
| 50 | #define R_SPARC_LOPLT10 26 |
| 51 | #define R_SPARC_PCPLT32 27 |
| 52 | #define R_SPARC_PCPLT22 28 |
| 53 | #define R_SPARC_PCPLT10 29 |
| 54 | #define R_SPARC_10 30 |
| 55 | #define R_SPARC_11 31 |
| 56 | #define R_SPARC_64 32 |
| 57 | #define R_SPARC_OLO10 33 |
| 58 | #define R_SPARC_WDISP16 40 |
| 59 | #define R_SPARC_WDISP19 41 |
| 60 | #define R_SPARC_7 43 |
| 61 | #define R_SPARC_5 44 |
| 62 | #define R_SPARC_6 45 |
| 63 | |
| 64 | /* Bits present in AT_HWCAP, primarily for Sparc32. */ |
| 65 | |
| 66 | #define HWCAP_SPARC_FLUSH 1 /* CPU supports flush instruction. */ |
| 67 | #define HWCAP_SPARC_STBAR 2 |
| 68 | #define HWCAP_SPARC_SWAP 4 |
| 69 | #define HWCAP_SPARC_MULDIV 8 |
| 70 | #define HWCAP_SPARC_V9 16 |
| 71 | #define HWCAP_SPARC_ULTRA3 32 |
| 72 | |
| 73 | /* For the most part we present code dumps in the format |
| 74 | * Solaris does. |
| 75 | */ |
| 76 | typedef unsigned long elf_greg_t; |
| 77 | #define ELF_NGREG 38 |
| 78 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
| 79 | |
| 80 | /* Format is: |
| 81 | * G0 --> G7 |
| 82 | * O0 --> O7 |
| 83 | * L0 --> L7 |
| 84 | * I0 --> I7 |
| 85 | * PSR, PC, nPC, Y, WIM, TBR |
| 86 | */ |
| 87 | #define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \ |
| 88 | do { unsigned long *dest = &(__elf_regs[0]); \ |
| 89 | struct pt_regs *src = (__pt_regs); \ |
| 90 | unsigned long __user *sp; \ |
| 91 | memcpy(&dest[0], &src->u_regs[0], \ |
| 92 | sizeof(unsigned long) * 16); \ |
| 93 | /* Don't try this at home kids... */ \ |
| 94 | sp = (unsigned long __user *) src->u_regs[14]; \ |
| 95 | copy_from_user(&dest[16], sp, \ |
| 96 | sizeof(unsigned long) * 16); \ |
| 97 | dest[32] = src->psr; \ |
| 98 | dest[33] = src->pc; \ |
| 99 | dest[34] = src->npc; \ |
| 100 | dest[35] = src->y; \ |
| 101 | dest[36] = dest[37] = 0; /* XXX */ \ |
| 102 | } while(0); /* Janitors: Don't touch this colon. */ |
| 103 | |
| 104 | typedef struct { |
| 105 | union { |
| 106 | unsigned long pr_regs[32]; |
| 107 | double pr_dregs[16]; |
| 108 | } pr_fr; |
| 109 | unsigned long __unused; |
| 110 | unsigned long pr_fsr; |
| 111 | unsigned char pr_qcnt; |
| 112 | unsigned char pr_q_entrysize; |
| 113 | unsigned char pr_en; |
| 114 | unsigned int pr_q[64]; |
| 115 | } elf_fpregset_t; |
| 116 | |
| 117 | #define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \ |
| 118 | ({ ELF_CORE_COPY_REGS((*(__elf_regs)), (__tsk)->thread.kregs); 1; }) |
| 119 | |
| 120 | /* |
| 121 | * This is used to ensure we don't load something for the wrong architecture. |
| 122 | */ |
| 123 | #define elf_check_arch(x) ((x)->e_machine == EM_SPARC) |
| 124 | |
| 125 | /* |
| 126 | * These are used to set parameters in the core dumps. |
| 127 | */ |
| 128 | #define ELF_ARCH EM_SPARC |
| 129 | #define ELF_CLASS ELFCLASS32 |
| 130 | #define ELF_DATA ELFDATA2MSB |
| 131 | |
| 132 | #define USE_ELF_CORE_DUMP |
| 133 | #ifndef CONFIG_SUN4 |
| 134 | #define ELF_EXEC_PAGESIZE 4096 |
| 135 | #else |
| 136 | #define ELF_EXEC_PAGESIZE 8192 |
| 137 | #endif |
| 138 | |
| 139 | |
| 140 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical |
| 141 | use of this is to invoke "./ld.so someprog" to test out a new version of |
| 142 | the loader. We need to make sure that it is out of the way of the program |
| 143 | that it will "exec", and that there is sufficient room for the brk. */ |
| 144 | |
| 145 | #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE) |
| 146 | |
| 147 | /* This yields a mask that user programs can use to figure out what |
| 148 | instruction set this cpu supports. This can NOT be done in userspace |
| 149 | on Sparc. */ |
| 150 | |
| 151 | /* Sun4c has none of the capabilities, most sun4m's have them all. |
| 152 | * XXX This is gross, set some global variable at boot time. -DaveM |
| 153 | */ |
| 154 | #define ELF_HWCAP ((ARCH_SUN4C_SUN4) ? 0 : \ |
| 155 | (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \ |
| 156 | HWCAP_SPARC_SWAP | \ |
| 157 | ((srmmu_modtype != Cypress && \ |
| 158 | srmmu_modtype != Cypress_vE && \ |
| 159 | srmmu_modtype != Cypress_vD) ? \ |
| 160 | HWCAP_SPARC_MULDIV : 0))) |
| 161 | |
| 162 | /* This yields a string that ld.so will use to load implementation |
| 163 | specific libraries for optimization. This is more specific in |
| 164 | intent than poking at uname or /proc/cpuinfo. */ |
| 165 | |
| 166 | #define ELF_PLATFORM (NULL) |
| 167 | |
| 168 | #ifdef __KERNEL__ |
| 169 | #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) |
| 170 | #endif |
| 171 | |
| 172 | #endif /* !(__ASMSPARC_ELF_H) */ |