1 #ifndef__A_OUT_GNU_H__ 2 #define__A_OUT_GNU_H__ 3
4 #define __GNU_EXEC_MACROS__
5
6 #ifndef __STRUCT_EXEC_OVERRIDE__
7
8 #include <asm/a.out.h>
9
10 #endif/* __STRUCT_EXEC_OVERRIDE__ */ 11
12 /* these go in the N_MACHTYPE field */ 13 enummachine_type{ 14 #ifdefined (M_OLDSUN2)
15 M__OLDSUN2 = M_OLDSUN2,
16 #else 17 M_OLDSUN2 = 0,
18 #endif 19 #ifdefined (M_68010)
20 M__68010 = M_68010,
21 #else 22 M_68010 = 1,
23 #endif 24 #ifdefined (M_68020)
25 M__68020 = M_68020,
26 #else 27 M_68020 = 2,
28 #endif 29 #ifdefined (M_SPARC)
30 M__SPARC = M_SPARC,
31 #else 32 M_SPARC = 3,
33 #endif 34 /* skip a bunch so we don't run into any of sun's numbers */ 35 M_386 = 100,
36 M_MIPS1 = 151, /* MIPS R3000/R3000 binary */ 37 M_MIPS2 = 152, /* MIPS R6000/R4000 binary */ 38 };
39
40 #if !defined (N_MAGIC)
41 #defineN_MAGIC(exec) ((exec).a_info & 0xffff)
42 #endif 43 #define N_MACHTYPE(exec) ((enummachine_type)(((exec).a_info >> 16) & 0xff))
44 #defineN_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)))
51
52 #define N_SET_MACHTYPE(exec, machtype) \
53 ((exec).a_info = \
54 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
55
56 #define N_SET_FLAGS(exec, flags) \
57 ((exec).a_info = \
58 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
59
60 /* Code indicating object file or impure executable. */ 61 #defineOMAGIC 0407
62 /* Code indicating pure executable. */ 63 #defineNMAGIC 0410
64 /* Code indicating demand-paged executable. */ 65 #defineZMAGIC 0413
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 */ 68 #defineQMAGIC 0314
69
70 /* Code indicating core file. */ 71 #defineCMAGIC 0421
72
73 #if !defined (N_BADMAG)
74 #defineN_BADMAG(x) (N_MAGIC(x) != OMAGIC \
75 && N_MAGIC(x) != NMAGIC \
76 && N_MAGIC(x) != ZMAGIC \
77 && N_MAGIC(x) != QMAGIC)
78 #endif 79
80 #define_N_HDROFF(x) (1024 - sizeof (structexec))
81
82 #if !defined (N_TXTOFF)
83 #defineN_TXTOFF(x) \
84 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (structexec) : \
85 (N_MAGIC(x) == QMAGIC ? 0 : sizeof (structexec)))
86 #endif 87
88 #if !defined (N_DATOFF)
89 #defineN_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
90 #endif 91
92 #if !defined (N_TRELOFF)
93 #defineN_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
94 #endif 95
96 #if !defined (N_DRELOFF)
97 #defineN_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
98 #endif 99
100 #if !defined (N_SYMOFF)
101 #defineN_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
102 #endif 103
104 #if !defined (N_STROFF)
105 #defineN_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
106 #endif 107
108 /* Address of text segment in memory after it is loaded. */ 109 #if !defined (N_TXTADDR)
110 #defineN_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
111 #endif 112
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 #ifdefined(vax) || defined(hp300) || defined(pyr)
117 #defineSEGMENT_SIZE page_size
118 #endif 119 #ifdef sony
120 #defineSEGMENT_SIZE 0x2000
121 #endif/* Sony. */ 122 #ifdef is68k
123 #defineSEGMENT_SIZE 0x20000
124 #endif 125 #ifdefined(m68k) && defined(PORTAR)
126 #definePAGE_SIZE 0x400
127 #defineSEGMENT_SIZEPAGE_SIZE 128 #endif 129
130 #ifdeflinux 131 #include <asm/page.h>
132 #ifdef__i386__ 133 #defineSEGMENT_SIZE 1024
134 #else 135 #defineSEGMENT_SIZEPAGE_SIZE 136 #endif 137 #endif 138
139 #define_N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
140
141 #define_N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
142
143 #ifndefN_DATADDR 144 #defineN_DATADDR(x) \
145 (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
146 : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
147 #endif 148
149 /* Address of bss segment in memory after it is loaded. */ 150 #if !defined (N_BSSADDR)
151 #defineN_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
152 #endif 153
154 #if !defined (N_NLIST_DECLARED)
155 structnlist{ 156 union{ 157 char *n_name;
158 structnlist *n_next;
159 long n_strx;
160 } n_un;
161 unsignedcharn_type;
162 char n_other;
163 short n_desc;
164 unsignedlongn_value;
165 };
166 #endif/* no N_NLIST_DECLARED. */ 167
168 #if !defined (N_UNDF)
169 #defineN_UNDF 0
170 #endif 171 #if !defined (N_ABS)
172 #defineN_ABS 2
173 #endif 174 #if !defined (N_TEXT)
175 #defineN_TEXT 4
176 #endif 177 #if !defined (N_DATA)
178 #defineN_DATA 6
179 #endif 180 #if !defined (N_BSS)
181 #defineN_BSS 8
182 #endif 183 #if !defined (N_FN)
184 #defineN_FN 15
185 #endif 186
187 #if !defined (N_EXT)
188 #defineN_EXT 1
189 #endif 190 #if !defined (N_TYPE)
191 #defineN_TYPE 036
192 #endif 193 #if !defined (N_STAB)
194 #defineN_STAB 0340
195 #endif 196
197 /* The following type indicates the definition of a symbol as being 198 an indirect reference to another symbol. The other symbol 199 appears as an undefined reference, immediately following this symbol. 200
201 Indirection is asymmetrical. The other symbol's value will be used 202 to satisfy requests for the indirect symbol, but not vice versa. 203 If the other symbol does not have a definition, libraries will 204 be searched to find a definition. */ 205 #define N_INDR 0xa
206
207 /* The following symbols refer to set elements. 208 All the N_SET[ATDB] symbols with the same name form one set. 209 Space is allocated for the set in the text section, and each set 210 element's value is stored into one word of the space. 211 The first word of the space is the length of the set (number of elements). 212
213 The address of the set is made into an N_SETV symbol 214 whose name is the same as the name of the set. 215 This symbol acts like a N_DATA global symbol 216 in that it can satisfy undefined external references. */ 217
218 /* These appear as input to LD, in a .o file. */ 219 #define N_SETA 0x14 /* Absolute set element symbol */ 220 #define N_SETT 0x16 /* Text set element symbol */ 221 #define N_SETD 0x18 /* Data set element symbol */ 222 #define N_SETB 0x1A /* Bss set element symbol */ 223
224 /* This is output from LD. */ 225 #define N_SETV 0x1C /* Pointer to set vector in data area. */ 226
227 #if !defined (N_RELOCATION_INFO_DECLARED)
228 /* This structure describes a single relocation to be performed. 229 The text-relocation section of the file is a vector of these structures, 230 all of which apply to the text section. 231 Likewise, the data-relocation section applies to the data section. */ 232
233 struct relocation_info
234 { 235 /* Address (within segment) to be relocated. */ 236 int r_address;
237 /* The meaning of r_symbolnum depends on r_extern. */ 238 unsignedint r_symbolnum:24;
239 /* Nonzero means value is a pc-relative offset 240 and it should be relocated for changes in its own address 241 as well as for changes in the symbol or section specified. */ 242 unsignedint r_pcrel:1;
243 /* Length (as exponent of 2) of the field to be relocated. 244 Thus, a value of 2 indicates 1<<2 bytes. */ 245 unsignedint r_length:2;
246 /* 1 => relocate with value of symbol. 247 r_symbolnum is the index of the symbol 248 in file's the symbol table. 249 0 => relocate with the address of a segment. 250 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS 251 (the N_EXT bit may be set also, but signifies nothing). */ 252 unsignedint r_extern:1;
253 /* Four bits that aren't used, but when writing an object file 254 it is desirable to clear them. */ 255 #ifdef NS32K
256 unsigned r_bsr:1;
257 unsigned r_disp:1;
258 unsignedr_pad:2;
259 #else 260 unsignedintr_pad:4;
261 #endif 262 };
263 #endif/* no N_RELOCATION_INFO_DECLARED. */ 264
265
266 #endif/* __A_OUT_GNU_H__ */