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>
13 #include <asm/spitfire.h>
19 #define STT_REGISTER 13
22 * Sparc ELF relocation types
24 #define R_SPARC_NONE 0
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
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
57 #define R_SPARC_OLO10 33
58 #define R_SPARC_WDISP16 40
59 #define R_SPARC_WDISP19 41
64 /* Bits present in AT_HWCAP, primarily for Sparc32. */
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 #define HWCAP_SPARC_BLKINIT 64
75 * These are used to set parameters in the core dumps.
78 #define ELF_ARCH EM_SPARCV9
79 #define ELF_CLASS ELFCLASS64
80 #define ELF_DATA ELFDATA2MSB
82 typedef unsigned long elf_greg_t
;
85 typedef elf_greg_t elf_gregset_t
[ELF_NGREG
];
86 /* Format of 64-bit elf_gregset_t is:
96 #define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \
97 do { unsigned long *dest = &(__elf_regs[0]); \
98 struct pt_regs *src = (__pt_regs); \
99 unsigned long __user *sp; \
101 for(i = 0; i < 16; i++) \
102 dest[i] = src->u_regs[i]; \
103 /* Don't try this at home kids... */ \
104 sp = (unsigned long __user *) \
105 ((src->u_regs[14] + STACK_BIAS) \
106 & 0xfffffffffffffff8UL); \
107 for(i = 0; i < 16; i++) \
108 __get_user(dest[i+16], &sp[i]); \
109 dest[32] = src->tstate; \
110 dest[33] = src->tpc; \
111 dest[34] = src->tnpc; \
116 unsigned long pr_regs
[32];
117 unsigned long pr_fsr
;
118 unsigned long pr_gsr
;
119 unsigned long pr_fprs
;
123 #define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \
124 ({ ELF_CORE_COPY_REGS((*(__elf_regs)), task_pt_regs(__tsk)); 1; })
127 * This is used to ensure we don't load something for the wrong architecture.
129 #ifndef elf_check_arch
130 #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */
133 #define USE_ELF_CORE_DUMP
134 #define ELF_EXEC_PAGESIZE PAGE_SIZE
136 /* This is the location that an ET_DYN program is loaded if exec'ed. Typical
137 use of this is to invoke "./ld.so someprog" to test out a new version of
138 the loader. We need to make sure that it is out of the way of the program
139 that it will "exec", and that there is sufficient room for the brk. */
141 #ifndef ELF_ET_DYN_BASE
142 #define ELF_ET_DYN_BASE 0x0000010000000000UL
146 /* This yields a mask that user programs can use to figure out what
147 instruction set this cpu supports. */
149 /* On Ultra, we support all of the v8 capabilities. */
150 static inline unsigned int sparc64_elf_hwcap(void)
152 unsigned int cap
= (HWCAP_SPARC_FLUSH
| HWCAP_SPARC_STBAR
|
153 HWCAP_SPARC_SWAP
| HWCAP_SPARC_MULDIV
|
156 if (tlb_type
== cheetah
|| tlb_type
== cheetah_plus
)
157 cap
|= HWCAP_SPARC_ULTRA3
;
158 else if (tlb_type
== hypervisor
)
159 cap
|= HWCAP_SPARC_BLKINIT
;
164 #define ELF_HWCAP sparc64_elf_hwcap();
166 /* This yields a string that ld.so will use to load implementation
167 specific libraries for optimization. This is more specific in
168 intent than poking at uname or /proc/cpuinfo. */
170 #define ELF_PLATFORM (NULL)
173 #define SET_PERSONALITY(ex, ibcs2) \
174 do { unsigned long new_flags = current_thread_info()->flags; \
175 new_flags &= _TIF_32BIT; \
176 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
177 new_flags |= _TIF_32BIT; \
179 new_flags &= ~_TIF_32BIT; \
180 if ((current_thread_info()->flags & _TIF_32BIT) \
182 set_thread_flag(TIF_ABI_PENDING); \
184 clear_thread_flag(TIF_ABI_PENDING); \
185 /* flush_thread will update pgd cache */ \
187 set_personality(PER_SVR4); \
188 else if (current->personality != PER_LINUX32) \
189 set_personality(PER_LINUX); \
193 #endif /* !(__ASM_SPARC64_ELF_H) */