]>
Commit | Line | Data |
---|---|---|
61a153e5 RP |
1 | #ifndef __A_OUT_GNU_H__ |
2 | #define __A_OUT_GNU_H__ | |
3 | ||
af483be8 | 4 | #include "aout/reloc.h" |
61a153e5 RP |
5 | |
6 | #define __GNU_EXEC_MACROS__ | |
7 | ||
8 | #ifndef __STRUCT_EXEC_OVERRIDE__ | |
9 | ||
bad3df67 JG |
10 | /* This is the layout on disk of a Unix V7, Berkeley, SunOS, Vax Ultrix |
11 | "struct exec". Don't assume that on this machine, the "struct exec" | |
12 | will lay out the same sizes or alignments. */ | |
13 | ||
14 | struct exec_bytes { | |
a39116f1 RP |
15 | unsigned char a_info[4]; |
16 | unsigned char a_text[4]; | |
17 | unsigned char a_data[4]; | |
18 | unsigned char a_bss[4]; | |
19 | unsigned char a_syms[4]; | |
20 | unsigned char a_entry[4]; | |
21 | unsigned char a_trsize[4]; | |
22 | unsigned char a_drsize[4]; | |
bad3df67 JG |
23 | }; |
24 | ||
25 | /* How big the "struct exec" is on disk */ | |
26 | #define EXEC_BYTES_SIZE (8 * 4) | |
27 | ||
28 | /* This is the layout in memory of a "struct exec" while we process it. */ | |
29 | ||
61a153e5 RP |
30 | struct exec |
31 | { | |
a39116f1 RP |
32 | unsigned long a_info; /* Use macros N_MAGIC, etc for access */ |
33 | unsigned a_text; /* length of text, in bytes */ | |
34 | unsigned a_data; /* length of data, in bytes */ | |
35 | unsigned a_bss; /* length of uninitialized data area for file, in bytes */ | |
36 | unsigned a_syms; /* length of symbol table data in file, in bytes */ | |
37 | unsigned a_entry; /* start address */ | |
38 | unsigned a_trsize; /* length of relocation info for text, in bytes */ | |
39 | unsigned a_drsize; /* length of relocation info for data, in bytes */ | |
61a153e5 RP |
40 | }; |
41 | ||
42 | #endif /* __STRUCT_EXEC_OVERRIDE__ */ | |
43 | ||
44 | /* these go in the N_MACHTYPE field */ | |
45 | /* These symbols could be defined by code from Suns...punt 'em */ | |
bad3df67 | 46 | #undef M_UNKNOWN |
61a153e5 RP |
47 | #undef M_68010 |
48 | #undef M_68020 | |
49 | #undef M_SPARC | |
50 | enum machine_type { | |
a39116f1 RP |
51 | M_UNKNOWN = 0, |
52 | M_68010 = 1, | |
53 | M_68020 = 2, | |
54 | M_SPARC = 3, | |
55 | /* skip a bunch so we don't run into any of sun's numbers */ | |
56 | M_386 = 100, | |
57 | M_29K = 101, | |
58 | M_RS6000 = 102, /* IBM RS/6000 */ | |
59 | /* HP/BSD formats */ | |
60 | M_HP200 = 200, /* hp200 (68010) BSD binary */ | |
61 | M_HP300 = 300, /* hp300 (68020+68881) BSD binary */ | |
62 | M_HPUX23 = 0x020C, /* hp200/300 HPUX binary */ | |
61a153e5 RP |
63 | }; |
64 | ||
65 | #define N_MAGIC(exec) ((exec).a_info & 0xffff) | |
66 | #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff)) | |
67 | #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff) | |
68 | #define N_SET_INFO(exec, magic, type, flags) \ | |
a39116f1 RP |
69 | ((exec).a_info = ((magic) & 0xffff) \ |
70 | | (((int)(type) & 0xff) << 16) \ | |
71 | | (((flags) & 0xff) << 24)) | |
61a153e5 | 72 | #define N_SET_MAGIC(exec, magic) \ |
a39116f1 | 73 | ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff))) |
61a153e5 RP |
74 | |
75 | #define N_SET_MACHTYPE(exec, machtype) \ | |
a39116f1 RP |
76 | ((exec).a_info = \ |
77 | ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16)) | |
61a153e5 RP |
78 | |
79 | #define N_SET_FLAGS(exec, flags) \ | |
a39116f1 RP |
80 | ((exec).a_info = \ |
81 | ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24)) | |
61a153e5 RP |
82 | |
83 | /* Code indicating object file or impure executable. */ | |
84 | #define OMAGIC 0407 | |
85 | /* Code indicating pure executable. */ | |
86 | #define NMAGIC 0410 | |
87 | /* Code indicating demand-paged executable. */ | |
88 | #define ZMAGIC 0413 | |
89 | ||
bad3df67 JG |
90 | /* Virtual Address of text segment from the a.out file. For OMAGIC, |
91 | (almost always "unlinked .o's" these days), should be zero. | |
bad3df67 JG |
92 | For linked files, should reflect reality if we know it. */ |
93 | ||
94 | #ifndef N_TXTADDR | |
66d4e1bb JG |
95 | #define N_TXTADDR(x) (N_MAGIC(x)==OMAGIC? 0 : TEXT_START_ADDR) |
96 | #endif | |
97 | ||
98 | #ifndef N_BADMAG | |
99 | #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \ | |
a39116f1 RP |
100 | && N_MAGIC(x) != NMAGIC \ |
101 | && N_MAGIC(x) != ZMAGIC) | |
66d4e1bb JG |
102 | #endif |
103 | ||
d7f8f106 JG |
104 | /* By default, segment size is constant. But on some machines, it can |
105 | be a function of the a.out header (e.g. machine type). */ | |
106 | #ifndef N_SEGSIZE | |
107 | #define N_SEGSIZE(x) SEGMENT_SIZE | |
108 | #endif | |
a39116f1 RP |
109 | |
110 | /* This complexity is for encapsulated COFF support */ | |
66d4e1bb | 111 | #ifndef _N_HDROFF |
d7f8f106 | 112 | #define _N_HDROFF(x) (N_SEGSIZE(x) - sizeof (struct exec)) |
66d4e1bb JG |
113 | #endif |
114 | ||
115 | #ifndef N_TXTOFF | |
116 | #define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \ | |
a39116f1 RP |
117 | _N_HDROFF((x)) + sizeof (struct exec) : \ |
118 | sizeof (struct exec)) | |
66d4e1bb JG |
119 | #endif |
120 | ||
121 | ||
122 | #ifndef N_DATOFF | |
123 | #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) | |
124 | #endif | |
125 | ||
126 | #ifndef N_TRELOFF | |
127 | #define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data ) | |
128 | #endif | |
129 | ||
130 | #ifndef N_DRELOFF | |
131 | #define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize ) | |
bad3df67 | 132 | #endif |
61a153e5 | 133 | |
66d4e1bb JG |
134 | #ifndef N_SYMOFF |
135 | #define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize ) | |
61a153e5 | 136 | #endif |
66d4e1bb JG |
137 | |
138 | #ifndef N_STROFF | |
139 | #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) | |
61a153e5 | 140 | #endif |
66d4e1bb JG |
141 | |
142 | /* Address of text segment in memory after it is loaded. */ | |
143 | #ifndef N_TXTADDR | |
144 | #define N_TXTADDR(x) 0 | |
61a153e5 | 145 | #endif |
a39116f1 | 146 | |
61a153e5 RP |
147 | #ifndef N_DATADDR |
148 | #define N_DATADDR(x) \ | |
bad3df67 | 149 | (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \ |
d7f8f106 | 150 | : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1)))) |
61a153e5 RP |
151 | #endif |
152 | ||
153 | /* Address of bss segment in memory after it is loaded. */ | |
154 | #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) | |
155 | \f | |
156 | struct nlist { | |
a39116f1 RP |
157 | union { |
158 | char *n_name; | |
159 | struct nlist *n_next; | |
160 | long n_strx; | |
161 | } n_un; | |
162 | unsigned char n_type; | |
163 | char n_other; | |
164 | short n_desc; | |
165 | unsigned long n_value; | |
61a153e5 RP |
166 | }; |
167 | ||
168 | #define N_UNDF 0 | |
169 | #define N_ABS 2 | |
170 | #define N_TEXT 4 | |
171 | #define N_DATA 6 | |
172 | #define N_BSS 8 | |
e557edcf | 173 | #define N_COMM 0x12 /* common (visible in shared lib commons) */ |
30c52cdf | 174 | #define N_FN 0x1F /* File name of a .o file */ |
61a153e5 | 175 | |
30c52cdf JG |
176 | /* Note: N_EXT can only usefully be OR-ed with N_UNDF, N_ABS, N_TEXT, |
177 | N_DATA, or N_BSS. When the low-order bit of other types is set, | |
178 | (e.g. N_WARNING versus N_FN), they are two different types. */ | |
61a153e5 RP |
179 | #define N_EXT 1 |
180 | #define N_TYPE 036 | |
181 | #define N_STAB 0340 | |
182 | ||
183 | /* The following type indicates the definition of a symbol as being | |
184 | an indirect reference to another symbol. The other symbol | |
185 | appears as an undefined reference, immediately following this symbol. | |
a39116f1 | 186 | |
61a153e5 RP |
187 | Indirection is asymmetrical. The other symbol's value will be used |
188 | to satisfy requests for the indirect symbol, but not vice versa. | |
189 | If the other symbol does not have a definition, libraries will | |
190 | be searched to find a definition. */ | |
e929a4c5 | 191 | |
9bbfd057 | 192 | #define N_INDR 0xa |
61a153e5 RP |
193 | |
194 | /* The following symbols refer to set elements. | |
195 | All the N_SET[ATDB] symbols with the same name form one set. | |
196 | Space is allocated for the set in the text section, and each set | |
197 | element's value is stored into one word of the space. | |
198 | The first word of the space is the length of the set (number of elements). | |
a39116f1 | 199 | |
61a153e5 RP |
200 | The address of the set is made into an N_SETV symbol |
201 | whose name is the same as the name of the set. | |
202 | This symbol acts like a N_DATA global symbol | |
203 | in that it can satisfy undefined external references. */ | |
204 | ||
205 | /* These appear as input to LD, in a .o file. */ | |
206 | #define N_SETA 0x14 /* Absolute set element symbol */ | |
207 | #define N_SETT 0x16 /* Text set element symbol */ | |
208 | #define N_SETD 0x18 /* Data set element symbol */ | |
209 | #define N_SETB 0x1A /* Bss set element symbol */ | |
210 | ||
211 | /* This is output from LD. */ | |
212 | #define N_SETV 0x1C /* Pointer to set vector in data area. */ | |
e557edcf JG |
213 | |
214 | /* Warning symbol. The text gives a warning message, the next symbol | |
215 | in the table will be undefined. When the symbol is referenced, the | |
216 | message is printed. */ | |
217 | ||
218 | #define N_WARNING 0x1e | |
61a153e5 RP |
219 | \f |
220 | /* This structure describes a single relocation to be performed. | |
221 | The text-relocation section of the file is a vector of these structures, | |
222 | all of which apply to the text section. | |
223 | Likewise, the data-relocation section applies to the data section. */ | |
224 | ||
bad3df67 JG |
225 | /* The following enum and struct were borrowed from SunOS's |
226 | /usr/include/sun4/a.out.h and extended to handle | |
227 | other machines. It is currently used on SPARC and AMD 29000. | |
a39116f1 | 228 | |
bad3df67 JG |
229 | reloc_ext_bytes is how it looks on disk. reloc_info_extended is |
230 | how we might process it on a native host. */ | |
61a153e5 | 231 | |
bad3df67 | 232 | struct reloc_ext_bytes { |
a39116f1 RP |
233 | unsigned char r_address[4]; |
234 | unsigned char r_index[3]; | |
235 | unsigned char r_bits[1]; | |
236 | unsigned char r_addend[4]; | |
61a153e5 RP |
237 | }; |
238 | ||
bad3df67 JG |
239 | #define RELOC_EXT_BITS_EXTERN_BIG 0x80 |
240 | #define RELOC_EXT_BITS_EXTERN_LITTLE 0x01 | |
241 | ||
242 | #define RELOC_EXT_BITS_TYPE_BIG 0x1F | |
243 | #define RELOC_EXT_BITS_TYPE_SH_BIG 0 | |
244 | #define RELOC_EXT_BITS_TYPE_LITTLE 0xF8 | |
245 | #define RELOC_EXT_BITS_TYPE_SH_LITTLE 3 | |
246 | ||
247 | #define RELOC_EXT_SIZE 12 /* Bytes per relocation entry */ | |
61a153e5 RP |
248 | |
249 | struct reloc_info_extended | |
250 | { | |
a39116f1 RP |
251 | unsigned long r_address; |
252 | unsigned int r_index:24; | |
61a153e5 | 253 | # define r_symbolnum r_index |
a39116f1 RP |
254 | unsigned r_extern:1; |
255 | unsigned :2; | |
256 | /* RS/6000 compiler does not support enum bitfield | |
257 | enum reloc_type r_type:5; */ | |
258 | enum reloc_type r_type; | |
259 | long int r_addend; | |
61a153e5 RP |
260 | }; |
261 | ||
bad3df67 JG |
262 | /* The standard, old-fashioned, Berkeley compatible relocation struct */ |
263 | ||
264 | struct reloc_std_bytes { | |
a39116f1 RP |
265 | unsigned char r_address[4]; |
266 | unsigned char r_index[3]; | |
267 | unsigned char r_bits[1]; | |
61a153e5 RP |
268 | }; |
269 | ||
bad3df67 JG |
270 | #define RELOC_STD_BITS_PCREL_BIG 0x80 |
271 | #define RELOC_STD_BITS_PCREL_LITTLE 0x01 | |
272 | ||
273 | #define RELOC_STD_BITS_LENGTH_BIG 0x60 | |
274 | #define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */ | |
275 | #define RELOC_STD_BITS_LENGTH_LITTLE 0x06 | |
276 | #define RELOC_STD_BITS_LENGTH_SH_LITTLE 1 | |
277 | ||
278 | #define RELOC_STD_BITS_EXTERN_BIG 0x10 | |
279 | #define RELOC_STD_BITS_EXTERN_LITTLE 0x08 | |
280 | ||
281 | #define RELOC_STD_BITS_BASEREL_BIG 0x08 | |
282 | #define RELOC_STD_BITS_BASEREL_LITTLE 0x08 | |
283 | ||
284 | #define RELOC_STD_BITS_JMPTABLE_BIG 0x04 | |
285 | #define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04 | |
286 | ||
287 | #define RELOC_STD_BITS_RELATIVE_BIG 0x02 | |
288 | #define RELOC_STD_BITS_RELATIVE_LITTLE 0x02 | |
61a153e5 | 289 | |
bad3df67 | 290 | #define RELOC_STD_SIZE 8 /* Bytes per relocation entry */ |
61a153e5 | 291 | |
f0494a6e | 292 | #ifndef CUSTOM_RELOC_FORMAT |
61a153e5 RP |
293 | struct relocation_info |
294 | { | |
a39116f1 RP |
295 | /* Address (within segment) to be relocated. */ |
296 | int r_address; | |
297 | /* The meaning of r_symbolnum depends on r_extern. */ | |
298 | unsigned int r_symbolnum:24; | |
299 | /* Nonzero means value is a pc-relative offset | |
300 | and it should be relocated for changes in its own address | |
301 | as well as for changes in the symbol or section specified. */ | |
302 | unsigned int r_pcrel:1; | |
303 | /* Length (as exponent of 2) of the field to be relocated. | |
304 | Thus, a value of 2 indicates 1<<2 bytes. */ | |
305 | unsigned int r_length:2; | |
306 | /* 1 => relocate with value of symbol. | |
307 | r_symbolnum is the index of the symbol | |
308 | in file's the symbol table. | |
309 | 0 => relocate with the address of a segment. | |
310 | r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS | |
311 | (the N_EXT bit may be set also, but signifies nothing). */ | |
312 | unsigned int r_extern:1; | |
313 | /* The next three bits are for SunOS shared libraries, and seem to | |
314 | be undocumented. */ | |
315 | unsigned int r_baserel:1; /* Linkage table relative */ | |
316 | unsigned int r_jmptable:1; /* pc-relative to jump table */ | |
317 | ||
f827120d RP |
318 | #ifdef TC_NS32K |
319 | #define r_bsr r_baserel | |
320 | #define r_disp r_jmptable | |
321 | #endif /* TC_NS32K */ | |
a39116f1 RP |
322 | |
323 | unsigned int r_relative:1; /* "relative relocation" */ | |
324 | /* unused */ | |
325 | unsigned int r_pad:1; /* Padding -- set to zero */ | |
61a153e5 | 326 | }; |
f0494a6e | 327 | #endif /* CUSTOM_RELOC_FORMAT */ |
61a153e5 | 328 | |
61a153e5 | 329 | #endif /* __A_OUT_GNU_H__ */ |
a39116f1 RP |
330 | |
331 | /* end of a.out.gnu.h */ |