* Makefile.in: add target "binutils.ms"
[deliverable/binutils-gdb.git] / include / aout64.h
1 /* `a.out' object-file definitions, including extensions to 64-bit fields */
2
3 #ifndef __A_OUT_64_H__
4 #define __A_OUT_64_H__
5
6 /* This is the layout on disk of the 32-bit or 64-bit exec header. */
7
8 struct external_exec
9 {
10 bfd_byte e_info[4]; /* magic number and stuff */
11 bfd_byte e_text[BYTES_IN_WORD]; /* length of text section in bytes */
12 bfd_byte e_data[BYTES_IN_WORD]; /* length of data section in bytes */
13 bfd_byte e_bss[BYTES_IN_WORD]; /* length of bss area in bytes */
14 bfd_byte e_syms[BYTES_IN_WORD]; /* length of symbol table in bytes */
15 bfd_byte e_entry[BYTES_IN_WORD]; /* start address */
16 bfd_byte e_trsize[BYTES_IN_WORD]; /* length of text relocation info */
17 bfd_byte e_drsize[BYTES_IN_WORD]; /* length of data relocation info */
18 };
19
20 #define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7)
21
22 /* By default, segment size is constant. But on some machines, it can
23 be a function of the a.out header (e.g. machine type). */
24 #ifndef N_SEGSIZE
25 #define N_SEGSIZE(x) SEGMENT_SIZE
26 #endif
27
28 #define _N_HDROFF(x) (N_SEGSIZE(x) - EXEC_BYTES_SIZE)
29 /* address in an a.out of the text section. When demand paged, it's
30 set up a bit to make nothing at 0, when an object file it's 0.
31 There's a special hack case when the entry point is < TEXT_START_ADDR
32 for executables, then the real start is 0
33 */
34
35 #define N_TXTADDR(x) \
36 (N_MAGIC(x)==OMAGIC? 0 \
37 : (N_MAGIC(x) == ZMAGIC && (x).a_entry < TEXT_START_ADDR)? 0 \
38 : TEXT_START_ADDR)
39
40 /* offset in an a.out of the start of the text section. When demand
41 paged, this is the start of the file
42 */
43
44 #define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? 0 : EXEC_BYTES_SIZE)
45 #if ARCH_SIZE==64
46 #define PAGE_SIZE 0x2000
47 #define OMAGIC 0x1001 /* Code indicating object file */
48 #define ZMAGIC 0x1002 /* Code indicating demand-paged executable. */
49 #define NMAGIC 0x1003 /* Code indicating pure executable. */
50 #else
51 #ifndef PAGE_SIZE
52 #define PAGE_SIZE 0x2000
53 #endif
54 #define OMAGIC 0407 /* Code indicating object file or impure executable. */
55 #define NMAGIC 0410 /* Code indicating pure executable. */
56 #define ZMAGIC 0413 /* Code indicating demand-paged executable. */
57 #endif
58
59 #define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
60 && N_MAGIC(x) != NMAGIC \
61 && N_MAGIC(x) != ZMAGIC)
62
63
64
65 #define N_DATADDR(x) \
66 (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
67 : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1))))
68
69 #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
70
71
72 #define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text )
73 #define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
74 #define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
75 #define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
76 #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
77
78
79 /* Symbols */
80 struct external_nlist {
81 bfd_byte e_strx[BYTES_IN_WORD]; /* index into string table of name */
82 bfd_byte e_type[1]; /* type of symbol */
83 bfd_byte e_other[1]; /* misc info (usually empty) */
84 bfd_byte e_desc[2]; /* description field */
85 bfd_byte e_value[BYTES_IN_WORD]; /* value of symbol */
86 };
87
88 #define EXTERNAL_NLIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD)
89
90 struct internal_nlist {
91 unsigned long n_strx; /* index into string table of name */
92 unsigned char n_type; /* type of symbol */
93 unsigned char n_other; /* misc info (usually empty) */
94 unsigned short n_desc; /* description field */
95 bfd_vma n_value; /* value of symbol */
96 };
97
98 /* The n_type field is the symbol type, containing: */
99
100 #define N_UNDF 0 /* Undefined symbol */
101 #define N_ABS 2 /* Absolute symbol -- defined at particular addr */
102 #define N_TEXT 4 /* Text sym -- defined at offset in text seg */
103 #define N_DATA 6 /* Data sym -- defined at offset in data seg */
104 #define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */
105 #define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */
106 #define N_FN 0x1f /* File name of .o file */
107 /* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT,
108 N_DATA, or N_BSS. When the low-order bit of other types is set,
109 (e.g. N_WARNING versus N_FN), they are two different types. */
110 #define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */
111 #define N_TYPE 0x1e
112 #define N_STAB 0xe0 /* If any of these bits are on, it's a debug symbol */
113
114 #define N_INDR 0x0a
115
116 /* The following symbols refer to set elements.
117 All the N_SET[ATDB] symbols with the same name form one set.
118 Space is allocated for the set in the text section, and each set
119 elements value is stored into one word of the space.
120 The first word of the space is the length of the set (number of elements).
121
122 The address of the set is made into an N_SETV symbol
123 whose name is the same as the name of the set.
124 This symbol acts like a N_DATA global symbol
125 in that it can satisfy undefined external references. */
126
127 /* These appear as input to LD, in a .o file. */
128 #define N_SETA 0x14 /* Absolute set element symbol */
129 #define N_SETT 0x16 /* Text set element symbol */
130 #define N_SETD 0x18 /* Data set element symbol */
131 #define N_SETB 0x1A /* Bss set element symbol */
132
133 /* This is output from LD. */
134 #define N_SETV 0x1C /* Pointer to set vector in data area. */
135
136 /* Warning symbol. The text gives a warning message, the next symbol
137 in the table will be undefined. When the symbol is referenced, the
138 message is printed. */
139
140 #define N_WARNING 0x1e
141
142 /* Relocations
143
144 There are two types of relocation flavours for a.out systems,
145 standard and extended. The standard form is used on systems where the
146 instruction has room for all the bits of an offset to the operand, whilst
147 the extended form is used when an address operand has to be split over n
148 instructions. Eg, on the 68k, each move instruction can reference
149 the target with a displacement of 16 or 32 bits. On the sparc, move
150 instructions use an offset of 14 bits, so the offset is stored in
151 the reloc field, and the data in the section is ignored.
152 */
153
154 /* This structure describes a single relocation to be performed.
155 The text-relocation section of the file is a vector of these structures,
156 all of which apply to the text section.
157 Likewise, the data-relocation section applies to the data section. */
158
159 struct reloc_std_external {
160 bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
161 bfd_byte r_index[3]; /* symbol table index of symbol */
162 bfd_byte r_type[1]; /* relocation type */
163 };
164
165 #define RELOC_STD_BITS_PCREL_BIG 0x80
166 #define RELOC_STD_BITS_PCREL_LITTLE 0x01
167
168 #define RELOC_STD_BITS_LENGTH_BIG 0x60
169 #define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
170 #define RELOC_STD_BITS_LENGTH_LITTLE 0x06
171 #define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
172
173 #define RELOC_STD_BITS_EXTERN_BIG 0x10
174 #define RELOC_STD_BITS_EXTERN_LITTLE 0x08
175
176 #define RELOC_STD_BITS_BASEREL_BIG 0x08
177 #define RELOC_STD_BITS_BASEREL_LITTLE 0x08
178
179 #define RELOC_STD_BITS_JMPTABLE_BIG 0x04
180 #define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
181
182 #define RELOC_STD_BITS_RELATIVE_BIG 0x02
183 #define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
184
185 #define RELOC_STD_SIZE (BYTES_IN_WORD + 3 + 1) /* Bytes per relocation entry */
186
187 struct reloc_std_internal
188 {
189 bfd_vma r_address; /* Address (within segment) to be relocated. */
190 /* The meaning of r_symbolnum depends on r_extern. */
191 unsigned int r_symbolnum:24;
192 /* Nonzero means value is a pc-relative offset
193 and it should be relocated for changes in its own address
194 as well as for changes in the symbol or section specified. */
195 unsigned int r_pcrel:1;
196 /* Length (as exponent of 2) of the field to be relocated.
197 Thus, a value of 2 indicates 1<<2 bytes. */
198 unsigned int r_length:2;
199 /* 1 => relocate with value of symbol.
200 r_symbolnum is the index of the symbol
201 in files the symbol table.
202 0 => relocate with the address of a segment.
203 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
204 (the N_EXT bit may be set also, but signifies nothing). */
205 unsigned int r_extern:1;
206 /* The next three bits are for SunOS shared libraries, and seem to
207 be undocumented. */
208 unsigned int r_baserel:1; /* Linkage table relative */
209 unsigned int r_jmptable:1; /* pc-relative to jump table */
210 unsigned int r_relative:1; /* "relative relocation" */
211 /* unused */
212 unsigned int r_pad:1; /* Padding -- set to zero */
213 };
214
215
216 /* EXTENDED RELOCS */
217
218 struct reloc_ext_external {
219 bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */
220 bfd_byte r_index[3]; /* symbol table index of symbol */
221 bfd_byte r_type[1]; /* relocation type */
222 bfd_byte r_addend[BYTES_IN_WORD]; /* datum addend */
223 };
224
225 #define RELOC_EXT_BITS_EXTERN_BIG 0x80
226 #define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
227
228 #define RELOC_EXT_BITS_TYPE_BIG 0x1F
229 #define RELOC_EXT_BITS_TYPE_SH_BIG 0
230 #define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
231 #define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
232
233 /* Bytes per relocation entry */
234 #define RELOC_EXT_SIZE (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD)
235
236 enum reloc_type
237 {
238 /* simple relocations */
239 RELOC_8, /* data[0:7] = addend + sv */
240 RELOC_16, /* data[0:15] = addend + sv */
241 RELOC_32, /* data[0:31] = addend + sv */
242 /* pc-rel displacement */
243 RELOC_DISP8, /* data[0:7] = addend - pc + sv */
244 RELOC_DISP16, /* data[0:15] = addend - pc + sv */
245 RELOC_DISP32, /* data[0:31] = addend - pc + sv */
246 /* Special */
247 RELOC_WDISP30, /* data[0:29] = (addend + sv - pc)>>2 */
248 RELOC_WDISP22, /* data[0:21] = (addend + sv - pc)>>2 */
249 RELOC_HI22, /* data[0:21] = (addend + sv)>>10 */
250 RELOC_22, /* data[0:21] = (addend + sv) */
251 RELOC_13, /* data[0:12] = (addend + sv) */
252 RELOC_LO10, /* data[0:9] = (addend + sv) */
253 RELOC_SFA_BASE,
254 RELOC_SFA_OFF13,
255 /* P.I.C. (base-relative) */
256 RELOC_BASE10, /* Not sure - maybe we can do this the */
257 RELOC_BASE13, /* right way now */
258 RELOC_BASE22,
259 /* for some sort of pc-rel P.I.C. (?) */
260 RELOC_PC10,
261 RELOC_PC22,
262 /* P.I.C. jump table */
263 RELOC_JMP_TBL,
264 /* reputedly for shared libraries somehow */
265 RELOC_SEGOFF16,
266 RELOC_GLOB_DAT,
267 RELOC_JMP_SLOT,
268 RELOC_RELATIVE,
269
270 RELOC_11,
271 RELOC_WDISP2_14,
272 RELOC_WDISP19,
273 RELOC_HHI22, /* data[0:21] = (addend + sv) >> 42 */
274 RELOC_HLO10, /* data[0:9] = (addend + sv) >> 32 */
275
276 /* 29K relocation types */
277 RELOC_JUMPTARG,
278 RELOC_CONST,
279 RELOC_CONSTH,
280
281 /* All the new ones I can think of *//*v9*/
282
283 RELOC_64, /* data[0:63] = addend + sv *//*v9*/
284 RELOC_DISP64, /* data[0:63] = addend - pc + sv *//*v9*/
285 RELOC_WDISP21, /* data[0:20] = (addend + sv - pc)>>2 *//*v9*/
286 RELOC_DISP21, /* data[0:20] = addend - pc + sv *//*v9*/
287 RELOC_DISP14, /* data[0:13] = addend - pc + sv *//*v9*/
288 /* Q .
289 What are the other ones,
290 Since this is a clean slate, can we throw away the ones we dont
291 understand ? Should we sort the values ? What about using a
292 microcode format like the 68k ?
293 */
294 NO_RELOC
295 };
296
297
298 struct reloc_internal {
299 bfd_vma r_address; /* offset of of data to relocate */
300 long r_index; /* symbol table index of symbol */
301 enum reloc_type r_type; /* relocation type */
302 bfd_vma r_addend; /* datum addend */
303 };
304
305 /* Q.
306 Should the length of the string table be 4 bytes or 8 bytes ?
307
308 Q.
309 What about archive indexes ?
310
311 */
312
313 #endif /* __A_OUT_64_H__ */
This page took 0.041576 seconds and 4 git commands to generate.