1 #ifndef __A_OUT_GNU_H__
2 #define __A_OUT_GNU_H__
4 #define __GNU_EXEC_MACROS__
6 #ifndef __STRUCT_EXEC_OVERRIDE__
10 #endif /* __STRUCT_EXEC_OVERRIDE__ */
12 /* these go in the N_MACHTYPE field */
14 #if defined (M_OLDSUN2)
15 M__OLDSUN2 = M_OLDSUN2,
34 /* skip a bunch so we don't run into any of sun's numbers */
36 M_MIPS1 = 151, /* MIPS R3000/R3000 binary */
37 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
40 #if !defined (N_MAGIC)
41 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
43 #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
44 #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
45 #define N_SET_INFO(exec, magic, type, flags) \
46 ((exec).a_info = ((magic) & 0xffff) \
47 | (((int)(type) & 0xff) << 16) \
48 | (((flags) & 0xff) << 24))
49 #define N_SET_MAGIC(exec, magic) \
50 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
52 #define N_SET_MACHTYPE(exec, machtype) \
54 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
56 #define N_SET_FLAGS(exec, flags) \
58 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
60 /* Code indicating object file or impure executable. */
62 /* Code indicating pure executable. */
64 /* Code indicating demand-paged executable. */
66 /* This indicates a demand-paged executable with the header in the text.
67 The first page is unmapped to help trap NULL pointer references */
70 /* Code indicating core file. */
73 #if !defined (N_BADMAG)
74 #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
75 && N_MAGIC(x) != NMAGIC \
76 && N_MAGIC(x) != ZMAGIC \
77 && N_MAGIC(x) != QMAGIC)
80 #define _N_HDROFF(x) (1024 - sizeof (struct exec))
82 #if !defined (N_TXTOFF)
84 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
85 (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
88 #if !defined (N_DATOFF)
89 #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
92 #if !defined (N_TRELOFF)
93 #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
96 #if !defined (N_DRELOFF)
97 #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
100 #if !defined (N_SYMOFF)
101 #define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
104 #if !defined (N_STROFF)
105 #define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
108 /* Address of text segment in memory after it is loaded. */
109 #if !defined (N_TXTADDR)
110 #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
113 /* Address of data segment in memory after it is loaded.
114 Note that it is up to you to define SEGMENT_SIZE
115 on machines not listed here. */
116 #if defined(vax) || defined(hp300) || defined(pyr)
117 #define SEGMENT_SIZE page_size
120 #define SEGMENT_SIZE 0x2000
123 #define SEGMENT_SIZE 0x20000
125 #if defined(m68k) && defined(PORTAR)
126 #define PAGE_SIZE 0x400
127 #define SEGMENT_SIZE PAGE_SIZE
130 #if !defined(SEGMENT_SIZE)
132 #if defined(__i386__) || defined(__mc68000__)
133 #define SEGMENT_SIZE 1024
134 #elif defined(__sparc__)
135 #define SEGMENT_SIZE 0x2000
137 #if defined(PAGE_SIZE)
138 #define SEGMENT_SIZE PAGE_SIZE
144 #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
146 #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
149 #define N_DATADDR(x) \
150 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
151 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
154 /* Address of bss segment in memory after it is loaded. */
155 #if !defined (N_BSSADDR)
156 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
159 #if !defined (N_NLIST_DECLARED)
163 struct nlist *n_next;
166 unsigned char n_type;
169 unsigned long n_value;
171 #endif /* no N_NLIST_DECLARED. */
173 #if !defined (N_UNDF)
179 #if !defined (N_TEXT)
182 #if !defined (N_DATA)
195 #if !defined (N_TYPE)
198 #if !defined (N_STAB)
202 /* The following type indicates the definition of a symbol as being
203 an indirect reference to another symbol. The other symbol
204 appears as an undefined reference, immediately following this symbol.
206 Indirection is asymmetrical. The other symbol's value will be used
207 to satisfy requests for the indirect symbol, but not vice versa.
208 If the other symbol does not have a definition, libraries will
209 be searched to find a definition. */
212 /* The following symbols refer to set elements.
213 All the N_SET[ATDB] symbols with the same name form one set.
214 Space is allocated for the set in the text section, and each set
215 element's value is stored into one word of the space.
216 The first word of the space is the length of the set (number of elements).
218 The address of the set is made into an N_SETV symbol
219 whose name is the same as the name of the set.
220 This symbol acts like a N_DATA global symbol
221 in that it can satisfy undefined external references. */
223 /* These appear as input to LD, in a .o file. */
224 #define N_SETA 0x14 /* Absolute set element symbol */
225 #define N_SETT 0x16 /* Text set element symbol */
226 #define N_SETD 0x18 /* Data set element symbol */
227 #define N_SETB 0x1A /* Bss set element symbol */
229 /* This is output from LD. */
230 #define N_SETV 0x1C /* Pointer to set vector in data area. */
232 #if !defined (N_RELOCATION_INFO_DECLARED)
233 /* This structure describes a single relocation to be performed.
234 The text-relocation section of the file is a vector of these structures,
235 all of which apply to the text section.
236 Likewise, the data-relocation section applies to the data section. */
238 struct relocation_info
240 /* Address (within segment) to be relocated. */
242 /* The meaning of r_symbolnum depends on r_extern. */
243 unsigned int r_symbolnum:24;
244 /* Nonzero means value is a pc-relative offset
245 and it should be relocated for changes in its own address
246 as well as for changes in the symbol or section specified. */
247 unsigned int r_pcrel:1;
248 /* Length (as exponent of 2) of the field to be relocated.
249 Thus, a value of 2 indicates 1<<2 bytes. */
250 unsigned int r_length:2;
251 /* 1 => relocate with value of symbol.
252 r_symbolnum is the index of the symbol
253 in file's the symbol table.
254 0 => relocate with the address of a segment.
255 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
256 (the N_EXT bit may be set also, but signifies nothing). */
257 unsigned int r_extern:1;
258 /* Four bits that aren't used, but when writing an object file
259 it is desirable to clear them. */
265 unsigned int r_pad:4;
268 #endif /* no N_RELOCATION_INFO_DECLARED. */
271 #endif /* __A_OUT_GNU_H__ */