1 /* `a.out.adobe' differences from standard a.out files
3 Copyright 2001 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
19 #ifndef __A_OUT_ADOBE_H__
20 #define __A_OUT_ADOBE_H__
22 #define BYTES_IN_WORD 4
24 /* Struct external_exec is the same. */
26 /* This is the layout on disk of the 32-bit or 64-bit exec header. */
30 bfd_byte e_info
[4]; /* magic number and stuff */
31 bfd_byte e_text
[BYTES_IN_WORD
]; /* length of text section in bytes */
32 bfd_byte e_data
[BYTES_IN_WORD
]; /* length of data section in bytes */
33 bfd_byte e_bss
[BYTES_IN_WORD
]; /* length of bss area in bytes */
34 bfd_byte e_syms
[BYTES_IN_WORD
]; /* length of symbol table in bytes */
35 bfd_byte e_entry
[BYTES_IN_WORD
]; /* start address */
36 bfd_byte e_trsize
[BYTES_IN_WORD
]; /* length of text relocation info */
37 bfd_byte e_drsize
[BYTES_IN_WORD
]; /* length of data relocation info */
40 #define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7)
42 /* Magic numbers for a.out files */
45 #define ZMAGIC 0xAD0BE /* Cute, eh? */
49 #define N_BADMAG(x) ((x).a_info != ZMAGIC)
51 /* By default, segment size is constant. But some machines override this
52 to be a function of the a.out header (e.g. machine type). */
54 #define N_SEGSIZE(x) SEGMENT_SIZE
56 #undef N_SEGSIZE /* FIXMEXXXX */
58 /* Segment information for the a.out.Adobe format is specified after the
59 file header. It contains N segment descriptors, followed by one with
62 The actual text of the segments starts at N_TXTOFF in the file,
63 regardless of how many or how few segment headers there are. */
65 struct external_segdesc
{
66 unsigned char e_type
[1];
67 unsigned char e_size
[3];
68 unsigned char e_virtbase
[4];
69 unsigned char e_filebase
[4];
72 struct internal_segdesc
{
73 unsigned int a_type
:8; /* Segment type N_TEXT, N_DATA, 0 */
74 unsigned int a_size
:24; /* Segment size */
75 bfd_vma a_virtbase
; /* Virtual address */
76 unsigned int a_filebase
; /* Base address in object file */
79 #define N_TXTADDR(x) \
81 /* This is documented to be at 1024, but appears to really be at 2048.
83 #define N_TXTOFF(x) 2048
85 #define N_TXTSIZE(x) ((x).a_text)
91 /* Offsets of the various portions of the file after the text segment. */
93 #define N_DATOFF(x) ( N_TXTOFF(x) + N_TXTSIZE(x) )
94 #define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data )
95 #define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize )
96 #define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize )
97 #define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms )
100 struct external_nlist
{
101 bfd_byte e_strx
[BYTES_IN_WORD
]; /* index into string table of name */
102 bfd_byte e_type
[1]; /* type of symbol */
103 bfd_byte e_other
[1]; /* misc info (usually empty) */
104 bfd_byte e_desc
[2]; /* description field */
105 bfd_byte e_value
[BYTES_IN_WORD
]; /* value of symbol */
108 #define EXTERNAL_NLIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD)
110 struct internal_nlist
{
111 unsigned long n_strx
; /* index into string table of name */
112 unsigned char n_type
; /* type of symbol */
113 unsigned char n_other
; /* misc info (usually empty) */
114 unsigned short n_desc
; /* description field */
115 bfd_vma n_value
; /* value of symbol */
118 /* The n_type field is the symbol type, containing: */
120 #define N_UNDF 0 /* Undefined symbol */
121 #define N_ABS 2 /* Absolute symbol -- defined at particular addr */
122 #define N_TEXT 4 /* Text sym -- defined at offset in text seg */
123 #define N_DATA 6 /* Data sym -- defined at offset in data seg */
124 #define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */
125 #define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */
126 #define N_FN 0x1f /* File name of .o file */
127 #define N_FN_SEQ 0x0C /* N_FN from Sequent compilers (sigh) */
128 /* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT,
129 N_DATA, or N_BSS. When the low-order bit of other types is set,
130 (e.g. N_WARNING versus N_FN), they are two different types. */
131 #define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */
133 #define N_STAB 0xe0 /* If any of these bits are on, it's a debug symbol */
137 /* The following symbols refer to set elements.
138 All the N_SET[ATDB] symbols with the same name form one set.
139 Space is allocated for the set in the text section, and each set
140 elements value is stored into one word of the space.
141 The first word of the space is the length of the set (number of elements).
143 The address of the set is made into an N_SETV symbol
144 whose name is the same as the name of the set.
145 This symbol acts like a N_DATA global symbol
146 in that it can satisfy undefined external references. */
148 /* These appear as input to LD, in a .o file. */
149 #define N_SETA 0x14 /* Absolute set element symbol */
150 #define N_SETT 0x16 /* Text set element symbol */
151 #define N_SETD 0x18 /* Data set element symbol */
152 #define N_SETB 0x1A /* Bss set element symbol */
154 /* This is output from LD. */
155 #define N_SETV 0x1C /* Pointer to set vector in data area. */
157 /* Warning symbol. The text gives a warning message, the next symbol
158 in the table will be undefined. When the symbol is referenced, the
159 message is printed. */
161 #define N_WARNING 0x1e
165 There are two types of relocation flavours for a.out systems,
166 standard and extended. The standard form is used on systems where the
167 instruction has room for all the bits of an offset to the operand, whilst
168 the extended form is used when an address operand has to be split over n
169 instructions. Eg, on the 68k, each move instruction can reference
170 the target with a displacement of 16 or 32 bits. On the sparc, move
171 instructions use an offset of 14 bits, so the offset is stored in
172 the reloc field, and the data in the section is ignored.
175 /* This structure describes a single relocation to be performed.
176 The text-relocation section of the file is a vector of these structures,
177 all of which apply to the text section.
178 Likewise, the data-relocation section applies to the data section. */
180 struct reloc_std_external
{
181 bfd_byte r_address
[BYTES_IN_WORD
]; /* offset of of data to relocate */
182 bfd_byte r_index
[3]; /* symbol table index of symbol */
183 bfd_byte r_type
[1]; /* relocation type */
186 #define RELOC_STD_BITS_PCREL_BIG 0x80
187 #define RELOC_STD_BITS_PCREL_LITTLE 0x01
189 #define RELOC_STD_BITS_LENGTH_BIG 0x60
190 #define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
191 #define RELOC_STD_BITS_LENGTH_LITTLE 0x06
192 #define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
194 #define RELOC_STD_BITS_EXTERN_BIG 0x10
195 #define RELOC_STD_BITS_EXTERN_LITTLE 0x08
197 #define RELOC_STD_BITS_BASEREL_BIG 0x08
198 #define RELOC_STD_BITS_BASEREL_LITTLE 0x08
200 #define RELOC_STD_BITS_JMPTABLE_BIG 0x04
201 #define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
203 #define RELOC_STD_BITS_RELATIVE_BIG 0x02
204 #define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
206 #define RELOC_STD_SIZE (BYTES_IN_WORD + 3 + 1) /* Bytes per relocation entry */
208 struct reloc_std_internal
210 bfd_vma r_address
; /* Address (within segment) to be relocated. */
211 /* The meaning of r_symbolnum depends on r_extern. */
212 unsigned int r_symbolnum
:24;
213 /* Nonzero means value is a pc-relative offset
214 and it should be relocated for changes in its own address
215 as well as for changes in the symbol or section specified. */
216 unsigned int r_pcrel
:1;
217 /* Length (as exponent of 2) of the field to be relocated.
218 Thus, a value of 2 indicates 1<<2 bytes. */
219 unsigned int r_length
:2;
220 /* 1 => relocate with value of symbol.
221 r_symbolnum is the index of the symbol
222 in files the symbol table.
223 0 => relocate with the address of a segment.
224 r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
225 (the N_EXT bit may be set also, but signifies nothing). */
226 unsigned int r_extern
:1;
227 /* The next three bits are for SunOS shared libraries, and seem to
229 unsigned int r_baserel
:1; /* Linkage table relative */
230 unsigned int r_jmptable
:1; /* pc-relative to jump table */
231 unsigned int r_relative
:1; /* "relative relocation" */
233 unsigned int r_pad
:1; /* Padding -- set to zero */
237 /* EXTENDED RELOCS */
239 struct reloc_ext_external
{
240 bfd_byte r_address
[BYTES_IN_WORD
]; /* offset of of data to relocate */
241 bfd_byte r_index
[3]; /* symbol table index of symbol */
242 bfd_byte r_type
[1]; /* relocation type */
243 bfd_byte r_addend
[BYTES_IN_WORD
]; /* datum addend */
246 #define RELOC_EXT_BITS_EXTERN_BIG 0x80
247 #define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
249 #define RELOC_EXT_BITS_TYPE_BIG 0x1F
250 #define RELOC_EXT_BITS_TYPE_SH_BIG 0
251 #define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
252 #define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
254 /* Bytes per relocation entry */
255 #define RELOC_EXT_SIZE (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD)
259 /* simple relocations */
260 RELOC_8
, /* data[0:7] = addend + sv */
261 RELOC_16
, /* data[0:15] = addend + sv */
262 RELOC_32
, /* data[0:31] = addend + sv */
263 /* pc-rel displacement */
264 RELOC_DISP8
, /* data[0:7] = addend - pc + sv */
265 RELOC_DISP16
, /* data[0:15] = addend - pc + sv */
266 RELOC_DISP32
, /* data[0:31] = addend - pc + sv */
268 RELOC_WDISP30
, /* data[0:29] = (addend + sv - pc)>>2 */
269 RELOC_WDISP22
, /* data[0:21] = (addend + sv - pc)>>2 */
270 RELOC_HI22
, /* data[0:21] = (addend + sv)>>10 */
271 RELOC_22
, /* data[0:21] = (addend + sv) */
272 RELOC_13
, /* data[0:12] = (addend + sv) */
273 RELOC_LO10
, /* data[0:9] = (addend + sv) */
276 /* P.I.C. (base-relative) */
277 RELOC_BASE10
, /* Not sure - maybe we can do this the */
278 RELOC_BASE13
, /* right way now */
280 /* for some sort of pc-rel P.I.C. (?) */
283 /* P.I.C. jump table */
285 /* reputedly for shared libraries somehow */
294 RELOC_HHI22
, /* data[0:21] = (addend + sv) >> 42 */
295 RELOC_HLO10
, /* data[0:9] = (addend + sv) >> 32 */
297 /* 29K relocation types */
306 struct reloc_internal
{
307 bfd_vma r_address
; /* offset of of data to relocate */
308 long r_index
; /* symbol table index of symbol */
309 enum reloc_type r_type
; /* relocation type */
310 bfd_vma r_addend
; /* datum addend */
313 #endif /* __A_OUT_ADOBE_H__ */