Merge intel-deliver and amd-deliver "include" directories, and the
[deliverable/binutils-gdb.git] / gas / a.out.gnu.h
1 #ifndef __A_OUT_GNU_H__
2 #define __A_OUT_GNU_H__
3
4 #include "reloc.h"
5
6 #define __GNU_EXEC_MACROS__
7
8 #ifndef __STRUCT_EXEC_OVERRIDE__
9
10 /* This is the layout on disk of a Unix V7, Berkeley, SunOS, Vax Ultrix
11 "struct exec". Don't assume that on this machine, the "struct exec"
12 will lay out the same sizes or alignments. */
13
14 struct exec_bytes {
15 unsigned char a_info[4];
16 unsigned char a_text[4];
17 unsigned char a_data[4];
18 unsigned char a_bss[4];
19 unsigned char a_syms[4];
20 unsigned char a_entry[4];
21 unsigned char a_trsize[4];
22 unsigned char a_drsize[4];
23 };
24
25 /* How big the "struct exec" is on disk */
26 #define EXEC_BYTES_SIZE (8 * 4)
27
28 /* This is the layout in memory of a "struct exec" while we process it. */
29
30 struct exec
31 {
32 unsigned long a_info; /* Use macros N_MAGIC, etc for access */
33 unsigned a_text; /* length of text, in bytes */
34 unsigned a_data; /* length of data, in bytes */
35 unsigned a_bss; /* length of uninitialized data area for file, in bytes */
36 unsigned a_syms; /* length of symbol table data in file, in bytes */
37 unsigned a_entry; /* start address */
38 unsigned a_trsize; /* length of relocation info for text, in bytes */
39 unsigned a_drsize; /* length of relocation info for data, in bytes */
40 };
41
42 #endif /* __STRUCT_EXEC_OVERRIDE__ */
43
44 /* these go in the N_MACHTYPE field */
45 /* These symbols could be defined by code from Suns...punt 'em */
46 #undef M_UNKNOWN
47 #undef M_68010
48 #undef M_68020
49 #undef M_SPARC
50 enum machine_type {
51 M_UNKNOWN = 0,
52 M_68010 = 1,
53 M_68020 = 2,
54 M_SPARC = 3,
55 /* skip a bunch so we don't run into any of sun's numbers */
56 M_386 = 100,
57 M_29K = 101,
58 };
59
60 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
61 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
62 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
63 #define N_SET_INFO(exec, magic, type, flags) \
64 ((exec).a_info = ((magic) & 0xffff) \
65 | (((int)(type) & 0xff) << 16) \
66 | (((flags) & 0xff) << 24))
67 #define N_SET_MAGIC(exec, magic) \
68 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
69
70 #define N_SET_MACHTYPE(exec, machtype) \
71 ((exec).a_info = \
72 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
73
74 #define N_SET_FLAGS(exec, flags) \
75 ((exec).a_info = \
76 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
77
78 /* Code indicating object file or impure executable. */
79 #define OMAGIC 0407
80 /* Code indicating pure executable. */
81 #define NMAGIC 0410
82 /* Code indicating demand-paged executable. */
83 #define ZMAGIC 0413
84
85 /* Address of text segment in memory after it is loaded. */
86 /* Don't load things at zero, it encourages zero-pointer bugs */
87 #ifndef TEXT_START_ADDR
88 #define TEXT_START_ADDR 0x10000
89 #endif
90
91 /* Virtual Address of text segment from the a.out file. For OMAGIC,
92 (almost always "unlinked .o's" these days), should be zero.
93 Sun added a kludge so that shared libraries linked ZMAGIC get
94 an address of zero if a_entry (!!!) is lower than the otherwise
95 expected text address. These kludges have gotta go!
96 For linked files, should reflect reality if we know it. */
97
98 #ifndef N_TXTADDR
99 #define N_TXTADDR(x) \
100 (N_MAGIC(x)==OMAGIC? 0 \
101 : (N_MAGIC(x) == ZMAGIC && (x).a_entry < TEXT_START_ADDR)? 0 \
102 : TEXT_START_ADDR)
103 #endif
104
105 /* Address of data segment in memory after it is loaded.
106 Note that it is up to you to define SEGMENT_SIZE
107 on machines not listed here. */
108 #if defined(hp300) || defined(pyr)
109 #define SEGMENT_SIZE page_size
110 #endif
111 #ifdef sony
112 #define SEGMENT_SIZE 0x2000
113 #endif /* Sony. */
114 #ifdef is68k
115 #define SEGMENT_SIZE 0x20000
116 #endif
117 #if defined(m68k) && defined(PORTAR)
118 #define PAGE_SIZE 0x400
119 #define SEGMENT_SIZE PAGE_SIZE
120 #endif
121
122 #ifndef N_DATADDR
123 #define N_DATADDR(x) \
124 (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
125 : (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
126 #endif
127
128 /* Address of bss segment in memory after it is loaded. */
129 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
130 \f
131 struct nlist {
132 union {
133 char *n_name;
134 struct nlist *n_next;
135 long n_strx;
136 } n_un;
137 unsigned char n_type;
138 char n_other;
139 short n_desc;
140 unsigned long n_value;
141 };
142
143 #define N_UNDF 0
144 #define N_ABS 2
145 #define N_TEXT 4
146 #define N_DATA 6
147 #define N_BSS 8
148 #define N_FN 15
149
150 #define N_EXT 1
151 #define N_TYPE 036
152 #define N_STAB 0340
153
154 /* The following type indicates the definition of a symbol as being
155 an indirect reference to another symbol. The other symbol
156 appears as an undefined reference, immediately following this symbol.
157
158 Indirection is asymmetrical. The other symbol's value will be used
159 to satisfy requests for the indirect symbol, but not vice versa.
160 If the other symbol does not have a definition, libraries will
161 be searched to find a definition. */
162 #define N_INDR 0xa
163
164 /* The following symbols refer to set elements.
165 All the N_SET[ATDB] symbols with the same name form one set.
166 Space is allocated for the set in the text section, and each set
167 element's value is stored into one word of the space.
168 The first word of the space is the length of the set (number of elements).
169
170 The address of the set is made into an N_SETV symbol
171 whose name is the same as the name of the set.
172 This symbol acts like a N_DATA global symbol
173 in that it can satisfy undefined external references. */
174
175 /* These appear as input to LD, in a .o file. */
176 #define N_SETA 0x14 /* Absolute set element symbol */
177 #define N_SETT 0x16 /* Text set element symbol */
178 #define N_SETD 0x18 /* Data set element symbol */
179 #define N_SETB 0x1A /* Bss set element symbol */
180
181 /* This is output from LD. */
182 #define N_SETV 0x1C /* Pointer to set vector in data area. */
183 \f
184 /* This structure describes a single relocation to be performed.
185 The text-relocation section of the file is a vector of these structures,
186 all of which apply to the text section.
187 Likewise, the data-relocation section applies to the data section. */
188
189 /* The following enum and struct were borrowed from SunOS's
190 /usr/include/sun4/a.out.h and extended to handle
191 other machines. It is currently used on SPARC and AMD 29000.
192
193 reloc_ext_bytes is how it looks on disk. reloc_info_extended is
194 how we might process it on a native host. */
195
196 struct reloc_ext_bytes {
197 unsigned char r_address[4];
198 unsigned char r_index[3];
199 unsigned char r_bits[1];
200 unsigned char r_addend[4];
201 };
202
203 #define RELOC_EXT_BITS_EXTERN_BIG 0x80
204 #define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
205
206 #define RELOC_EXT_BITS_TYPE_BIG 0x1F
207 #define RELOC_EXT_BITS_TYPE_SH_BIG 0
208 #define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
209 #define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
210
211 #define RELOC_EXT_SIZE 12 /* Bytes per relocation entry */
212
213 struct reloc_info_extended
214 {
215 unsigned long r_address;
216 unsigned int r_index:24;
217 # define r_symbolnum r_index
218 unsigned r_extern:1;
219 unsigned :2;
220 enum reloc_type r_type:5;
221 long int r_addend;
222 };
223
224 /* The standard, old-fashioned, Berkeley compatible relocation struct */
225
226 struct reloc_std_bytes {
227 unsigned char r_address[4];
228 unsigned char r_index[3];
229 unsigned char r_bits[1];
230 };
231
232 #define RELOC_STD_BITS_PCREL_BIG 0x80
233 #define RELOC_STD_BITS_PCREL_LITTLE 0x01
234
235 #define RELOC_STD_BITS_LENGTH_BIG 0x60
236 #define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
237 #define RELOC_STD_BITS_LENGTH_LITTLE 0x06
238 #define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
239
240 #define RELOC_STD_BITS_EXTERN_BIG 0x10
241 #define RELOC_STD_BITS_EXTERN_LITTLE 0x08
242
243 #define RELOC_STD_BITS_BASEREL_BIG 0x08
244 #define RELOC_STD_BITS_BASEREL_LITTLE 0x08
245
246 #define RELOC_STD_BITS_JMPTABLE_BIG 0x04
247 #define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
248
249 #define RELOC_STD_BITS_RELATIVE_BIG 0x02
250 #define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
251
252 #define RELOC_STD_SIZE 8 /* Bytes per relocation entry */
253
254 struct relocation_info
255 {
256 /* Address (within segment) to be relocated. */
257 int r_address;
258 /* The meaning of r_symbolnum depends on r_extern. */
259 unsigned int r_symbolnum:24;
260 /* Nonzero means value is a pc-relative offset
261 and it should be relocated for changes in its own address
262 as well as for changes in the symbol or section specified. */
263 unsigned int r_pcrel:1;
264 /* Length (as exponent of 2) of the field to be relocated.
265 Thus, a value of 2 indicates 1<<2 bytes. */
266 unsigned int r_length:2;
267 /* 1 => relocate with value of symbol.
268 r_symbolnum is the index of the symbol
269 in file's the symbol table.
270 0 => relocate with the address of a segment.
271 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
272 (the N_EXT bit may be set also, but signifies nothing). */
273 unsigned int r_extern:1;
274 /* The next three bits are for SunOS shared libraries, and seem to
275 be undocumented. */
276 unsigned int r_baserel:1; /* Linkage table relative */
277 unsigned int r_jmptable:1; /* pc-relative to jump table */
278 unsigned int r_relative:1; /* "relative relocation" */
279 /* unused */
280 unsigned int r_pad:1; /* Padding -- set to zero */
281 };
282
283 #endif /* __A_OUT_GNU_H__ */
This page took 0.034257 seconds and 4 git commands to generate.