1 /* external.h -- External COFF structures
3 Copyright (C) 2001-2024 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 3 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,
18 MA 02110-1301, USA. */
20 #ifndef COFF_EXTERNAL_H
21 #define COFF_EXTERNAL_H
23 #ifndef DO_NOT_DEFINE_FILHDR
24 /********************** FILE HEADER **********************/
26 struct external_filehdr
28 char f_magic
[2]; /* magic number */
29 char f_nscns
[2]; /* number of sections */
30 char f_timdat
[4]; /* time & date stamp */
31 char f_symptr
[4]; /* file pointer to symtab */
32 char f_nsyms
[4]; /* number of symtab entries */
33 char f_opthdr
[2]; /* sizeof(optional hdr) */
34 char f_flags
[2]; /* flags */
37 #define FILHDR struct external_filehdr
41 #ifndef DO_NOT_DEFINE_AOUTHDR
42 /********************** AOUT "OPTIONAL HEADER" **********************/
44 typedef struct external_aouthdr
46 char magic
[2]; /* type of file */
47 char vstamp
[2]; /* version stamp */
48 char tsize
[4]; /* text size in bytes, padded to FW bdry*/
49 char dsize
[4]; /* initialized data " " */
50 char bsize
[4]; /* uninitialized data " " */
51 char entry
[4]; /* entry pt. */
52 char text_start
[4]; /* base of text used for this file */
53 char data_start
[4]; /* base of data used for this file */
60 typedef struct external_aouthdr64
62 char magic
[2]; /* Type of file. */
63 char vstamp
[2]; /* Version stamp. */
64 char tsize
[4]; /* Text size in bytes, padded to FW bdry*/
65 char dsize
[4]; /* Initialized data " ". */
66 char bsize
[4]; /* Uninitialized data " ". */
67 char entry
[4]; /* Entry pt. */
68 char text_start
[4]; /* Base of text used for this file. */
71 #define AOUTHDRSZ64 24
73 #endif /* not DO_NOT_DEFINE_AOUTHDR */
75 #ifndef DO_NOT_DEFINE_SCNHDR
76 /********************** SECTION HEADER **********************/
78 struct external_scnhdr
80 char s_name
[8]; /* section name */
81 char s_paddr
[4]; /* physical address, aliased s_nlib */
82 char s_vaddr
[4]; /* virtual address */
83 char s_size
[4]; /* section size */
84 char s_scnptr
[4]; /* file ptr to raw data for section */
85 char s_relptr
[4]; /* file ptr to relocation */
86 char s_lnnoptr
[4]; /* file ptr to line numbers */
87 char s_nreloc
[2]; /* number of relocation entries */
88 char s_nlnno
[2]; /* number of line number entries */
89 char s_flags
[4]; /* flags */
92 #define SCNHDR struct external_scnhdr
95 /* Names of "special" sections. */
100 #define _COMMENT ".comment"
102 #endif /* not DO_NOT_DEFINE_SCNHDR */
104 #ifndef DO_NOT_DEFINE_LINENO
106 /********************** LINE NUMBERS **********************/
109 #error L_LNNO_SIZE needs to be defined
112 /* 1 line number entry for every "breakpointable" source line in a section.
113 Line numbers are grouped on a per function basis; first entry in a function
114 grouping will have l_lnno = 0 and in place of physical address will be the
115 symbol table index of the function name. */
116 struct external_lineno
120 char l_symndx
[4]; /* function name symbol index, iff l_lnno == 0*/
121 char l_paddr
[4]; /* (physical) address of line number */
124 char l_lnno
[L_LNNO_SIZE
]; /* line number */
127 #define LINENO struct external_lineno
128 #define LINESZ (4 + L_LNNO_SIZE)
131 #define GET_LINENO_LNNO(abfd, ext) H_GET_32 (abfd, (ext->l_lnno))
132 #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_32 (abfd, val, (ext->l_lnno))
135 #define GET_LINENO_LNNO(abfd, ext) H_GET_16 (abfd, (ext->l_lnno))
136 #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_16 (abfd, val, (ext->l_lnno))
139 #endif /* not DO_NOT_DEFINE_LINENO */
141 #ifndef DO_NOT_DEFINE_SYMENT
142 /********************** SYMBOLS **********************/
144 #define E_SYMNMLEN 8 /* # characters in a symbol name */
146 #define E_FILNMLEN 14
148 #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
150 struct external_syment
154 char e_name
[E_SYMNMLEN
];
170 #define SYMENT struct external_syment
189 #endif /* not DO_NOT_DEFINE_SYMENT */
191 #ifndef DO_NOT_DEFINE_AUXENT
193 union external_auxent
197 char x_tagndx
[4]; /* str, un, or enum tag indx */
203 char x_lnno
[2]; /* declaration line number */
204 char x_size
[2]; /* str/union/array size */
207 char x_fsize
[4]; /* size of function */
213 struct /* if ISFCN, tag, or .bb */
215 char x_lnnoptr
[4]; /* ptr to fcn line # */
216 char x_endndx
[4]; /* entry ndx past block end */
219 struct /* if ISARY, up to 4 dimen. */
221 char x_dimen
[E_DIMNUM
][2];
226 char x_tvndx
[2]; /* tv index */
232 char x_fname
[E_FILNMLEN
];
244 char x_scnlen
[4]; /* section length */
245 char x_nreloc
[2]; /* # relocation entries */
246 char x_nlinno
[2]; /* # line numbers */
247 #ifdef INCLUDE_COMDAT_FIELDS_IN_AUXENT
248 char x_checksum
[4]; /* section COMDAT checksum */
249 char x_associated
[2]; /* COMDAT associated section index */
250 char x_comdat
[1]; /* COMDAT selection number */
256 char x_tvfill
[4]; /* tv fill value */
257 char x_tvlen
[2]; /* length of .tv */
258 char x_tvran
[2][2]; /* tv range */
259 } x_tv
; /* info about .tv section (in auxent of symbol .tv)) */
262 #define AUXENT union external_auxent
265 #define _ETEXT "etext"
267 #endif /* not DO_NOT_DEFINE_AUXENT */
269 #endif /* COFF_EXTERNAL_H */