1 #ifndef __A_OUT_GNU_H__
2 #define __A_OUT_GNU_H__
8 #define __GNU_EXEC_MACROS__
10 #ifndef __STRUCT_EXEC_OVERRIDE__
14 unsigned long a_info
; /* Use macros N_MAGIC, etc for access */
15 unsigned a_text
; /* size of text, in bytes */
16 unsigned a_data
; /* size of data, in bytes */
17 unsigned a_bss
; /* size of uninitialized data area, in bytes */
18 unsigned a_syms
; /* length of symbol table data, in bytes */
19 unsigned a_entry
; /* start address */
20 unsigned a_trsize
; /* size of reloc info for text, in bytes */
21 unsigned a_drsize
; /* size of reloc info for data, in bytes */
23 #if defined (sequent) && defined (i386)
25 { /* Global Descriptor Table */
30 unsigned a_shdata
; /* size of initialized shared data */
31 unsigned a_shbss
; /* size of uninitialized shared data */
32 unsigned a_shdrsize
; /* size of shared data relocation */
33 unsigned a_bootstrap
[11]; /* bootstrap for standalone */
34 unsigned a_reserved
[3]; /* reserved for future use */
35 unsigned a_version
; /* object version */
36 #endif /* Sequent Symmetry, Dynix 3.x */
39 #endif /* __STRUCT_EXEC_OVERRIDE__ */
41 /* these go in the N_MACHTYPE field */
43 #if defined (M_OLDSUN2)
44 M__OLDSUN2
= M_OLDSUN2
,
63 /* skip a bunch so we don't run into any of sun's numbers */
67 #if defined (sequent) && defined (i386)
69 /* Dynix 3 wants the magic number to be the whole first longword. */
71 #define N_MAGIC(exec) ((exec).a_info)
72 #define N_MACHTYPE(exec) 0
73 #define N_FLAGS(exec) 0
74 #define N_SET_INFO(exec, magic, type, flags) N_SET_MAGIC ((exec), (magic))
75 #define N_SET_MAGIC(exec, magic) ((exec).a_info = (magic))
76 #define N_SET_MACHTYPE(exec, machtype) ((void) 0)
77 #define N_SET_FLAGS(exec, flags) ((void) 0)
78 #define OMAGIC 0x12eb /* impure format - for .o's */
79 #define ZMAGIC 0x22eb /* demand load format - zero at zero */
80 #define NMAGIC you lose /* syntax error -- no pure format */
81 #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != ZMAGIC)
82 #define N_ADDRADJ(x) (N_MAGIC(x) == ZMAGIC ? SEGMENT_SIZE : 0)
83 #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text - N_ADDRADJ(x))
84 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data + (x).a_shdata)
85 #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize + (x).a_shdrsize)
86 #define N_TXTADDR(x) SEGMENT_SIZE
87 #define N_COMM 0x0a /** conflicts with N_INDR **/
89 /* Note that the Dynix binutils believe that N_SET[TDB] are
90 N_SH{DATA,BSS,COMM} -- be wary when mixing GNU & Dynix objects. */
91 #define PAGE_SIZE 4096
92 #define SEGMENT_SIZE PAGE_SIZE
94 #else /* !(sequent && i386) */
96 #if !defined (N_MAGIC)
97 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
99 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
100 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
101 #define N_SET_INFO(exec, magic, type, flags) \
102 ((exec).a_info = ((magic) & 0xffff) \
103 | (((int)(type) & 0xff) << 16) \
104 | (((flags) & 0xff) << 24))
105 #define N_SET_MAGIC(exec, magic) \
106 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
108 #define N_SET_MACHTYPE(exec, machtype) \
110 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
112 #define N_SET_FLAGS(exec, flags) \
114 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
116 #endif /* sequent && i386 */
119 /* Code indicating object file or impure executable. */
121 /* Code indicating pure executable. */
123 /* Code indicating demand-paged executable. */
125 #endif /* not OMAGIC */
127 #if !defined (N_BADMAG)
128 #define N_BADMAG(x) \
129 (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
130 && N_MAGIC(x) != ZMAGIC)
133 #define _N_BADMAG(x) \
134 (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
135 && N_MAGIC(x) != ZMAGIC)
138 #define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec))
140 #define _N_HDROFF(x) (- sizeof (struct exec))
143 #if !defined (N_TXTOFF)
144 #define N_TXTOFF(x) \
145 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
148 #if !defined (N_DATOFF)
149 #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
152 #if !defined (N_TRELOFF)
153 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
156 #if !defined (N_DRELOFF)
157 #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
160 #if !defined (N_SYMOFF)
161 #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
164 #if !defined (N_STROFF)
165 #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
168 /* Address of text segment in memory after it is loaded. */
169 #if !defined (N_TXTADDR)
170 #define N_TXTADDR(x) 0
173 /* Address of data segment in memory after it is loaded.
174 Note that it is up to you to define SEGMENT_SIZE
175 on machines not listed here. */
176 #if defined (hp300) || defined (mips)
177 #define PAGE_SIZE 4096
179 #if defined (sparc) || defined (NeXT)
180 #define PAGE_SIZE 0x2000
182 #if defined (sony) || (defined (sun) && defined (mc68000))
183 #define SEGMENT_SIZE 0x2000
184 #endif /* Sony or 68k Sun. */
186 #define SEGMENT_SIZE 0x20000
188 #if defined(m68k) && defined(PORTAR)
189 #define PAGE_SIZE 0x400
191 #if defined(i386) && !defined(sequent)
192 /* For COFF encapsulation. */
193 #define SEGMENT_SIZE 0x400000
196 /* This used to be first in this paragraph and under:
197 if (defined(vax) || defined(hp300) || defined(pyr) || defined(sparc) \
198 || (defined(m68k) && defined(PORTAR)) \
199 || defined (NeXT) || defined (mips)) */
200 #define SEGMENT_SIZE PAGE_SIZE
203 /* This value is for i386-minix, but that has no predefine.
204 Making it default will only cause confusion on machines
205 which have no proper value defined. */
209 #define PAGSIZ PAGE_SIZE
210 #define SEGSIZ SEGMENT_SIZE
212 #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
214 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
217 #define N_DATADDR(x) \
218 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
219 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
222 /* Address of bss segment in memory after it is loaded. */
223 #if !defined (N_BSSADDR)
224 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
227 #if !defined (N_NLIST_DECLARED)
231 struct nlist
*n_next
;
234 unsigned char n_type
;
237 unsigned long n_value
;
239 #endif /* no N_NLIST_DECLARED. */
241 #if !defined (N_UNDF)
247 #if !defined (N_TEXT)
250 #if !defined (N_DATA)
256 #if !defined (N_COMM)
266 #if !defined (N_TYPE)
269 #if !defined (N_STAB)
273 /* The following type indicates the definition of a symbol as being
274 an indirect reference to another symbol. The other symbol
275 appears as an undefined reference, immediately following this symbol.
277 Indirection is asymmetrical. The other symbol's value will be used
278 to satisfy requests for the indirect symbol, but not vice versa.
279 If the other symbol does not have a definition, libraries will
280 be searched to find a definition. */
283 /* The following symbols refer to set elements.
284 All the N_SET[ATDB] symbols with the same name form one set.
285 Space is allocated for the set in the text section, and each set
286 element's value is stored into one word of the space.
287 The first word of the space is the length of the set (number of elements).
289 The address of the set is made into an N_SETV symbol
290 whose name is the same as the name of the set.
291 This symbol acts like a N_DATA global symbol
292 in that it can satisfy undefined external references. */
294 /* These appear as input to LD, in a .o file. */
295 #define N_SETA 0x14 /* Absolute set element symbol */
296 #define N_SETT 0x16 /* Text set element symbol */
297 #define N_SETD 0x18 /* Data set element symbol */
298 #define N_SETB 0x1A /* Bss set element symbol */
300 /* This is output from LD. */
301 #define N_SETV 0x1C /* Pointer to set vector in data area. */
303 #if !defined (N_RELOCATION_INFO_DECLARED)
304 /* This structure describes a single relocation to be performed.
305 The text-relocation section of the file is a vector of these structures,
306 all of which apply to the text section.
307 Likewise, the data-relocation section applies to the data section. */
309 struct relocation_info
311 /* Address (within segment) to be relocated. */
313 /* The meaning of r_symbolnum depends on r_extern. */
314 unsigned int r_symbolnum
:24;
315 /* Nonzero means value is a pc-relative offset
316 and it should be relocated for changes in its own address
317 as well as for changes in the symbol or section specified. */
318 unsigned int r_pcrel
:1;
319 /* Length (as exponent of 2) of the field to be relocated.
320 Thus, a value of 2 indicates 1<<2 bytes. */
321 unsigned int r_length
:2;
322 /* 1 => relocate with value of symbol.
323 r_symbolnum is the index of the symbol
324 in file's the symbol table.
325 0 => relocate with the address of a segment.
326 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
327 (the N_EXT bit may be set also, but signifies nothing). */
328 unsigned int r_extern
:1;
329 /* Four bits that aren't used, but when writing an object file
330 it is desirable to clear them. */
331 unsigned int r_pad
:4;
333 #endif /* no N_RELOCATION_INFO_DECLARED. */
339 #endif /* __A_OUT_GNU_H__ */