1 /* $Id: elf.h,v 1.32 2002/02/09 19:49:31 davem Exp $ */
2 #ifndef __ASM_SPARC64_ELF_H
3 #define __ASM_SPARC64_ELF_H
6 * ELF register definitions..
9 #include <asm/ptrace.h>
11 #include <asm/processor.h>
12 #include <asm/uaccess.h>
18 #define STT_REGISTER 13
21 * Sparc ELF relocation types
23 #define R_SPARC_NONE 0
27 #define R_SPARC_DISP8 4
28 #define R_SPARC_DISP16 5
29 #define R_SPARC_DISP32 6
30 #define R_SPARC_WDISP30 7
31 #define R_SPARC_WDISP22 8
32 #define R_SPARC_HI22 9
35 #define R_SPARC_LO10 12
36 #define R_SPARC_GOT10 13
37 #define R_SPARC_GOT13 14
38 #define R_SPARC_GOT22 15
39 #define R_SPARC_PC10 16
40 #define R_SPARC_PC22 17
41 #define R_SPARC_WPLT30 18
42 #define R_SPARC_COPY 19
43 #define R_SPARC_GLOB_DAT 20
44 #define R_SPARC_JMP_SLOT 21
45 #define R_SPARC_RELATIVE 22
46 #define R_SPARC_UA32 23
47 #define R_SPARC_PLT32 24
48 #define R_SPARC_HIPLT22 25
49 #define R_SPARC_LOPLT10 26
50 #define R_SPARC_PCPLT32 27
51 #define R_SPARC_PCPLT22 28
52 #define R_SPARC_PCPLT10 29
56 #define R_SPARC_OLO10 33
57 #define R_SPARC_WDISP16 40
58 #define R_SPARC_WDISP19 41
63 /* Bits present in AT_HWCAP, primarily for Sparc32. */
65 #define HWCAP_SPARC_FLUSH 1 /* CPU supports flush instruction. */
66 #define HWCAP_SPARC_STBAR 2
67 #define HWCAP_SPARC_SWAP 4
68 #define HWCAP_SPARC_MULDIV 8
69 #define HWCAP_SPARC_V9 16
70 #define HWCAP_SPARC_ULTRA3 32
73 * These are used to set parameters in the core dumps.
76 #define ELF_ARCH EM_SPARCV9
77 #define ELF_CLASS ELFCLASS64
78 #define ELF_DATA ELFDATA2MSB
80 typedef unsigned long elf_greg_t;
83 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
84 /* Format of 64-bit elf_gregset_t is:
94 #define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \
95 do { unsigned long *dest = &(__elf_regs[0]); \
96 struct pt_regs *src = (__pt_regs); \
97 unsigned long __user *sp; \
99 for(i = 0; i < 16; i++) \
100 dest[i] = src->u_regs[i]; \
101 /* Don't try this at home kids... */ \
102 sp = (unsigned long __user *) \
103 ((src->u_regs[14] + STACK_BIAS) \
104 & 0xfffffffffffffff8UL); \
105 for(i = 0; i < 16; i++) \
106 __get_user(dest[i+16], &sp[i]); \
107 dest[32] = src->tstate; \
108 dest[33] = src->tpc; \
109 dest[34] = src->tnpc; \
114 unsigned long pr_regs[32];
115 unsigned long pr_fsr;
116 unsigned long pr_gsr;
117 unsigned long pr_fprs;
121 #define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \
122 ({ ELF_CORE_COPY_REGS((*(__elf_regs)), (__tsk)->thread_info->kregs); 1; })
125 * This is used to ensure we don't load something for the wrong architecture.
127 #ifndef elf_check_arch
128 #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */
131 #define USE_ELF_CORE_DUMP
132 #define ELF_EXEC_PAGESIZE PAGE_SIZE
134 /* This is the location that an ET_DYN program is loaded if exec'ed. Typical
135 use of this is to invoke "./ld.so someprog" to test out a new version of
136 the loader. We need to make sure that it is out of the way of the program
137 that it will "exec", and that there is sufficient room for the brk. */
139 #ifndef ELF_ET_DYN_BASE
140 #define ELF_ET_DYN_BASE 0x0000010000000000UL
144 /* This yields a mask that user programs can use to figure out what
145 instruction set this cpu supports. */
147 /* On Ultra, we support all of the v8 capabilities. */
148 #define ELF_HWCAP ((HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \
149 HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | \
151 ((tlb_type == cheetah || tlb_type == cheetah_plus) ? \
152 HWCAP_SPARC_ULTRA3 : 0))
154 /* This yields a string that ld.so will use to load implementation
155 specific libraries for optimization. This is more specific in
156 intent than poking at uname or /proc/cpuinfo. */
158 #define ELF_PLATFORM (NULL)
161 #define SET_PERSONALITY(ex, ibcs2) \
162 do { unsigned long new_flags = current_thread_info()->flags; \
163 new_flags &= _TIF_32BIT; \
164 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
165 new_flags |= _TIF_32BIT; \
167 new_flags &= ~_TIF_32BIT; \
168 if ((current_thread_info()->flags & _TIF_32BIT) \
170 set_thread_flag(TIF_ABI_PENDING); \
172 clear_thread_flag(TIF_ABI_PENDING); \
173 /* flush_thread will update pgd cache */ \
175 set_personality(PER_SVR4); \
176 else if (current->personality != PER_LINUX32) \
177 set_personality(PER_LINUX); \
181 #endif /* !(__ASM_SPARC64_ELF_H) */