1 |
1275 |
phoenix |
/*
|
2 |
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
3 |
|
|
* License. See the file "COPYING" in the main directory of this archive
|
4 |
|
|
* for more details.
|
5 |
|
|
*/
|
6 |
|
|
#ifndef _ASM_ELF_H
|
7 |
|
|
#define _ASM_ELF_H
|
8 |
|
|
|
9 |
|
|
#include <asm/ptrace.h>
|
10 |
|
|
#include <asm/user.h>
|
11 |
|
|
|
12 |
|
|
/* ELF header e_flags defines. */
|
13 |
|
|
/* MIPS architecture level. */
|
14 |
|
|
#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
|
15 |
|
|
#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
|
16 |
|
|
#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
|
17 |
|
|
#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
|
18 |
|
|
#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
|
19 |
|
|
#define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */
|
20 |
|
|
#define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */
|
21 |
|
|
/* The ABI of a file. */
|
22 |
|
|
#define EF_MIPS_ABI_O32 0x00001000 /* O32 ABI. */
|
23 |
|
|
#define EF_MIPS_ABI_O64 0x00002000 /* O32 extended for 64 bit. */
|
24 |
|
|
|
25 |
|
|
#ifndef ELF_ARCH
|
26 |
|
|
/* ELF register definitions */
|
27 |
|
|
#define ELF_NGREG 45
|
28 |
|
|
#define ELF_NFPREG 33
|
29 |
|
|
|
30 |
|
|
typedef unsigned long elf_greg_t;
|
31 |
|
|
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
|
32 |
|
|
|
33 |
|
|
typedef double elf_fpreg_t;
|
34 |
|
|
typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
|
35 |
|
|
|
36 |
|
|
/*
|
37 |
|
|
* This is used to ensure we don't load something for the wrong architecture.
|
38 |
|
|
*/
|
39 |
|
|
#define elf_check_arch(hdr) \
|
40 |
|
|
({ \
|
41 |
|
|
int __res = 1; \
|
42 |
|
|
struct elfhdr *__h = (hdr); \
|
43 |
|
|
\
|
44 |
|
|
if (__h->e_machine != EM_MIPS) \
|
45 |
|
|
__res = 0; \
|
46 |
|
|
if (__h->e_ident[EI_CLASS] == ELFCLASS32) \
|
47 |
|
|
__res = 0; \
|
48 |
|
|
\
|
49 |
|
|
__res; \
|
50 |
|
|
})
|
51 |
|
|
|
52 |
|
|
/*
|
53 |
|
|
* These are used to set parameters in the core dumps.
|
54 |
|
|
*/
|
55 |
|
|
#define ELF_CLASS ELFCLASS64
|
56 |
|
|
#ifdef __MIPSEB__
|
57 |
|
|
#define ELF_DATA ELFDATA2MSB
|
58 |
|
|
#elif __MIPSEL__
|
59 |
|
|
#define ELF_DATA ELFDATA2LSB
|
60 |
|
|
#endif
|
61 |
|
|
#define ELF_ARCH EM_MIPS
|
62 |
|
|
#endif /* !defined(ELF_ARCH) */
|
63 |
|
|
|
64 |
|
|
#define USE_ELF_CORE_DUMP
|
65 |
|
|
#define ELF_EXEC_PAGESIZE PAGE_SIZE
|
66 |
|
|
|
67 |
|
|
#define ELF_CORE_COPY_REGS(_dest,_regs) \
|
68 |
|
|
memcpy((char *) &_dest, (char *) _regs, \
|
69 |
|
|
sizeof(struct pt_regs));
|
70 |
|
|
|
71 |
|
|
/* This yields a mask that user programs can use to figure out what
|
72 |
|
|
instruction set this cpu supports. This could be done in userspace,
|
73 |
|
|
but it's not easy, and we've already done it here. */
|
74 |
|
|
|
75 |
|
|
#define ELF_HWCAP (0)
|
76 |
|
|
|
77 |
|
|
/* This yields a string that ld.so will use to load implementation
|
78 |
|
|
specific libraries for optimization. This is more specific in
|
79 |
|
|
intent than poking at uname or /proc/cpuinfo.
|
80 |
|
|
|
81 |
|
|
For the moment, we have only optimizations for the Intel generations,
|
82 |
|
|
but that could change... */
|
83 |
|
|
|
84 |
|
|
#define ELF_PLATFORM (NULL)
|
85 |
|
|
|
86 |
|
|
/*
|
87 |
|
|
* See comments in asm-alpha/elf.h, this is the same thing
|
88 |
|
|
* on the MIPS.
|
89 |
|
|
*/
|
90 |
|
|
#define ELF_PLAT_INIT(_r, load_addr) do { \
|
91 |
|
|
_r->regs[1] = _r->regs[2] = _r->regs[3] = _r->regs[4] = 0; \
|
92 |
|
|
_r->regs[5] = _r->regs[6] = _r->regs[7] = _r->regs[8] = 0; \
|
93 |
|
|
_r->regs[9] = _r->regs[10] = _r->regs[11] = _r->regs[12] = 0; \
|
94 |
|
|
_r->regs[13] = _r->regs[14] = _r->regs[15] = _r->regs[16] = 0; \
|
95 |
|
|
_r->regs[17] = _r->regs[18] = _r->regs[19] = _r->regs[20] = 0; \
|
96 |
|
|
_r->regs[21] = _r->regs[22] = _r->regs[23] = _r->regs[24] = 0; \
|
97 |
|
|
_r->regs[25] = _r->regs[26] = _r->regs[27] = _r->regs[28] = 0; \
|
98 |
|
|
_r->regs[30] = _r->regs[31] = 0; \
|
99 |
|
|
} while (0)
|
100 |
|
|
|
101 |
|
|
/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
|
102 |
|
|
use of this is to invoke "./ld.so someprog" to test out a new version of
|
103 |
|
|
the loader. We need to make sure that it is out of the way of the program
|
104 |
|
|
that it will "exec", and that there is sufficient room for the brk. */
|
105 |
|
|
|
106 |
|
|
#ifndef ELF_ET_DYN_BASE
|
107 |
|
|
#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
|
108 |
|
|
#endif
|
109 |
|
|
|
110 |
|
|
#ifdef __KERNEL__
|
111 |
|
|
#define SET_PERSONALITY(ex, ibcs2) \
|
112 |
|
|
do { current->thread.mflags &= ~MF_ABI_MASK; \
|
113 |
|
|
if ((ex).e_ident[EI_CLASS] == ELFCLASS32) { \
|
114 |
|
|
if ((((ex).e_flags & EF_MIPS_ABI2) != 0) && \
|
115 |
|
|
((ex).e_flags & EF_MIPS_ABI) == 0) \
|
116 |
|
|
current->thread.mflags |= MF_N32; \
|
117 |
|
|
else \
|
118 |
|
|
current->thread.mflags |= MF_O32; \
|
119 |
|
|
} else \
|
120 |
|
|
current->thread.mflags |= MF_N64; \
|
121 |
|
|
if (ibcs2) \
|
122 |
|
|
set_personality(PER_SVR4); \
|
123 |
|
|
else if (current->personality != PER_LINUX32) \
|
124 |
|
|
set_personality(PER_LINUX); \
|
125 |
|
|
} while (0)
|
126 |
|
|
#endif
|
127 |
|
|
|
128 |
|
|
#endif /* _ASM_ELF_H */
|