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