| 1 |
/* Internal format of COFF object file data structures, for GNU BFD. |
| 2 |
This file is part of BFD, the Binary File Descriptor library. |
| 3 |
|
| 4 |
Copyright (C) 1999-2025 Free Software Foundation, Inc. |
| 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 3 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., 51 Franklin Street - Fifth Floor, Boston, |
| 19 |
MA 02110-1301, USA. */ |
| 20 |
|
| 21 |
#ifndef GNU_COFF_INTERNAL_H |
| 22 |
#define GNU_COFF_INTERNAL_H 1 |
| 23 |
|
| 24 |
/* extra stuff in a PE header. */ |
| 25 |
|
| 26 |
struct internal_extra_pe_filehdr |
| 27 |
{ |
| 28 |
/* DOS header data follows for PE stuff */ |
| 29 |
unsigned short e_magic; /* Magic number, 0x5a4d */ |
| 30 |
unsigned short e_cblp; /* Bytes on last page of file, 0x90 */ |
| 31 |
unsigned short e_cp; /* Pages in file, 0x3 */ |
| 32 |
unsigned short e_crlc; /* Relocations, 0x0 */ |
| 33 |
unsigned short e_cparhdr; /* Size of header in paragraphs, 0x4 */ |
| 34 |
unsigned short e_minalloc; /* Minimum extra paragraphs needed, 0x0 */ |
| 35 |
unsigned short e_maxalloc; /* Maximum extra paragraphs needed, 0xFFFF */ |
| 36 |
unsigned short e_ss; /* Initial (relative) SS value, 0x0 */ |
| 37 |
unsigned short e_sp; /* Initial SP value, 0xb8 */ |
| 38 |
unsigned short e_csum; /* Checksum, 0x0 */ |
| 39 |
unsigned short e_ip; /* Initial IP value, 0x0 */ |
| 40 |
unsigned short e_cs; /* Initial (relative) CS value, 0x0 */ |
| 41 |
unsigned short e_lfarlc; /* File address of relocation table, 0x40 */ |
| 42 |
unsigned short e_ovno; /* Overlay number, 0x0 */ |
| 43 |
unsigned short e_res[4]; /* Reserved words, all 0x0 */ |
| 44 |
unsigned short e_oemid; /* OEM identifier (for e_oeminfo), 0x0 */ |
| 45 |
unsigned short e_oeminfo; /* OEM information; e_oemid specific, 0x0 */ |
| 46 |
unsigned short e_res2[10]; /* Reserved words, all 0x0 */ |
| 47 |
bfd_vma e_lfanew; /* File address of new exe header, 0x80 */ |
| 48 |
char dos_message[64]; /* Text which always follows DOS header. */ |
| 49 |
bfd_vma nt_signature; /* required NT signature, 0x4550 */ |
| 50 |
}; |
| 51 |
|
| 52 |
struct internal_filehdr |
| 53 |
{ |
| 54 |
struct internal_extra_pe_filehdr pe; |
| 55 |
|
| 56 |
/* Standard coff internal info. */ |
| 57 |
unsigned short f_magic; /* magic number */ |
| 58 |
unsigned int f_nscns; /* number of sections */ |
| 59 |
long f_timdat; /* time & date stamp */ |
| 60 |
bfd_vma f_symptr; /* file pointer to symtab */ |
| 61 |
long f_nsyms; /* number of symtab entries */ |
| 62 |
unsigned short f_opthdr; /* sizeof(optional hdr) */ |
| 63 |
unsigned short f_flags; /* flags */ |
| 64 |
unsigned short f_target_id; /* (TI COFF specific) */ |
| 65 |
}; |
| 66 |
|
| 67 |
|
| 68 |
/* Bits for f_flags: |
| 69 |
F_RELFLG relocation info stripped from file |
| 70 |
F_EXEC file is executable (no unresolved external references) |
| 71 |
F_LNNO line numbers stripped from file |
| 72 |
F_LSYMS local symbols stripped from file |
| 73 |
F_AR16WR file is 16-bit little-endian |
| 74 |
F_AR32WR file is 32-bit little-endian |
| 75 |
F_AR32W file is 32-bit big-endian |
| 76 |
F_DYNLOAD rs/6000 aix: dynamically loadable w/imports & exports |
| 77 |
F_SHROBJ rs/6000 aix: file is a shared object |
| 78 |
F_DLL PE format DLL */ |
| 79 |
|
| 80 |
#define F_RELFLG (0x0001) |
| 81 |
#define F_EXEC (0x0002) |
| 82 |
#define F_LNNO (0x0004) |
| 83 |
#define F_LSYMS (0x0008) |
| 84 |
#define F_AR16WR (0x0080) |
| 85 |
#define F_AR32WR (0x0100) |
| 86 |
#define F_AR32W (0x0200) |
| 87 |
#define F_DYNLOAD (0x1000) |
| 88 |
#define F_SHROBJ (0x2000) |
| 89 |
#define F_DLL (0x2000) |
| 90 |
|
| 91 |
/* Extra structure which is used in the optional header. */ |
| 92 |
typedef struct _IMAGE_DATA_DIRECTORY |
| 93 |
{ |
| 94 |
bfd_vma VirtualAddress; |
| 95 |
long Size; |
| 96 |
} IMAGE_DATA_DIRECTORY; |
| 97 |
#define PE_EXPORT_TABLE 0 |
| 98 |
#define PE_IMPORT_TABLE 1 |
| 99 |
#define PE_RESOURCE_TABLE 2 |
| 100 |
#define PE_EXCEPTION_TABLE 3 |
| 101 |
#define PE_CERTIFICATE_TABLE 4 |
| 102 |
#define PE_BASE_RELOCATION_TABLE 5 |
| 103 |
#define PE_DEBUG_DATA 6 |
| 104 |
#define PE_ARCHITECTURE 7 |
| 105 |
#define PE_GLOBAL_PTR 8 |
| 106 |
#define PE_TLS_TABLE 9 |
| 107 |
#define PE_LOAD_CONFIG_TABLE 10 |
| 108 |
#define PE_BOUND_IMPORT_TABLE 11 |
| 109 |
#define PE_IMPORT_ADDRESS_TABLE 12 |
| 110 |
#define PE_DELAY_IMPORT_DESCRIPTOR 13 |
| 111 |
#define PE_CLR_RUNTIME_HEADER 14 |
| 112 |
/* DataDirectory[15] is currently reserved, so no define. */ |
| 113 |
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 |
| 114 |
|
| 115 |
/* Extra structure used in debug directory. */ |
| 116 |
struct internal_IMAGE_DEBUG_DIRECTORY |
| 117 |
{ |
| 118 |
unsigned long Characteristics; |
| 119 |
unsigned long TimeDateStamp; |
| 120 |
unsigned short MajorVersion; |
| 121 |
unsigned short MinorVersion; |
| 122 |
unsigned long Type; |
| 123 |
unsigned long SizeOfData; |
| 124 |
unsigned long AddressOfRawData; |
| 125 |
unsigned long PointerToRawData; |
| 126 |
}; |
| 127 |
|
| 128 |
#define PE_IMAGE_DEBUG_TYPE_UNKNOWN 0 |
| 129 |
#define PE_IMAGE_DEBUG_TYPE_COFF 1 |
| 130 |
#define PE_IMAGE_DEBUG_TYPE_CODEVIEW 2 |
| 131 |
#define PE_IMAGE_DEBUG_TYPE_FPO 3 |
| 132 |
#define PE_IMAGE_DEBUG_TYPE_MISC 4 |
| 133 |
#define PE_IMAGE_DEBUG_TYPE_EXCEPTION 5 |
| 134 |
#define PE_IMAGE_DEBUG_TYPE_FIXUP 6 |
| 135 |
#define PE_IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7 |
| 136 |
#define PE_IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8 |
| 137 |
#define PE_IMAGE_DEBUG_TYPE_BORLAND 9 |
| 138 |
#define PE_IMAGE_DEBUG_TYPE_RESERVED10 10 |
| 139 |
#define PE_IMAGE_DEBUG_TYPE_CLSID 11 |
| 140 |
#define PE_IMAGE_DEBUG_TYPE_VC_FEATURE 12 |
| 141 |
#define PE_IMAGE_DEBUG_TYPE_POGO 13 |
| 142 |
#define PE_IMAGE_DEBUG_TYPE_ILTCG 14 |
| 143 |
#define PE_IMAGE_DEBUG_TYPE_MPX 15 |
| 144 |
#define PE_IMAGE_DEBUG_TYPE_REPRO 16 |
| 145 |
|
| 146 |
/* Extra structure for a codeview debug record */ |
| 147 |
#define CV_INFO_SIGNATURE_LENGTH 16 |
| 148 |
|
| 149 |
typedef struct _CODEVIEW_INFO |
| 150 |
{ |
| 151 |
unsigned long CVSignature; |
| 152 |
char Signature[CV_INFO_SIGNATURE_LENGTH]; |
| 153 |
unsigned int SignatureLength; |
| 154 |
unsigned long Age; |
| 155 |
/* char PdbFileName[]; */ |
| 156 |
} CODEVIEW_INFO; |
| 157 |
|
| 158 |
/* Default image base for NT. */ |
| 159 |
#define NT_EXE_IMAGE_BASE 0x400000 |
| 160 |
#define NT_DLL_IMAGE_BASE 0x10000000 |
| 161 |
|
| 162 |
/* Default image base for BeOS. */ |
| 163 |
#define BEOS_EXE_IMAGE_BASE 0x80000000 |
| 164 |
#define BEOS_DLL_IMAGE_BASE 0x10000000 |
| 165 |
|
| 166 |
/* Extra stuff in a PE aouthdr */ |
| 167 |
|
| 168 |
#define PE_DEF_SECTION_ALIGNMENT 0x1000 |
| 169 |
#ifndef PE_DEF_FILE_ALIGNMENT |
| 170 |
# define PE_DEF_FILE_ALIGNMENT 0x200 |
| 171 |
#endif |
| 172 |
|
| 173 |
struct internal_extra_pe_aouthdr |
| 174 |
{ |
| 175 |
/* FIXME: The following entries are in AOUTHDR. But they aren't |
| 176 |
available internally in bfd. We add them here so that objdump |
| 177 |
can dump them. */ |
| 178 |
/* The state of the image file. */ |
| 179 |
short Magic; |
| 180 |
/* Linker major version number. */ |
| 181 |
char MajorLinkerVersion; |
| 182 |
/* Linker minor version number. */ |
| 183 |
char MinorLinkerVersion; |
| 184 |
/* Total size of all code sections. */ |
| 185 |
bfd_vma SizeOfCode; |
| 186 |
/* Total size of all initialized data sections. */ |
| 187 |
bfd_vma SizeOfInitializedData; |
| 188 |
/* Total size of all uninitialized data sections. */ |
| 189 |
bfd_vma SizeOfUninitializedData; |
| 190 |
/* Address of entry point relative to image base. */ |
| 191 |
bfd_vma AddressOfEntryPoint; |
| 192 |
/* Address of the first code section relative to image base. */ |
| 193 |
bfd_vma BaseOfCode; |
| 194 |
/* Address of the first data section relative to image base. */ |
| 195 |
bfd_vma BaseOfData; |
| 196 |
|
| 197 |
/* PE stuff */ |
| 198 |
bfd_vma ImageBase; /* Address of specific location in memory that |
| 199 |
file is located, NT default 0x10000. */ |
| 200 |
|
| 201 |
uint32_t SectionAlignment; /* Section alignment default 0x1000. */ |
| 202 |
uint32_t FileAlignment; /* File alignment default 0x200. */ |
| 203 |
short MajorOperatingSystemVersion; /* Minimum version of the operating. */ |
| 204 |
short MinorOperatingSystemVersion; /* System req'd for exe, default 1. */ |
| 205 |
short MajorImageVersion; /* User defineable field to store version of */ |
| 206 |
short MinorImageVersion; /* exe or dll being created, default to 0. */ |
| 207 |
short MajorSubsystemVersion; /* Minimum subsystem version required to */ |
| 208 |
short MinorSubsystemVersion; /* run exe; default to 3.1. */ |
| 209 |
uint32_t Win32Version; /* Set to 0. */ |
| 210 |
uint32_t SizeOfImage; /* Size of memory to allocate for prog. */ |
| 211 |
uint32_t SizeOfHeaders; /* Size of PE header and section table. */ |
| 212 |
uint32_t CheckSum; /* Set to 0. */ |
| 213 |
short Subsystem; |
| 214 |
|
| 215 |
/* Type of subsystem exe uses for user interface, |
| 216 |
possible values: |
| 217 |
1 - NATIVE Doesn't require a subsystem |
| 218 |
2 - WINDOWS_GUI runs in Windows GUI subsystem |
| 219 |
3 - WINDOWS_CUI runs in Windows char sub. (console app) |
| 220 |
5 - OS2_CUI runs in OS/2 character subsystem |
| 221 |
7 - POSIX_CUI runs in Posix character subsystem. */ |
| 222 |
unsigned short DllCharacteristics; /* flags for DLL init. */ |
| 223 |
bfd_vma SizeOfStackReserve; /* Amount of memory to reserve. */ |
| 224 |
bfd_vma SizeOfStackCommit; /* Amount of memory initially committed for |
| 225 |
initial thread's stack, default 0x1000. */ |
| 226 |
bfd_vma SizeOfHeapReserve; /* Amount of virtual memory to reserve and */ |
| 227 |
bfd_vma SizeOfHeapCommit; /* commit, don't know what to defaut it to. */ |
| 228 |
uint32_t LoaderFlags; /* Can probably set to 0. */ |
| 229 |
uint32_t NumberOfRvaAndSizes; /* Number of entries in next entry, 16. */ |
| 230 |
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; |
| 231 |
}; |
| 232 |
|
| 233 |
struct internal_aouthdr |
| 234 |
{ |
| 235 |
short magic; /* type of file */ |
| 236 |
short vstamp; /* version stamp */ |
| 237 |
bfd_vma tsize; /* text size in bytes, padded to FW bdry*/ |
| 238 |
bfd_vma dsize; /* initialized data " " */ |
| 239 |
bfd_vma bsize; /* uninitialized data " " */ |
| 240 |
bfd_vma entry; /* entry pt. */ |
| 241 |
bfd_vma text_start; /* base of text used for this file */ |
| 242 |
bfd_vma data_start; /* base of data used for this file */ |
| 243 |
|
| 244 |
/* RS/6000 stuff */ |
| 245 |
bfd_vma o_toc; /* address of TOC */ |
| 246 |
short o_snentry; /* section number for entry point */ |
| 247 |
short o_sntext; /* section number for text */ |
| 248 |
short o_sndata; /* section number for data */ |
| 249 |
short o_sntoc; /* section number for toc */ |
| 250 |
short o_snloader; /* section number for loader section */ |
| 251 |
short o_snbss; /* section number for bss */ |
| 252 |
short o_algntext; /* max alignment for text */ |
| 253 |
short o_algndata; /* max alignment for data */ |
| 254 |
short o_modtype; /* Module type field, 1R,RE,RO */ |
| 255 |
short o_cputype; /* Encoded CPU type */ |
| 256 |
bfd_vma o_maxstack; /* max stack size allowed. */ |
| 257 |
bfd_vma o_maxdata; /* max data size allowed. */ |
| 258 |
char o_flags; /* Flags and TLS alignment */ |
| 259 |
short o_sntdata; /* section number for tdata */ |
| 260 |
short o_sntbss; /* section number for tbss */ |
| 261 |
short o_x64flags; /* XCOFF64 flags */ |
| 262 |
|
| 263 |
|
| 264 |
/* ECOFF stuff */ |
| 265 |
bfd_vma bss_start; /* Base of bss section. */ |
| 266 |
bfd_vma gp_value; /* GP register value. */ |
| 267 |
unsigned long gprmask; /* General registers used. */ |
| 268 |
unsigned long cprmask[4]; /* Coprocessor registers used. */ |
| 269 |
unsigned long fprmask; /* Floating pointer registers used. */ |
| 270 |
|
| 271 |
/* Apollo stuff */ |
| 272 |
long o_inlib; /* inlib data */ |
| 273 |
long o_sri; /* Static Resource Information */ |
| 274 |
long vid[2]; /* Version id */ |
| 275 |
|
| 276 |
struct internal_extra_pe_aouthdr pe; |
| 277 |
}; |
| 278 |
|
| 279 |
/* Storage classes. */ |
| 280 |
|
| 281 |
/* This used to be defined as -1, but now n_sclass is unsigned. */ |
| 282 |
#define C_EFCN 0xff /* physical end of function */ |
| 283 |
#define C_NULL 0 |
| 284 |
#define C_AUTO 1 /* automatic variable */ |
| 285 |
#define C_EXT 2 /* external symbol */ |
| 286 |
#define C_STAT 3 /* static */ |
| 287 |
#define C_REG 4 /* register variable */ |
| 288 |
#define C_EXTDEF 5 /* external definition */ |
| 289 |
#define C_LABEL 6 /* label */ |
| 290 |
#define C_ULABEL 7 /* undefined label */ |
| 291 |
#define C_MOS 8 /* member of structure */ |
| 292 |
#define C_ARG 9 /* function argument */ |
| 293 |
#define C_STRTAG 10 /* structure tag */ |
| 294 |
#define C_MOU 11 /* member of union */ |
| 295 |
#define C_UNTAG 12 /* union tag */ |
| 296 |
#define C_TPDEF 13 /* type definition */ |
| 297 |
#define C_USTATIC 14 /* undefined static */ |
| 298 |
#define C_ENTAG 15 /* enumeration tag */ |
| 299 |
#define C_MOE 16 /* member of enumeration */ |
| 300 |
#define C_REGPARM 17 /* register parameter */ |
| 301 |
#define C_FIELD 18 /* bit field */ |
| 302 |
#define C_AUTOARG 19 /* auto argument */ |
| 303 |
#define C_LASTENT 20 /* dummy entry (end of block) */ |
| 304 |
#define C_BLOCK 100 /* ".bb" or ".eb" */ |
| 305 |
#define C_FCN 101 /* ".bf" or ".ef" */ |
| 306 |
#define C_EOS 102 /* end of structure */ |
| 307 |
#define C_FILE 103 /* file name */ |
| 308 |
#define C_LINE 104 /* line # reformatted as symbol table entry */ |
| 309 |
#define C_ALIAS 105 /* duplicate tag */ |
| 310 |
#define C_HIDDEN 106 /* ext symbol in dmert public lib */ |
| 311 |
#define C_WEAKEXT 127 /* weak symbol -- GNU extension. */ |
| 312 |
|
| 313 |
/* New storage classes for TI COFF */ |
| 314 |
#define C_UEXT 19 /* Tentative external definition */ |
| 315 |
#define C_STATLAB 20 /* Static load time label */ |
| 316 |
#define C_EXTLAB 21 /* External load time label */ |
| 317 |
#define C_SYSTEM 23 /* System Wide variable */ |
| 318 |
|
| 319 |
/* New storage classes for WINDOWS_NT */ |
| 320 |
#define C_SECTION 104 /* section name */ |
| 321 |
#define C_NT_WEAK 105 /* weak external */ |
| 322 |
|
| 323 |
/* New storage classes for 80960 */ |
| 324 |
|
| 325 |
/* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */ |
| 326 |
#define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */ |
| 327 |
|
| 328 |
#define C_SCALL 107 /* Procedure reachable via system call */ |
| 329 |
#define C_LEAFEXT 108 /* External leaf */ |
| 330 |
#define C_LEAFSTAT 113 /* Static leaf */ |
| 331 |
#define C_OPTVAR 109 /* Optimized variable */ |
| 332 |
#define C_DEFINE 110 /* Preprocessor #define */ |
| 333 |
#define C_PRAGMA 111 /* Advice to compiler or linker */ |
| 334 |
#define C_SEGMENT 112 /* 80960 segment name */ |
| 335 |
|
| 336 |
/* New storage classes for RS/6000 */ |
| 337 |
#define C_HIDEXT 107 /* Un-named external symbol */ |
| 338 |
#define C_BINCL 108 /* Marks beginning of include file */ |
| 339 |
#define C_EINCL 109 /* Marks ending of include file */ |
| 340 |
#define C_AIX_WEAKEXT 111 /* AIX definition of C_WEAKEXT. */ |
| 341 |
#define C_DWARF 112 /* DWARF symbol */ |
| 342 |
|
| 343 |
#define C_NULL_VALUE 0x00de1e00 /* Value for a C_NULL deleted entry. */ |
| 344 |
|
| 345 |
#ifdef AIX_WEAK_SUPPORT |
| 346 |
#undef C_WEAKEXT |
| 347 |
#define C_WEAKEXT C_AIX_WEAKEXT |
| 348 |
#endif |
| 349 |
|
| 350 |
/* storage classes for stab symbols for RS/6000 */ |
| 351 |
#define C_GSYM (0x80) |
| 352 |
#define C_LSYM (0x81) |
| 353 |
#define C_PSYM (0x82) |
| 354 |
#define C_RSYM (0x83) |
| 355 |
#define C_RPSYM (0x84) |
| 356 |
#define C_STSYM (0x85) |
| 357 |
#define C_TCSYM (0x86) |
| 358 |
#define C_BCOMM (0x87) |
| 359 |
#define C_ECOML (0x88) |
| 360 |
#define C_ECOMM (0x89) |
| 361 |
#define C_DECL (0x8c) |
| 362 |
#define C_ENTRY (0x8d) |
| 363 |
#define C_FUN (0x8e) |
| 364 |
#define C_BSTAT (0x8f) |
| 365 |
#define C_ESTAT (0x90) |
| 366 |
#define C_GTLS (0x97) |
| 367 |
#define C_STTLS (0x98) |
| 368 |
|
| 369 |
/* Storage classes for Thumb symbols */ |
| 370 |
#define C_THUMBEXT (128 + C_EXT) /* 130 */ |
| 371 |
#define C_THUMBSTAT (128 + C_STAT) /* 131 */ |
| 372 |
#define C_THUMBLABEL (128 + C_LABEL) /* 134 */ |
| 373 |
#define C_THUMBEXTFUNC (C_THUMBEXT + 20) /* 150 */ |
| 374 |
#define C_THUMBSTATFUNC (C_THUMBSTAT + 20) /* 151 */ |
| 375 |
|
| 376 |
/* True if XCOFF symbols of class CLASS have auxiliary csect information. */ |
| 377 |
#define CSECT_SYM_P(CLASS) \ |
| 378 |
((CLASS) == C_EXT || (CLASS) == C_AIX_WEAKEXT || (CLASS) == C_HIDEXT) |
| 379 |
|
| 380 |
#define SCNNMLEN (8) |
| 381 |
|
| 382 |
struct internal_scnhdr |
| 383 |
{ |
| 384 |
char s_name[SCNNMLEN] ATTRIBUTE_NONSTRING; /* section name */ |
| 385 |
|
| 386 |
/* Physical address, aliased s_nlib. |
| 387 |
In the pei format, this field is the virtual section size |
| 388 |
(the size of the section after being loaded int memory), |
| 389 |
NOT the physical address. */ |
| 390 |
bfd_vma s_paddr; |
| 391 |
|
| 392 |
bfd_vma s_vaddr; /* virtual address */ |
| 393 |
bfd_vma s_size; /* section size */ |
| 394 |
bfd_vma s_scnptr; /* file ptr to raw data for section */ |
| 395 |
bfd_vma s_relptr; /* file ptr to relocation */ |
| 396 |
bfd_vma s_lnnoptr; /* file ptr to line numbers */ |
| 397 |
unsigned long s_nreloc; /* number of relocation entries */ |
| 398 |
unsigned long s_nlnno; /* number of line number entries*/ |
| 399 |
unsigned long s_flags; /* flags */ |
| 400 |
unsigned char s_page; /* TI COFF load page */ |
| 401 |
}; |
| 402 |
|
| 403 |
/* s_flags "type". */ |
| 404 |
#define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */ |
| 405 |
#define STYP_DSECT (0x0001) /* "dummy": relocated only*/ |
| 406 |
#define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, |
| 407 |
not loaded */ |
| 408 |
#define STYP_GROUP (0x0004) /* "grouped": formed of input sections */ |
| 409 |
#define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, |
| 410 |
loaded */ |
| 411 |
#define STYP_COPY (0x0010) /* "copy": for decision function used by field |
| 412 |
update; not allocated, not relocated, |
| 413 |
loaded; |
| 414 |
reloc & lineno entries processed normally */ |
| 415 |
#define STYP_TEXT (0x0020) /* section contains text only */ |
| 416 |
#define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), |
| 417 |
sections which appear in SHARED segments |
| 418 |
of the Pfile will have the S_SHRSEG flag |
| 419 |
set by ogen, to inform dufr that updating |
| 420 |
1 copy of the proc. will update all |
| 421 |
process invocations. */ |
| 422 |
#define STYP_DATA (0x0040) /* section contains data only */ |
| 423 |
#define STYP_BSS (0x0080) /* section contains bss only */ |
| 424 |
#define S_NEWFCN (0x0100) /* In a minimal file or an update file, |
| 425 |
a new function (as compared with a |
| 426 |
replaced function) */ |
| 427 |
#define STYP_INFO (0x0200) /* comment: not allocated not relocated, |
| 428 |
not loaded */ |
| 429 |
#define STYP_OVER (0x0400) /* overlay: relocated not allocated or |
| 430 |
loaded */ |
| 431 |
#define STYP_LIB (0x0800) /* for .lib: same as INFO */ |
| 432 |
#define STYP_MERGE (0x2000) /* merge section -- combines with text, |
| 433 |
data or bss sections only */ |
| 434 |
#define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op |
| 435 |
instructions wherever padding is necessary |
| 436 |
and there is a word of contiguous bytes |
| 437 |
beginning on a word boundary. */ |
| 438 |
|
| 439 |
#define STYP_LIT (0x8020) /* Literal data (like STYP_TEXT) */ |
| 440 |
|
| 441 |
|
| 442 |
/* 1 line number entry for every "breakpointable" source line in a section. |
| 443 |
Line numbers are grouped on a per function basis; first entry in a function |
| 444 |
grouping will have l_lnno = 0 and in place of physical address will be the |
| 445 |
symbol table index of the function name. */ |
| 446 |
|
| 447 |
struct internal_lineno |
| 448 |
{ |
| 449 |
union |
| 450 |
{ |
| 451 |
bfd_signed_vma l_symndx; /* function name symbol index, iff l_lnno == 0 */ |
| 452 |
bfd_signed_vma l_paddr; /* (physical) address of line number */ |
| 453 |
} l_addr; |
| 454 |
unsigned long l_lnno; /* line number */ |
| 455 |
}; |
| 456 |
|
| 457 |
#define SYMNMLEN 8 /* # characters in a symbol name */ |
| 458 |
|
| 459 |
struct internal_syment |
| 460 |
{ |
| 461 |
union |
| 462 |
{ |
| 463 |
char _n_name[SYMNMLEN] ATTRIBUTE_NONSTRING; /* old COFF version */ |
| 464 |
struct |
| 465 |
{ |
| 466 |
uintptr_t _n_zeroes; /* new == 0 */ |
| 467 |
uintptr_t _n_offset; /* offset into string table */ |
| 468 |
} _n_n; |
| 469 |
char *_n_nptr[2]; /* allows for overlaying */ |
| 470 |
} _n; |
| 471 |
bfd_vma n_value; /* value of symbol */ |
| 472 |
int n_scnum; /* section number */ |
| 473 |
unsigned short n_flags; /* copy of flags from filhdr */ |
| 474 |
unsigned short n_type; /* type and derived type */ |
| 475 |
unsigned char n_sclass; /* storage class */ |
| 476 |
unsigned char n_numaux; /* number of aux. entries */ |
| 477 |
}; |
| 478 |
|
| 479 |
#define n_name _n._n_name |
| 480 |
#define n_zeroes _n._n_n._n_zeroes |
| 481 |
#define n_offset _n._n_n._n_offset |
| 482 |
|
| 483 |
/* Relocatable symbols have number of the section in which they are defined, |
| 484 |
or one of the following: */ |
| 485 |
|
| 486 |
#define N_UNDEF ((int)0) /* undefined symbol */ |
| 487 |
#define N_ABS ((int)-1) /* value of symbol is absolute */ |
| 488 |
#define N_DEBUG ((int)-2) /* debugging symbol -- value is meaningless */ |
| 489 |
#define N_TV ((int)-3) /* indicates symbol needs preload transfer |
| 490 |
vector */ |
| 491 |
#define P_TV ((int)-4) /* indicates symbol needs postload transfer |
| 492 |
vector */ |
| 493 |
|
| 494 |
/* Type of a symbol, in low N bits of the word. */ |
| 495 |
|
| 496 |
#define T_NULL 0 |
| 497 |
#define T_VOID 1 /* function argument (only used by compiler) */ |
| 498 |
#define T_CHAR 2 /* character */ |
| 499 |
#define T_SHORT 3 /* short integer */ |
| 500 |
#define T_INT 4 /* integer */ |
| 501 |
#define T_LONG 5 /* long integer */ |
| 502 |
#define T_FLOAT 6 /* floating point */ |
| 503 |
#define T_DOUBLE 7 /* double word */ |
| 504 |
#define T_STRUCT 8 /* structure */ |
| 505 |
#define T_UNION 9 /* union */ |
| 506 |
#define T_ENUM 10 /* enumeration */ |
| 507 |
#define T_MOE 11 /* member of enumeration*/ |
| 508 |
#define T_UCHAR 12 /* unsigned character */ |
| 509 |
#define T_USHORT 13 /* unsigned short */ |
| 510 |
#define T_UINT 14 /* unsigned integer */ |
| 511 |
#define T_ULONG 15 /* unsigned long */ |
| 512 |
#define T_LNGDBL 16 /* long double */ |
| 513 |
|
| 514 |
/* Derived types, in n_type. */ |
| 515 |
|
| 516 |
#define DT_NON (0) /* no derived type */ |
| 517 |
#define DT_PTR (1) /* pointer */ |
| 518 |
#define DT_FCN (2) /* function */ |
| 519 |
#define DT_ARY (3) /* array */ |
| 520 |
|
| 521 |
#define BTYPE(x) ((x) & N_BTMASK) |
| 522 |
#define DTYPE(x) (((x) & N_TMASK) >> N_BTSHFT) |
| 523 |
|
| 524 |
#define ISPTR(x) \ |
| 525 |
(((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_PTR << N_BTSHFT)) |
| 526 |
#define ISFCN(x) \ |
| 527 |
(((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_FCN << N_BTSHFT)) |
| 528 |
#define ISARY(x) \ |
| 529 |
(((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_ARY << N_BTSHFT)) |
| 530 |
#define ISTAG(x) \ |
| 531 |
((x) == C_STRTAG || (x) == C_UNTAG || (x) == C_ENTAG) |
| 532 |
#define DECREF(x) \ |
| 533 |
((((x) >> N_TSHIFT) & ~ N_BTMASK) | ((x) & N_BTMASK)) |
| 534 |
|
| 535 |
/* Visibility flag, in XCOFF n_type. */ |
| 536 |
#define SYM_V_INTERNAL 0x1000 |
| 537 |
#define SYM_V_HIDDEN 0x2000 |
| 538 |
#define SYM_V_PROTECTED 0x3000 |
| 539 |
#define SYM_V_EXPORTED 0x4000 |
| 540 |
#define SYM_V_MASK 0xF000 |
| 541 |
|
| 542 |
#define FILNMLEN 14 /* # characters in a file name */ |
| 543 |
#define DIMNUM 4 /* # array dimensions in auxiliary entry */ |
| 544 |
|
| 545 |
union internal_auxent |
| 546 |
{ |
| 547 |
struct |
| 548 |
{ |
| 549 |
union |
| 550 |
{ |
| 551 |
uint32_t u32; /* str, un, or enum tag indx */ |
| 552 |
struct coff_ptr_struct *p; |
| 553 |
} x_tagndx; |
| 554 |
|
| 555 |
union |
| 556 |
{ |
| 557 |
struct |
| 558 |
{ |
| 559 |
uint16_t x_lnno; /* declaration line number */ |
| 560 |
uint16_t x_size; /* str/union/array size */ |
| 561 |
} x_lnsz; |
| 562 |
uint32_t x_fsize; /* size of function */ |
| 563 |
} x_misc; |
| 564 |
|
| 565 |
union |
| 566 |
{ |
| 567 |
struct |
| 568 |
{ /* if ISFCN, tag, or .bb */ |
| 569 |
uint64_t x_lnnoptr; /* ptr to fcn line # */ |
| 570 |
union |
| 571 |
{ /* entry ndx past block end */ |
| 572 |
uint32_t u32; |
| 573 |
struct coff_ptr_struct *p; |
| 574 |
} x_endndx; |
| 575 |
} x_fcn; |
| 576 |
|
| 577 |
struct |
| 578 |
{ /* if ISARY, up to 4 dimen. */ |
| 579 |
uint16_t x_dimen[DIMNUM]; |
| 580 |
} x_ary; |
| 581 |
} x_fcnary; |
| 582 |
|
| 583 |
uint16_t x_tvndx; /* tv index */ |
| 584 |
} x_sym; |
| 585 |
|
| 586 |
struct |
| 587 |
{ |
| 588 |
union |
| 589 |
{ |
| 590 |
/* PR 17754: We used to use FILNMLEN for the size of the x_fname |
| 591 |
array, but that causes problems as PE targets use a larger |
| 592 |
value. We cannot use their definition of E_FILNMLEN as this |
| 593 |
header can be used without including any PE headers. */ |
| 594 |
char x_fname[20]; |
| 595 |
struct |
| 596 |
{ |
| 597 |
/* PR 28630: We use uintptr_t because these fields may be |
| 598 |
used to hold pointers. We assume that this type is at least |
| 599 |
32 bits. */ |
| 600 |
uintptr_t x_zeroes; |
| 601 |
uintptr_t x_offset; |
| 602 |
} x_n; |
| 603 |
} x_n; |
| 604 |
|
| 605 |
uint8_t x_ftype; |
| 606 |
} x_file; |
| 607 |
|
| 608 |
struct |
| 609 |
{ |
| 610 |
uint32_t x_scnlen; /* section length */ |
| 611 |
uint16_t x_nreloc; /* # relocation entries */ |
| 612 |
uint16_t x_nlinno; /* # line numbers */ |
| 613 |
uint32_t x_checksum; /* section COMDAT checksum for PE */ |
| 614 |
uint16_t x_associated; /* COMDAT associated section index for PE */ |
| 615 |
uint8_t x_comdat; /* COMDAT selection number for PE */ |
| 616 |
} x_scn; |
| 617 |
|
| 618 |
/* info about .tv section (in auxent of symbol .tv). */ |
| 619 |
struct |
| 620 |
{ |
| 621 |
uint32_t x_tvfill; /* tv fill value */ |
| 622 |
uint16_t x_tvlen; /* length of .tv */ |
| 623 |
uint16_t x_tvran[2]; /* tv range */ |
| 624 |
} x_tv; |
| 625 |
|
| 626 |
/* RS/6000-specific auxent - last auxent for every external symbol. */ |
| 627 |
struct |
| 628 |
{ |
| 629 |
union |
| 630 |
{ /* csect length or enclosing csect */ |
| 631 |
uint64_t u64; |
| 632 |
struct coff_ptr_struct *p; |
| 633 |
} x_scnlen; |
| 634 |
uint32_t x_parmhash; /* parm type hash index */ |
| 635 |
uint16_t x_snhash; /* sect num with parm hash */ |
| 636 |
uint8_t x_smtyp; /* symbol align and type */ |
| 637 |
/* 0-4 - Log 2 of alignment */ |
| 638 |
/* 5-7 - symbol type */ |
| 639 |
uint8_t x_smclas; /* storage mapping class */ |
| 640 |
uint32_t x_stab; /* dbx stab info index */ |
| 641 |
uint16_t x_snstab; /* sect num with dbx stab */ |
| 642 |
} x_csect; /* csect definition information */ |
| 643 |
|
| 644 |
/* x_smtyp values: */ |
| 645 |
|
| 646 |
#define SMTYP_ALIGN(x) ((x) >> 3) /* log2 of alignment */ |
| 647 |
#define SMTYP_SMTYP(x) ((x) & 0x7) /* symbol type */ |
| 648 |
/* Symbol type values: */ |
| 649 |
#define XTY_ER 0 /* External reference */ |
| 650 |
#define XTY_SD 1 /* Csect definition */ |
| 651 |
#define XTY_LD 2 /* Label definition */ |
| 652 |
#define XTY_CM 3 /* .BSS */ |
| 653 |
#define XTY_EM 4 /* Error message */ |
| 654 |
#define XTY_US 5 /* "Reserved for internal use" */ |
| 655 |
|
| 656 |
/* x_smclas values: */ |
| 657 |
|
| 658 |
#define XMC_PR 0 /* Read-only program code */ |
| 659 |
#define XMC_RO 1 /* Read-only constant */ |
| 660 |
#define XMC_DB 2 /* Read-only debug dictionary table */ |
| 661 |
#define XMC_TC 3 /* Read-write general TOC entry */ |
| 662 |
#define XMC_UA 4 /* Read-write unclassified */ |
| 663 |
#define XMC_RW 5 /* Read-write data */ |
| 664 |
#define XMC_GL 6 /* Read-only global linkage */ |
| 665 |
#define XMC_XO 7 /* Read-only extended operation */ |
| 666 |
#define XMC_SV 8 /* Read-only supervisor call */ |
| 667 |
#define XMC_BS 9 /* Read-write BSS */ |
| 668 |
#define XMC_DS 10 /* Read-write descriptor csect */ |
| 669 |
#define XMC_UC 11 /* Read-write unnamed Fortran common */ |
| 670 |
#define XMC_TI 12 /* Read-only traceback index csect */ |
| 671 |
#define XMC_TB 13 /* Read-only traceback table csect */ |
| 672 |
/* 14 ??? */ |
| 673 |
#define XMC_TC0 15 /* Read-write TOC anchor */ |
| 674 |
#define XMC_TD 16 /* Read-write data in TOC */ |
| 675 |
|
| 676 |
struct |
| 677 |
{ |
| 678 |
uint64_t x_scnlen; /* Section length */ |
| 679 |
uint64_t x_nreloc; /* Number of relocation entries */ |
| 680 |
} x_sect; |
| 681 |
}; |
| 682 |
|
| 683 |
struct internal_reloc |
| 684 |
{ |
| 685 |
bfd_vma r_vaddr; /* Virtual address of reference */ |
| 686 |
long r_symndx; /* Index into symbol table */ |
| 687 |
unsigned short r_type; /* Relocation type */ |
| 688 |
unsigned char r_size; /* Used by RS/6000 and ECOFF */ |
| 689 |
unsigned char r_extern; /* Used by ECOFF */ |
| 690 |
unsigned long r_offset; /* Used by Alpha ECOFF, SPARC, others */ |
| 691 |
}; |
| 692 |
|
| 693 |
#define IMAGE_REL_BASED_ABSOLUTE 0 |
| 694 |
#define IMAGE_REL_BASED_HIGH 1 |
| 695 |
#define IMAGE_REL_BASED_LOW 2 |
| 696 |
#define IMAGE_REL_BASED_HIGHLOW 3 |
| 697 |
#define IMAGE_REL_BASED_HIGHADJ 4 |
| 698 |
#define IMAGE_REL_BASED_MIPS_JMPADDR 5 |
| 699 |
#define IMAGE_REL_BASED_ARM_MOV32 5 |
| 700 |
#define IMAGE_REL_BASED_RISCV_HIGH20 5 |
| 701 |
#define IMAGE_REL_BASED_THUMB_MOV32 7 |
| 702 |
#define IMAGE_REL_BASED_RISCV_LOW12I 7 |
| 703 |
#define IMAGE_REL_BASED_RISCV_LOW12S 8 |
| 704 |
#define IMAGE_REL_BASED_LOONGARCH32_MARK_LA 8 |
| 705 |
#define IMAGE_REL_BASED_LOONGARCH64_MARK_LA 8 |
| 706 |
#define IMAGE_REL_BASED_MIPS_JMPADDR16 9 |
| 707 |
#define IMAGE_REL_BASED_DIR64 10 |
| 708 |
|
| 709 |
#endif /* GNU_COFF_INTERNAL_H */ |