OSDN Git Service

a8675bd86024d9b6b53f6e4beb89fed43b6cf1c3
[pf3gnuchains/pf3gnuchains3x.git] / include / coff / rs6k64.h
1 /* IBM RS/6000 "XCOFF64" file definitions for BFD.
2
3    Copyright 2000 Free Software Foundation, Inc.
4
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.
9    
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.
14    
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18
19 #define DO_NOT_DEFINE_AOUTHDR
20 #define DO_NOT_DEFINE_SCNHDR
21 #define DO_NOT_DEFINE_LINENO
22 #define DO_NOT_DEFINE_AUXENT
23 #include "coff/external.h"
24
25         /* IBM RS/6000 */
26 #define U803XTOCMAGIC 0757      /* readonly text segments and TOC, XCOFF64 */
27
28 #define BADMAG(x) ((x).f_magic != U803XTOCMAGIC)
29
30 /********************** AOUT "OPTIONAL HEADER" **********************/
31
32 typedef struct 
33 {
34   unsigned char magic[2];       /* type of file                 */
35   unsigned char vstamp[2];      /* version stamp                */
36   unsigned char o_debugger[4];  /* reserved                     */
37   unsigned char text_start[8];  /* base of text used for this file */
38   unsigned char data_start[8];  /* base of data used for this file */
39   unsigned char o_toc[8];       /* address of TOC */
40   unsigned char o_snentry[2];   /* section number of entry point */
41   unsigned char o_sntext[2];    /* section number of .text section */
42   unsigned char o_sndata[2];    /* section number of .data section */
43   unsigned char o_sntoc[2];     /* section number of TOC */
44   unsigned char o_snloader[2];  /* section number of .loader section */
45   unsigned char o_snbss[2];     /* section number of .bss section */
46   unsigned char o_algntext[2];  /* .text alignment */
47   unsigned char o_algndata[2];  /* .data alignment */
48   unsigned char o_modtype[2];   /* module type (??) */
49   unsigned char o_cputype[2];   /* cpu type */
50   unsigned char o_resv2[4];     /* reserved                     */
51   unsigned char tsize[8];       /* text size bytes, padded to FW bdry */
52   unsigned char dsize[8];       /* initialized data "  "        */
53   unsigned char bsize[8];       /* uninitialized data "   "     */
54   unsigned char entry[8];       /* entry pt.                    */
55   unsigned char o_maxstack[8];  /* max stack size (??)          */
56   unsigned char o_maxdata[8];   /* max data size (??)           */
57   unsigned char o_resv3[16];    /* reserved                     */
58 }
59 AOUTHDR;
60
61 #define AOUTSZ 120
62 #define SMALL_AOUTSZ (0)
63 #define AOUTHDRSZ 72
64
65 #define RS6K_AOUTHDR_OMAGIC     0x0107  /* old: text & data writeable */
66 #define RS6K_AOUTHDR_NMAGIC     0x0108  /* new: text r/o, data r/w */
67 #define RS6K_AOUTHDR_ZMAGIC     0x010B  /* paged: text r/o, both page-aligned */
68
69
70 /********************** SECTION HEADER **********************/
71 struct external_scnhdr
72 {
73         char    s_name[8];      /* section name                 */
74         char    s_paddr[8];     /* physical address, aliased s_nlib */
75         char    s_vaddr[8];     /* virtual address              */
76         char    s_size[8];      /* section size                 */
77         char    s_scnptr[8];    /* file ptr to raw data for section */
78         char    s_relptr[8];    /* file ptr to relocation       */
79         char    s_lnnoptr[8];   /* file ptr to line numbers     */
80         char    s_nreloc[4];    /* number of relocation entries */
81         char    s_nlnno[4];     /* number of line number entries*/
82         char    s_flags[4];     /* flags                        */
83         char    s_pad[4];       /* padding */  
84 };
85
86 /*
87  * names of "special" sections
88  */
89 #define _TEXT   ".text"
90 #define _DATA   ".data"
91 #define _BSS    ".bss"
92 #define _PAD    ".pad"
93 #define _LOADER ".loader"
94
95 #define SCNHDR  struct external_scnhdr
96
97 #define SCNHSZ  72
98
99 /* XCOFF uses a special .loader section with type STYP_LOADER.  */
100 #define STYP_LOADER 0x1000
101
102 /* XCOFF uses a special .debug section with type STYP_DEBUG.  */
103 #define STYP_DEBUG 0x2000
104
105 /* XCOFF handles line number or relocation overflow by creating
106    another section header with STYP_OVRFLO set.  */
107 #define STYP_OVRFLO 0x8000
108
109 /********************** LINE NUMBERS **********************/
110
111 /* 1 line number entry for every "breakpointable" source line in a section.
112    Line numbers are grouped on a per function basis; first entry in a function
113    grouping will have l_lnno = 0 and in place of physical address will be the
114    symbol table index of the function name.  */
115 struct external_lineno
116 {
117   union
118   {
119     char l_symndx[8];/* function name symbol index, iff l_lnno == 0*/
120     char l_paddr[8];    /* (physical) address of line number    */
121   } l_addr;
122
123   char l_lnno[4];               /* line number          */
124 };
125
126 #define LINENO  struct external_lineno
127 #define LINESZ  12
128
129
130 union external_auxent
131 {
132   struct
133   {
134     union
135     {
136       struct
137       {
138         char x_lnno[4];         /* declaration line number */
139         char x_size[2];         /* str/union/array size */
140       } x_lnsz;
141       
142       struct
143       {
144         char x_lnnoptr[8];/* ptr to fcn line */
145         char x_fsize[4];         /* size of function */
146         char x_endndx[4];        /* entry ndx past block end */
147       } x_fcn;
148
149     } x_fcnary;
150
151   } x_sym;
152          
153   union
154   {
155     char x_fname[E_FILNMLEN];
156     
157     struct
158     {
159       char x_zeroes[4];
160       char x_offset[4];
161       char          x_pad[6];
162       unsigned char x_ftype[1];
163       unsigned char x_resv[2];
164     } x_n;
165
166   } x_file;
167
168   struct
169   {
170     char x_exptr[8];
171     char x_fsize[4];
172     char x_endndx[4];
173     char x_pad[1];
174   } x_except;
175
176   struct
177   {
178     unsigned char x_scnlen_lo[4];
179     unsigned char x_parmhash[4];
180     unsigned char x_snhash[2];
181     unsigned char x_smtyp[1];
182     unsigned char x_smclas[1];
183     unsigned char x_scnlen_hi[4];
184     unsigned char x_pad[1];
185   } x_csect;    
186
187   struct
188   {
189     char x_pad[17];
190     char x_auxtype[1];
191   } x_auxtype;
192 };
193
194 #define AUXENT  union external_auxent
195 #define AUXESZ  18
196
197 #define DBXMASK 0x80            /* for dbx storage mask */
198 #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
199
200 /* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h */
201 #define _AUX_EXCEPT     255
202 #define _AUX_FCN        254
203 #define _AUX_SYM        253
204 #define _AUX_FILE       252
205 #define _AUX_CSECT      251
206
207 /********************** RELOCATION DIRECTIVES **********************/
208
209 struct external_reloc
210 {
211   char r_vaddr[8];
212   char r_symndx[4];
213   char r_size[1];
214   char r_type[1];
215 };
216
217 #define RELOC struct external_reloc
218 #define RELSZ 14
219
220 #define DEFAULT_DATA_SECTION_ALIGNMENT 4
221 #define DEFAULT_BSS_SECTION_ALIGNMENT 4
222 #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
223 /* For new sections we havn't heard of before */
224 #define DEFAULT_SECTION_ALIGNMENT 4