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