xref: /netbsd-src/tools/mips-elf2ecoff/machine/ecoff_machdep.h (revision 3e2605f3b9c557c5bdafd19f85208c37f2e0e6e0)
1 /*	$NetBSD: ecoff_machdep.h,v 1.3 2017/02/24 03:44:54 christos Exp $	*/
2 
3 /*
4  * Copyright (c) 1997 Jonathan Stone
5  * All rights reserved.
6  *
7  * Copyright (c) 1994 Adam Glass
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by Adam Glass.
21  * 4. The name of the Author may not be used to endorse or promote products
22  *    derived from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL Adam Glass BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36 
37 #define ECOFF_LDPGSZ 4096
38 
39 #define ECOFF_PAD
40 #define ECOFF32_PAD
41 
42 #define ECOFF32_MACHDEP \
43         ecoff32_ulong gprmask; \
44         ecoff32_ulong cprmask[4]; \
45         ecoff32_ulong gp_value
46 
47 #define ECOFF_MACHDEP \
48         u_long gprmask; \
49         u_long cprmask[4]; \
50         u_long gp_value
51 #ifdef _KERNEL
52 #include <mips/locore.h>		/* mips CPU architecture levels */
53 #define _MIPS3_OK() CPUISMIPS3
54 #else
55 #define _MIPS3_OK() /*CONSTCOND*/1
56 #endif
57 
58 
59 #define ECOFF_MAGIC_MIPSEB	0x0160	/* mips1, big-endian */
60 #define ECOFF_MAGIC_MIPSEL	0x0162	/* mips1, little-endian */
61 #define ECOFF_MAGIC_MIPSEL3	0x0142	/* mips3, little-endian */
62 
63 #if BYTE_ORDER == LITTLE_ENDIAN
64 #define ECOFF_BADMAG(ep) \
65     (!								\
66 	((ep)->f.f_magic == ECOFF_MAGIC_MIPSEL ||		\
67 	 (_MIPS3_OK() && (ep)->f.f_magic == ECOFF_MAGIC_MIPSEL3)) \
68     )
69 #endif
70 #if BYTE_ORDER == BIG_ENDIAN
71 #define ECOFF_BADMAG(ep) ((ep)->f.f_magic != ECOFF_MAGIC_MIPSEB)
72 #endif
73 
74 
75 #define ECOFF_SEGMENT_ALIGNMENT(ep) ((ep)->a.vstamp < 23 ? 8 : 16)
76 #define ECOFF32_SEGMENT_ALIGNMENT(ep) ((ep)->a.vstamp < 23 ? 8 : 16)
77 
78 #ifdef _KERNEL
79 struct proc;
80 struct exec_package;
81 void	cpu_exec_ecoff_setregs(struct lwp *, struct exec_package *, vaddr_t);
82 #endif	/* _KERNEL */
83 
84 
85 struct ecoff32_symhdr {
86 	int16_t		magic;
87 	int16_t		vstamp;
88 	int32_t		ilineMax;
89 	int32_t		cbLine;
90 	int32_t		cbLineOffset;
91 	int32_t		idnMax;
92 	int32_t		cbDnOffset;
93 	int32_t		ipdMax;
94 	int32_t		cbPdOffset;
95 	int32_t		isymMax;
96 	int32_t		cbSymOffset;
97 	int32_t		ioptMax;
98 	int32_t		cbOptOffset;
99 	int32_t		iauxMax;
100 	int32_t		cbAuxOffset;
101 	int32_t		issMax;
102 	int32_t		cbSsOffset;
103 	int32_t		issExtMax;
104 	int32_t		cbSsExtOffset;
105 	int32_t		ifdMax;
106 	int32_t		cbFdOffset;
107 	int32_t		crfd;
108 	int32_t		cbRfdOffset;
109 	int32_t		iextMax;
110 	int32_t		cbExtOffset;
111 };
112 
113 /*
114  * ECOFF symbol definitions for 32-bit mips.
115  * XXX 64-bit (mips3?) may be different.
116  */
117 struct ecoff_symhdr {
118 	int16_t		magic;
119 	int16_t		vstamp;
120 	int32_t		ilineMax;
121 	int32_t		cbLine;
122 	int32_t		cbLineOffset;
123 	int32_t		idnMax;
124 	int32_t		cbDnOffset;
125 	int32_t		ipdMax;
126 	int32_t		cbPdOffset;
127 	int32_t		isymMax;
128 	int32_t		cbSymOffset;
129 	int32_t		ioptMax;
130 	int32_t		cbOptOffset;
131 	int32_t		iauxMax;
132 	int32_t		cbAuxOffset;
133 	int32_t		issMax;
134 	int32_t		cbSsOffset;
135 	int32_t		issExtMax;
136 	int32_t		cbSsExtOffset;
137 	int32_t		ifdMax;
138 	int32_t		cbFdOffset;
139 	int32_t		crfd;
140 	int32_t		cbRfdOffset;
141 	int32_t		iextMax;
142 	int32_t		cbExtOffset;
143 };
144 
145 /* Macro for field name used by cgd's Alpha-derived code */
146 #define esymMax iextMax
147 
148 
149 struct ecoff_extsym {
150 	u_int16_t	es_flags;
151 	u_int16_t	es_ifd;
152 	int32_t		es_strindex;
153 	int32_t		es_value;
154 	unsigned	es_type:6;
155 	unsigned	es_class:5;
156 	unsigned	:1;
157 	unsigned	es_symauxindex:20;
158 };
159 
160 struct ecoff32_extsym {
161 	uint16_t	es_flags;
162 	uint16_t	es_ifd;
163 	int32_t		es_strindex;
164 	int32_t		es_value;
165 	unsigned	es_type:6;
166 	unsigned	es_class:5;
167 	unsigned	:1;
168 	unsigned	es_symauxindex:20;
169 };
170