Remove unused include files.
[deliverable/binutils-gdb.git] / include / aout64.h
1 #ifndef __A_OUT_64_H__
2 #define __A_OUT_64_H__
3
4
5 /* This is the layout on disk of the 64 bit exec header. */
6
7 struct external_exec
8 {
9 bfd_byte e_info[4]; /* magic number and stuff */
10 bfd_byte e_text[BYTES_IN_WORD]; /* length of text section in bytes */
11 bfd_byte e_data[BYTES_IN_WORD]; /* length of data section in bytes */
12 bfd_byte e_bss[BYTES_IN_WORD]; /* length of bss area in bytes */
13 bfd_byte e_syms[BYTES_IN_WORD]; /* length of symbol table in bytes */
14 bfd_byte e_entry[BYTES_IN_WORD]; /* start address */
15 bfd_byte e_trsize[BYTES_IN_WORD]; /* length of text relocation info */
16 bfd_byte e_drsize[BYTES_IN_WORD]; /* length of data relocation info */
17 };
18
19
20 #define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7)
21
22 /* This is the layout in memory of a "struct exec" while we process it. */
23 struct internal_exec
24 {
25 long a_info; /* Magic number and flags packed */
26 bfd_vma a_text; /* length of text, in bytes */
27 bfd_vma a_data; /* length of data, in bytes */
28 bfd_vma a_bss; /* length of uninitialized data area for file */
29 bfd_vma a_syms; /* length of symbol table data in file */
30 bfd_vma a_entry; /* start address */
31 bfd_vma a_trsize; /* length of relocation info for text, in bytes */
32 bfd_vma a_drsize; /* length of relocation info for data, in bytes */
33 };
34
35
36 /* Magic number is written
37 < MSB >
38 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
39 < FLAGS > < MACHINE TYPE > < MAGIC >
40 */
41 enum machine_type {
42 M_UNKNOWN = 0,
43 M_68010 = 1,
44 M_68020 = 2,
45 M_SPARC = 3,
46 /* skip a bunch so we dont run into any of suns numbers */
47 M_386 = 100,
48 M_29K = 101,
49 M_NEWONE = 200,
50 M_NEWTWO = 201,
51
52 };
53
54 #define N_DYNAMIC(exec) ((exec).a_info & 0x8000000)
55
56 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
57 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
58 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
59 #define N_SET_INFO(exec, magic, type, flags) \
60 ((exec).a_info = ((magic) & 0xffff) \
61 | (((int)(type) & 0xff) << 16) \
62 | (((flags) & 0xff) << 24))
63
64 #define N_SET_MAGIC(exec, magic) \
65 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
66
67 #define N_SET_MACHTYPE(exec, machtype) \
68 ((exec).a_info = \
69 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
70
71 #define N_SET_FLAGS(exec, flags) \
72 ((exec).a_info = \
73 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
74
75 /* By default, segment size is constant. But on some machines, it can
76 be a function of the a.out header (e.g. machine type). */
77 #ifndef N_SEGSIZE
78 #define N_SEGSIZE(x) SEGMENT_SIZE
79 #endif
80
81 #define _N_HDROFF(x) (N_SEGSIZE(x) - EXEC_BYTES_SIZE)
82 /* address in an a.out of the text section. When demand paged, it's
83 set up a bit to make nothing at 0, when an object file it's 0.
84 There's a special hack case when the entry point is < TEXT_START_ADDR
85 for executables, then the real start is 0
86 */
87
88 #define N_TXTADDR(x) \
89 (N_MAGIC(x)==OMAGIC? 0 \
90 : (N_MAGIC(x) == ZMAGIC && (x).a_entry < TEXT_START_ADDR)? 0 \
91 : TEXT_START_ADDR)
92
93 /* offset in an a.out of the start of the text section. When demand
94 paged, this is the start of the file
95 */
96
97 #define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? 0 : EXEC_BYTES_SIZE)
98 #if ARCH_SIZE==64
99 #define PAGE_SIZE 0x2000
100 #define OMAGIC 0x1001 /* Code indicating object file */
101 #define ZMAGIC 0x1002 /* Code indicating demand-paged executable. */
102 #define NMAGIC 0x1003 /* Code indicating pure executable. */
103 #else
104 #ifndef PAGE_SIZE
105 #define PAGE_SIZE 0x2000
106 #endif
107 #define OMAGIC 0407 /* Code indicating object file or impure executable. */
108 #define NMAGIC 0410 /* Code indicating pure executable. */
109 #define ZMAGIC 0413 /* Code indicating demand-paged executable. */
110 #endif
111
112 #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
113 && N_MAGIC(x) != NMAGIC \
114 && N_MAGIC(x) != ZMAGIC)
115
116
117
118 #define N_DATADDR(x) \
119 (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
120 : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1))))
121
122 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
123
124
125 #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
126 #define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
127 #define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
128 #define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
129 #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
130
131
132 /* Symbols */
133 struct external_nlist {
134 bfd_byte e_strx[BYTES_IN_WORD]; /* index into string table of symbol name */
135 bfd_byte e_type[1]; /* type of symbol */
136 bfd_byte e_other[1]; /* misc info (usually empty) */
137 bfd_byte e_desc[2]; /* description field */
138 bfd_byte e_value[BYTES_IN_WORD];/* value of symbol */
139 };
140
141 #define EXTERNAL_LIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD)
142 struct internal_nlist {
143 char *strx; /* index into string table of symbol name */
144 uint8_type n_type; /* type of symbol */
145 uint8_type n_other; /* misc info (usually empty) */
146 uint16_type n_desc; /* description field */
147 bfd_vma n_value; /* value of symbol */
148 };
149
150 /* The n_type field is packed :
151
152 7 6 5 4 3 2 1 0
153 ^- if set the symbol is externaly visible
154 0 local
155 1 N_EXT external
156 ^ ^ ^---- select which section the symbol belongs to
157 0 0 0 0 x N_UNDF, undefined
158 0 0 0 1 x N_ABS, no section, base at 0
159 0 0 1 0 x N_TEXT, text section
160 0 0 1 1 x N_DATA, data section
161 0 1 0 0 x N_BSS, bss section
162 ^---------- if set the symbol is a set element
163 1 0 1 0 x N_SETA absolute set element symbol
164 1 0 1 1 x N_SETT text set element symbol
165 1 1 0 0 x N_SETD data set element symbol
166 1 1 0 1 x N_SETB bss set element symbol
167 1 1 1 0 x N_SETV pointer to set vector in data area
168 1 1 1 1 0 N_TYPE mask for all of the above
169
170 1 1 1 0 0 0 0 0 N_STAB type is a stab
171 */
172
173 #define N_UNDF 0
174 #define N_ABS 2
175 #define N_TEXT 4
176 #define N_DATA 6
177 #define N_BSS 8
178 #define N_FN 0x0e
179 #define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */
180 #define N_EXT 1
181 #define N_TYPE 0x1e
182 #define N_STAB 0xe0
183
184 #define N_INDR 0x0a
185
186 /* The following symbols refer to set elements.
187 All the N_SET[ATDB] symbols with the same name form one set.
188 Space is allocated for the set in the text section, and each set
189 elements value is stored into one word of the space.
190 The first word of the space is the length of the set (number of elements).
191
192 The address of the set is made into an N_SETV symbol
193 whose name is the same as the name of the set.
194 This symbol acts like a N_DATA global symbol
195 in that it can satisfy undefined external references. */
196
197 /* These appear as input to LD, in a .o file. */
198 #define N_SETA 0x14 /* Absolute set element symbol */
199 #define N_SETT 0x16 /* Text set element symbol */
200 #define N_SETD 0x18 /* Data set element symbol */
201 #define N_SETB 0x1A /* Bss set element symbol */
202
203 /* This is output from LD. */
204 #define N_SETV 0x1C /* Pointer to set vector in data area. */
205
206 /* Warning symbol. The text gives a warning message, the next symbol
207 in the table will be undefined. When the symbol is referenced, the
208 message is printed. */
209
210 #define N_WARNING 0x1e
211
212 /* Relocations
213
214 There are two types of relocation flavours for a.out systems,
215 standard and extended. The standard form is used on systems where
216 the instruction has room for all the bits of an offset to the operand, whilst the
217 extended form is used when an address operand has to be split over n
218 instructions. Eg, on the 68k, each move instruction can reference
219 the target with a displacement of 16 or 32 bits. On the sparc, move
220 instructions use an offset of 14 bits, so the offset is stored in
221 the reloc field, and the data in the section is ignored.
222 */
223
224 /* This structure describes a single relocation to be performed.
225 The text-relocation section of the file is a vector of these structures,
226 all of which apply to the text section.
227 Likewise, the data-relocation section applies to the data section. */
228
229 struct reloc_std_external {
230 bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
231 bfd_byte r_index[3]; /* symbol table index of symbol */
232 bfd_byte r_type[1]; /* relocation type */
233 };
234
235 #define RELOC_STD_BITS_PCREL_BIG 0x80
236 #define RELOC_STD_BITS_PCREL_LITTLE 0x01
237
238 #define RELOC_STD_BITS_LENGTH_BIG 0x60
239 #define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
240 #define RELOC_STD_BITS_LENGTH_LITTLE 0x06
241 #define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
242
243 #define RELOC_STD_BITS_EXTERN_BIG 0x10
244 #define RELOC_STD_BITS_EXTERN_LITTLE 0x08
245
246 #define RELOC_STD_BITS_BASEREL_BIG 0x08
247 #define RELOC_STD_BITS_BASEREL_LITTLE 0x08
248
249 #define RELOC_STD_BITS_JMPTABLE_BIG 0x04
250 #define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
251
252 #define RELOC_STD_BITS_RELATIVE_BIG 0x02
253 #define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
254
255 #define RELOC_STD_SIZE (BYTES_IN_WORD + 3 + 1) /* Bytes per relocation entry */
256
257 struct reloc_std_internal
258 {
259 bfd_vma r_address; /* Address (within segment) to be relocated. */
260 /* The meaning of r_symbolnum depends on r_extern. */
261 unsigned int r_symbolnum:24;
262 /* Nonzero means value is a pc-relative offset
263 and it should be relocated for changes in its own address
264 as well as for changes in the symbol or section specified. */
265 unsigned int r_pcrel:1;
266 /* Length (as exponent of 2) of the field to be relocated.
267 Thus, a value of 2 indicates 1<<2 bytes. */
268 unsigned int r_length:2;
269 /* 1 => relocate with value of symbol.
270 r_symbolnum is the index of the symbol
271 in files the symbol table.
272 0 => relocate with the address of a segment.
273 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
274 (the N_EXT bit may be set also, but signifies nothing). */
275 unsigned int r_extern:1;
276 /* The next three bits are for SunOS shared libraries, and seem to
277 be undocumented. */
278 unsigned int r_baserel:1; /* Linkage table relative */
279 unsigned int r_jmptable:1; /* pc-relative to jump table */
280 unsigned int r_relative:1; /* "relative relocation" */
281 /* unused */
282 unsigned int r_pad:1; /* Padding -- set to zero */
283 };
284
285
286 /* EXTENDED RELOCS */
287
288 struct reloc_ext_external {
289 bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
290 bfd_byte r_index[3]; /* symbol table index of symbol */
291 bfd_byte r_type[1]; /* relocation type */
292 bfd_byte r_addend[BYTES_IN_WORD]; /* datum addend */
293 };
294
295 #define RELOC_EXT_BITS_EXTERN_BIG 0x80
296 #define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
297
298 #define RELOC_EXT_BITS_TYPE_BIG 0x1F
299 #define RELOC_EXT_BITS_TYPE_SH_BIG 0
300 #define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
301 #define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
302
303 #define RELOC_EXT_SIZE (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD) /* Bytes per relocation entry */
304
305 enum reloc_type
306 {
307
308
309
310
311
312 /* simple relocations */
313 RELOC_8, /* data[0:7] = addend + sv */
314 RELOC_16, /* data[0:15] = addend + sv */
315 RELOC_32, /* data[0:31] = addend + sv */
316 /* pc-rel displacement */
317 RELOC_DISP8, /* data[0:7] = addend - pc + sv */
318 RELOC_DISP16, /* data[0:15] = addend - pc + sv */
319 RELOC_DISP32, /* data[0:31] = addend - pc + sv */
320 /* Special */
321 RELOC_WDISP30, /* data[0:29] = (addend + sv - pc)>>2 */
322 RELOC_WDISP22, /* data[0:21] = (addend + sv - pc)>>2 */
323 RELOC_HI22, /* data[0:21] = (addend + sv)>>10 */
324 RELOC_22, /* data[0:21] = (addend + sv) */
325 RELOC_13, /* data[0:12] = (addend + sv) */
326 RELOC_LO10, /* data[0:9] = (addend + sv) */
327 RELOC_SFA_BASE,
328 RELOC_SFA_OFF13,
329 /* P.I.C. (base-relative) */
330 RELOC_BASE10, /* Not sure - maybe we can do this the */
331 RELOC_BASE13, /* right way now */
332 RELOC_BASE22,
333 /* for some sort of pc-rel P.I.C. (?) */
334 RELOC_PC10,
335 RELOC_PC22,
336 /* P.I.C. jump table */
337 RELOC_JMP_TBL,
338 /* reputedly for shared libraries somehow */
339 RELOC_SEGOFF16,
340 RELOC_GLOB_DAT,
341 RELOC_JMP_SLOT,
342 RELOC_RELATIVE,
343
344 RELOC_11,
345 RELOC_WDISP2_14,
346 RELOC_WDISP19,
347 RELOC_HHI22, /* data[0:21] = (addend + sv) >> 42 */
348 RELOC_HLO10, /* data[0:9] = (addend + sv) >> 32 */
349
350 /* 29K relocation types */
351 RELOC_JUMPTARG,
352 RELOC_CONST,
353 RELOC_CONSTH,
354
355 /* All the new ones I can think of *//*v9*/
356
357 RELOC_64, /* data[0:63] = addend + sv *//*v9*/
358 RELOC_DISP64, /* data[0:63] = addend - pc + sv *//*v9*/
359 RELOC_WDISP21, /* data[0:20] = (addend + sv - pc)>>2 *//*v9*/
360 RELOC_DISP21, /* data[0:20] = addend - pc + sv *//*v9*/
361 RELOC_DISP14, /* data[0:13] = addend - pc + sv *//*v9*/
362 /* Q .
363 What are the other ones,
364 Since this is a clean slate, can we throw away the ones we dont
365 understand ? Should we sort the values ? What about using a
366 microcode format like the 68k ?
367 */
368 NO_RELOC
369 };
370
371
372 struct reloc_internal {
373 bfd_vma r_address; /* offset of of data to relocate */
374 long r_index; /* symbol table index of symbol */
375 enum reloc_type r_type; /* relocation type */
376 bfd_vma r_addend; /* datum addend */
377 };
378
379 /* Q.
380 Should the length of the string table be 4 bytes or 8 bytes ?
381
382 Q.
383 What about archive indexes ?
384
385 */
386
387 #endif /* __A_OUT_GNU_H__ */
This page took 0.057741 seconds and 4 git commands to generate.