more changes on original files
[linux-2.4.git] / include / asm-parisc / elf.h
1 #ifndef __ASMPARISC_ELF_H
2 #define __ASMPARISC_ELF_H
3
4 /*
5  * ELF register definitions..
6  */
7
8 #include <asm/ptrace.h>
9
10 #define EM_PARISC 15
11
12 /*
13  * The following definitions are those for 32-bit ELF binaries on a 32-bit kernel
14  * and for 64-bit binaries on a 64-bit kernel.  To run 32-bit binaries on a 64-bit
15  * kernel, arch/parisc64/kernel/binfmt_elf32.c defines these macros appropriately
16  * and then #includes binfmt_elf.c, which then includes this file.
17  */
18 #ifndef ELF_CLASS
19
20 /*
21  * This is used to ensure we don't load something for the wrong architecture.
22  *
23  * Note that this header file is used by default in fs/binfmt_elf.c. So
24  * the following macros are for the default case. However, for the 64
25  * bit kernel we also support 32 bit parisc binaries. To do that
26  * arch/parisc64/kernel/binfmt_elf32.c defines its own set of these
27  * macros, and then it includes fs/binfmt_elf.c to provide an alternate
28  * elf binary handler for 32 bit binaries (on the 64 bit kernel).
29  */
30 #ifdef __LP64__
31 #define ELF_CLASS       ELFCLASS64
32 #else
33 #define ELF_CLASS       ELFCLASS32
34 #endif
35
36 typedef unsigned long elf_greg_t;
37
38 /* This yields a string that ld.so will use to load implementation
39    specific libraries for optimization.  This is more specific in
40    intent than poking at uname or /proc/cpuinfo.
41
42    For the moment, we have only optimizations for the Intel generations,
43    but that could change... */
44
45 #define ELF_PLATFORM  ("PARISC\0" /*+((boot_cpu_data.x86-3)*5) */)
46
47 #ifdef __KERNEL__
48 #define SET_PERSONALITY(ex, ibcs2) \
49         current->personality = PER_LINUX
50 #endif
51
52 /*
53  * Fill in general registers in a core dump.  This saves pretty
54  * much the same registers as hp-ux, although in a different order.
55  * Registers marked # below are not currently saved in pt_regs, so
56  * we use their current values here.
57  *
58  *      gr0..gr31
59  *      sr0..sr7
60  *      iaoq0..iaoq1
61  *      iasq0..iasq1
62  *      cr11 (sar)
63  *      cr19 (iir)
64  *      cr20 (isr)
65  *      cr21 (ior)
66  *  #   cr22 (ipsw)
67  *  #   cr0 (recovery counter)
68  *  #   cr24..cr31 (temporary registers)
69  *  #   cr8,9,12,13 (protection IDs)
70  *  #   cr10 (scr/ccr)
71  *  #   cr15 (ext int enable mask)
72  *
73  */
74
75 #define ELF_CORE_COPY_REGS(dst, pt)     \
76         memset(dst, 0, sizeof(dst));    /* don't leak any "random" bits */ \
77         memcpy(dst + 0, pt->gr, 32 * sizeof(elf_greg_t)); \
78         memcpy(dst + 32, pt->sr, 8 * sizeof(elf_greg_t)); \
79         memcpy(dst + 40, pt->iaoq, 2 * sizeof(elf_greg_t)); \
80         memcpy(dst + 42, pt->iasq, 2 * sizeof(elf_greg_t)); \
81         dst[44] = pt->sar;   dst[45] = pt->iir; \
82         dst[46] = pt->isr;   dst[47] = pt->ior; \
83         dst[48] = mfctl(22); dst[49] = mfctl(0); \
84         dst[50] = mfctl(24); dst[51] = mfctl(25); \
85         dst[52] = mfctl(26); dst[53] = mfctl(27); \
86         dst[54] = mfctl(28); dst[55] = mfctl(29); \
87         dst[56] = mfctl(30); dst[57] = mfctl(31); \
88         dst[58] = mfctl( 8); dst[59] = mfctl( 9); \
89         dst[60] = mfctl(12); dst[61] = mfctl(13); \
90         dst[62] = mfctl(10); dst[63] = mfctl(15);
91
92 #endif /* ! ELF_CLASS */
93
94 #define ELF_NGREG 80    /* We only need 64 at present, but leave space
95                            for expansion. */
96 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
97
98 #define ELF_NFPREG 32
99 typedef double elf_fpreg_t;
100 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
101
102 struct pt_regs; /* forward declaration... */
103
104
105 #define elf_check_arch(x) ((x)->e_machine == EM_PARISC && (x)->e_ident[EI_CLASS] == ELF_CLASS)
106
107 /*
108  * These are used to set parameters in the core dumps.
109  */
110 #define ELF_DATA        ELFDATA2MSB
111 #define ELF_ARCH        EM_PARISC
112
113 /* %r23 is set by ld.so to a pointer to a function which might be 
114    registered using atexit.  This provides a mean for the dynamic
115    linker to call DT_FINI functions for shared libraries that have
116    been loaded before the code runs.
117
118    So that we can use the same startup file with static executables,
119    we start programs with a value of 0 to indicate that there is no
120    such function.  */
121 #define ELF_PLAT_INIT(_r, load_addr)       _r->gr[23] = 0
122
123 #define USE_ELF_CORE_DUMP
124 #define ELF_EXEC_PAGESIZE       4096
125
126 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
127    use of this is to invoke "./ld.so someprog" to test out a new version of
128    the loader.  We need to make sure that it is out of the way of the program
129    that it will "exec", and that there is sufficient room for the brk.
130
131    (2 * TASK_SIZE / 3) turns into something undefined when run through a
132    32 bit preprocessor and in some cases results in the kernel trying to map
133    ld.so to the kernel virtual base. Use a sane value instead. /Jes 
134   */
135
136 #define ELF_ET_DYN_BASE         (TASK_UNMAPPED_BASE + 0x01000000)
137
138 /* This yields a mask that user programs can use to figure out what
139    instruction set this CPU supports.  This could be done in user space,
140    but it's not easy, and we've already done it here.  */
141
142 #define ELF_HWCAP       0
143 /* (boot_cpu_data.x86_capability) */
144
145 #endif