* configure.in: Define DEFAULT_ARCH for i386.
[binutils.git] / gas / config / aout_gnu.h
blob52ea70d28847c36b782d545341c58898c3177487
1 /* This file is aout_gnu.h
3 Copyright (C) 1987-1992 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #ifndef __A_OUT_GNU_H__
22 #define __A_OUT_GNU_H__
24 /* There are two main flavours of a.out, one which uses the standard
25 relocations, and one which uses extended relocations.
27 Today, the extended reloc uses are
28 TC_SPARC, TC_A29K
30 each must define the enum reloc_type
34 #define USE_EXTENDED_RELOC (defined(TC_SPARC) || defined(TC_A29K))
36 #if defined(TC_SPARC) || defined(TC_A29K)
37 enum reloc_type
39 RELOC_8, RELOC_16, RELOC_32,/* simple relocations */
40 RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, /* pc-rel displacement */
41 RELOC_WDISP30, RELOC_WDISP22,
42 RELOC_HI22, RELOC_22,
43 RELOC_13, RELOC_LO10,
44 RELOC_SFA_BASE, RELOC_SFA_OFF13,
45 RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, /* P.I.C. (base-relative) */
46 RELOC_PC10, RELOC_PC22, /* for some sort of pc-rel P.I.C. (?) */
47 RELOC_JMP_TBL, /* P.I.C. jump table */
48 RELOC_SEGOFF16, /* reputedly for shared libraries somehow */
49 RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
50 RELOC_10, RELOC_11,
51 RELOC_WDISP2_14,
52 RELOC_WDISP19,
53 RELOC_HHI22,
54 RELOC_HLO10,
56 /* 29K relocation types */
57 RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
59 RELOC_WDISP14, RELOC_WDISP21,
61 NO_RELOC
64 #endif /* TC_SPARC or TC_A29K */
66 #define __GNU_EXEC_MACROS__
68 #ifndef __STRUCT_EXEC_OVERRIDE__
70 /* This is the layout on disk of a Unix V7, Berkeley, SunOS, Vax Ultrix
71 "struct exec". Don't assume that on this machine, the "struct exec"
72 will lay out the same sizes or alignments. */
74 struct exec_bytes
76 unsigned char a_info[4];
77 unsigned char a_text[4];
78 unsigned char a_data[4];
79 unsigned char a_bss[4];
80 unsigned char a_syms[4];
81 unsigned char a_entry[4];
82 unsigned char a_trsize[4];
83 unsigned char a_drsize[4];
86 /* How big the "struct exec" is on disk */
87 #define EXEC_BYTES_SIZE (8 * 4)
89 /* This is the layout in memory of a "struct exec" while we process it. */
91 struct exec
93 unsigned long a_info; /* Use macros N_MAGIC, etc for access */
94 unsigned a_text; /* length of text, in bytes */
95 unsigned a_data; /* length of data, in bytes */
96 unsigned a_bss; /* length of uninitialized data area for file, in bytes */
97 unsigned a_syms; /* length of symbol table data in file, in bytes */
98 unsigned a_entry; /* start address */
99 unsigned a_trsize; /* length of relocation info for text, in bytes */
100 unsigned a_drsize; /* length of relocation info for data, in bytes */
103 #endif /* __STRUCT_EXEC_OVERRIDE__ */
105 /* these go in the N_MACHTYPE field */
106 /* These symbols could be defined by code from Suns...punt 'em */
107 #undef M_UNKNOWN
108 #undef M_68010
109 #undef M_68020
110 #undef M_SPARC
111 enum machine_type
113 M_UNKNOWN = 0,
114 M_68010 = 1,
115 M_68020 = 2,
116 M_SPARC = 3,
117 /* skip a bunch so we don't run into any of sun's numbers */
118 M_386 = 100,
119 M_29K = 101,
120 M_RS6000 = 102, /* IBM RS/6000 */
121 /* HP/BSD formats */
122 M_HP200 = 200, /* hp200 (68010) BSD binary */
123 M_HP300 = 300, /* hp300 (68020+68881) BSD binary */
124 M_HPUX23 = 0x020C /* hp200/300 HPUX binary */
127 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
128 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
129 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
130 #define N_SET_INFO(exec, magic, type, flags) \
131 ((exec).a_info = ((magic) & 0xffff) \
132 | (((int)(type) & 0xff) << 16) \
133 | (((flags) & 0xff) << 24))
134 #define N_SET_MAGIC(exec, magic) \
135 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
137 #define N_SET_MACHTYPE(exec, machtype) \
138 ((exec).a_info = \
139 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
141 #define N_SET_FLAGS(exec, flags) \
142 ((exec).a_info = \
143 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
145 /* Code indicating object file or impure executable. */
146 #ifndef OMAGIC
147 #define OMAGIC 0407
148 #endif
149 /* Code indicating pure executable. */
150 #define NMAGIC 0410
151 /* Code indicating demand-paged executable. */
152 #define ZMAGIC 0413
154 /* Virtual Address of text segment from the a.out file. For OMAGIC,
155 (almost always "unlinked .o's" these days), should be zero.
156 For linked files, should reflect reality if we know it. */
158 #ifndef N_TXTADDR
159 #define N_TXTADDR(x) (N_MAGIC(x)==OMAGIC? 0 : TEXT_START_ADDR)
160 #endif
162 #ifndef N_BADMAG
163 #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
164 && N_MAGIC(x) != NMAGIC \
165 && N_MAGIC(x) != ZMAGIC)
166 #endif
168 /* By default, segment size is constant. But on some machines, it can
169 be a function of the a.out header (e.g. machine type). */
170 #ifndef N_SEGSIZE
171 #define N_SEGSIZE(x) SEGMENT_SIZE
172 #endif
174 /* This complexity is for encapsulated COFF support */
175 #ifndef _N_HDROFF
176 #define _N_HDROFF(x) (N_SEGSIZE(x) - sizeof (struct exec))
177 #endif
179 #ifndef N_TXTOFF
180 #define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \
181 _N_HDROFF((x)) + sizeof (struct exec) : \
182 sizeof (struct exec))
183 #endif
185 #ifndef N_DATOFF
186 #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
187 #endif
189 #ifndef N_TRELOFF
190 #define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
191 #endif
193 #ifndef N_DRELOFF
194 #define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
195 #endif
197 #ifndef N_SYMOFF
198 #define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
199 #endif
201 #ifndef N_STROFF
202 #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
203 #endif
205 /* Address of text segment in memory after it is loaded. */
206 #ifndef N_TXTADDR
207 #define N_TXTADDR(x) 0
208 #endif
210 #ifndef N_DATADDR
211 #define N_DATADDR(x) \
212 (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
213 : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1))))
214 #endif
216 /* Address of bss segment in memory after it is loaded. */
217 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
219 struct nlist
221 union
223 char *n_name;
224 struct nlist *n_next;
225 long n_strx;
227 n_un;
228 unsigned char n_type;
229 char n_other;
230 short n_desc;
231 unsigned long n_value;
234 #define N_UNDF 0
235 #define N_ABS 2
236 #define N_TEXT 4
237 #define N_DATA 6
238 #define N_BSS 8
239 #define N_COMM 0x12 /* common (visible in shared lib commons) */
240 #define N_FN 0x1F /* File name of a .o file */
242 /* Note: N_EXT can only usefully be OR-ed with N_UNDF, N_ABS, N_TEXT,
243 N_DATA, or N_BSS. When the low-order bit of other types is set,
244 (e.g. N_WARNING versus N_FN), they are two different types. */
245 #define N_EXT 1
246 #define N_TYPE 036
247 #define N_STAB 0340
249 /* The following type indicates the definition of a symbol as being
250 an indirect reference to another symbol. The other symbol
251 appears as an undefined reference, immediately following this symbol.
253 Indirection is asymmetrical. The other symbol's value will be used
254 to satisfy requests for the indirect symbol, but not vice versa.
255 If the other symbol does not have a definition, libraries will
256 be searched to find a definition. */
258 #define N_INDR 0xa
260 /* The following symbols refer to set elements.
261 All the N_SET[ATDB] symbols with the same name form one set.
262 Space is allocated for the set in the text section, and each set
263 element's value is stored into one word of the space.
264 The first word of the space is the length of the set (number of elements).
266 The address of the set is made into an N_SETV symbol
267 whose name is the same as the name of the set.
268 This symbol acts like a N_DATA global symbol
269 in that it can satisfy undefined external references. */
271 /* These appear as input to LD, in a .o file. */
272 #define N_SETA 0x14 /* Absolute set element symbol */
273 #define N_SETT 0x16 /* Text set element symbol */
274 #define N_SETD 0x18 /* Data set element symbol */
275 #define N_SETB 0x1A /* Bss set element symbol */
277 /* This is output from LD. */
278 #define N_SETV 0x1C /* Pointer to set vector in data area. */
280 /* Warning symbol. The text gives a warning message, the next symbol
281 in the table will be undefined. When the symbol is referenced, the
282 message is printed. */
284 #define N_WARNING 0x1e
286 /* Weak symbols. These are a GNU extension to the a.out format. The
287 semantics are those of ELF weak symbols. Weak symbols are always
288 externally visible. The N_WEAK? values are squeezed into the
289 available slots. The value of a N_WEAKU symbol is 0. The values
290 of the other types are the definitions. */
291 #define N_WEAKU 0x0d /* Weak undefined symbol. */
292 #define N_WEAKA 0x0e /* Weak absolute symbol. */
293 #define N_WEAKT 0x0f /* Weak text symbol. */
294 #define N_WEAKD 0x10 /* Weak data symbol. */
295 #define N_WEAKB 0x11 /* Weak bss symbol. */
297 /* This structure describes a single relocation to be performed.
298 The text-relocation section of the file is a vector of these structures,
299 all of which apply to the text section.
300 Likewise, the data-relocation section applies to the data section. */
302 /* The following enum and struct were borrowed from SunOS's
303 /usr/include/sun4/a.out.h and extended to handle
304 other machines. It is currently used on SPARC and AMD 29000.
306 reloc_ext_bytes is how it looks on disk. reloc_info_extended is
307 how we might process it on a native host. */
308 #if USE_EXTENDED_RELOC
310 struct reloc_ext_bytes
312 unsigned char r_address[4];
313 unsigned char r_index[3];
314 unsigned char r_bits[1];
315 unsigned char r_addend[4];
318 #define RELOC_EXT_BITS_EXTERN_BIG 0x80
319 #define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
321 #define RELOC_EXT_BITS_TYPE_BIG 0x1F
322 #define RELOC_EXT_BITS_TYPE_SH_BIG 0
323 #define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
324 #define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
326 #define RELOC_EXT_SIZE 12 /* Bytes per relocation entry */
328 struct reloc_info_extended
330 unsigned long r_address;
331 unsigned int r_index:24;
332 # define r_symbolnum r_index
333 unsigned r_extern:1;
334 unsigned:2;
335 /* RS/6000 compiler does not support enum bitfield
336 enum reloc_type r_type:5; */
337 enum reloc_type r_type;
338 long int r_addend;
341 #else
343 /* The standard, old-fashioned, Berkeley compatible relocation struct */
345 #ifdef TC_I860
346 /* NOTE: three bits max, see struct reloc_info_i860.r_type */
347 enum i860_reloc_type
349 NO_RELOC = 0, BRADDR, LOW0, LOW1, LOW2, LOW3, LOW4, SPLIT0, SPLIT1, SPLIT2, RELOC_32,
352 typedef enum i860_reloc_type reloc_type;
354 /* NOTE: two bits max, see reloc_info_i860.r_type */
355 enum highlow_type
357 NO_SPEC = 0, PAIR, HIGH, HIGHADJ,
360 struct reloc_info_i860
362 unsigned long r_address;
364 * Using bit fields here is a bad idea because the order is not portable. :-(
366 unsigned int r_symbolnum:24;
367 unsigned int r_pcrel:1;
368 unsigned int r_extern:1;
369 /* combining the two field simplifies the argument passing in "new_fix()" */
370 /* and is compatible with the existing Sparc #ifdef's */
371 /* r_type: highlow_type - bits 5,4; reloc_type - bits 3-0 */
372 unsigned int r_type:6;
373 long r_addend;
376 #endif /* TC_I860 */
378 struct reloc_std_bytes
380 unsigned char r_address[4];
381 unsigned char r_index[3];
382 unsigned char r_bits[1];
385 #define RELOC_STD_BITS_PCREL_BIG 0x80
386 #define RELOC_STD_BITS_PCREL_LITTLE 0x01
388 #define RELOC_STD_BITS_LENGTH_BIG 0x60
389 #define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
390 #define RELOC_STD_BITS_LENGTH_LITTLE 0x06
391 #define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
393 #define RELOC_STD_BITS_EXTERN_BIG 0x10
394 #define RELOC_STD_BITS_EXTERN_LITTLE 0x08
396 #define RELOC_STD_BITS_BASEREL_BIG 0x08
397 #define RELOC_STD_BITS_BASEREL_LITTLE 0x08
399 #define RELOC_STD_BITS_JMPTABLE_BIG 0x04
400 #define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
402 #define RELOC_STD_BITS_RELATIVE_BIG 0x02
403 #define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
405 #define RELOC_STD_SIZE 8 /* Bytes per relocation entry */
407 #endif /* USE_EXTENDED_RELOC */
409 #ifndef CUSTOM_RELOC_FORMAT
410 struct relocation_info
412 /* Address (within segment) to be relocated. */
413 int r_address;
414 /* The meaning of r_symbolnum depends on r_extern. */
415 unsigned int r_symbolnum:24;
416 /* Nonzero means value is a pc-relative offset
417 and it should be relocated for changes in its own address
418 as well as for changes in the symbol or section specified. */
419 unsigned int r_pcrel:1;
420 /* Length (as exponent of 2) of the field to be relocated.
421 Thus, a value of 2 indicates 1<<2 bytes. */
422 unsigned int r_length:2;
423 /* 1 => relocate with value of symbol.
424 r_symbolnum is the index of the symbol
425 in file's the symbol table.
426 0 => relocate with the address of a segment.
427 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
428 (the N_EXT bit may be set also, but signifies nothing). */
429 unsigned int r_extern:1;
430 /* The next three bits are for SunOS shared libraries, and seem to
431 be undocumented. */
432 #ifdef TC_NS32K
433 unsigned int r_bsr:1;
434 unsigned int r_disp:2;
435 #else
436 unsigned int r_baserel:1; /* Linkage table relative */
437 unsigned int r_jmptable:1; /* pc-relative to jump table */
438 unsigned int r_relative:1; /* "relative relocation" */
439 #endif /* TC_NS32K */
440 /* unused */
441 unsigned int r_pad:1; /* Padding -- set to zero */
444 #endif /* CUSTOM_RELOC_FORMAT */
446 #endif /* __A_OUT_GNU_H__ */
448 /* end of aout_gnu.h */