1 | /*
|
---|
2 | * MINIX 1.7.x
|
---|
3 | * GNU version based on Linux 1.1.45 version
|
---|
4 | * if _MINIX_EXEC defined use old MINIX GNU format
|
---|
5 | */
|
---|
6 |
|
---|
7 | #ifndef __A_OUT_GNU_H__
|
---|
8 | #define __A_OUT_GNU_H__
|
---|
9 |
|
---|
10 | #define __GNU_EXEC_MACROS__
|
---|
11 |
|
---|
12 | #ifndef __STRUCT_EXEC_OVERRIDE__
|
---|
13 |
|
---|
14 | struct exec
|
---|
15 | {
|
---|
16 | unsigned long a_info; /* Use macros N_MAGIC, etc for access */
|
---|
17 | unsigned a_text; /* length of text, in bytes */
|
---|
18 | unsigned a_data; /* length of data, in bytes */
|
---|
19 | unsigned a_bss; /* length of uninitialized data area for file, in bytes */
|
---|
20 | unsigned a_syms; /* length of symbol table data in file, in bytes */
|
---|
21 | unsigned a_entry; /* start address */
|
---|
22 | unsigned a_trsize; /* length of relocation info for text, in bytes */
|
---|
23 | unsigned a_drsize; /* length of relocation info for data, in bytes */
|
---|
24 | #ifdef _MINIX_EXEC
|
---|
25 | unsigned a_smagic; /* SMAGIC */
|
---|
26 | unsigned a_memsize; /* Dynamic Memory Size */
|
---|
27 | #endif
|
---|
28 | };
|
---|
29 |
|
---|
30 | #ifdef _MINIX_EXEC
|
---|
31 | #define GNU_SMAGIC 0xdeadbabe
|
---|
32 | #define GNU_DYNMEM (64 * 1024)
|
---|
33 | #else
|
---|
34 | #define GNU_STACK 64 /* Default Stack */
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #endif /* __STRUCT_EXEC_OVERRIDE__ */
|
---|
38 |
|
---|
39 | /* these go in the N_MACHTYPE field */
|
---|
40 | enum machine_type {
|
---|
41 | #if defined (M_OLDSUN2)
|
---|
42 | M__OLDSUN2 = M_OLDSUN2,
|
---|
43 | #else
|
---|
44 | M_OLDSUN2 = 0,
|
---|
45 | #endif
|
---|
46 | #if defined (M_68010)
|
---|
47 | M__68010 = M_68010,
|
---|
48 | #else
|
---|
49 | M_68010 = 1,
|
---|
50 | #endif
|
---|
51 | #if defined (M_68020)
|
---|
52 | M__68020 = M_68020,
|
---|
53 | #else
|
---|
54 | M_68020 = 2,
|
---|
55 | #endif
|
---|
56 | #if defined (M_SPARC)
|
---|
57 | M__SPARC = M_SPARC,
|
---|
58 | #else
|
---|
59 | M_SPARC = 3,
|
---|
60 | #endif
|
---|
61 | /* skip a bunch so we don't run into any of sun's numbers */
|
---|
62 | M_386 = 100
|
---|
63 | };
|
---|
64 |
|
---|
65 | #if !defined (N_MAGIC)
|
---|
66 | #define N_MAGIC(exec) ((exec).a_info & 0xffff)
|
---|
67 | #endif
|
---|
68 | #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
|
---|
69 | #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
|
---|
70 | #define N_SET_INFO(exec, magic, type, flags) \
|
---|
71 | ((exec).a_info = ((magic) & 0xffff) \
|
---|
72 | | (((int)(type) & 0xff) << 16) \
|
---|
73 | | (((flags) & 0xff) << 24))
|
---|
74 | #define N_SET_MAGIC(exec, magic) \
|
---|
75 | ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
|
---|
76 |
|
---|
77 | #define N_SET_MACHTYPE(exec, machtype) \
|
---|
78 | ((exec).a_info = \
|
---|
79 | ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
|
---|
80 |
|
---|
81 | #define N_SET_FLAGS(exec, flags) \
|
---|
82 | ((exec).a_info = \
|
---|
83 | ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
|
---|
84 |
|
---|
85 | #ifdef _MINIX
|
---|
86 | #define N_SET_MEMORY(exec, mem) \
|
---|
87 | ((exec).a_info = \
|
---|
88 | ((exec).a_info & 0x0000FFFF) | (((mem) & 0xFFFF) << 16))
|
---|
89 | #define N_MEMORY(exec) (((exec).a_info >> 16) & 0xFFFF)
|
---|
90 | #endif
|
---|
91 |
|
---|
92 | /* Code indicating object file or impure executable. */
|
---|
93 | #define OMAGIC 0407
|
---|
94 | /* Code indicating pure executable. */
|
---|
95 | #define NMAGIC 0410
|
---|
96 | /* Code indicating demand-paged executable. */
|
---|
97 | #define ZMAGIC 0413
|
---|
98 | /* This indicates a demand-paged executable with the header in the text.
|
---|
99 | The first page is unmapped to help trap NULL pointer references */
|
---|
100 | #define QMAGIC 0314
|
---|
101 |
|
---|
102 | /* Code indicating core file. */
|
---|
103 | #define CMAGIC 0421
|
---|
104 |
|
---|
105 | #if !defined (N_BADMAG)
|
---|
106 | #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
|
---|
107 | && N_MAGIC(x) != NMAGIC \
|
---|
108 | && N_MAGIC(x) != ZMAGIC \
|
---|
109 | && N_MAGIC(x) != QMAGIC)
|
---|
110 | #endif
|
---|
111 |
|
---|
112 | #define _N_HDROFF(x) (1024 - sizeof (struct exec))
|
---|
113 |
|
---|
114 | #if !defined (N_TXTOFF)
|
---|
115 | #define N_TXTOFF(x) \
|
---|
116 | (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
|
---|
117 | (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | #if !defined (N_DATOFF)
|
---|
121 | #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | #if !defined (N_TRELOFF)
|
---|
125 | #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
|
---|
126 | #endif
|
---|
127 |
|
---|
128 | #if !defined (N_DRELOFF)
|
---|
129 | #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
|
---|
130 | #endif
|
---|
131 |
|
---|
132 | #if !defined (N_SYMOFF)
|
---|
133 | #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
|
---|
134 | #endif
|
---|
135 |
|
---|
136 | #if !defined (N_STROFF)
|
---|
137 | #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
|
---|
138 | #endif
|
---|
139 |
|
---|
140 | /* Address of text segment in memory after it is loaded. */
|
---|
141 | #if !defined (N_TXTADDR)
|
---|
142 | #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | /* Address of data segment in memory after it is loaded.
|
---|
146 | Note that it is up to you to define SEGMENT_SIZE
|
---|
147 | on machines not listed here. */
|
---|
148 | #if defined(vax) || defined(hp300) || defined(pyr)
|
---|
149 | #define SEGMENT_SIZE page_size
|
---|
150 | #endif
|
---|
151 | #ifdef sony
|
---|
152 | #define SEGMENT_SIZE 0x2000
|
---|
153 | #endif /* Sony. */
|
---|
154 | #ifdef is68k
|
---|
155 | #define SEGMENT_SIZE 0x20000
|
---|
156 | #endif
|
---|
157 | #if defined(m68k) && defined(PORTAR)
|
---|
158 | #define PAGE_SIZE 0x400
|
---|
159 | #define SEGMENT_SIZE PAGE_SIZE
|
---|
160 | #endif
|
---|
161 |
|
---|
162 | #ifndef PAGE_SIZE
|
---|
163 | #define PAGE_SIZE 1024
|
---|
164 | #endif
|
---|
165 |
|
---|
166 | #ifndef SEGMENT_SIZE
|
---|
167 | #define SEGMENT_SIZE PAGE_SIZE
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
|
---|
171 |
|
---|
172 | #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
|
---|
173 |
|
---|
174 | #ifndef N_DATADDR
|
---|
175 | #define N_DATADDR(x) \
|
---|
176 | (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
|
---|
177 | : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
|
---|
178 | #endif
|
---|
179 |
|
---|
180 | /* Address of bss segment in memory after it is loaded. */
|
---|
181 | #if !defined (N_BSSADDR)
|
---|
182 | #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
|
---|
183 | #endif
|
---|
184 | |
---|
185 |
|
---|
186 | #if !defined (N_NLIST_DECLARED)
|
---|
187 | struct nlist {
|
---|
188 | union {
|
---|
189 | char *n_name;
|
---|
190 | struct nlist *n_next;
|
---|
191 | long n_strx;
|
---|
192 | } n_un;
|
---|
193 | unsigned char n_type;
|
---|
194 | char n_other;
|
---|
195 | short n_desc;
|
---|
196 | unsigned long n_value;
|
---|
197 | };
|
---|
198 | #endif /* no N_NLIST_DECLARED. */
|
---|
199 |
|
---|
200 | #if !defined (N_UNDF)
|
---|
201 | #define N_UNDF 0
|
---|
202 | #endif
|
---|
203 | #if !defined (N_ABS)
|
---|
204 | #define N_ABS 2
|
---|
205 | #endif
|
---|
206 | #if !defined (N_TEXT)
|
---|
207 | #define N_TEXT 4
|
---|
208 | #endif
|
---|
209 | #if !defined (N_DATA)
|
---|
210 | #define N_DATA 6
|
---|
211 | #endif
|
---|
212 | #if !defined (N_BSS)
|
---|
213 | #define N_BSS 8
|
---|
214 | #endif
|
---|
215 | #if !defined (N_FN)
|
---|
216 | #define N_FN 15
|
---|
217 | #endif
|
---|
218 |
|
---|
219 | #if !defined (N_EXT)
|
---|
220 | #define N_EXT 1
|
---|
221 | #endif
|
---|
222 | #if !defined (N_TYPE)
|
---|
223 | #define N_TYPE 036
|
---|
224 | #endif
|
---|
225 | #if !defined (N_STAB)
|
---|
226 | #define N_STAB 0340
|
---|
227 | #endif
|
---|
228 |
|
---|
229 | /* The following type indicates the definition of a symbol as being
|
---|
230 | an indirect reference to another symbol. The other symbol
|
---|
231 | appears as an undefined reference, immediately following this symbol.
|
---|
232 |
|
---|
233 | Indirection is asymmetrical. The other symbol's value will be used
|
---|
234 | to satisfy requests for the indirect symbol, but not vice versa.
|
---|
235 | If the other symbol does not have a definition, libraries will
|
---|
236 | be searched to find a definition. */
|
---|
237 | #define N_INDR 0xa
|
---|
238 |
|
---|
239 | /* The following symbols refer to set elements.
|
---|
240 | All the N_SET[ATDB] symbols with the same name form one set.
|
---|
241 | Space is allocated for the set in the text section, and each set
|
---|
242 | element's value is stored into one word of the space.
|
---|
243 | The first word of the space is the length of the set (number of elements).
|
---|
244 |
|
---|
245 | The address of the set is made into an N_SETV symbol
|
---|
246 | whose name is the same as the name of the set.
|
---|
247 | This symbol acts like a N_DATA global symbol
|
---|
248 | in that it can satisfy undefined external references. */
|
---|
249 |
|
---|
250 | /* These appear as input to LD, in a .o file. */
|
---|
251 | #define N_SETA 0x14 /* Absolute set element symbol */
|
---|
252 | #define N_SETT 0x16 /* Text set element symbol */
|
---|
253 | #define N_SETD 0x18 /* Data set element symbol */
|
---|
254 | #define N_SETB 0x1A /* Bss set element symbol */
|
---|
255 |
|
---|
256 | /* This is output from LD. */
|
---|
257 | #define N_SETV 0x1C /* Pointer to set vector in data area. */
|
---|
258 | |
---|
259 |
|
---|
260 | #if !defined (N_RELOCATION_INFO_DECLARED)
|
---|
261 | /* This structure describes a single relocation to be performed.
|
---|
262 | The text-relocation section of the file is a vector of these structures,
|
---|
263 | all of which apply to the text section.
|
---|
264 | Likewise, the data-relocation section applies to the data section. */
|
---|
265 |
|
---|
266 | struct relocation_info
|
---|
267 | {
|
---|
268 | /* Address (within segment) to be relocated. */
|
---|
269 | int r_address;
|
---|
270 | /* The meaning of r_symbolnum depends on r_extern. */
|
---|
271 | unsigned int r_symbolnum:24;
|
---|
272 | /* Nonzero means value is a pc-relative offset
|
---|
273 | and it should be relocated for changes in its own address
|
---|
274 | as well as for changes in the symbol or section specified. */
|
---|
275 | unsigned int r_pcrel:1;
|
---|
276 | /* Length (as exponent of 2) of the field to be relocated.
|
---|
277 | Thus, a value of 2 indicates 1<<2 bytes. */
|
---|
278 | unsigned int r_length:2;
|
---|
279 | /* 1 => relocate with value of symbol.
|
---|
280 | r_symbolnum is the index of the symbol
|
---|
281 | in file's the symbol table.
|
---|
282 | 0 => relocate with the address of a segment.
|
---|
283 | r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
|
---|
284 | (the N_EXT bit may be set also, but signifies nothing). */
|
---|
285 | unsigned int r_extern:1;
|
---|
286 | /* Four bits that aren't used, but when writing an object file
|
---|
287 | it is desirable to clear them. */
|
---|
288 | #ifdef NS32K
|
---|
289 | unsigned r_bsr:1;
|
---|
290 | unsigned r_disp:1;
|
---|
291 | unsigned r_pad:2;
|
---|
292 | #else
|
---|
293 | unsigned int r_pad:4;
|
---|
294 | #endif
|
---|
295 | };
|
---|
296 | #endif /* no N_RELOCATION_INFO_DECLARED. */
|
---|
297 |
|
---|
298 |
|
---|
299 | #endif /* __A_OUT_GNU_H__ */
|
---|