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)
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #ifndef __A_OUT_GNU_H__
22 #define __A_OUT_GNU_H__
27 RELOC_LO16, /* lo16(sym) */
28 RELOC_HI16, /* hi16(sym) */
29 RELOC_PC16, /* bb0, bb1, bcnd */
30 RELOC_PC26, /* br, bsr */
31 RELOC_32, /* jump tables, etc */
32 RELOC_IW16, /* global access through linker regs 28 */
34 #else /* not TC_M88K */
37 /* NOTE: three bits max, see struct reloc_info_i860.r_type */
38 NO_RELOC = 0, BRADDR, LOW0, LOW1, LOW2, LOW3, LOW4, SPLIT0, SPLIT1, SPLIT2, RELOC_32,
40 #else /* not TC_I860 */
42 RELOC_8, RELOC_16, RELOC_32, /* simple relocations */
43 RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, /* pc-rel displacement */
44 RELOC_WDISP30, RELOC_WDISP22,
47 RELOC_SFA_BASE, RELOC_SFA_OFF13,
48 RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, /* P.I.C. (base-relative) */
49 RELOC_PC10, RELOC_PC22, /* for some sort of pc-rel P.I.C. (?) */
50 RELOC_JMP_TBL, /* P.I.C. jump table */
51 RELOC_SEGOFF16, /* reputedly for shared libraries somehow */
52 RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
60 /* 29K relocation types */
61 RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
63 RELOC_WDISP14, RELOC_WDISP21,
64 #endif /* not TC_SPARC */
68 /* Used internally by gas */
73 #endif /* not TC_I860 */
74 #endif /* not TC_M88K */
79 /* NOTE: two bits max, see reloc_info_i860.r_type */
81 NO_SPEC = 0, PAIR, HIGH, HIGHADJ,
86 #define __GNU_EXEC_MACROS__
88 #ifndef __STRUCT_EXEC_OVERRIDE__
90 /* This is the layout on disk of a Unix V7, Berkeley, SunOS, Vax Ultrix
91 "struct exec". Don't assume that on this machine, the "struct exec"
92 will lay out the same sizes or alignments. */
95 unsigned char a_info[4];
96 unsigned char a_text[4];
97 unsigned char a_data[4];
98 unsigned char a_bss[4];
99 unsigned char a_syms[4];
100 unsigned char a_entry[4];
101 unsigned char a_trsize[4];
102 unsigned char a_drsize[4];
105 /* How big the "struct exec" is on disk */
106 #define EXEC_BYTES_SIZE (8 * 4)
108 /* This is the layout in memory of a "struct exec" while we process it. */
112 unsigned long a_info; /* Use macros N_MAGIC, etc for access */
113 unsigned a_text; /* length of text, in bytes */
114 unsigned a_data; /* length of data, in bytes */
115 unsigned a_bss; /* length of uninitialized data area for file, in bytes */
116 unsigned a_syms; /* length of symbol table data in file, in bytes */
117 unsigned a_entry; /* start address */
118 unsigned a_trsize; /* length of relocation info for text, in bytes */
119 unsigned a_drsize; /* length of relocation info for data, in bytes */
122 #endif /* __STRUCT_EXEC_OVERRIDE__ */
124 /* these go in the N_MACHTYPE field */
125 /* These symbols could be defined by code from Suns...punt 'em */
135 /* skip a bunch so we don't run into any of sun's numbers */
138 M_RS6000 = 102, /* IBM RS/6000 */
140 M_HP200 = 200, /* hp200 (68010) BSD binary */
141 M_HP300 = 300, /* hp300 (68020+68881) BSD binary */
142 M_HPUX23 = 0x020C, /* hp200/300 HPUX binary */
145 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
146 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
147 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
148 #define N_SET_INFO(exec, magic, type, flags) \
149 ((exec).a_info = ((magic) & 0xffff) \
150 | (((int)(type) & 0xff) << 16) \
151 | (((flags) & 0xff) << 24))
152 #define N_SET_MAGIC(exec, magic) \
153 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
155 #define N_SET_MACHTYPE(exec, machtype) \
157 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
159 #define N_SET_FLAGS(exec, flags) \
161 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
163 /* Code indicating object file or impure executable. */
165 /* Code indicating pure executable. */
167 /* Code indicating demand-paged executable. */
170 /* Virtual Address of text segment from the a.out file. For OMAGIC,
171 (almost always "unlinked .o's" these days), should be zero.
172 For linked files, should reflect reality if we know it. */
175 #define N_TXTADDR(x) (N_MAGIC(x) == OMAGIC? 0 : TEXT_START_ADDR)
179 #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
180 && N_MAGIC(x) != NMAGIC \
181 && N_MAGIC(x) != ZMAGIC)
184 /* By default, segment size is constant. But on some machines, it can
185 be a function of the a.out header (e.g. machine type). */
187 #define N_SEGSIZE(x) SEGMENT_SIZE
190 /* This complexity is for encapsulated COFF support */
192 #define _N_HDROFF(x) (N_SEGSIZE(x) - sizeof (struct exec))
196 #define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \
197 _N_HDROFF((x)) + sizeof (struct exec) : \
198 sizeof (struct exec))
203 #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
207 #define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
211 #define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
215 #define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
219 #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
222 /* Address of text segment in memory after it is loaded. */
224 #define N_TXTADDR(x) 0
228 #define N_DATADDR(x) \
229 (N_MAGIC(x) == OMAGIC? (N_TXTADDR(x)+(x).a_text) \
230 : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1))))
233 /* Address of bss segment in memory after it is loaded. */
234 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
239 struct nlist *n_next;
242 unsigned char n_type;
245 unsigned long n_value;
253 #define N_COMM 0x12 /* common (visible in shared lib commons) */
254 #define N_FN 0x1F /* File name of a .o file */
256 /* Note: N_EXT can only usefully be OR-ed with N_UNDF, N_ABS, N_TEXT,
257 N_DATA, or N_BSS. When the low-order bit of other types is set,
258 (e.g. N_WARNING versus N_FN), they are two different types. */
263 /* The following type indicates the definition of a symbol as being
264 an indirect reference to another symbol. The other symbol
265 appears as an undefined reference, immediately following this symbol.
267 Indirection is asymmetrical. The other symbol's value will be used
268 to satisfy requests for the indirect symbol, but not vice versa.
269 If the other symbol does not have a definition, libraries will
270 be searched to find a definition. */
274 /* The following type indicates the size of the symbol it refers to */
277 /* The following symbols refer to set elements.
278 All the N_SET[ATDB] symbols with the same name form one set.
279 Space is allocated for the set in the text section, and each set
280 element's value is stored into one word of the space.
281 The first word of the space is the length of the set (number of elements).
283 The address of the set is made into an N_SETV symbol
284 whose name is the same as the name of the set.
285 This symbol acts like a N_DATA global symbol
286 in that it can satisfy undefined external references. */
288 /* These appear as input to LD, in a .o file. */
289 #define N_SETA 0x14 /* Absolute set element symbol */
290 #define N_SETT 0x16 /* Text set element symbol */
291 #define N_SETD 0x18 /* Data set element symbol */
292 #define N_SETB 0x1A /* Bss set element symbol */
294 /* This is output from LD. */
295 #define N_SETV 0x1C /* Pointer to set vector in data area. */
297 /* Warning symbol. The text gives a warning message, the next symbol
298 in the table will be undefined. When the symbol is referenced, the
299 message is printed. */
301 #define N_WARNING 0x1e
303 /* This structure describes a single relocation to be performed.
304 The text-relocation section of the file is a vector of these structures,
305 all of which apply to the text section.
306 Likewise, the data-relocation section applies to the data section. */
308 /* The following enum and struct were borrowed from SunOS's
309 /usr/include/sun4/a.out.h and extended to handle
310 other machines. It is currently used on SPARC and AMD 29000.
312 reloc_ext_bytes is how it looks on disk. reloc_info_extended is
313 how we might process it on a native host. */
315 struct reloc_ext_bytes {
316 unsigned char r_address[4];
317 unsigned char r_index[3];
318 unsigned char r_bits[1];
319 unsigned char r_addend[4];
322 struct reloc_info_i860
324 unsigned long r_address;
326 * Using bit fields here is a bad idea because the order is not portable. :-(
328 unsigned int r_symbolnum: 24;
329 unsigned int r_pcrel : 1;
330 unsigned int r_extern : 1;
331 /* combining the two field simplifies the argument passing in "new_fix()" */
332 /* and is compatible with the existing Sparc #ifdef's */
333 /* r_type: highlow_type - bits 5,4; reloc_type - bits 3-0 */
334 unsigned int r_type : 6;
339 #define RELOC_EXT_BITS_EXTERN_BIG 0x80
340 #define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
342 #define RELOC_EXT_BITS_TYPE_BIG 0x1F
343 #define RELOC_EXT_BITS_TYPE_SH_BIG 0
344 #define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
345 #define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
347 #define RELOC_EXT_SIZE 12 /* Bytes per relocation entry */
349 struct reloc_info_extended
351 unsigned long r_address;
352 unsigned int r_index:24;
353 # define r_symbolnum r_index
356 /* RS/6000 compiler does not support enum bitfield
357 enum reloc_type r_type:5; */
358 enum reloc_type r_type;
362 /* The standard, old-fashioned, Berkeley compatible relocation struct */
364 struct reloc_std_bytes {
365 unsigned char r_address[4];
366 unsigned char r_index[3];
367 unsigned char r_bits[1];
370 #define RELOC_STD_BITS_PCREL_BIG 0x80
371 #define RELOC_STD_BITS_PCREL_LITTLE 0x01
373 #define RELOC_STD_BITS_LENGTH_BIG 0x60
374 #define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
375 #define RELOC_STD_BITS_LENGTH_LITTLE 0x06
376 #define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
378 #define RELOC_STD_BITS_EXTERN_BIG 0x10
379 #define RELOC_STD_BITS_EXTERN_LITTLE 0x08
381 #define RELOC_STD_BITS_BASEREL_BIG 0x08
382 #define RELOC_STD_BITS_BASEREL_LITTLE 0x08
384 #define RELOC_STD_BITS_JMPTABLE_BIG 0x04
385 #define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
387 #define RELOC_STD_BITS_RELATIVE_BIG 0x02
388 #define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
390 #define RELOC_STD_SIZE 8 /* Bytes per relocation entry */
392 #ifndef CUSTOM_RELOC_FORMAT
393 struct relocation_info {
394 /* Address (within segment) to be relocated. */
396 /* The meaning of r_symbolnum depends on r_extern. */
397 #if defined(TC_NS32K) && !defined(TE_SEQUENT)
398 unsigned int r_symbolnum:22;
399 unsigned int r_copy:1;
400 unsigned int r_relative:1;
402 unsigned int r_symbolnum:24;
404 /* Nonzero means value is a pc-relative offset
405 and it should be relocated for changes in its own address
406 as well as for changes in the symbol or section specified. */
407 unsigned int r_pcrel:1;
408 /* Length (as exponent of 2) of the field to be relocated.
409 Thus, a value of 2 indicates 1<<2 bytes. */
410 unsigned int r_length:2;
411 /* 1 => relocate with value of symbol.
412 r_symbolnum is the index of the symbol
413 in file's the symbol table.
414 0 => relocate with the address of a segment.
415 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
416 (the N_EXT bit may be set also, but signifies nothing). */
417 unsigned int r_extern:1;
420 unsigned int r_bsr:1;
422 unsigned int r_jmptable:1;
424 unsigned int r_disp:2;
425 unsigned int r_baserel:1;
427 /* The next three bits are for SunOS shared libraries, and seem to
429 unsigned int r_baserel:1; /* Linkage table relative */
430 unsigned int r_jmptable:1; /* pc-relative to jump table */
431 unsigned int r_relative:1; /* "relative relocation" */
433 unsigned int r_pad:1; /* Padding -- set to zero */
436 #endif /* CUSTOM_RELOC_FORMAT */
438 #endif /* __A_OUT_GNU_H__ */