OSDN Git Service

974b62e1630eb26f09390586e162c821153be8a0
[pf3gnuchains/pf3gnuchains3x.git] / include / coff / mcore.h
1 /* Motorolla MCore support for BFD.
2    Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19
20 /* This file holds definitions specific to the MCore COFF/PE ABI. */
21
22 #ifndef _COFF_MORE_H
23 #define _COFF_MORE_H
24
25
26 #define E_DIMNUM        4       /* # array dimensions in auxiliary entry */
27
28 #define IMAGE_REL_MCORE_ABSOLUTE                0x0000
29 #define IMAGE_REL_MCORE_ADDR32                  0x0001
30 #define IMAGE_REL_MCORE_PCREL_IMM8BY4           0x0002
31 #define IMAGE_REL_MCORE_PCREL_IMM11BY2          0x0003
32 #define IMAGE_REL_MCORE_PCREL_IMM4BY2           0x0004
33 #define IMAGE_REL_MCORE_PCREL_32                0x0005
34 #define IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2      0x0006
35
36 #define PEMCORE
37
38 typedef struct 
39 {
40   char  magic      [2];         /* type of file                         */
41   char  vstamp     [2];         /* version stamp                        */
42   char  tsize      [4];         /* text size in bytes, padded to FW bdry*/
43   char  dsize      [4];         /* initialized data "  "                */
44   char  bsize      [4];         /* uninitialized data "   "             */
45   char  entry      [4];         /* entry pt.                            */
46   char  text_start [4];         /* base of text used for this file */
47   char  data_start [4];         /* base of data used for this file */
48 }
49 AOUTHDR;
50
51 #define AOUTSZ 28
52 #define AOUTHDRSZ 28
53
54 #define OMAGIC          0404    /* object files, eg as output */
55 #define ZMAGIC          0413    /* demand load format, eg normal ld output */
56 #define STMAGIC         0401    /* target shlib */
57 #define SHMAGIC         0443    /* host   shlib */
58
59 /* From winnt.h */
60 #define IMAGE_NT_OPTIONAL_HDR_MAGIC        0x10b
61
62
63 /* Define some NT default values. */
64 #define NT_SECTION_ALIGNMENT 0x1000
65 #define NT_FILE_ALIGNMENT    0x200  
66 #define NT_DEF_RESERVE       0x100000
67 #define NT_DEF_COMMIT        0x1000
68
69
70 struct external_reloc
71 {
72   char r_vaddr  [4];
73   char r_symndx [4];
74   char r_type   [2];
75   char r_offset [4];
76 };
77
78 #define RELOC struct external_reloc
79 #define RELSZ 14
80
81 #define MCOREMAGIC      0xb00  /* I just made this up */ 
82
83 #define MCOREBADMAG(x) (((x).f_magic!= MCOREMAGIC))
84
85 struct external_filehdr
86 {
87   char f_magic  [2];    /* magic number                 */
88   char f_nscns  [2];    /* number of sections           */
89   char f_timdat [4];    /* time & date stamp            */
90   char f_symptr [4];    /* file pointer to symtab       */
91   char f_nsyms  [4];    /* number of symtab entries     */
92   char f_opthdr [2];    /* sizeof(optional hdr)         */
93   char f_flags  [2];    /* flags                        */
94 };
95
96 #define FILHDR  struct external_filehdr
97 #define FILHSZ  20
98
99
100 #define E_SYMNMLEN      8       /* # characters in a symbol name        */
101 #define E_FILNMLEN      14      /* # characters in a file name          */
102 #define E_DIMNUM        4       /* # array dimensions in auxiliary entry */
103
104 struct external_syment 
105 {
106   union
107   {
108     char e_name [E_SYMNMLEN];
109     struct
110     {
111       char e_zeroes [4];
112       char e_offset [4];
113     } e;
114   } e;
115   
116   char e_value  [4];
117   char e_scnum  [2];
118   char e_type   [2];
119   char e_sclass [1];
120   char e_numaux [1];
121 };
122
123 #define N_BTMASK        0xf
124 #define N_TMASK         0x30
125 #define N_BTSHFT        4
126 #define N_TSHIFT        2
127
128 union external_auxent
129 {
130   struct
131   {
132     char x_tagndx [4];          /* str, un, or enum tag indx */
133     
134     union
135     {
136       struct
137       {
138         char  x_lnno [2];       /* declaration line number */
139         char  x_size [2];       /* str/union/array size */
140       } x_lnsz;
141
142       char x_fsize [4];         /* size of function */
143
144     } x_misc;
145
146     union
147     {
148       struct                    /* if ISFCN, tag, or .bb */
149       {
150         char x_lnnoptr [4];     /* ptr to fcn line # */
151         char x_endndx  [4];     /* entry ndx past block end */
152       } x_fcn;
153
154       struct                    /* if ISARY, up to 4 dimen. */
155       {
156         char x_dimen [E_DIMNUM][2];
157       } x_ary;
158       
159     } x_fcnary;
160
161     char x_tvndx [2];           /* tv index */
162
163   } x_sym;
164
165   union
166   {
167     char x_fname [E_FILNMLEN];
168     
169     struct
170     {
171       char x_zeroes [4];
172       char x_offset [4];
173     } x_n;
174     
175   } x_file;
176
177   struct
178   {
179     char x_scnlen     [4];      /* section length */
180     char x_nreloc     [2];      /* # relocation entries */
181     char x_nlinno     [2];      /* # line numbers */
182     char x_checksum   [4];      /* section COMDAT checksum */
183     char x_associated [2];      /* COMDAT associated section index */
184     char x_comdat     [1];      /* COMDAT selection number */
185   } x_scn;
186
187   struct
188   {
189     char x_tvfill [4];          /* tv fill value */
190     char x_tvlen  [2];          /* length of .tv */
191     char x_tvran  [2][2];       /* tv range */
192   } x_tv;                       /* info about .tv section (in auxent of symbol .tv)) */
193 };
194
195 #define SYMENT  struct external_syment
196 #define SYMESZ  18      
197 #define AUXENT  union external_auxent
198 #define AUXESZ  18
199
200 /* 1 line number entry for every "breakpointable" source line in a section.
201    Line numbers are grouped on a per function basis; first entry in a function
202    grouping will have l_lnno = 0 and in place of physical address will be the
203    symbol table index of the function name.  */
204 struct external_lineno
205 {
206   union
207   {
208     char l_symndx [4];  /* function name symbol index, iff l_lnno == 0*/
209     char l_paddr  [4];  /* (physical) address of line number    */
210   } l_addr;
211
212   char l_lnno [2];      /* line number          */
213 };
214
215 #define LINENO  struct external_lineno
216 #define LINESZ  6
217
218 #define GET_LINENO_LNNO(abfd, ext)     bfd_h_get_32 (abfd, (bfd_byte *) (ext->l_lnno));
219 #define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32 (abfd, val, (bfd_byte *) (ext->l_lnno));
220
221 struct external_scnhdr
222 {
223   char  s_name    [8];  /* section name                 */
224   char  s_paddr   [4];  /* physical address, aliased s_nlib */
225   char  s_vaddr   [4];  /* virtual address              */
226   char  s_size    [4];  /* section size                 */
227   char  s_scnptr  [4];  /* file ptr to raw data for section */
228   char  s_relptr  [4];  /* file ptr to relocation       */
229   char  s_lnnoptr [4];  /* file ptr to line numbers     */
230   char  s_nreloc  [2];  /* number of relocation entries */
231   char  s_nlnno   [2];  /* number of line number entries*/
232   char  s_flags   [4];  /* flags                        */
233 };
234
235 #define SCNHDR  struct external_scnhdr
236 #define SCNHSZ  40
237
238 /* Names of "special" sections.  */
239 #define _TEXT   ".text"
240 #define _DATA   ".data"
241 #define _BSS    ".bss"
242
243
244
245 #endif /* __COFF_MCORE_H */