| 1 |
/* external.h -- External COFF structures |
| 2 |
|
| 3 |
Copyright (C) 2001-2025 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 3 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., 51 Franklin Street - Fifth Floor, Boston, |
| 18 |
MA 02110-1301, USA. */ |
| 19 |
|
| 20 |
#ifndef COFF_EXTERNAL_H |
| 21 |
#define COFF_EXTERNAL_H |
| 22 |
|
| 23 |
#ifndef DO_NOT_DEFINE_FILHDR |
| 24 |
|
| 25 |
#define FILHDR struct external_filehdr |
| 26 |
#define FILHSZ 20 |
| 27 |
|
| 28 |
struct external_filehdr |
| 29 |
{ |
| 30 |
char f_magic[2]; /* magic number */ |
| 31 |
char f_nscns[2]; /* number of sections */ |
| 32 |
char f_timdat[4]; /* time & date stamp */ |
| 33 |
char f_symptr[4]; /* file pointer to symtab */ |
| 34 |
char f_nsyms[4]; /* number of symtab entries */ |
| 35 |
char f_opthdr[2]; /* sizeof(optional hdr) */ |
| 36 |
char f_flags[2]; /* flags */ |
| 37 |
}; |
| 38 |
#endif |
| 39 |
|
| 40 |
#ifndef DO_NOT_DEFINE_AOUTHDR |
| 41 |
|
| 42 |
#define AOUTHDRSZ 28 |
| 43 |
#define AOUTSZ 28 |
| 44 |
|
| 45 |
typedef struct external_aouthdr |
| 46 |
{ |
| 47 |
char magic[2]; /* type of file */ |
| 48 |
char vstamp[2]; /* version stamp */ |
| 49 |
char tsize[4]; /* text size in bytes, padded to FW bdry*/ |
| 50 |
char dsize[4]; /* initialized data " " */ |
| 51 |
char bsize[4]; /* uninitialized data " " */ |
| 52 |
char entry[4]; /* entry pt. */ |
| 53 |
char text_start[4]; /* base of text used for this file */ |
| 54 |
char data_start[4]; /* base of data used for this file */ |
| 55 |
} ATTRIBUTE_PACKED |
| 56 |
AOUTHDR; |
| 57 |
|
| 58 |
#define AOUTHDRSZ64 24 |
| 59 |
|
| 60 |
typedef struct external_aouthdr64 |
| 61 |
{ |
| 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. */ |
| 69 |
} |
| 70 |
AOUTHDR64; |
| 71 |
|
| 72 |
#endif /* not DO_NOT_DEFINE_AOUTHDR */ |
| 73 |
|
| 74 |
#ifndef DO_NOT_DEFINE_SCNHDR |
| 75 |
|
| 76 |
#define SCNHDR struct external_scnhdr |
| 77 |
#define SCNHSZ 40 |
| 78 |
|
| 79 |
struct external_scnhdr |
| 80 |
{ |
| 81 |
char s_name[8]; /* section name */ |
| 82 |
char s_paddr[4]; /* physical address, aliased s_nlib */ |
| 83 |
char s_vaddr[4]; /* virtual address */ |
| 84 |
char s_size[4]; /* section size */ |
| 85 |
char s_scnptr[4]; /* file ptr to raw data for section */ |
| 86 |
char s_relptr[4]; /* file ptr to relocation */ |
| 87 |
char s_lnnoptr[4]; /* file ptr to line numbers */ |
| 88 |
char s_nreloc[2]; /* number of relocation entries */ |
| 89 |
char s_nlnno[2]; /* number of line number entries */ |
| 90 |
char s_flags[4]; /* flags */ |
| 91 |
}; |
| 92 |
|
| 93 |
/* Names of "special" sections. */ |
| 94 |
|
| 95 |
#define _TEXT ".text" |
| 96 |
#define _DATA ".data" |
| 97 |
#define _BSS ".bss" |
| 98 |
#define _COMMENT ".comment" |
| 99 |
#define _LIB ".lib" |
| 100 |
#endif /* not DO_NOT_DEFINE_SCNHDR */ |
| 101 |
|
| 102 |
#ifndef DO_NOT_DEFINE_LINENO |
| 103 |
|
| 104 |
#ifndef L_LNNO_SIZE |
| 105 |
#error L_LNNO_SIZE needs to be defined |
| 106 |
#endif |
| 107 |
|
| 108 |
#define LINENO struct external_lineno |
| 109 |
#define LINESZ (4 + L_LNNO_SIZE) |
| 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[4]; /* function name symbol index, iff l_lnno == 0*/ |
| 120 |
char l_paddr[4]; /* (physical) address of line number */ |
| 121 |
} l_addr; |
| 122 |
|
| 123 |
char l_lnno[L_LNNO_SIZE]; /* line number */ |
| 124 |
}; |
| 125 |
|
| 126 |
#if L_LNNO_SIZE == 4 |
| 127 |
#define GET_LINENO_LNNO(abfd, ext) H_GET_32 (abfd, (ext->l_lnno)) |
| 128 |
#define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_32 (abfd, val, (ext->l_lnno)) |
| 129 |
#endif |
| 130 |
#if L_LNNO_SIZE == 2 |
| 131 |
#define GET_LINENO_LNNO(abfd, ext) H_GET_16 (abfd, (ext->l_lnno)) |
| 132 |
#define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_16 (abfd, val, (ext->l_lnno)) |
| 133 |
#endif |
| 134 |
|
| 135 |
#endif /* not DO_NOT_DEFINE_LINENO */ |
| 136 |
|
| 137 |
#ifndef DO_NOT_DEFINE_SYMENT |
| 138 |
|
| 139 |
#define E_SYMNMLEN 8 /* # characters in a symbol name */ |
| 140 |
#define SYMESZ 18 |
| 141 |
|
| 142 |
typedef struct external_syment |
| 143 |
{ |
| 144 |
union |
| 145 |
{ |
| 146 |
char e_name[E_SYMNMLEN]; |
| 147 |
|
| 148 |
struct |
| 149 |
{ |
| 150 |
char e_zeroes[4]; |
| 151 |
char e_offset[4]; |
| 152 |
} e; |
| 153 |
} e; |
| 154 |
|
| 155 |
char e_value[4]; |
| 156 |
char e_scnum[2]; |
| 157 |
char e_type[2]; |
| 158 |
char e_sclass[1]; |
| 159 |
char e_numaux[1]; |
| 160 |
} ATTRIBUTE_PACKED |
| 161 |
SYMENT; |
| 162 |
|
| 163 |
#ifndef N_BTMASK |
| 164 |
#define N_BTMASK 0xf |
| 165 |
#endif |
| 166 |
|
| 167 |
#ifndef N_TMASK |
| 168 |
#define N_TMASK 0x30 |
| 169 |
#endif |
| 170 |
|
| 171 |
#ifndef N_BTSHFT |
| 172 |
#define N_BTSHFT 4 |
| 173 |
#endif |
| 174 |
|
| 175 |
#ifndef N_TSHIFT |
| 176 |
#define N_TSHIFT 2 |
| 177 |
#endif |
| 178 |
|
| 179 |
#endif /* not DO_NOT_DEFINE_SYMENT */ |
| 180 |
|
| 181 |
#ifndef DO_NOT_DEFINE_AUXENT |
| 182 |
|
| 183 |
#define E_FILNMLEN 14 /* # characters in a file name */ |
| 184 |
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ |
| 185 |
#define AUXESZ 18 |
| 186 |
|
| 187 |
typedef union external_auxent |
| 188 |
{ |
| 189 |
struct |
| 190 |
{ |
| 191 |
char x_tagndx[4]; /* str, un, or enum tag indx */ |
| 192 |
|
| 193 |
union |
| 194 |
{ |
| 195 |
struct |
| 196 |
{ |
| 197 |
char x_lnno[2]; /* declaration line number */ |
| 198 |
char x_size[2]; /* str/union/array size */ |
| 199 |
} x_lnsz; |
| 200 |
|
| 201 |
char x_fsize[4]; /* size of function */ |
| 202 |
|
| 203 |
} x_misc; |
| 204 |
|
| 205 |
union |
| 206 |
{ |
| 207 |
struct /* if ISFCN, tag, or .bb */ |
| 208 |
{ |
| 209 |
char x_lnnoptr[4]; /* ptr to fcn line # */ |
| 210 |
char x_endndx[4]; /* entry ndx past block end */ |
| 211 |
} x_fcn; |
| 212 |
|
| 213 |
struct /* if ISARY, up to 4 dimen. */ |
| 214 |
{ |
| 215 |
char x_dimen[E_DIMNUM][2]; |
| 216 |
} x_ary; |
| 217 |
|
| 218 |
} x_fcnary; |
| 219 |
|
| 220 |
char x_tvndx[2]; /* tv index */ |
| 221 |
|
| 222 |
} x_sym; |
| 223 |
|
| 224 |
union |
| 225 |
{ |
| 226 |
/* Make x_fname the full auxent size, so that if coff/pe.h |
| 227 |
redefines E_FILNMLEN from 14 to 18 we don't trigger sanitisers |
| 228 |
accessing x_fname. Beware use of sizeof (x_file.x_fname). */ |
| 229 |
char x_fname[AUXESZ]; |
| 230 |
|
| 231 |
struct |
| 232 |
{ |
| 233 |
char x_zeroes[4]; |
| 234 |
char x_offset[4]; |
| 235 |
} x_n; |
| 236 |
|
| 237 |
} x_file; |
| 238 |
|
| 239 |
struct |
| 240 |
{ |
| 241 |
char x_scnlen[4]; /* section length */ |
| 242 |
char x_nreloc[2]; /* # relocation entries */ |
| 243 |
char x_nlinno[2]; /* # line numbers */ |
| 244 |
#ifdef INCLUDE_COMDAT_FIELDS_IN_AUXENT |
| 245 |
char x_checksum[4]; /* section COMDAT checksum */ |
| 246 |
char x_associated[2]; /* COMDAT associated section index */ |
| 247 |
char x_comdat[1]; /* COMDAT selection number */ |
| 248 |
#endif |
| 249 |
} x_scn; |
| 250 |
|
| 251 |
/* info about .tv section (in auxent of symbol .tv). */ |
| 252 |
struct |
| 253 |
{ |
| 254 |
char x_tvfill[4]; /* tv fill value */ |
| 255 |
char x_tvlen[2]; /* length of .tv */ |
| 256 |
char x_tvran[2][2]; /* tv range */ |
| 257 |
} x_tv; |
| 258 |
} ATTRIBUTE_PACKED |
| 259 |
AUXENT; |
| 260 |
|
| 261 |
#endif /* not DO_NOT_DEFINE_AUXENT */ |
| 262 |
|
| 263 |
#endif /* COFF_EXTERNAL_H */ |