xref: /openbsd-src/gnu/usr.bin/binutils/include/coff/external.h (revision 272a140b8ad54120f5c6308aa962815d8af3bd19)
1d2201f2fSdrahn /* external.h  -- External COFF structures
2d2201f2fSdrahn 
3d2201f2fSdrahn    Copyright 2001 Free Software Foundation, Inc.
4d2201f2fSdrahn 
5d2201f2fSdrahn    This program is free software; you can redistribute it and/or modify
6d2201f2fSdrahn    it under the terms of the GNU General Public License as published by
7d2201f2fSdrahn    the Free Software Foundation; either version 2 of the License, or
8d2201f2fSdrahn    (at your option) any later version.
9d2201f2fSdrahn 
10d2201f2fSdrahn    This program is distributed in the hope that it will be useful,
11d2201f2fSdrahn    but WITHOUT ANY WARRANTY; without even the implied warranty of
12d2201f2fSdrahn    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13d2201f2fSdrahn    GNU General Public License for more details.
14d2201f2fSdrahn 
15d2201f2fSdrahn    You should have received a copy of the GNU General Public License
16d2201f2fSdrahn    along with this program; if not, write to the Free Software
17d2201f2fSdrahn    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18d2201f2fSdrahn 
19d2201f2fSdrahn #ifndef COFF_EXTERNAL_H
20d2201f2fSdrahn #define COFF_EXTERNAL_H
21d2201f2fSdrahn 
22d2201f2fSdrahn #ifndef DO_NOT_DEFINE_FILHDR
23d2201f2fSdrahn /********************** FILE HEADER **********************/
24d2201f2fSdrahn 
25d2201f2fSdrahn struct external_filehdr
26d2201f2fSdrahn   {
27d2201f2fSdrahn     char f_magic[2];	/* magic number			*/
28d2201f2fSdrahn     char f_nscns[2];	/* number of sections		*/
29d2201f2fSdrahn     char f_timdat[4];	/* time & date stamp		*/
30d2201f2fSdrahn     char f_symptr[4];	/* file pointer to symtab	*/
31d2201f2fSdrahn     char f_nsyms[4];	/* number of symtab entries	*/
32d2201f2fSdrahn     char f_opthdr[2];	/* sizeof(optional hdr)		*/
33d2201f2fSdrahn     char f_flags[2];	/* flags			*/
34d2201f2fSdrahn   };
35d2201f2fSdrahn 
36d2201f2fSdrahn #define	FILHDR	struct external_filehdr
37d2201f2fSdrahn #define	FILHSZ	20
38d2201f2fSdrahn #endif
39d2201f2fSdrahn 
40d2201f2fSdrahn #ifndef DO_NOT_DEFINE_AOUTHDR
41d2201f2fSdrahn /********************** AOUT "OPTIONAL HEADER" **********************/
42d2201f2fSdrahn 
43d2201f2fSdrahn typedef struct external_aouthdr
44d2201f2fSdrahn   {
45d2201f2fSdrahn     char magic[2];	/* type of file				*/
46d2201f2fSdrahn     char vstamp[2];	/* version stamp			*/
47d2201f2fSdrahn     char tsize[4];	/* text size in bytes, padded to FW bdry*/
48d2201f2fSdrahn     char dsize[4];	/* initialized data "  "		*/
49d2201f2fSdrahn     char bsize[4];	/* uninitialized data "   "		*/
50d2201f2fSdrahn     char entry[4];	/* entry pt.				*/
51d2201f2fSdrahn     char text_start[4];	/* base of text used for this file 	*/
52d2201f2fSdrahn     char data_start[4];	/* base of data used for this file 	*/
53d2201f2fSdrahn   }
54d2201f2fSdrahn AOUTHDR;
55d2201f2fSdrahn 
56d2201f2fSdrahn #define AOUTHDRSZ 28
57d2201f2fSdrahn #define AOUTSZ 28
58d2201f2fSdrahn #endif
59d2201f2fSdrahn 
60*272a140bSkettenis typedef struct external_aouthdr64
61*272a140bSkettenis {
62*272a140bSkettenis   char magic[2];	/* Type of file.			*/
63*272a140bSkettenis   char vstamp[2];	/* Version stamp.			*/
64*272a140bSkettenis   char tsize[4];	/* Text size in bytes, padded to FW bdry*/
65*272a140bSkettenis   char dsize[4];	/* Initialized data "  ".		*/
66*272a140bSkettenis   char bsize[4];	/* Uninitialized data "   ".		*/
67*272a140bSkettenis   char entry[4];	/* Entry pt.				*/
68*272a140bSkettenis   char text_start[4];	/* Base of text used for this file. 	*/
69*272a140bSkettenis }
70*272a140bSkettenis AOUTHDR64;
71*272a140bSkettenis #define AOUTHDRSZ64	24
72*272a140bSkettenis 
73d2201f2fSdrahn #ifndef DO_NOT_DEFINE_SCNHDR
74d2201f2fSdrahn /********************** SECTION HEADER **********************/
75d2201f2fSdrahn 
76d2201f2fSdrahn struct external_scnhdr
77d2201f2fSdrahn   {
78d2201f2fSdrahn     char s_name[8];	/* section name				*/
79d2201f2fSdrahn     char s_paddr[4];	/* physical address, aliased s_nlib 	*/
80d2201f2fSdrahn     char s_vaddr[4];	/* virtual address			*/
81d2201f2fSdrahn     char s_size[4];	/* section size				*/
82d2201f2fSdrahn     char s_scnptr[4];	/* file ptr to raw data for section 	*/
83d2201f2fSdrahn     char s_relptr[4];	/* file ptr to relocation		*/
84d2201f2fSdrahn     char s_lnnoptr[4];	/* file ptr to line numbers		*/
85d2201f2fSdrahn     char s_nreloc[2];	/* number of relocation entries		*/
86d2201f2fSdrahn     char s_nlnno[2];	/* number of line number entries	*/
87d2201f2fSdrahn     char s_flags[4];	/* flags				*/
88d2201f2fSdrahn   };
89d2201f2fSdrahn 
90d2201f2fSdrahn #define	SCNHDR	struct external_scnhdr
91d2201f2fSdrahn #define	SCNHSZ	40
92d2201f2fSdrahn 
93d2201f2fSdrahn /* Names of "special" sections.  */
94d2201f2fSdrahn 
95d2201f2fSdrahn #define _TEXT	 ".text"
96d2201f2fSdrahn #define _DATA	 ".data"
97d2201f2fSdrahn #define _BSS	 ".bss"
98d2201f2fSdrahn #define _COMMENT ".comment"
99d2201f2fSdrahn #define _LIB     ".lib"
100d2201f2fSdrahn #endif /* not DO_NOT_DEFINE_SCNHDR */
101d2201f2fSdrahn 
102d2201f2fSdrahn #ifndef DO_NOT_DEFINE_LINENO
103d2201f2fSdrahn 
104d2201f2fSdrahn /********************** LINE NUMBERS **********************/
105d2201f2fSdrahn 
106d2201f2fSdrahn #ifndef L_LNNO_SIZE
107d2201f2fSdrahn #error  L_LNNO_SIZE needs to be defined
108d2201f2fSdrahn #endif
109d2201f2fSdrahn 
110d2201f2fSdrahn /* 1 line number entry for every "breakpointable" source line in a section.
111d2201f2fSdrahn    Line numbers are grouped on a per function basis; first entry in a function
112d2201f2fSdrahn    grouping will have l_lnno = 0 and in place of physical address will be the
113d2201f2fSdrahn    symbol table index of the function name.  */
114d2201f2fSdrahn struct external_lineno
115d2201f2fSdrahn {
116d2201f2fSdrahn   union
117d2201f2fSdrahn   {
118d2201f2fSdrahn     char l_symndx[4];	/* function name symbol index, iff l_lnno == 0*/
119d2201f2fSdrahn     char l_paddr[4];	/* (physical) address of line number	*/
120d2201f2fSdrahn   } l_addr;
121d2201f2fSdrahn 
122d2201f2fSdrahn   char l_lnno[L_LNNO_SIZE];	/* line number		*/
123d2201f2fSdrahn };
124d2201f2fSdrahn 
125d2201f2fSdrahn #define	LINENO	struct external_lineno
126d2201f2fSdrahn #define	LINESZ	(4 + L_LNNO_SIZE)
127d2201f2fSdrahn 
128d2201f2fSdrahn #if L_LNNO_SIZE == 4
129d2201f2fSdrahn #define GET_LINENO_LNNO(abfd, ext)      H_GET_32 (abfd,      (ext->l_lnno))
130d2201f2fSdrahn #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_32 (abfd, val, (ext->l_lnno))
131d2201f2fSdrahn #endif
132d2201f2fSdrahn #if L_LNNO_SIZE == 2
133d2201f2fSdrahn #define GET_LINENO_LNNO(abfd, ext)      H_GET_16 (abfd,      (ext->l_lnno))
134d2201f2fSdrahn #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_16 (abfd, val, (ext->l_lnno))
135d2201f2fSdrahn #endif
136d2201f2fSdrahn 
137d2201f2fSdrahn #endif /* not DO_NOT_DEFINE_LINENO */
138d2201f2fSdrahn 
139d2201f2fSdrahn #ifndef DO_NOT_DEFINE_SYMENT
140d2201f2fSdrahn /********************** SYMBOLS **********************/
141d2201f2fSdrahn 
142d2201f2fSdrahn #define E_SYMNMLEN	8	/* # characters in a symbol name	*/
143d2201f2fSdrahn #ifndef E_FILNMLEN
144d2201f2fSdrahn #define E_FILNMLEN	14
145d2201f2fSdrahn #endif
146d2201f2fSdrahn #define E_DIMNUM	4	/* # array dimensions in auxiliary entry */
147d2201f2fSdrahn 
148d2201f2fSdrahn struct external_syment
149d2201f2fSdrahn {
150d2201f2fSdrahn   union
151d2201f2fSdrahn   {
152d2201f2fSdrahn     char e_name[E_SYMNMLEN];
153d2201f2fSdrahn 
154d2201f2fSdrahn     struct
155d2201f2fSdrahn     {
156d2201f2fSdrahn       char e_zeroes[4];
157d2201f2fSdrahn       char e_offset[4];
158d2201f2fSdrahn     } e;
159d2201f2fSdrahn   } e;
160d2201f2fSdrahn 
161d2201f2fSdrahn   char e_value[4];
162d2201f2fSdrahn   char e_scnum[2];
163d2201f2fSdrahn   char e_type[2];
164d2201f2fSdrahn   char e_sclass[1];
165d2201f2fSdrahn   char e_numaux[1];
166d2201f2fSdrahn };
167d2201f2fSdrahn 
168d2201f2fSdrahn #define	SYMENT	struct external_syment
169d2201f2fSdrahn #define	SYMESZ	18
170d2201f2fSdrahn 
171d2201f2fSdrahn #ifndef N_BTMASK
172d2201f2fSdrahn #define N_BTMASK	0xf
173d2201f2fSdrahn #endif
174d2201f2fSdrahn 
175d2201f2fSdrahn #ifndef N_TMASK
176d2201f2fSdrahn #define N_TMASK		0x30
177d2201f2fSdrahn #endif
178d2201f2fSdrahn 
179d2201f2fSdrahn #ifndef N_BTSHFT
180d2201f2fSdrahn #define N_BTSHFT	4
181d2201f2fSdrahn #endif
182d2201f2fSdrahn 
183d2201f2fSdrahn #ifndef N_TSHIFT
184d2201f2fSdrahn #define N_TSHIFT	2
185d2201f2fSdrahn #endif
186d2201f2fSdrahn 
187d2201f2fSdrahn #endif /* not DO_NOT_DEFINE_SYMENT */
188d2201f2fSdrahn 
189d2201f2fSdrahn #ifndef DO_NOT_DEFINE_AUXENT
190d2201f2fSdrahn 
191d2201f2fSdrahn union external_auxent
192d2201f2fSdrahn {
193d2201f2fSdrahn   struct
194d2201f2fSdrahn   {
195d2201f2fSdrahn     char x_tagndx[4];		/* str, un, or enum tag indx */
196d2201f2fSdrahn 
197d2201f2fSdrahn     union
198d2201f2fSdrahn     {
199d2201f2fSdrahn       struct
200d2201f2fSdrahn       {
201d2201f2fSdrahn 	char  x_lnno[2]; /* declaration line number */
202d2201f2fSdrahn 	char  x_size[2]; /* str/union/array size */
203d2201f2fSdrahn       } x_lnsz;
204d2201f2fSdrahn 
205d2201f2fSdrahn       char x_fsize[4];	/* size of function */
206d2201f2fSdrahn 
207d2201f2fSdrahn     } x_misc;
208d2201f2fSdrahn 
209d2201f2fSdrahn     union
210d2201f2fSdrahn     {
211d2201f2fSdrahn       struct 		/* if ISFCN, tag, or .bb */
212d2201f2fSdrahn       {
213d2201f2fSdrahn 	char x_lnnoptr[4];	/* ptr to fcn line # */
214d2201f2fSdrahn 	char x_endndx[4];	/* entry ndx past block end */
215d2201f2fSdrahn       } x_fcn;
216d2201f2fSdrahn 
217d2201f2fSdrahn       struct 		/* if ISARY, up to 4 dimen. */
218d2201f2fSdrahn       {
219d2201f2fSdrahn 	char x_dimen[E_DIMNUM][2];
220d2201f2fSdrahn       } x_ary;
221d2201f2fSdrahn 
222d2201f2fSdrahn     } x_fcnary;
223d2201f2fSdrahn 
224d2201f2fSdrahn     char x_tvndx[2];	/* tv index */
225d2201f2fSdrahn 
226d2201f2fSdrahn   } x_sym;
227d2201f2fSdrahn 
228d2201f2fSdrahn   union
229d2201f2fSdrahn   {
230d2201f2fSdrahn     char x_fname[E_FILNMLEN];
231d2201f2fSdrahn 
232d2201f2fSdrahn     struct
233d2201f2fSdrahn     {
234d2201f2fSdrahn       char x_zeroes[4];
235d2201f2fSdrahn       char x_offset[4];
236d2201f2fSdrahn     } x_n;
237d2201f2fSdrahn 
238d2201f2fSdrahn   } x_file;
239d2201f2fSdrahn 
240d2201f2fSdrahn   struct
241d2201f2fSdrahn   {
242d2201f2fSdrahn     char x_scnlen[4];	/* section length */
243d2201f2fSdrahn     char x_nreloc[2];	/* # relocation entries */
244d2201f2fSdrahn     char x_nlinno[2];	/* # line numbers */
245d2201f2fSdrahn #ifdef INCLUDE_COMDAT_FIELDS_IN_AUXENT
246d2201f2fSdrahn     char x_checksum[4];		   /* section COMDAT checksum	      */
247d2201f2fSdrahn     char x_associated[2];	   /* COMDAT associated section index */
248d2201f2fSdrahn     char x_comdat[1];		   /* COMDAT selection number	      */
249d2201f2fSdrahn #endif
250d2201f2fSdrahn   } x_scn;
251d2201f2fSdrahn 
252d2201f2fSdrahn   struct
253d2201f2fSdrahn   {
254d2201f2fSdrahn     char x_tvfill[4];	/* tv fill value */
255d2201f2fSdrahn     char x_tvlen[2];	/* length of .tv */
256d2201f2fSdrahn     char x_tvran[2][2];	/* tv range */
257d2201f2fSdrahn   } x_tv;		/* info about .tv section (in auxent of symbol .tv)) */
258d2201f2fSdrahn };
259d2201f2fSdrahn 
260d2201f2fSdrahn #define	AUXENT	union external_auxent
261d2201f2fSdrahn #define	AUXESZ	18
262d2201f2fSdrahn 
263d2201f2fSdrahn #define _ETEXT	"etext"
264d2201f2fSdrahn 
265d2201f2fSdrahn #endif /* not DO_NOT_DEFINE_AUXENT */
266d2201f2fSdrahn 
267d2201f2fSdrahn #endif /* COFF_EXTERNAL_H */
268