xref: /netbsd-src/external/gpl3/gdb/dist/include/coff/internal.h (revision 6817db7f6bcc94c9b2ba339c5139981a23c88cf9)
198b9484cSchristos /* Internal format of COFF object file data structures, for GNU BFD.
298b9484cSchristos    This file is part of BFD, the Binary File Descriptor library.
398b9484cSchristos 
4*6817db7fSchristos    Copyright (C) 1999-2024 Free Software Foundation, Inc.
598b9484cSchristos 
698b9484cSchristos    This program is free software; you can redistribute it and/or modify
798b9484cSchristos    it under the terms of the GNU General Public License as published by
898b9484cSchristos    the Free Software Foundation; either version 3 of the License, or
998b9484cSchristos    (at your option) any later version.
1098b9484cSchristos 
1198b9484cSchristos    This program is distributed in the hope that it will be useful,
1298b9484cSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1398b9484cSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1498b9484cSchristos    GNU General Public License for more details.
1598b9484cSchristos 
1698b9484cSchristos    You should have received a copy of the GNU General Public License
1798b9484cSchristos    along with this program; if not, write to the Free Software
1898b9484cSchristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
1998b9484cSchristos    MA 02110-1301, USA.  */
2098b9484cSchristos 
2198b9484cSchristos #ifndef GNU_COFF_INTERNAL_H
2298b9484cSchristos #define GNU_COFF_INTERNAL_H 1
2398b9484cSchristos 
2498b9484cSchristos /* First, make "signed char" work, even on old compilers. */
2598b9484cSchristos #ifndef signed
2698b9484cSchristos #ifndef __STDC__
2798b9484cSchristos #define	signed			/**/
2898b9484cSchristos #endif
2998b9484cSchristos #endif
3098b9484cSchristos 
3198b9484cSchristos /********************** FILE HEADER **********************/
3298b9484cSchristos 
3398b9484cSchristos /* extra stuff in a PE header. */
3498b9484cSchristos 
3598b9484cSchristos struct internal_extra_pe_filehdr
3698b9484cSchristos {
3798b9484cSchristos   /* DOS header data follows for PE stuff */
3898b9484cSchristos   unsigned short e_magic;	/* Magic number, 0x5a4d */
3998b9484cSchristos   unsigned short e_cblp;	/* Bytes on last page of file, 0x90 */
4098b9484cSchristos   unsigned short e_cp;		/* Pages in file, 0x3 */
4198b9484cSchristos   unsigned short e_crlc;	/* Relocations, 0x0 */
4298b9484cSchristos   unsigned short e_cparhdr;	/* Size of header in paragraphs, 0x4 */
4398b9484cSchristos   unsigned short e_minalloc;	/* Minimum extra paragraphs needed, 0x0 */
4498b9484cSchristos   unsigned short e_maxalloc;	/* Maximum extra paragraphs needed, 0xFFFF */
4598b9484cSchristos   unsigned short e_ss;		/* Initial (relative) SS value, 0x0 */
4698b9484cSchristos   unsigned short e_sp;		/* Initial SP value, 0xb8 */
4798b9484cSchristos   unsigned short e_csum;	/* Checksum, 0x0 */
4898b9484cSchristos   unsigned short e_ip;		/* Initial IP value, 0x0 */
4998b9484cSchristos   unsigned short e_cs;		/* Initial (relative) CS value, 0x0 */
5098b9484cSchristos   unsigned short e_lfarlc;	/* File address of relocation table, 0x40 */
5198b9484cSchristos   unsigned short e_ovno;	/* Overlay number, 0x0 */
5298b9484cSchristos   unsigned short e_res[4];	/* Reserved words, all 0x0 */
5398b9484cSchristos   unsigned short e_oemid;	/* OEM identifier (for e_oeminfo), 0x0 */
5498b9484cSchristos   unsigned short e_oeminfo;	/* OEM information; e_oemid specific, 0x0 */
5598b9484cSchristos   unsigned short e_res2[10];	/* Reserved words, all 0x0 */
5698b9484cSchristos   bfd_vma  e_lfanew;		/* File address of new exe header, 0x80 */
57*6817db7fSchristos   char dos_message[64];		/* Text which always follows DOS header.  */
5898b9484cSchristos   bfd_vma  nt_signature;   	/* required NT signature, 0x4550 */
5998b9484cSchristos };
6098b9484cSchristos 
6198b9484cSchristos struct internal_filehdr
6298b9484cSchristos {
6398b9484cSchristos   struct internal_extra_pe_filehdr pe;
6498b9484cSchristos 
6598b9484cSchristos   /* Standard coff internal info.  */
6698b9484cSchristos   unsigned short f_magic;	/* magic number			*/
67968cf8f2Schristos   unsigned int   f_nscns;	/* number of sections		*/
6898b9484cSchristos   long f_timdat;		/* time & date stamp		*/
6998b9484cSchristos   bfd_vma f_symptr;		/* file pointer to symtab	*/
7098b9484cSchristos   long f_nsyms;			/* number of symtab entries	*/
7198b9484cSchristos   unsigned short f_opthdr;	/* sizeof(optional hdr)		*/
7298b9484cSchristos   unsigned short f_flags;	/* flags			*/
7398b9484cSchristos   unsigned short f_target_id;	/* (TI COFF specific)		*/
7498b9484cSchristos };
7598b9484cSchristos 
7698b9484cSchristos 
7798b9484cSchristos /* Bits for f_flags:
7898b9484cSchristos  	F_RELFLG	relocation info stripped from file
7998b9484cSchristos  	F_EXEC		file is executable (no unresolved external references)
8098b9484cSchristos  	F_LNNO		line numbers stripped from file
8198b9484cSchristos  	F_LSYMS		local symbols stripped from file
8298b9484cSchristos  	F_AR16WR	file is 16-bit little-endian
8398b9484cSchristos  	F_AR32WR	file is 32-bit little-endian
8498b9484cSchristos  	F_AR32W		file is 32-bit big-endian
8598b9484cSchristos  	F_DYNLOAD	rs/6000 aix: dynamically loadable w/imports & exports
8698b9484cSchristos  	F_SHROBJ	rs/6000 aix: file is a shared object
878dffb485Schristos 	F_DLL           PE format DLL  */
8898b9484cSchristos 
8998b9484cSchristos #define	F_RELFLG	(0x0001)
9098b9484cSchristos #define	F_EXEC		(0x0002)
9198b9484cSchristos #define	F_LNNO		(0x0004)
9298b9484cSchristos #define	F_LSYMS		(0x0008)
9398b9484cSchristos #define	F_AR16WR	(0x0080)
9498b9484cSchristos #define	F_AR32WR	(0x0100)
9598b9484cSchristos #define	F_AR32W     	(0x0200)
9698b9484cSchristos #define	F_DYNLOAD	(0x1000)
9798b9484cSchristos #define	F_SHROBJ	(0x2000)
9898b9484cSchristos #define F_DLL           (0x2000)
9998b9484cSchristos 
10098b9484cSchristos /* Extra structure which is used in the optional header.  */
10198b9484cSchristos typedef struct _IMAGE_DATA_DIRECTORY
10298b9484cSchristos {
10398b9484cSchristos   bfd_vma VirtualAddress;
10498b9484cSchristos   long    Size;
10598b9484cSchristos }  IMAGE_DATA_DIRECTORY;
10698b9484cSchristos #define PE_EXPORT_TABLE			0
10798b9484cSchristos #define PE_IMPORT_TABLE			1
10898b9484cSchristos #define PE_RESOURCE_TABLE		2
10998b9484cSchristos #define PE_EXCEPTION_TABLE		3
11098b9484cSchristos #define PE_CERTIFICATE_TABLE		4
11198b9484cSchristos #define PE_BASE_RELOCATION_TABLE	5
11298b9484cSchristos #define PE_DEBUG_DATA			6
11398b9484cSchristos #define PE_ARCHITECTURE			7
11498b9484cSchristos #define PE_GLOBAL_PTR			8
11598b9484cSchristos #define PE_TLS_TABLE			9
11698b9484cSchristos #define PE_LOAD_CONFIG_TABLE		10
11798b9484cSchristos #define PE_BOUND_IMPORT_TABLE		11
11898b9484cSchristos #define PE_IMPORT_ADDRESS_TABLE		12
11998b9484cSchristos #define PE_DELAY_IMPORT_DESCRIPTOR	13
12098b9484cSchristos #define PE_CLR_RUNTIME_HEADER		14
12198b9484cSchristos /* DataDirectory[15] is currently reserved, so no define. */
12298b9484cSchristos #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES  16
12398b9484cSchristos 
124968cf8f2Schristos /* Extra structure used in debug directory.  */
125968cf8f2Schristos struct internal_IMAGE_DEBUG_DIRECTORY
126968cf8f2Schristos {
127968cf8f2Schristos   unsigned long  Characteristics;
128968cf8f2Schristos   unsigned long  TimeDateStamp;
129968cf8f2Schristos   unsigned short MajorVersion;
130968cf8f2Schristos   unsigned short MinorVersion;
131968cf8f2Schristos   unsigned long  Type;
132968cf8f2Schristos   unsigned long  SizeOfData;
133968cf8f2Schristos   unsigned long  AddressOfRawData;
134968cf8f2Schristos   unsigned long  PointerToRawData;
135968cf8f2Schristos };
136968cf8f2Schristos 
137968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_UNKNOWN          0
138968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_COFF             1
139968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_CODEVIEW         2
140968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_FPO              3
141968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_MISC             4
142968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_EXCEPTION        5
143968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_FIXUP            6
144968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_OMAP_TO_SRC      7
145968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_OMAP_FROM_SRC    8
146968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_BORLAND          9
147968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_RESERVED10       10
148968cf8f2Schristos #define PE_IMAGE_DEBUG_TYPE_CLSID            11
1498dffb485Schristos #define PE_IMAGE_DEBUG_TYPE_VC_FEATURE       12
1508dffb485Schristos #define PE_IMAGE_DEBUG_TYPE_POGO             13
1518dffb485Schristos #define PE_IMAGE_DEBUG_TYPE_ILTCG            14
1528dffb485Schristos #define PE_IMAGE_DEBUG_TYPE_MPX              15
1538dffb485Schristos #define PE_IMAGE_DEBUG_TYPE_REPRO            16
154968cf8f2Schristos 
155968cf8f2Schristos /* Extra structure for a codeview debug record */
156968cf8f2Schristos #define CV_INFO_SIGNATURE_LENGTH 16
157968cf8f2Schristos 
158968cf8f2Schristos typedef struct _CODEVIEW_INFO
159968cf8f2Schristos {
160968cf8f2Schristos   unsigned long CVSignature;
161968cf8f2Schristos   char          Signature[CV_INFO_SIGNATURE_LENGTH];
162968cf8f2Schristos   unsigned int  SignatureLength;
163968cf8f2Schristos   unsigned long Age;
1648dffb485Schristos   /* char PdbFileName[];  */
165968cf8f2Schristos } CODEVIEW_INFO;
166968cf8f2Schristos 
16798b9484cSchristos /* Default image base for NT.  */
16898b9484cSchristos #define NT_EXE_IMAGE_BASE 0x400000
16998b9484cSchristos #define NT_DLL_IMAGE_BASE 0x10000000
17098b9484cSchristos 
17198b9484cSchristos /* Default image base for BeOS. */
17298b9484cSchristos #define BEOS_EXE_IMAGE_BASE 0x80000000
17398b9484cSchristos #define BEOS_DLL_IMAGE_BASE 0x10000000
17498b9484cSchristos 
17598b9484cSchristos /* Extra stuff in a PE aouthdr */
17698b9484cSchristos 
17798b9484cSchristos #define PE_DEF_SECTION_ALIGNMENT 0x1000
17898b9484cSchristos #ifndef PE_DEF_FILE_ALIGNMENT
17998b9484cSchristos # define PE_DEF_FILE_ALIGNMENT 0x200
18098b9484cSchristos #endif
18198b9484cSchristos 
18298b9484cSchristos struct internal_extra_pe_aouthdr
18398b9484cSchristos {
18498b9484cSchristos   /* FIXME: The following entries are in AOUTHDR.  But they aren't
18598b9484cSchristos      available internally in bfd.  We add them here so that objdump
18698b9484cSchristos      can dump them.  */
187968cf8f2Schristos   /* The state of the image file.  */
18898b9484cSchristos   short Magic;
189968cf8f2Schristos   /* Linker major version number.  */
19098b9484cSchristos   char MajorLinkerVersion;
191968cf8f2Schristos   /* Linker minor version number.  */
19298b9484cSchristos   char MinorLinkerVersion;
193968cf8f2Schristos   /* Total size of all code sections.  */
1948dffb485Schristos   bfd_vma SizeOfCode;
195968cf8f2Schristos   /* Total size of all initialized data sections.  */
1968dffb485Schristos   bfd_vma SizeOfInitializedData;
197968cf8f2Schristos   /* Total size of all uninitialized data sections.  */
1988dffb485Schristos   bfd_vma SizeOfUninitializedData;
19998b9484cSchristos   /* Address of entry point relative to image base.  */
20098b9484cSchristos   bfd_vma AddressOfEntryPoint;
20198b9484cSchristos   /* Address of the first code section relative to image base.  */
20298b9484cSchristos   bfd_vma BaseOfCode;
20398b9484cSchristos   /* Address of the first data section relative to image base.  */
20498b9484cSchristos   bfd_vma BaseOfData;
20598b9484cSchristos 
20698b9484cSchristos   /* PE stuff  */
207968cf8f2Schristos   bfd_vma ImageBase;		/* Address of specific location in memory that
208968cf8f2Schristos 				   file is located, NT default 0x10000.  */
20998b9484cSchristos 
2108dffb485Schristos   uint32_t SectionAlignment;	/* Section alignment default 0x1000.  */
2118dffb485Schristos   uint32_t FileAlignment;	/* File alignment default 0x200.  */
212968cf8f2Schristos   short MajorOperatingSystemVersion; /* Minimum version of the operating.  */
2138dffb485Schristos   short MinorOperatingSystemVersion; /* System req'd for exe, default 1.  */
214968cf8f2Schristos   short MajorImageVersion;	/* User defineable field to store version of */
215968cf8f2Schristos   short MinorImageVersion;	/*  exe or dll being created, default to 0.  */
216968cf8f2Schristos   short MajorSubsystemVersion;	/* Minimum subsystem version required to */
217968cf8f2Schristos   short MinorSubsystemVersion;	/*  run exe; default to 3.1.  */
2188dffb485Schristos   uint32_t Reserved1;		/* Seems to be 0.  */
2198dffb485Schristos   uint32_t SizeOfImage;		/* Size of memory to allocate for prog.  */
2208dffb485Schristos   uint32_t SizeOfHeaders;	/* Size of PE header and section table.  */
2218dffb485Schristos   uint32_t CheckSum;		/* Set to 0.  */
22298b9484cSchristos   short Subsystem;
22398b9484cSchristos 
224968cf8f2Schristos   /* Type of subsystem exe uses for user interface,
22598b9484cSchristos      possible values:
22698b9484cSchristos      1 - NATIVE   Doesn't require a subsystem
22798b9484cSchristos      2 - WINDOWS_GUI runs in Windows GUI subsystem
22898b9484cSchristos      3 - WINDOWS_CUI runs in Windows char sub. (console app)
22998b9484cSchristos      5 - OS2_CUI runs in OS/2 character subsystem
230968cf8f2Schristos      7 - POSIX_CUI runs in Posix character subsystem.  */
231968cf8f2Schristos   unsigned short DllCharacteristics; /* flags for DLL init.  */
232968cf8f2Schristos   bfd_vma SizeOfStackReserve;	/* Amount of memory to reserve.  */
233968cf8f2Schristos   bfd_vma SizeOfStackCommit;	/* Amount of memory initially committed for
2348dffb485Schristos 				   initial thread's stack, default 0x1000.  */
235968cf8f2Schristos   bfd_vma SizeOfHeapReserve;	/* Amount of virtual memory to reserve and */
236968cf8f2Schristos   bfd_vma SizeOfHeapCommit;	/*  commit, don't know what to defaut it to.  */
2378dffb485Schristos   uint32_t LoaderFlags;		/* Can probably set to 0.  */
2388dffb485Schristos   uint32_t NumberOfRvaAndSizes;	/* Number of entries in next entry, 16.  */
23998b9484cSchristos   IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
24098b9484cSchristos };
24198b9484cSchristos 
24298b9484cSchristos /********************** AOUT "OPTIONAL HEADER" **********************/
24398b9484cSchristos struct internal_aouthdr
24498b9484cSchristos {
24598b9484cSchristos   short magic;			/* type of file				*/
24698b9484cSchristos   short vstamp;			/* version stamp			*/
24798b9484cSchristos   bfd_vma tsize;		/* text size in bytes, padded to FW bdry*/
24898b9484cSchristos   bfd_vma dsize;		/* initialized data "  "		*/
24998b9484cSchristos   bfd_vma bsize;		/* uninitialized data "   "		*/
25098b9484cSchristos   bfd_vma entry;		/* entry pt.				*/
25198b9484cSchristos   bfd_vma text_start;		/* base of text used for this file */
25298b9484cSchristos   bfd_vma data_start;		/* base of data used for this file */
25398b9484cSchristos 
25498b9484cSchristos   /* RS/6000 stuff */
25598b9484cSchristos   bfd_vma o_toc;		/* address of TOC			*/
25698b9484cSchristos   short o_snentry;		/* section number for entry point */
25798b9484cSchristos   short o_sntext;		/* section number for text	*/
25898b9484cSchristos   short o_sndata;		/* section number for data	*/
25998b9484cSchristos   short o_sntoc;		/* section number for toc	*/
26098b9484cSchristos   short o_snloader;		/* section number for loader section */
26198b9484cSchristos   short o_snbss;		/* section number for bss	*/
26298b9484cSchristos   short o_algntext;		/* max alignment for text	*/
26398b9484cSchristos   short o_algndata;		/* max alignment for data	*/
26498b9484cSchristos   short o_modtype;		/* Module type field, 1R,RE,RO	*/
26598b9484cSchristos   short o_cputype;		/* Encoded CPU type		*/
26698b9484cSchristos   bfd_vma o_maxstack;		/* max stack size allowed.	*/
26798b9484cSchristos   bfd_vma o_maxdata;		/* max data size allowed.	*/
2684b169a6bSchristos   char o_flags;			/* Flags and TLS alignment	*/
2694b169a6bSchristos   short o_sntdata;		/* section number for tdata	*/
2704b169a6bSchristos   short o_sntbss;		/* section number for tbss	*/
2714b169a6bSchristos   short o_x64flags;		/* XCOFF64 flags		*/
2724b169a6bSchristos 
27398b9484cSchristos 
27498b9484cSchristos   /* ECOFF stuff */
27598b9484cSchristos   bfd_vma bss_start;		/* Base of bss section.		*/
27698b9484cSchristos   bfd_vma gp_value;		/* GP register value.		*/
27798b9484cSchristos   unsigned long gprmask;	/* General registers used.	*/
27898b9484cSchristos   unsigned long cprmask[4];	/* Coprocessor registers used.	*/
27998b9484cSchristos   unsigned long fprmask;	/* Floating pointer registers used.  */
28098b9484cSchristos 
28198b9484cSchristos   /* Apollo stuff */
28298b9484cSchristos   long o_inlib;			/* inlib data */
28398b9484cSchristos   long o_sri;			/* Static Resource Information */
28498b9484cSchristos   long vid[2];			/* Version id */
28598b9484cSchristos 
28698b9484cSchristos   struct internal_extra_pe_aouthdr pe;
28798b9484cSchristos };
28898b9484cSchristos 
28998b9484cSchristos /********************** STORAGE CLASSES **********************/
29098b9484cSchristos 
29198b9484cSchristos /* This used to be defined as -1, but now n_sclass is unsigned.  */
29298b9484cSchristos #define C_EFCN		0xff	/* physical end of function	*/
29398b9484cSchristos #define C_NULL		0
29498b9484cSchristos #define C_AUTO		1	/* automatic variable		*/
29598b9484cSchristos #define C_EXT		2	/* external symbol		*/
29698b9484cSchristos #define C_STAT		3	/* static			*/
29798b9484cSchristos #define C_REG		4	/* register variable		*/
29898b9484cSchristos #define C_EXTDEF	5	/* external definition		*/
29998b9484cSchristos #define C_LABEL		6	/* label			*/
30098b9484cSchristos #define C_ULABEL	7	/* undefined label		*/
30198b9484cSchristos #define C_MOS		8	/* member of structure		*/
30298b9484cSchristos #define C_ARG		9	/* function argument		*/
30398b9484cSchristos #define C_STRTAG	10	/* structure tag		*/
30498b9484cSchristos #define C_MOU		11	/* member of union		*/
30598b9484cSchristos #define C_UNTAG		12	/* union tag			*/
30698b9484cSchristos #define C_TPDEF		13	/* type definition		*/
30798b9484cSchristos #define C_USTATIC	14	/* undefined static		*/
30898b9484cSchristos #define C_ENTAG		15	/* enumeration tag		*/
30998b9484cSchristos #define C_MOE		16	/* member of enumeration	*/
31098b9484cSchristos #define C_REGPARM	17	/* register parameter		*/
31198b9484cSchristos #define C_FIELD		18	/* bit field			*/
31298b9484cSchristos #define C_AUTOARG	19	/* auto argument		*/
31398b9484cSchristos #define C_LASTENT	20	/* dummy entry (end of block)	*/
31498b9484cSchristos #define C_BLOCK		100	/* ".bb" or ".eb"		*/
31598b9484cSchristos #define C_FCN		101	/* ".bf" or ".ef"		*/
31698b9484cSchristos #define C_EOS		102	/* end of structure		*/
31798b9484cSchristos #define C_FILE		103	/* file name			*/
31898b9484cSchristos #define C_LINE		104	/* line # reformatted as symbol table entry */
31998b9484cSchristos #define C_ALIAS	 	105	/* duplicate tag		*/
32098b9484cSchristos #define C_HIDDEN	106	/* ext symbol in dmert public lib */
32198b9484cSchristos #define C_WEAKEXT	127	/* weak symbol -- GNU extension.  */
32298b9484cSchristos 
32398b9484cSchristos /* New storage classes for TI COFF */
32498b9484cSchristos #define C_UEXT		19	/* Tentative external definition */
32598b9484cSchristos #define C_STATLAB	20	/* Static load time label */
32698b9484cSchristos #define C_EXTLAB	21	/* External load time label */
32798b9484cSchristos #define C_SYSTEM	23	/* System Wide variable */
32898b9484cSchristos 
32998b9484cSchristos /* New storage classes for WINDOWS_NT   */
33098b9484cSchristos #define C_SECTION       104     /* section name */
33198b9484cSchristos #define C_NT_WEAK	105	/* weak external */
33298b9484cSchristos 
33398b9484cSchristos  /* New storage classes for 80960 */
33498b9484cSchristos 
33598b9484cSchristos /* C_LEAFPROC is obsolete.  Use C_LEAFEXT or C_LEAFSTAT */
33698b9484cSchristos #define C_LEAFPROC	108	/* Leaf procedure, "call" via BAL */
33798b9484cSchristos 
33898b9484cSchristos #define C_SCALL		107	/* Procedure reachable via system call */
33998b9484cSchristos #define C_LEAFEXT       108	/* External leaf */
34098b9484cSchristos #define C_LEAFSTAT      113	/* Static leaf */
34198b9484cSchristos #define C_OPTVAR	109	/* Optimized variable		*/
34298b9484cSchristos #define C_DEFINE	110	/* Preprocessor #define		*/
34398b9484cSchristos #define C_PRAGMA	111	/* Advice to compiler or linker	*/
34498b9484cSchristos #define C_SEGMENT	112	/* 80960 segment name		*/
34598b9484cSchristos 
34698b9484cSchristos  /* New storage classes for RS/6000 */
34798b9484cSchristos #define C_HIDEXT        107	/* Un-named external symbol */
34898b9484cSchristos #define C_BINCL         108	/* Marks beginning of include file */
34998b9484cSchristos #define C_EINCL         109	/* Marks ending of include file */
35098b9484cSchristos #define C_AIX_WEAKEXT   111	/* AIX definition of C_WEAKEXT.  */
3514b169a6bSchristos #define C_DWARF         112	/* DWARF symbol  */
35298b9484cSchristos 
35398b9484cSchristos #define C_NULL_VALUE	0x00de1e00    /* Value for a C_NULL deleted entry.  */
35498b9484cSchristos 
355*6817db7fSchristos #ifdef AIX_WEAK_SUPPORT
35698b9484cSchristos #undef C_WEAKEXT
35798b9484cSchristos #define C_WEAKEXT       C_AIX_WEAKEXT
35898b9484cSchristos #endif
35998b9484cSchristos 
36098b9484cSchristos  /* storage classes for stab symbols for RS/6000 */
36198b9484cSchristos #define C_GSYM          (0x80)
36298b9484cSchristos #define C_LSYM          (0x81)
36398b9484cSchristos #define C_PSYM          (0x82)
36498b9484cSchristos #define C_RSYM          (0x83)
36598b9484cSchristos #define C_RPSYM         (0x84)
36698b9484cSchristos #define C_STSYM         (0x85)
36798b9484cSchristos #define C_TCSYM         (0x86)
36898b9484cSchristos #define C_BCOMM         (0x87)
36998b9484cSchristos #define C_ECOML         (0x88)
37098b9484cSchristos #define C_ECOMM         (0x89)
37198b9484cSchristos #define C_DECL          (0x8c)
37298b9484cSchristos #define C_ENTRY         (0x8d)
37398b9484cSchristos #define C_FUN           (0x8e)
37498b9484cSchristos #define C_BSTAT         (0x8f)
37598b9484cSchristos #define C_ESTAT         (0x90)
37603467a24Schristos #define C_GTLS          (0x97)
37703467a24Schristos #define C_STTLS         (0x98)
37898b9484cSchristos 
37998b9484cSchristos /* Storage classes for Thumb symbols */
38098b9484cSchristos #define C_THUMBEXT      (128 + C_EXT)		/* 130 */
38198b9484cSchristos #define C_THUMBSTAT     (128 + C_STAT)		/* 131 */
38298b9484cSchristos #define C_THUMBLABEL    (128 + C_LABEL)		/* 134 */
38398b9484cSchristos #define C_THUMBEXTFUNC  (C_THUMBEXT  + 20)	/* 150 */
38498b9484cSchristos #define C_THUMBSTATFUNC (C_THUMBSTAT + 20)	/* 151 */
38598b9484cSchristos 
3864b169a6bSchristos /* True if XCOFF symbols of class CLASS have auxiliary csect information.  */
38798b9484cSchristos #define CSECT_SYM_P(CLASS) \
38898b9484cSchristos   ((CLASS) == C_EXT || (CLASS) == C_AIX_WEAKEXT || (CLASS) == C_HIDEXT)
38998b9484cSchristos 
39098b9484cSchristos /********************** SECTION HEADER **********************/
39198b9484cSchristos 
39298b9484cSchristos #define SCNNMLEN (8)
39398b9484cSchristos 
39498b9484cSchristos struct internal_scnhdr
39598b9484cSchristos {
3964559860eSchristos   char s_name[SCNNMLEN] ATTRIBUTE_NONSTRING;	/* section name	*/
39798b9484cSchristos 
39898b9484cSchristos   /* Physical address, aliased s_nlib.
39998b9484cSchristos      In the pei format, this field is the virtual section size
40098b9484cSchristos      (the size of the section after being loaded int memory),
40198b9484cSchristos      NOT the physical address.  */
40298b9484cSchristos   bfd_vma s_paddr;
40398b9484cSchristos 
40498b9484cSchristos   bfd_vma s_vaddr;		/* virtual address		*/
40598b9484cSchristos   bfd_vma s_size;		/* section size			*/
40698b9484cSchristos   bfd_vma s_scnptr;		/* file ptr to raw data for section */
40798b9484cSchristos   bfd_vma s_relptr;		/* file ptr to relocation	*/
40898b9484cSchristos   bfd_vma s_lnnoptr;		/* file ptr to line numbers	*/
40998b9484cSchristos   unsigned long s_nreloc;	/* number of relocation entries	*/
41098b9484cSchristos   unsigned long s_nlnno;	/* number of line number entries*/
4114b169a6bSchristos   unsigned long s_flags;	/* flags			*/
41298b9484cSchristos   unsigned char s_page;         /* TI COFF load page            */
41398b9484cSchristos };
41498b9484cSchristos 
41598b9484cSchristos /* s_flags "type".  */
41698b9484cSchristos #define STYP_REG	 (0x0000)	/* "regular": allocated, relocated, loaded */
41798b9484cSchristos #define STYP_DSECT	 (0x0001)	/* "dummy":  relocated only*/
41898b9484cSchristos #define STYP_NOLOAD	 (0x0002)	/* "noload": allocated, relocated, not loaded */
41998b9484cSchristos #define STYP_GROUP	 (0x0004)	/* "grouped": formed of input sections */
42098b9484cSchristos #define STYP_PAD	 (0x0008)	/* "padding": not allocated, not relocated, loaded */
42198b9484cSchristos #define STYP_COPY	 (0x0010)	/* "copy": for decision function used by field update;  not allocated, not relocated,
42298b9484cSchristos 									     loaded; reloc & lineno entries processed normally */
42398b9484cSchristos #define STYP_TEXT	 (0x0020)	/* section contains text only */
42498b9484cSchristos #define S_SHRSEG	 (0x0020)	/* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
42598b9484cSchristos 									     will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
42698b9484cSchristos 									     update all process invocations. */
42798b9484cSchristos #define STYP_DATA	 (0x0040)	/* section contains data only */
42898b9484cSchristos #define STYP_BSS	 (0x0080)	/* section contains bss only */
42998b9484cSchristos #define S_NEWFCN	 (0x0100)	/* In a minimal file or an update file, a new function (as compared with a replaced function) */
43098b9484cSchristos #define STYP_INFO	 (0x0200)	/* comment: not allocated not relocated, not loaded */
43198b9484cSchristos #define STYP_OVER	 (0x0400)	/* overlay: relocated not allocated or loaded */
43298b9484cSchristos #define STYP_LIB	 (0x0800)	/* for .lib: same as INFO */
43398b9484cSchristos #define STYP_MERGE	 (0x2000)	/* merge section -- combines with text, data or bss sections only */
43498b9484cSchristos #define STYP_REVERSE_PAD (0x4000)	/* section will be padded with no-op instructions
43598b9484cSchristos 					   wherever padding is necessary and there is a
43698b9484cSchristos 					   word of contiguous bytes beginning on a word
43798b9484cSchristos 					   boundary. */
43898b9484cSchristos 
43998b9484cSchristos #define STYP_LIT	0x8020	/* Literal data (like STYP_TEXT) */
44098b9484cSchristos 
44198b9484cSchristos 
44298b9484cSchristos /********************** LINE NUMBERS **********************/
44398b9484cSchristos 
44498b9484cSchristos /* 1 line number entry for every "breakpointable" source line in a section.
44598b9484cSchristos    Line numbers are grouped on a per function basis; first entry in a function
44698b9484cSchristos    grouping will have l_lnno = 0 and in place of physical address will be the
44798b9484cSchristos    symbol table index of the function name.  */
44898b9484cSchristos 
44998b9484cSchristos struct internal_lineno
45098b9484cSchristos {
45198b9484cSchristos   union
45298b9484cSchristos   {
45398b9484cSchristos     bfd_signed_vma l_symndx;		/* function name symbol index, iff l_lnno == 0*/
45498b9484cSchristos     bfd_signed_vma l_paddr;		/* (physical) address of line number	*/
45598b9484cSchristos   }     l_addr;
45698b9484cSchristos   unsigned long l_lnno;		/* line number		*/
45798b9484cSchristos };
45898b9484cSchristos 
45998b9484cSchristos /********************** SYMBOLS **********************/
46098b9484cSchristos 
46198b9484cSchristos #define SYMNMLEN	8	/* # characters in a symbol name	*/
46298b9484cSchristos #define FILNMLEN	14	/* # characters in a file name		*/
46398b9484cSchristos #define DIMNUM		4	/* # array dimensions in auxiliary entry */
46498b9484cSchristos 
46598b9484cSchristos struct internal_syment
46698b9484cSchristos {
46798b9484cSchristos   union
46898b9484cSchristos   {
4694559860eSchristos     char _n_name[SYMNMLEN] ATTRIBUTE_NONSTRING;	/* old COFF version	*/
47098b9484cSchristos     struct
47198b9484cSchristos     {
4724b169a6bSchristos       uintptr_t _n_zeroes;	/* new == 0			*/
4734b169a6bSchristos       uintptr_t _n_offset;	/* offset into string table	*/
47498b9484cSchristos     }      _n_n;
47598b9484cSchristos     char *_n_nptr[2];		/* allows for overlaying	*/
47698b9484cSchristos   }     _n;
47798b9484cSchristos   bfd_vma n_value;		/* value of symbol		*/
478ba340e45Schristos   int n_scnum;			/* section number		*/
47998b9484cSchristos   unsigned short n_flags;	/* copy of flags from filhdr	*/
48098b9484cSchristos   unsigned short n_type;	/* type and derived type	*/
48198b9484cSchristos   unsigned char n_sclass;	/* storage class		*/
48298b9484cSchristos   unsigned char n_numaux;	/* number of aux. entries	*/
48398b9484cSchristos };
48498b9484cSchristos 
48598b9484cSchristos #define n_name		_n._n_name
48698b9484cSchristos #define n_zeroes	_n._n_n._n_zeroes
48798b9484cSchristos #define n_offset	_n._n_n._n_offset
48898b9484cSchristos 
48998b9484cSchristos /* Relocatable symbols have number of the section in which they are defined,
49098b9484cSchristos    or one of the following:  */
49198b9484cSchristos 
492ba340e45Schristos #define N_UNDEF	((int)0)	/* undefined symbol */
493ba340e45Schristos #define N_ABS	((int)-1)	/* value of symbol is absolute */
494ba340e45Schristos #define N_DEBUG	((int)-2)	/* debugging symbol -- value is meaningless */
495ba340e45Schristos #define N_TV	((int)-3)	/* indicates symbol needs preload transfer vector */
496ba340e45Schristos #define P_TV	((int)-4)	/* indicates symbol needs postload transfer vector*/
49798b9484cSchristos 
49898b9484cSchristos /* Type of a symbol, in low N bits of the word.  */
49998b9484cSchristos 
50098b9484cSchristos #define T_NULL		0
50198b9484cSchristos #define T_VOID		1	/* function argument (only used by compiler) */
50298b9484cSchristos #define T_CHAR		2	/* character		*/
50398b9484cSchristos #define T_SHORT		3	/* short integer	*/
50498b9484cSchristos #define T_INT		4	/* integer		*/
50598b9484cSchristos #define T_LONG		5	/* long integer		*/
50698b9484cSchristos #define T_FLOAT		6	/* floating point	*/
50798b9484cSchristos #define T_DOUBLE	7	/* double word		*/
50898b9484cSchristos #define T_STRUCT	8	/* structure 		*/
50998b9484cSchristos #define T_UNION		9	/* union 		*/
51098b9484cSchristos #define T_ENUM		10	/* enumeration 		*/
51198b9484cSchristos #define T_MOE		11	/* member of enumeration*/
51298b9484cSchristos #define T_UCHAR		12	/* unsigned character	*/
51398b9484cSchristos #define T_USHORT	13	/* unsigned short	*/
51498b9484cSchristos #define T_UINT		14	/* unsigned integer	*/
51598b9484cSchristos #define T_ULONG		15	/* unsigned long	*/
51698b9484cSchristos #define T_LNGDBL	16	/* long double		*/
51798b9484cSchristos 
51898b9484cSchristos /* Derived types, in n_type.  */
51998b9484cSchristos 
52098b9484cSchristos #define DT_NON		(0)	/* no derived type */
52198b9484cSchristos #define DT_PTR		(1)	/* pointer */
52298b9484cSchristos #define DT_FCN		(2)	/* function */
52398b9484cSchristos #define DT_ARY		(3)	/* array */
52498b9484cSchristos 
52598b9484cSchristos #define BTYPE(x)	((x) & N_BTMASK)
52698b9484cSchristos #define DTYPE(x)	(((x) & N_TMASK) >> N_BTSHFT)
52798b9484cSchristos 
52898b9484cSchristos #define ISPTR(x) \
52998b9484cSchristos   (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_PTR << N_BTSHFT))
53098b9484cSchristos #define ISFCN(x) \
53198b9484cSchristos   (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_FCN << N_BTSHFT))
53298b9484cSchristos #define ISARY(x) \
53398b9484cSchristos   (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_ARY << N_BTSHFT))
53498b9484cSchristos #define ISTAG(x) \
53598b9484cSchristos   ((x) == C_STRTAG || (x) == C_UNTAG || (x) == C_ENTAG)
53698b9484cSchristos #define DECREF(x) \
53798b9484cSchristos   ((((x) >> N_TSHIFT) & ~ N_BTMASK) | ((x) & N_BTMASK))
53898b9484cSchristos 
5394b169a6bSchristos /* Visibility flag, in XCOFF n_type.  */
5404b169a6bSchristos #define SYM_V_INTERNAL		0x1000
5414b169a6bSchristos #define SYM_V_HIDDEN		0x2000
5424b169a6bSchristos #define SYM_V_PROTECTED 	0x3000
5434b169a6bSchristos #define SYM_V_EXPORTED		0x4000
5444b169a6bSchristos #define SYM_V_MASK		0xF000
5454b169a6bSchristos 
54698b9484cSchristos union internal_auxent
54798b9484cSchristos {
54898b9484cSchristos   struct
54998b9484cSchristos   {
55098b9484cSchristos     union
55198b9484cSchristos     {
552*6817db7fSchristos       uint32_t u32;		/* str, un, or enum tag indx */
55398b9484cSchristos       struct coff_ptr_struct *p;
55498b9484cSchristos     } x_tagndx;
55598b9484cSchristos 
55698b9484cSchristos     union
55798b9484cSchristos     {
55898b9484cSchristos       struct
55998b9484cSchristos       {
560*6817db7fSchristos 	uint16_t x_lnno;	/* declaration line number */
561*6817db7fSchristos 	uint16_t x_size;	/* str/union/array size */
56298b9484cSchristos       } x_lnsz;
563*6817db7fSchristos       uint32_t x_fsize;		/* size of function */
56498b9484cSchristos     } x_misc;
56598b9484cSchristos 
56698b9484cSchristos     union
56798b9484cSchristos     {
56898b9484cSchristos       struct
56998b9484cSchristos       {				/* if ISFCN, tag, or .bb */
570*6817db7fSchristos 	uint64_t x_lnnoptr;	/* ptr to fcn line # */
57198b9484cSchristos 	union
57298b9484cSchristos 	{			/* entry ndx past block end */
573*6817db7fSchristos 	  uint32_t u32;
57498b9484cSchristos 	  struct coff_ptr_struct *p;
57598b9484cSchristos 	} x_endndx;
57698b9484cSchristos       } x_fcn;
57798b9484cSchristos 
57898b9484cSchristos       struct
57998b9484cSchristos       {				/* if ISARY, up to 4 dimen. */
580*6817db7fSchristos 	uint16_t x_dimen[DIMNUM];
58198b9484cSchristos       } x_ary;
58298b9484cSchristos     } x_fcnary;
58398b9484cSchristos 
584*6817db7fSchristos     uint16_t x_tvndx;		/* tv index */
58598b9484cSchristos   } x_sym;
58698b9484cSchristos 
5874b169a6bSchristos   struct
5884b169a6bSchristos   {
58998b9484cSchristos     union
59098b9484cSchristos     {
5914b169a6bSchristos       /* PR 17754: We used to use FILNMLEN for the size of the x_fname
5924b169a6bSchristos 	 array, but that causes problems as PE targets use a larger
5934b169a6bSchristos 	 value.  We cannot use their definition of E_FILNMLEN as this
594968cf8f2Schristos 	 header can be used without including any PE headers.  */
595968cf8f2Schristos       char x_fname[20];
59698b9484cSchristos       struct
59798b9484cSchristos       {
5984b169a6bSchristos 	/* PR 28630: We use uintptr_t because these fields may be
5994b169a6bSchristos 	   used to hold pointers.  We assume that this type is at least
6004b169a6bSchristos 	   32 bits.  */
6014b169a6bSchristos 	uintptr_t x_zeroes;
6024b169a6bSchristos 	uintptr_t x_offset;
60398b9484cSchristos       } x_n;
6044b169a6bSchristos     } x_n;
6054b169a6bSchristos 
606*6817db7fSchristos     uint8_t x_ftype;
60798b9484cSchristos   } x_file;
60898b9484cSchristos 
60998b9484cSchristos   struct
61098b9484cSchristos   {
611*6817db7fSchristos     uint32_t x_scnlen;		/* section length */
612*6817db7fSchristos     uint16_t x_nreloc;		/* # relocation entries */
613*6817db7fSchristos     uint16_t x_nlinno;		/* # line numbers */
614*6817db7fSchristos     uint32_t x_checksum;	/* section COMDAT checksum for PE */
615*6817db7fSchristos     uint16_t x_associated;	/* COMDAT associated section index for PE */
616*6817db7fSchristos     uint8_t x_comdat;		/* COMDAT selection number for PE */
61798b9484cSchristos   } x_scn;
61898b9484cSchristos 
61998b9484cSchristos   struct
62098b9484cSchristos   {
621*6817db7fSchristos     uint32_t x_tvfill;		/* tv fill value */
622*6817db7fSchristos     uint16_t x_tvlen;		/* length of .tv */
623*6817db7fSchristos     uint16_t x_tvran[2];	/* tv range */
62498b9484cSchristos   } x_tv;			/* info about .tv section (in auxent of symbol .tv)) */
62598b9484cSchristos 
62698b9484cSchristos   /******************************************
62798b9484cSchristos    * RS/6000-specific auxent - last auxent for every external symbol
62898b9484cSchristos    ******************************************/
62998b9484cSchristos   struct
63098b9484cSchristos   {
63198b9484cSchristos     union
63298b9484cSchristos       {				/* csect length or enclosing csect */
633*6817db7fSchristos 	uint64_t u64;
63498b9484cSchristos 	struct coff_ptr_struct *p;
63598b9484cSchristos       } x_scnlen;
636*6817db7fSchristos     uint32_t x_parmhash;	/* parm type hash index */
637*6817db7fSchristos     uint16_t x_snhash;		/* sect num with parm hash */
638*6817db7fSchristos     uint8_t x_smtyp;		/* symbol align and type */
63998b9484cSchristos     /* 0-4 - Log 2 of alignment */
64098b9484cSchristos     /* 5-7 - symbol type */
641*6817db7fSchristos     uint8_t x_smclas;		/* storage mapping class */
642*6817db7fSchristos     uint32_t x_stab;		/* dbx stab info index */
643*6817db7fSchristos     uint16_t x_snstab;		/* sect num with dbx stab */
64498b9484cSchristos   } x_csect;			/* csect definition information */
64598b9484cSchristos 
64698b9484cSchristos /* x_smtyp values:  */
64798b9484cSchristos 
64898b9484cSchristos #define	SMTYP_ALIGN(x)	((x) >> 3)	/* log2 of alignment */
64998b9484cSchristos #define	SMTYP_SMTYP(x)	((x) & 0x7)	/* symbol type */
65098b9484cSchristos /* Symbol type values:  */
65198b9484cSchristos #define	XTY_ER	0		/* External reference */
65298b9484cSchristos #define	XTY_SD	1		/* Csect definition */
65398b9484cSchristos #define	XTY_LD	2		/* Label definition */
65498b9484cSchristos #define XTY_CM	3		/* .BSS */
65598b9484cSchristos #define	XTY_EM	4		/* Error message */
65698b9484cSchristos #define	XTY_US	5		/* "Reserved for internal use" */
65798b9484cSchristos 
65898b9484cSchristos /* x_smclas values:  */
65998b9484cSchristos 
66098b9484cSchristos #define	XMC_PR	0		/* Read-only program code */
66198b9484cSchristos #define	XMC_RO	1		/* Read-only constant */
66298b9484cSchristos #define	XMC_DB	2		/* Read-only debug dictionary table */
66398b9484cSchristos #define	XMC_TC	3		/* Read-write general TOC entry */
66498b9484cSchristos #define	XMC_UA	4		/* Read-write unclassified */
66598b9484cSchristos #define	XMC_RW	5		/* Read-write data */
66698b9484cSchristos #define	XMC_GL	6		/* Read-only global linkage */
66798b9484cSchristos #define	XMC_XO	7		/* Read-only extended operation */
66898b9484cSchristos #define	XMC_SV	8		/* Read-only supervisor call */
66998b9484cSchristos #define	XMC_BS	9		/* Read-write BSS */
67098b9484cSchristos #define	XMC_DS	10		/* Read-write descriptor csect */
67198b9484cSchristos #define	XMC_UC	11		/* Read-write unnamed Fortran common */
67298b9484cSchristos #define	XMC_TI	12		/* Read-only traceback index csect */
67398b9484cSchristos #define	XMC_TB	13		/* Read-only traceback table csect */
67498b9484cSchristos /* 		14	??? */
67598b9484cSchristos #define	XMC_TC0	15		/* Read-write TOC anchor */
67698b9484cSchristos #define XMC_TD	16		/* Read-write data in TOC */
6774b169a6bSchristos 
6784b169a6bSchristos   struct
6794b169a6bSchristos   {
680*6817db7fSchristos     uint64_t x_scnlen;		/* Section length */
681*6817db7fSchristos     uint64_t x_nreloc;		/* Number of relocation entries */
6824b169a6bSchristos   } x_sect;
68398b9484cSchristos };
68498b9484cSchristos 
68598b9484cSchristos /********************** RELOCATION DIRECTIVES **********************/
68698b9484cSchristos 
68798b9484cSchristos struct internal_reloc
68898b9484cSchristos {
68998b9484cSchristos   bfd_vma r_vaddr;		/* Virtual address of reference */
69098b9484cSchristos   long r_symndx;		/* Index into symbol table	*/
69198b9484cSchristos   unsigned short r_type;	/* Relocation type		*/
69298b9484cSchristos   unsigned char r_size;		/* Used by RS/6000 and ECOFF	*/
69398b9484cSchristos   unsigned char r_extern;	/* Used by ECOFF		*/
69498b9484cSchristos   unsigned long r_offset;	/* Used by Alpha ECOFF, SPARC, others */
69598b9484cSchristos };
69698b9484cSchristos 
6974b169a6bSchristos #define IMAGE_REL_BASED_ABSOLUTE		0
6984b169a6bSchristos #define IMAGE_REL_BASED_HIGH			1
6994b169a6bSchristos #define IMAGE_REL_BASED_LOW			2
7004b169a6bSchristos #define IMAGE_REL_BASED_HIGHLOW			3
7014b169a6bSchristos #define IMAGE_REL_BASED_HIGHADJ			4
7024b169a6bSchristos #define IMAGE_REL_BASED_MIPS_JMPADDR		5
7034b169a6bSchristos #define IMAGE_REL_BASED_ARM_MOV32		5
7044b169a6bSchristos #define IMAGE_REL_BASED_RISCV_HIGH20		5
7054b169a6bSchristos #define IMAGE_REL_BASED_THUMB_MOV32		7
7064b169a6bSchristos #define IMAGE_REL_BASED_RISCV_LOW12I		7
7074b169a6bSchristos #define IMAGE_REL_BASED_RISCV_LOW12S		8
7084b169a6bSchristos #define IMAGE_REL_BASED_LOONGARCH32_MARK_LA	8
7094b169a6bSchristos #define IMAGE_REL_BASED_LOONGARCH64_MARK_LA	8
7104b169a6bSchristos #define IMAGE_REL_BASED_MIPS_JMPADDR16		9
7114b169a6bSchristos #define IMAGE_REL_BASED_DIR64			10
71298b9484cSchristos 
71398b9484cSchristos #endif /* GNU_COFF_INTERNAL_H */
714