record that files were removed
[deliverable/binutils-gdb.git] / gas / a.out.gnu.h
CommitLineData
01170860
RP
1/* This file is a.out.gnu.h
2
3 Copyright (C) 1987-1992 Free Software Foundation, Inc.
4
5 This file is part of GAS, the GNU Assembler.
6
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.
11
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.
16
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
61a153e5
RP
21#ifndef __A_OUT_GNU_H__
22#define __A_OUT_GNU_H__
23
af483be8 24#include "aout/reloc.h"
61a153e5
RP
25
26#define __GNU_EXEC_MACROS__
27
28#ifndef __STRUCT_EXEC_OVERRIDE__
29
bad3df67
JG
30/* This is the layout on disk of a Unix V7, Berkeley, SunOS, Vax Ultrix
31 "struct exec". Don't assume that on this machine, the "struct exec"
32 will lay out the same sizes or alignments. */
33
34struct exec_bytes {
a39116f1
RP
35 unsigned char a_info[4];
36 unsigned char a_text[4];
37 unsigned char a_data[4];
38 unsigned char a_bss[4];
39 unsigned char a_syms[4];
40 unsigned char a_entry[4];
41 unsigned char a_trsize[4];
42 unsigned char a_drsize[4];
bad3df67
JG
43};
44
45/* How big the "struct exec" is on disk */
46#define EXEC_BYTES_SIZE (8 * 4)
47
48/* This is the layout in memory of a "struct exec" while we process it. */
49
61a153e5
RP
50struct exec
51{
a39116f1
RP
52 unsigned long a_info; /* Use macros N_MAGIC, etc for access */
53 unsigned a_text; /* length of text, in bytes */
54 unsigned a_data; /* length of data, in bytes */
55 unsigned a_bss; /* length of uninitialized data area for file, in bytes */
56 unsigned a_syms; /* length of symbol table data in file, in bytes */
57 unsigned a_entry; /* start address */
58 unsigned a_trsize; /* length of relocation info for text, in bytes */
59 unsigned a_drsize; /* length of relocation info for data, in bytes */
61a153e5
RP
60};
61
62#endif /* __STRUCT_EXEC_OVERRIDE__ */
63
64/* these go in the N_MACHTYPE field */
65/* These symbols could be defined by code from Suns...punt 'em */
bad3df67 66#undef M_UNKNOWN
61a153e5
RP
67#undef M_68010
68#undef M_68020
69#undef M_SPARC
70enum machine_type {
a39116f1
RP
71 M_UNKNOWN = 0,
72 M_68010 = 1,
73 M_68020 = 2,
74 M_SPARC = 3,
75 /* skip a bunch so we don't run into any of sun's numbers */
76 M_386 = 100,
77 M_29K = 101,
78 M_RS6000 = 102, /* IBM RS/6000 */
79 /* HP/BSD formats */
80 M_HP200 = 200, /* hp200 (68010) BSD binary */
81 M_HP300 = 300, /* hp300 (68020+68881) BSD binary */
82 M_HPUX23 = 0x020C, /* hp200/300 HPUX binary */
61a153e5
RP
83};
84
85#define N_MAGIC(exec) ((exec).a_info & 0xffff)
86#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
87#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
88#define N_SET_INFO(exec, magic, type, flags) \
a39116f1
RP
89 ((exec).a_info = ((magic) & 0xffff) \
90 | (((int)(type) & 0xff) << 16) \
91 | (((flags) & 0xff) << 24))
61a153e5 92#define N_SET_MAGIC(exec, magic) \
a39116f1 93 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
61a153e5
RP
94
95#define N_SET_MACHTYPE(exec, machtype) \
a39116f1
RP
96 ((exec).a_info = \
97 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
61a153e5
RP
98
99#define N_SET_FLAGS(exec, flags) \
a39116f1
RP
100 ((exec).a_info = \
101 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
61a153e5
RP
102
103/* Code indicating object file or impure executable. */
104#define OMAGIC 0407
105/* Code indicating pure executable. */
106#define NMAGIC 0410
107/* Code indicating demand-paged executable. */
108#define ZMAGIC 0413
109
bad3df67
JG
110/* Virtual Address of text segment from the a.out file. For OMAGIC,
111 (almost always "unlinked .o's" these days), should be zero.
bad3df67
JG
112 For linked files, should reflect reality if we know it. */
113
114#ifndef N_TXTADDR
66d4e1bb
JG
115#define N_TXTADDR(x) (N_MAGIC(x)==OMAGIC? 0 : TEXT_START_ADDR)
116#endif
117
118#ifndef N_BADMAG
119#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
a39116f1
RP
120 && N_MAGIC(x) != NMAGIC \
121 && N_MAGIC(x) != ZMAGIC)
66d4e1bb
JG
122#endif
123
d7f8f106
JG
124/* By default, segment size is constant. But on some machines, it can
125 be a function of the a.out header (e.g. machine type). */
126#ifndef N_SEGSIZE
127#define N_SEGSIZE(x) SEGMENT_SIZE
128#endif
a39116f1
RP
129
130 /* This complexity is for encapsulated COFF support */
66d4e1bb 131#ifndef _N_HDROFF
d7f8f106 132#define _N_HDROFF(x) (N_SEGSIZE(x) - sizeof (struct exec))
66d4e1bb
JG
133#endif
134
135#ifndef N_TXTOFF
136#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \
a39116f1
RP
137 _N_HDROFF((x)) + sizeof (struct exec) : \
138 sizeof (struct exec))
66d4e1bb
JG
139#endif
140
141
142#ifndef N_DATOFF
143#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
144#endif
145
146#ifndef N_TRELOFF
147#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
148#endif
149
150#ifndef N_DRELOFF
151#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
bad3df67 152#endif
61a153e5 153
66d4e1bb
JG
154#ifndef N_SYMOFF
155#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
61a153e5 156#endif
66d4e1bb
JG
157
158#ifndef N_STROFF
159#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
61a153e5 160#endif
66d4e1bb
JG
161
162/* Address of text segment in memory after it is loaded. */
163#ifndef N_TXTADDR
164#define N_TXTADDR(x) 0
61a153e5 165#endif
a39116f1 166
61a153e5
RP
167#ifndef N_DATADDR
168#define N_DATADDR(x) \
bad3df67 169 (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
d7f8f106 170 : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1))))
61a153e5
RP
171#endif
172
173/* Address of bss segment in memory after it is loaded. */
174#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
175\f
176struct nlist {
a39116f1
RP
177 union {
178 char *n_name;
179 struct nlist *n_next;
180 long n_strx;
181 } n_un;
182 unsigned char n_type;
183 char n_other;
184 short n_desc;
185 unsigned long n_value;
61a153e5
RP
186};
187
188#define N_UNDF 0
189#define N_ABS 2
190#define N_TEXT 4
191#define N_DATA 6
192#define N_BSS 8
e557edcf 193#define N_COMM 0x12 /* common (visible in shared lib commons) */
30c52cdf 194#define N_FN 0x1F /* File name of a .o file */
61a153e5 195
30c52cdf
JG
196/* Note: N_EXT can only usefully be OR-ed with N_UNDF, N_ABS, N_TEXT,
197 N_DATA, or N_BSS. When the low-order bit of other types is set,
198 (e.g. N_WARNING versus N_FN), they are two different types. */
61a153e5
RP
199#define N_EXT 1
200#define N_TYPE 036
201#define N_STAB 0340
202
203/* The following type indicates the definition of a symbol as being
204 an indirect reference to another symbol. The other symbol
205 appears as an undefined reference, immediately following this symbol.
a39116f1 206
61a153e5
RP
207 Indirection is asymmetrical. The other symbol's value will be used
208 to satisfy requests for the indirect symbol, but not vice versa.
209 If the other symbol does not have a definition, libraries will
210 be searched to find a definition. */
e929a4c5 211
9bbfd057 212#define N_INDR 0xa
61a153e5
RP
213
214/* The following symbols refer to set elements.
215 All the N_SET[ATDB] symbols with the same name form one set.
216 Space is allocated for the set in the text section, and each set
217 element's value is stored into one word of the space.
218 The first word of the space is the length of the set (number of elements).
a39116f1 219
61a153e5
RP
220 The address of the set is made into an N_SETV symbol
221 whose name is the same as the name of the set.
222 This symbol acts like a N_DATA global symbol
223 in that it can satisfy undefined external references. */
224
225/* These appear as input to LD, in a .o file. */
226#define N_SETA 0x14 /* Absolute set element symbol */
227#define N_SETT 0x16 /* Text set element symbol */
228#define N_SETD 0x18 /* Data set element symbol */
229#define N_SETB 0x1A /* Bss set element symbol */
230
231/* This is output from LD. */
232#define N_SETV 0x1C /* Pointer to set vector in data area. */
e557edcf
JG
233
234/* Warning symbol. The text gives a warning message, the next symbol
235 in the table will be undefined. When the symbol is referenced, the
236 message is printed. */
237
238#define N_WARNING 0x1e
61a153e5
RP
239\f
240/* This structure describes a single relocation to be performed.
241 The text-relocation section of the file is a vector of these structures,
242 all of which apply to the text section.
243 Likewise, the data-relocation section applies to the data section. */
244
bad3df67
JG
245/* The following enum and struct were borrowed from SunOS's
246 /usr/include/sun4/a.out.h and extended to handle
247 other machines. It is currently used on SPARC and AMD 29000.
a39116f1 248
bad3df67
JG
249 reloc_ext_bytes is how it looks on disk. reloc_info_extended is
250 how we might process it on a native host. */
61a153e5 251
bad3df67 252struct reloc_ext_bytes {
a39116f1
RP
253 unsigned char r_address[4];
254 unsigned char r_index[3];
255 unsigned char r_bits[1];
256 unsigned char r_addend[4];
61a153e5
RP
257};
258
bad3df67
JG
259#define RELOC_EXT_BITS_EXTERN_BIG 0x80
260#define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
261
262#define RELOC_EXT_BITS_TYPE_BIG 0x1F
263#define RELOC_EXT_BITS_TYPE_SH_BIG 0
264#define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
265#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
266
267#define RELOC_EXT_SIZE 12 /* Bytes per relocation entry */
61a153e5
RP
268
269struct reloc_info_extended
270{
a39116f1
RP
271 unsigned long r_address;
272 unsigned int r_index:24;
61a153e5 273# define r_symbolnum r_index
a39116f1
RP
274 unsigned r_extern:1;
275 unsigned :2;
276 /* RS/6000 compiler does not support enum bitfield
277 enum reloc_type r_type:5; */
278 enum reloc_type r_type;
279 long int r_addend;
61a153e5
RP
280};
281
bad3df67
JG
282/* The standard, old-fashioned, Berkeley compatible relocation struct */
283
284struct reloc_std_bytes {
a39116f1
RP
285 unsigned char r_address[4];
286 unsigned char r_index[3];
287 unsigned char r_bits[1];
61a153e5
RP
288};
289
bad3df67
JG
290#define RELOC_STD_BITS_PCREL_BIG 0x80
291#define RELOC_STD_BITS_PCREL_LITTLE 0x01
292
293#define RELOC_STD_BITS_LENGTH_BIG 0x60
294#define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
295#define RELOC_STD_BITS_LENGTH_LITTLE 0x06
296#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
297
298#define RELOC_STD_BITS_EXTERN_BIG 0x10
299#define RELOC_STD_BITS_EXTERN_LITTLE 0x08
300
301#define RELOC_STD_BITS_BASEREL_BIG 0x08
302#define RELOC_STD_BITS_BASEREL_LITTLE 0x08
303
304#define RELOC_STD_BITS_JMPTABLE_BIG 0x04
305#define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
306
307#define RELOC_STD_BITS_RELATIVE_BIG 0x02
308#define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
61a153e5 309
bad3df67 310#define RELOC_STD_SIZE 8 /* Bytes per relocation entry */
61a153e5 311
f0494a6e 312#ifndef CUSTOM_RELOC_FORMAT
61a153e5
RP
313struct relocation_info
314{
a39116f1
RP
315 /* Address (within segment) to be relocated. */
316 int r_address;
317 /* The meaning of r_symbolnum depends on r_extern. */
318 unsigned int r_symbolnum:24;
319 /* Nonzero means value is a pc-relative offset
320 and it should be relocated for changes in its own address
321 as well as for changes in the symbol or section specified. */
322 unsigned int r_pcrel:1;
323 /* Length (as exponent of 2) of the field to be relocated.
324 Thus, a value of 2 indicates 1<<2 bytes. */
325 unsigned int r_length:2;
326 /* 1 => relocate with value of symbol.
327 r_symbolnum is the index of the symbol
328 in file's the symbol table.
329 0 => relocate with the address of a segment.
330 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
331 (the N_EXT bit may be set also, but signifies nothing). */
332 unsigned int r_extern:1;
333 /* The next three bits are for SunOS shared libraries, and seem to
334 be undocumented. */
335 unsigned int r_baserel:1; /* Linkage table relative */
336 unsigned int r_jmptable:1; /* pc-relative to jump table */
337
f827120d
RP
338#ifdef TC_NS32K
339#define r_bsr r_baserel
340#define r_disp r_jmptable
341#endif /* TC_NS32K */
a39116f1
RP
342
343 unsigned int r_relative:1; /* "relative relocation" */
344 /* unused */
345 unsigned int r_pad:1; /* Padding -- set to zero */
61a153e5 346};
f0494a6e 347#endif /* CUSTOM_RELOC_FORMAT */
61a153e5 348
61a153e5 349#endif /* __A_OUT_GNU_H__ */
a39116f1
RP
350
351/* end of a.out.gnu.h */
This page took 0.056404 seconds and 4 git commands to generate.