1 | /* IBM RS/6000 "XCOFF64" file definitions for BFD.
|
---|
2 | Copyright (C) 2000, 2002 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
---|
17 |
|
---|
18 | /********************** FILE HEADER **********************/
|
---|
19 |
|
---|
20 | struct external_filehdr
|
---|
21 | {
|
---|
22 | char f_magic[2]; /* magic number */
|
---|
23 | char f_nscns[2]; /* number of sections */
|
---|
24 | char f_timdat[4]; /* time & date stamp */
|
---|
25 | char f_symptr[8]; /* file pointer to symtab */
|
---|
26 | char f_opthdr[2]; /* sizeof(optional hdr) */
|
---|
27 | char f_flags[2]; /* flags */
|
---|
28 | char f_nsyms[4]; /* number of symtab entries */
|
---|
29 | };
|
---|
30 |
|
---|
31 | /* IBM RS/6000. */
|
---|
32 | #define U803XTOCMAGIC 0757 /* Aix 4.3 64-bit XCOFF */
|
---|
33 | #define U64_TOCMAGIC 0767 /* AIX 5+ 64-bit XCOFF */
|
---|
34 | #define BADMAG(x) ((x).f_magic != U803XTOCMAGIC && (x).f_magic != U64_TOCMAGIC)
|
---|
35 |
|
---|
36 | #define FILHDR struct external_filehdr
|
---|
37 | #define FILHSZ 24
|
---|
38 |
|
---|
39 | /********************** AOUT "OPTIONAL HEADER" **********************/
|
---|
40 |
|
---|
41 | typedef struct
|
---|
42 | {
|
---|
43 | unsigned char magic[2]; /* type of file */
|
---|
44 | unsigned char vstamp[2]; /* version stamp */
|
---|
45 | unsigned char o_debugger[4]; /* reserved */
|
---|
46 | unsigned char text_start[8]; /* base of text used for this file */
|
---|
47 | unsigned char data_start[8]; /* base of data used for this file */
|
---|
48 | unsigned char o_toc[8]; /* address of TOC */
|
---|
49 | unsigned char o_snentry[2]; /* section number of entry point */
|
---|
50 | unsigned char o_sntext[2]; /* section number of .text section */
|
---|
51 | unsigned char o_sndata[2]; /* section number of .data section */
|
---|
52 | unsigned char o_sntoc[2]; /* section number of TOC */
|
---|
53 | unsigned char o_snloader[2]; /* section number of .loader section */
|
---|
54 | unsigned char o_snbss[2]; /* section number of .bss section */
|
---|
55 | unsigned char o_algntext[2]; /* .text alignment */
|
---|
56 | unsigned char o_algndata[2]; /* .data alignment */
|
---|
57 | unsigned char o_modtype[2]; /* module type (??) */
|
---|
58 | unsigned char o_cputype[2]; /* cpu type */
|
---|
59 | unsigned char o_resv2[4]; /* reserved */
|
---|
60 | unsigned char tsize[8]; /* text size bytes, padded to FW bdry */
|
---|
61 | unsigned char dsize[8]; /* initialized data " " */
|
---|
62 | unsigned char bsize[8]; /* uninitialized data " " */
|
---|
63 | unsigned char entry[8]; /* entry pt. */
|
---|
64 | unsigned char o_maxstack[8]; /* max stack size (??) */
|
---|
65 | unsigned char o_maxdata[8]; /* max data size (??) */
|
---|
66 | unsigned char o_resv3[16]; /* reserved */
|
---|
67 | }
|
---|
68 | AOUTHDR;
|
---|
69 |
|
---|
70 | #define AOUTSZ 120
|
---|
71 | #define SMALL_AOUTSZ (0)
|
---|
72 | #define AOUTHDRSZ 72
|
---|
73 |
|
---|
74 | /********************** SECTION HEADER **********************/
|
---|
75 |
|
---|
76 | struct external_scnhdr
|
---|
77 | {
|
---|
78 | char s_name[8]; /* section name */
|
---|
79 | char s_paddr[8]; /* physical address, aliased s_nlib */
|
---|
80 | char s_vaddr[8]; /* virtual address */
|
---|
81 | char s_size[8]; /* section size */
|
---|
82 | char s_scnptr[8]; /* file ptr to raw data for section */
|
---|
83 | char s_relptr[8]; /* file ptr to relocation */
|
---|
84 | char s_lnnoptr[8]; /* file ptr to line numbers */
|
---|
85 | char s_nreloc[4]; /* number of relocation entries */
|
---|
86 | char s_nlnno[4]; /* number of line number entries*/
|
---|
87 | char s_flags[4]; /* flags */
|
---|
88 | char s_pad[4]; /* padding */
|
---|
89 | };
|
---|
90 |
|
---|
91 | #define SCNHDR struct external_scnhdr
|
---|
92 |
|
---|
93 | #define SCNHSZ 72
|
---|
94 |
|
---|
95 | /********************** LINE NUMBERS **********************/
|
---|
96 |
|
---|
97 | /* 1 line number entry for every "breakpointable" source line in a section.
|
---|
98 | Line numbers are grouped on a per function basis; first entry in a function
|
---|
99 | grouping will have l_lnno = 0 and in place of physical address will be the
|
---|
100 | symbol table index of the function name. */
|
---|
101 |
|
---|
102 | struct external_lineno
|
---|
103 | {
|
---|
104 | union
|
---|
105 | {
|
---|
106 | char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
|
---|
107 | char l_paddr[8]; /* (physical) address of line number */
|
---|
108 | } l_addr;
|
---|
109 |
|
---|
110 | char l_lnno[4]; /* line number */
|
---|
111 | };
|
---|
112 |
|
---|
113 | #define LINENO struct external_lineno
|
---|
114 |
|
---|
115 | #define LINESZ 12
|
---|
116 |
|
---|
117 | /********************** SYMBOLS **********************/
|
---|
118 |
|
---|
119 | #define E_SYMNMLEN 8 /* # characters in a symbol name */
|
---|
120 | #define E_FILNMLEN 14 /* # characters in a file name */
|
---|
121 | #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
|
---|
122 |
|
---|
123 | struct external_syment
|
---|
124 | {
|
---|
125 | char e_value[8];
|
---|
126 | char e_offset[4];
|
---|
127 | char e_scnum[2];
|
---|
128 | char e_type[2];
|
---|
129 | char e_sclass[1];
|
---|
130 | char e_numaux[1];
|
---|
131 | };
|
---|
132 |
|
---|
133 | #define N_BTMASK (017)
|
---|
134 | #define N_TMASK (060)
|
---|
135 | #define N_BTSHFT (4)
|
---|
136 | #define N_TSHIFT (2)
|
---|
137 |
|
---|
138 | union external_auxent
|
---|
139 | {
|
---|
140 | struct {
|
---|
141 | union {
|
---|
142 | struct {
|
---|
143 | char x_lnno[4]; /* declaration line number */
|
---|
144 | char x_size[2]; /* str/union/array size */
|
---|
145 | } x_lnsz;
|
---|
146 | struct {
|
---|
147 | char x_lnnoptr[8];/* ptr to fcn line */
|
---|
148 | char x_fsize[4]; /* size of function */
|
---|
149 | char x_endndx[4]; /* entry ndx past block end */
|
---|
150 | } x_fcn;
|
---|
151 | } x_fcnary;
|
---|
152 | } x_sym;
|
---|
153 |
|
---|
154 | union {
|
---|
155 | char x_fname[E_FILNMLEN];
|
---|
156 | struct {
|
---|
157 | char x_zeroes[4];
|
---|
158 | char x_offset[4];
|
---|
159 | char x_pad[6];
|
---|
160 | unsigned char x_ftype[1];
|
---|
161 | unsigned char x_resv[2];
|
---|
162 | } x_n;
|
---|
163 | } x_file;
|
---|
164 |
|
---|
165 | struct {
|
---|
166 | char x_exptr[8];
|
---|
167 | char x_fsize[4];
|
---|
168 | char x_endndx[4];
|
---|
169 | char x_pad[1];
|
---|
170 | } x_except;
|
---|
171 |
|
---|
172 | struct {
|
---|
173 | unsigned char x_scnlen_lo[4];
|
---|
174 | unsigned char x_parmhash[4];
|
---|
175 | unsigned char x_snhash[2];
|
---|
176 | unsigned char x_smtyp[1];
|
---|
177 | unsigned char x_smclas[1];
|
---|
178 | unsigned char x_scnlen_hi[4];
|
---|
179 | unsigned char x_pad[1];
|
---|
180 | } x_csect;
|
---|
181 |
|
---|
182 | struct {
|
---|
183 | char x_pad[17];
|
---|
184 | char x_auxtype[1];
|
---|
185 | } x_auxtype;
|
---|
186 | };
|
---|
187 |
|
---|
188 | #define SYMENT struct external_syment
|
---|
189 | #define SYMESZ 18
|
---|
190 | #define AUXENT union external_auxent
|
---|
191 | #define AUXESZ 18
|
---|
192 | #define DBXMASK 0x80 /* for dbx storage mask */
|
---|
193 | #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
|
---|
194 |
|
---|
195 | /* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h. */
|
---|
196 | #define _AUX_EXCEPT 255
|
---|
197 | #define _AUX_FCN 254
|
---|
198 | #define _AUX_SYM 253
|
---|
199 | #define _AUX_FILE 252
|
---|
200 | #define _AUX_CSECT 251
|
---|
201 |
|
---|
202 | /********************** RELOCATION DIRECTIVES **********************/
|
---|
203 |
|
---|
204 | struct external_reloc
|
---|
205 | {
|
---|
206 | char r_vaddr[8];
|
---|
207 | char r_symndx[4];
|
---|
208 | char r_size[1];
|
---|
209 | char r_type[1];
|
---|
210 | };
|
---|
211 |
|
---|
212 | #define RELOC struct external_reloc
|
---|
213 | #define RELSZ 14
|
---|
214 |
|
---|
215 | #define DEFAULT_DATA_SECTION_ALIGNMENT 4
|
---|
216 | #define DEFAULT_BSS_SECTION_ALIGNMENT 4
|
---|
217 | #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
|
---|
218 | /* For new sections we havn't heard of before */
|
---|
219 | #define DEFAULT_SECTION_ALIGNMENT 4
|
---|
220 |
|
---|
221 | /* The ldhdr structure. This appears at the start of the .loader
|
---|
222 | section. */
|
---|
223 |
|
---|
224 | struct external_ldhdr
|
---|
225 | {
|
---|
226 | bfd_byte l_version[4];
|
---|
227 | bfd_byte l_nsyms[4];
|
---|
228 | bfd_byte l_nreloc[4];
|
---|
229 | bfd_byte l_istlen[4];
|
---|
230 | bfd_byte l_nimpid[4];
|
---|
231 | bfd_byte l_stlen[4];
|
---|
232 | bfd_byte l_impoff[8];
|
---|
233 | bfd_byte l_stoff[8];
|
---|
234 | bfd_byte l_symoff[8];
|
---|
235 | bfd_byte l_rldoff[8];
|
---|
236 | };
|
---|
237 | #define LDHDRSZ (56)
|
---|
238 |
|
---|
239 | struct external_ldsym
|
---|
240 | {
|
---|
241 | bfd_byte l_value[8];
|
---|
242 | bfd_byte l_offset[4];
|
---|
243 | bfd_byte l_scnum[2];
|
---|
244 | bfd_byte l_smtype[1];
|
---|
245 | bfd_byte l_smclas[1];
|
---|
246 | bfd_byte l_ifile[4];
|
---|
247 | bfd_byte l_parm[4];
|
---|
248 | };
|
---|
249 |
|
---|
250 | #define LDSYMSZ (24)
|
---|
251 |
|
---|
252 | struct external_ldrel
|
---|
253 | {
|
---|
254 | bfd_byte l_vaddr[8];
|
---|
255 | bfd_byte l_rtype[2];
|
---|
256 | bfd_byte l_rsecnm[2];
|
---|
257 | bfd_byte l_symndx[4];
|
---|
258 | };
|
---|
259 |
|
---|
260 | #define LDRELSZ (16)
|
---|