xref: /openbsd-src/gnu/usr.bin/binutils/include/coff/internal.h (revision 272a140b8ad54120f5c6308aa962815d8af3bd19)
12159047fSniklas /* Internal format of COFF object file data structures, for GNU BFD.
2b55d4692Sfgsch    This file is part of BFD, the Binary File Descriptor library.
3b55d4692Sfgsch 
4*272a140bSkettenis    Copyright 1999, 2000, 2001, 2002, 2003, 2004. 2005, 2006, 2007, 2009
5*272a140bSkettenis    Free Software Foundation, Inc.
6b55d4692Sfgsch 
7b55d4692Sfgsch    This program is free software; you can redistribute it and/or modify
8b55d4692Sfgsch    it under the terms of the GNU General Public License as published by
9b55d4692Sfgsch    the Free Software Foundation; either version 2 of the License, or
10b55d4692Sfgsch    (at your option) any later version.
11b55d4692Sfgsch 
12b55d4692Sfgsch    This program is distributed in the hope that it will be useful,
13b55d4692Sfgsch    but WITHOUT ANY WARRANTY; without even the implied warranty of
14b55d4692Sfgsch    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15b55d4692Sfgsch    GNU General Public License for more details.
16b55d4692Sfgsch 
17b55d4692Sfgsch    You should have received a copy of the GNU General Public License
18b55d4692Sfgsch    along with this program; if not, write to the Free Software
19*272a140bSkettenis    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
202159047fSniklas 
21c88b1d6cSniklas #ifndef GNU_COFF_INTERNAL_H
22c88b1d6cSniklas #define GNU_COFF_INTERNAL_H 1
23c88b1d6cSniklas 
242159047fSniklas /* First, make "signed char" work, even on old compilers. */
252159047fSniklas #ifndef signed
262159047fSniklas #ifndef __STDC__
272159047fSniklas #define	signed			/**/
282159047fSniklas #endif
292159047fSniklas #endif
302159047fSniklas 
312159047fSniklas /********************** FILE HEADER **********************/
322159047fSniklas 
332159047fSniklas /* extra stuff in a PE header. */
342159047fSniklas 
352159047fSniklas struct internal_extra_pe_filehdr
362159047fSniklas {
372159047fSniklas   /* DOS header data follows for PE stuff */
382159047fSniklas   unsigned short e_magic;	/* Magic number, 0x5a4d */
392159047fSniklas   unsigned short e_cblp;	/* Bytes on last page of file, 0x90 */
402159047fSniklas   unsigned short e_cp;		/* Pages in file, 0x3 */
412159047fSniklas   unsigned short e_crlc;	/* Relocations, 0x0 */
422159047fSniklas   unsigned short e_cparhdr;	/* Size of header in paragraphs, 0x4 */
432159047fSniklas   unsigned short e_minalloc;	/* Minimum extra paragraphs needed, 0x0 */
442159047fSniklas   unsigned short e_maxalloc;	/* Maximum extra paragraphs needed, 0xFFFF */
452159047fSniklas   unsigned short e_ss;		/* Initial (relative) SS value, 0x0 */
462159047fSniklas   unsigned short e_sp;		/* Initial SP value, 0xb8 */
472159047fSniklas   unsigned short e_csum;	/* Checksum, 0x0 */
482159047fSniklas   unsigned short e_ip;		/* Initial IP value, 0x0 */
492159047fSniklas   unsigned short e_cs;		/* Initial (relative) CS value, 0x0 */
502159047fSniklas   unsigned short e_lfarlc;	/* File address of relocation table, 0x40 */
512159047fSniklas   unsigned short e_ovno;	/* Overlay number, 0x0 */
522159047fSniklas   unsigned short e_res[4];	/* Reserved words, all 0x0 */
532159047fSniklas   unsigned short e_oemid;	/* OEM identifier (for e_oeminfo), 0x0 */
542159047fSniklas   unsigned short e_oeminfo;	/* OEM information; e_oemid specific, 0x0 */
552159047fSniklas   unsigned short e_res2[10];	/* Reserved words, all 0x0 */
562159047fSniklas   bfd_vma  e_lfanew;		/* File address of new exe header, 0x80 */
572159047fSniklas   unsigned long dos_message[16]; /* text which always follows dos header */
582159047fSniklas   bfd_vma  nt_signature;   	/* required NT signature, 0x4550 */
592159047fSniklas };
602159047fSniklas 
61*272a140bSkettenis #define GO32_STUBSIZE 2048
62*272a140bSkettenis 
632159047fSniklas struct internal_filehdr
642159047fSniklas {
652159047fSniklas   struct internal_extra_pe_filehdr pe;
662159047fSniklas 
67*272a140bSkettenis   /* coff-stgo32 EXE stub header before BFD tdata has been allocated.
68*272a140bSkettenis      Its data is kept in INTERNAL_FILEHDR.GO32STUB afterwards.
69*272a140bSkettenis 
70*272a140bSkettenis      F_GO32STUB is set iff go32stub contains a valid data.  Artifical headers
71*272a140bSkettenis      created in BFD have no pre-set go32stub.  */
72*272a140bSkettenis   char go32stub[GO32_STUBSIZE];
73*272a140bSkettenis 
74c074d1c9Sdrahn   /* Standard coff internal info.  */
752159047fSniklas   unsigned short f_magic;	/* magic number			*/
762159047fSniklas   unsigned short f_nscns;	/* number of sections		*/
772159047fSniklas   long f_timdat;		/* time & date stamp		*/
782159047fSniklas   bfd_vma f_symptr;		/* file pointer to symtab	*/
792159047fSniklas   long f_nsyms;			/* number of symtab entries	*/
802159047fSniklas   unsigned short f_opthdr;	/* sizeof(optional hdr)		*/
812159047fSniklas   unsigned short f_flags;	/* flags			*/
82b55d4692Sfgsch   unsigned short f_target_id;	/* (TI COFF specific)		*/
832159047fSniklas };
842159047fSniklas 
852159047fSniklas 
862159047fSniklas /* Bits for f_flags:
87c074d1c9Sdrahn  	F_RELFLG	relocation info stripped from file
88c074d1c9Sdrahn  	F_EXEC		file is executable (no unresolved external references)
89c074d1c9Sdrahn  	F_LNNO		line numbers stripped from file
90c074d1c9Sdrahn  	F_LSYMS		local symbols stripped from file
91c074d1c9Sdrahn  	F_AR16WR	file is 16-bit little-endian
92c074d1c9Sdrahn  	F_AR32WR	file is 32-bit little-endian
93c074d1c9Sdrahn  	F_AR32W		file is 32-bit big-endian
94c074d1c9Sdrahn  	F_DYNLOAD	rs/6000 aix: dynamically loadable w/imports & exports
95c074d1c9Sdrahn  	F_SHROBJ	rs/6000 aix: file is a shared object
96*272a140bSkettenis 	F_DLL           PE format DLL
97*272a140bSkettenis 	F_GO32STUB      Field go32stub contains valid data.  */
982159047fSniklas 
992159047fSniklas #define	F_RELFLG	(0x0001)
1002159047fSniklas #define	F_EXEC		(0x0002)
1012159047fSniklas #define	F_LNNO		(0x0004)
1022159047fSniklas #define	F_LSYMS		(0x0008)
1032159047fSniklas #define	F_AR16WR	(0x0080)
1042159047fSniklas #define	F_AR32WR	(0x0100)
1052159047fSniklas #define	F_AR32W     	(0x0200)
1062159047fSniklas #define	F_DYNLOAD	(0x1000)
1072159047fSniklas #define	F_SHROBJ	(0x2000)
1082159047fSniklas #define F_DLL           (0x2000)
109*272a140bSkettenis #define F_GO32STUB      (0x4000)
1102159047fSniklas 
111c074d1c9Sdrahn /* Extra structure which is used in the optional header.  */
1122159047fSniklas typedef struct _IMAGE_DATA_DIRECTORY
1132159047fSniklas {
1142159047fSniklas   bfd_vma VirtualAddress;
1152159047fSniklas   long    Size;
1162159047fSniklas }  IMAGE_DATA_DIRECTORY;
117*272a140bSkettenis #define PE_EXPORT_TABLE			0
118*272a140bSkettenis #define PE_IMPORT_TABLE			1
119*272a140bSkettenis #define PE_RESOURCE_TABLE		2
120*272a140bSkettenis #define PE_EXCEPTION_TABLE		3
121*272a140bSkettenis #define PE_CERTIFICATE_TABLE		4
122*272a140bSkettenis #define PE_BASE_RELOCATION_TABLE	5
123*272a140bSkettenis #define PE_DEBUG_DATA			6
124*272a140bSkettenis #define PE_ARCHITECTURE			7
125*272a140bSkettenis #define PE_GLOBAL_PTR			8
126*272a140bSkettenis #define PE_TLS_TABLE			9
127*272a140bSkettenis #define PE_LOAD_CONFIG_TABLE		10
128*272a140bSkettenis #define PE_BOUND_IMPORT_TABLE		11
129*272a140bSkettenis #define PE_IMPORT_ADDRESS_TABLE		12
130*272a140bSkettenis #define PE_DELAY_IMPORT_DESCRIPTOR	13
131*272a140bSkettenis #define PE_CLR_RUNTIME_HEADER		14
132*272a140bSkettenis /* DataDirectory[15] is currently reserved, so no define. */
1332159047fSniklas #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES  16
1342159047fSniklas 
135b305b0f1Sespie /* Default image base for NT.  */
1362159047fSniklas #define NT_EXE_IMAGE_BASE 0x400000
1372159047fSniklas #define NT_DLL_IMAGE_BASE 0x10000000
1382159047fSniklas 
139b305b0f1Sespie /* Default image base for BeOS. */
140b305b0f1Sespie #define BEOS_EXE_IMAGE_BASE 0x80000000
141b305b0f1Sespie #define BEOS_DLL_IMAGE_BASE 0x10000000
142b305b0f1Sespie 
1432159047fSniklas /* Extra stuff in a PE aouthdr */
1442159047fSniklas 
1452159047fSniklas #define PE_DEF_SECTION_ALIGNMENT 0x1000
146b55d4692Sfgsch #ifndef PE_DEF_FILE_ALIGNMENT
1472159047fSniklas # define PE_DEF_FILE_ALIGNMENT 0x200
148b55d4692Sfgsch #endif
1492159047fSniklas 
1502159047fSniklas struct internal_extra_pe_aouthdr
1512159047fSniklas {
152*272a140bSkettenis   /* FIXME: The following entries are in AOUTHDR.  But they aren't
153*272a140bSkettenis      available internally in bfd.  We add them here so that objdump
154*272a140bSkettenis      can dump them.  */
155*272a140bSkettenis   /* The state of the image file  */
156*272a140bSkettenis   short Magic;
157*272a140bSkettenis   /* Linker major version number */
158*272a140bSkettenis   char MajorLinkerVersion;
159*272a140bSkettenis   /* Linker minor version number  */
160*272a140bSkettenis   char MinorLinkerVersion;
161*272a140bSkettenis   /* Total size of all code sections  */
162*272a140bSkettenis   long SizeOfCode;
163*272a140bSkettenis   /* Total size of all initialized data sections  */
164*272a140bSkettenis   long SizeOfInitializedData;
165*272a140bSkettenis   /* Total size of all uninitialized data sections  */
166*272a140bSkettenis   long SizeOfUninitializedData;
167*272a140bSkettenis   /* Address of entry point relative to image base.  */
168*272a140bSkettenis   bfd_vma AddressOfEntryPoint;
169*272a140bSkettenis   /* Address of the first code section relative to image base.  */
170*272a140bSkettenis   bfd_vma BaseOfCode;
171*272a140bSkettenis   /* Address of the first data section relative to image base.  */
172*272a140bSkettenis   bfd_vma BaseOfData;
173*272a140bSkettenis 
1742159047fSniklas   /* PE stuff  */
1752159047fSniklas   bfd_vma ImageBase;		/* address of specific location in memory that
1762159047fSniklas 				   file is located, NT default 0x10000 */
1772159047fSniklas 
1782159047fSniklas   bfd_vma SectionAlignment;	/* section alignment default 0x1000 */
1792159047fSniklas   bfd_vma FileAlignment;	/* file alignment default 0x200 */
1802159047fSniklas   short   MajorOperatingSystemVersion; /* minimum version of the operating */
1812159047fSniklas   short   MinorOperatingSystemVersion; /* system req'd for exe, default to 1*/
1822159047fSniklas   short   MajorImageVersion;	/* user defineable field to store version of */
1832159047fSniklas   short   MinorImageVersion;	/* exe or dll being created, default to 0 */
1842159047fSniklas   short   MajorSubsystemVersion; /* minimum subsystem version required to */
1852159047fSniklas   short   MinorSubsystemVersion; /* run exe; default to 3.1 */
1862159047fSniklas   long    Reserved1;		/* seems to be 0 */
1872159047fSniklas   long    SizeOfImage;		/* size of memory to allocate for prog */
1882159047fSniklas   long    SizeOfHeaders;	/* size of PE header and section table */
1892159047fSniklas   long    CheckSum;		/* set to 0 */
1902159047fSniklas   short   Subsystem;
1912159047fSniklas 
1922159047fSniklas   /* type of subsystem exe uses for user interface,
1932159047fSniklas      possible values:
1942159047fSniklas      1 - NATIVE   Doesn't require a subsystem
1952159047fSniklas      2 - WINDOWS_GUI runs in Windows GUI subsystem
1962159047fSniklas      3 - WINDOWS_CUI runs in Windows char sub. (console app)
1972159047fSniklas      5 - OS2_CUI runs in OS/2 character subsystem
1982159047fSniklas      7 - POSIX_CUI runs in Posix character subsystem */
199*272a140bSkettenis   unsigned short DllCharacteristics; /* flags for DLL init  */
2002159047fSniklas   bfd_vma SizeOfStackReserve;	/* amount of memory to reserve  */
2012159047fSniklas   bfd_vma SizeOfStackCommit;	/* amount of memory initially committed for
2022159047fSniklas 				   initial thread's stack, default is 0x1000 */
2032159047fSniklas   bfd_vma SizeOfHeapReserve;	/* amount of virtual memory to reserve and */
2042159047fSniklas   bfd_vma SizeOfHeapCommit;	/* commit, don't know what to defaut it to */
2052159047fSniklas   long    LoaderFlags;		/* can probably set to 0 */
2062159047fSniklas   long    NumberOfRvaAndSizes;	/* number of entries in next entry, 16 */
2072159047fSniklas   IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
2082159047fSniklas };
2092159047fSniklas 
2102159047fSniklas /********************** AOUT "OPTIONAL HEADER" **********************/
2112159047fSniklas struct internal_aouthdr
2122159047fSniklas {
2132159047fSniklas   short magic;			/* type of file				*/
2142159047fSniklas   short vstamp;			/* version stamp			*/
2152159047fSniklas   bfd_vma tsize;		/* text size in bytes, padded to FW bdry*/
2162159047fSniklas   bfd_vma dsize;		/* initialized data "  "		*/
2172159047fSniklas   bfd_vma bsize;		/* uninitialized data "   "		*/
2182159047fSniklas   bfd_vma entry;		/* entry pt.				*/
2192159047fSniklas   bfd_vma text_start;		/* base of text used for this file */
2202159047fSniklas   bfd_vma data_start;		/* base of data used for this file */
2212159047fSniklas 
2222159047fSniklas   /* i960 stuff */
2232159047fSniklas   unsigned long tagentries;	/* number of tag entries to follow */
2242159047fSniklas 
2252159047fSniklas   /* RS/6000 stuff */
226c074d1c9Sdrahn   bfd_vma o_toc;		/* address of TOC			*/
2272159047fSniklas   short o_snentry;		/* section number for entry point */
2282159047fSniklas   short o_sntext;		/* section number for text	*/
2292159047fSniklas   short o_sndata;		/* section number for data	*/
2302159047fSniklas   short o_sntoc;		/* section number for toc	*/
2312159047fSniklas   short o_snloader;		/* section number for loader section */
2322159047fSniklas   short o_snbss;		/* section number for bss	*/
2332159047fSniklas   short o_algntext;		/* max alignment for text	*/
2342159047fSniklas   short o_algndata;		/* max alignment for data	*/
2352159047fSniklas   short o_modtype;		/* Module type field, 1R,RE,RO	*/
2362159047fSniklas   short o_cputype;		/* Encoded CPU type		*/
237c074d1c9Sdrahn   bfd_vma o_maxstack;	/* max stack size allowed.	*/
238c074d1c9Sdrahn   bfd_vma o_maxdata;	/* max data size allowed.	*/
2392159047fSniklas 
2402159047fSniklas   /* ECOFF stuff */
2412159047fSniklas   bfd_vma bss_start;		/* Base of bss section.		*/
2422159047fSniklas   bfd_vma gp_value;		/* GP register value.		*/
2432159047fSniklas   unsigned long gprmask;	/* General registers used.	*/
2442159047fSniklas   unsigned long cprmask[4];	/* Coprocessor registers used.	*/
2452159047fSniklas   unsigned long fprmask;	/* Floating pointer registers used.  */
2462159047fSniklas 
2472159047fSniklas   /* Apollo stuff */
2482159047fSniklas   long o_inlib;			/* inlib data */
2492159047fSniklas   long o_sri;			/* Static Resource Information */
2502159047fSniklas   long vid[2];			/* Version id */
2512159047fSniklas 
2522159047fSniklas   struct internal_extra_pe_aouthdr pe;
2532159047fSniklas };
2542159047fSniklas 
2552159047fSniklas /********************** STORAGE CLASSES **********************/
2562159047fSniklas 
2572159047fSniklas /* This used to be defined as -1, but now n_sclass is unsigned.  */
2582159047fSniklas #define C_EFCN		0xff	/* physical end of function	*/
2592159047fSniklas #define C_NULL		0
2602159047fSniklas #define C_AUTO		1	/* automatic variable		*/
2612159047fSniklas #define C_EXT		2	/* external symbol		*/
2622159047fSniklas #define C_STAT		3	/* static			*/
2632159047fSniklas #define C_REG		4	/* register variable		*/
2642159047fSniklas #define C_EXTDEF	5	/* external definition		*/
2652159047fSniklas #define C_LABEL		6	/* label			*/
2662159047fSniklas #define C_ULABEL	7	/* undefined label		*/
2672159047fSniklas #define C_MOS		8	/* member of structure		*/
2682159047fSniklas #define C_ARG		9	/* function argument		*/
2692159047fSniklas #define C_STRTAG	10	/* structure tag		*/
2702159047fSniklas #define C_MOU		11	/* member of union		*/
2712159047fSniklas #define C_UNTAG		12	/* union tag			*/
2722159047fSniklas #define C_TPDEF		13	/* type definition		*/
2732159047fSniklas #define C_USTATIC	14	/* undefined static		*/
2742159047fSniklas #define C_ENTAG		15	/* enumeration tag		*/
2752159047fSniklas #define C_MOE		16	/* member of enumeration	*/
2762159047fSniklas #define C_REGPARM	17	/* register parameter		*/
2772159047fSniklas #define C_FIELD		18	/* bit field			*/
2782159047fSniklas #define C_AUTOARG	19	/* auto argument		*/
2792159047fSniklas #define C_LASTENT	20	/* dummy entry (end of block)	*/
2802159047fSniklas #define C_BLOCK		100	/* ".bb" or ".eb"		*/
2812159047fSniklas #define C_FCN		101	/* ".bf" or ".ef"		*/
2822159047fSniklas #define C_EOS		102	/* end of structure		*/
2832159047fSniklas #define C_FILE		103	/* file name			*/
2842159047fSniklas #define C_LINE		104	/* line # reformatted as symbol table entry */
2852159047fSniklas #define C_ALIAS	 	105	/* duplicate tag		*/
2862159047fSniklas #define C_HIDDEN	106	/* ext symbol in dmert public lib */
287007c2a45Smiod #define C_WEAKEXT	127	/* weak symbol -- GNU extension.  */
288b305b0f1Sespie 
289b55d4692Sfgsch /* New storage classes for TI COFF */
290b305b0f1Sespie #define C_UEXT		19	/* Tentative external definition */
291b305b0f1Sespie #define C_STATLAB	20	/* Static load time label */
292b305b0f1Sespie #define C_EXTLAB	21	/* External load time label */
293b305b0f1Sespie #define C_SYSTEM	23	/* System Wide variable */
294b305b0f1Sespie 
2952159047fSniklas /* New storage classes for WINDOWS_NT   */
2962159047fSniklas #define C_SECTION       104     /* section name */
2972159047fSniklas #define C_NT_WEAK	105	/* weak external */
2982159047fSniklas 
2992159047fSniklas  /* New storage classes for 80960 */
3002159047fSniklas 
3012159047fSniklas /* C_LEAFPROC is obsolete.  Use C_LEAFEXT or C_LEAFSTAT */
3022159047fSniklas #define C_LEAFPROC	108	/* Leaf procedure, "call" via BAL */
3032159047fSniklas 
3042159047fSniklas #define C_SCALL		107	/* Procedure reachable via system call */
3052159047fSniklas #define C_LEAFEXT       108	/* External leaf */
3062159047fSniklas #define C_LEAFSTAT      113	/* Static leaf */
3072159047fSniklas #define C_OPTVAR	109	/* Optimized variable		*/
3082159047fSniklas #define C_DEFINE	110	/* Preprocessor #define		*/
3092159047fSniklas #define C_PRAGMA	111	/* Advice to compiler or linker	*/
3102159047fSniklas #define C_SEGMENT	112	/* 80960 segment name		*/
3112159047fSniklas 
3122159047fSniklas   /* Storage classes for m88k */
3132159047fSniklas #define C_SHADOW        107     /* shadow symbol                */
3142159047fSniklas #define C_VERSION       108     /* coff version symbol          */
3152159047fSniklas 
3162159047fSniklas  /* New storage classes for RS/6000 */
3172159047fSniklas #define C_HIDEXT        107	/* Un-named external symbol */
3182159047fSniklas #define C_BINCL         108	/* Marks beginning of include file */
3192159047fSniklas #define C_EINCL         109	/* Marks ending of include file */
320*272a140bSkettenis #define C_AIX_WEAKEXT   111	/* AIX definition of C_WEAKEXT.  */
321*272a140bSkettenis 
322*272a140bSkettenis #if defined _AIX52 || defined AIX_WEAK_SUPPORT
323*272a140bSkettenis #undef C_WEAKEXT
324*272a140bSkettenis #define C_WEAKEXT       C_AIX_WEAKEXT
325*272a140bSkettenis #endif
3262159047fSniklas 
3272159047fSniklas  /* storage classes for stab symbols for RS/6000 */
3282159047fSniklas #define C_GSYM          (0x80)
3292159047fSniklas #define C_LSYM          (0x81)
3302159047fSniklas #define C_PSYM          (0x82)
3312159047fSniklas #define C_RSYM          (0x83)
3322159047fSniklas #define C_RPSYM         (0x84)
3332159047fSniklas #define C_STSYM         (0x85)
3342159047fSniklas #define C_TCSYM         (0x86)
3352159047fSniklas #define C_BCOMM         (0x87)
3362159047fSniklas #define C_ECOML         (0x88)
3372159047fSniklas #define C_ECOMM         (0x89)
3382159047fSniklas #define C_DECL          (0x8c)
3392159047fSniklas #define C_ENTRY         (0x8d)
3402159047fSniklas #define C_FUN           (0x8e)
3412159047fSniklas #define C_BSTAT         (0x8f)
3422159047fSniklas #define C_ESTAT         (0x90)
3432159047fSniklas 
344b305b0f1Sespie /* Storage classes for Thumb symbols */
345b305b0f1Sespie #define C_THUMBEXT      (128 + C_EXT)		/* 130 */
346b305b0f1Sespie #define C_THUMBSTAT     (128 + C_STAT)		/* 131 */
347b305b0f1Sespie #define C_THUMBLABEL    (128 + C_LABEL)		/* 134 */
348b305b0f1Sespie #define C_THUMBEXTFUNC  (C_THUMBEXT  + 20)	/* 150 */
349b305b0f1Sespie #define C_THUMBSTATFUNC (C_THUMBSTAT + 20)	/* 151 */
350b305b0f1Sespie 
351*272a140bSkettenis /* True if XCOFF symbols of class CLASS have auxillary csect information.  */
352*272a140bSkettenis #define CSECT_SYM_P(CLASS) \
353*272a140bSkettenis   ((CLASS) == C_EXT || (CLASS) == C_AIX_WEAKEXT || (CLASS) == C_HIDEXT)
354*272a140bSkettenis 
3552159047fSniklas /********************** SECTION HEADER **********************/
356c88b1d6cSniklas 
357c88b1d6cSniklas #define SCNNMLEN (8)
358c88b1d6cSniklas 
3592159047fSniklas struct internal_scnhdr
3602159047fSniklas {
361c88b1d6cSniklas   char s_name[SCNNMLEN];	/* section name			*/
3620c6d0228Sniklas 
3630c6d0228Sniklas   /* Physical address, aliased s_nlib.
3640c6d0228Sniklas      In the pei format, this field is the virtual section size
3650c6d0228Sniklas      (the size of the section after being loaded int memory),
3660c6d0228Sniklas      NOT the physical address.  */
3670c6d0228Sniklas   bfd_vma s_paddr;
3680c6d0228Sniklas 
3692159047fSniklas   bfd_vma s_vaddr;		/* virtual address		*/
3702159047fSniklas   bfd_vma s_size;		/* section size			*/
3712159047fSniklas   bfd_vma s_scnptr;		/* file ptr to raw data for section */
3722159047fSniklas   bfd_vma s_relptr;		/* file ptr to relocation	*/
3732159047fSniklas   bfd_vma s_lnnoptr;		/* file ptr to line numbers	*/
3742159047fSniklas   unsigned long s_nreloc;	/* number of relocation entries	*/
3752159047fSniklas   unsigned long s_nlnno;	/* number of line number entries*/
3762159047fSniklas   long s_flags;			/* flags			*/
3772159047fSniklas   long s_align;			/* used on I960			*/
378b55d4692Sfgsch   unsigned char s_page;         /* TI COFF load page            */
3792159047fSniklas };
3802159047fSniklas 
381c074d1c9Sdrahn /* s_flags "type".  */
3822159047fSniklas #define STYP_REG	 (0x0000)	/* "regular": allocated, relocated, loaded */
3832159047fSniklas #define STYP_DSECT	 (0x0001)	/* "dummy":  relocated only*/
3842159047fSniklas #define STYP_NOLOAD	 (0x0002)	/* "noload": allocated, relocated, not loaded */
3852159047fSniklas #define STYP_GROUP	 (0x0004)	/* "grouped": formed of input sections */
3862159047fSniklas #define STYP_PAD	 (0x0008)	/* "padding": not allocated, not relocated, loaded */
3872159047fSniklas #define STYP_COPY	 (0x0010)	/* "copy": for decision function used by field update;  not allocated, not relocated,
3882159047fSniklas 									     loaded; reloc & lineno entries processed normally */
3892159047fSniklas #define STYP_TEXT	 (0x0020)	/* section contains text only */
3902159047fSniklas #define S_SHRSEG	 (0x0020)	/* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
3912159047fSniklas 									     will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
3922159047fSniklas 									     update all process invocations. */
3932159047fSniklas #define STYP_DATA	 (0x0040)	/* section contains data only */
3942159047fSniklas #define STYP_BSS	 (0x0080)	/* section contains bss only */
3952159047fSniklas #define S_NEWFCN	 (0x0100)	/* In a minimal file or an update file, a new function (as compared with a replaced function) */
3962159047fSniklas #define STYP_INFO	 (0x0200)	/* comment: not allocated not relocated, not loaded */
3972159047fSniklas #define STYP_OVER	 (0x0400)	/* overlay: relocated not allocated or loaded */
3982159047fSniklas #define STYP_LIB	 (0x0800)	/* for .lib: same as INFO */
3992159047fSniklas #define STYP_MERGE	 (0x2000)	/* merge section -- combines with text, data or bss sections only */
400c074d1c9Sdrahn #define STYP_REVERSE_PAD (0x4000)	/* section will be padded with no-op instructions
401c074d1c9Sdrahn 					   wherever padding is necessary and there is a
402c074d1c9Sdrahn 					   word of contiguous bytes beginning on a word
403c074d1c9Sdrahn 					   boundary. */
4042159047fSniklas 
4052159047fSniklas #define STYP_LIT	0x8020	/* Literal data (like STYP_TEXT) */
4062159047fSniklas 
4072159047fSniklas 
4082159047fSniklas /********************** LINE NUMBERS **********************/
4092159047fSniklas 
4102159047fSniklas /* 1 line number entry for every "breakpointable" source line in a section.
411c074d1c9Sdrahn    Line numbers are grouped on a per function basis; first entry in a function
412c074d1c9Sdrahn    grouping will have l_lnno = 0 and in place of physical address will be the
413c074d1c9Sdrahn    symbol table index of the function name.  */
4142159047fSniklas 
4152159047fSniklas struct internal_lineno
4162159047fSniklas {
4172159047fSniklas   union
4182159047fSniklas   {
419c074d1c9Sdrahn     bfd_signed_vma l_symndx;		/* function name symbol index, iff l_lnno == 0*/
420c074d1c9Sdrahn     bfd_signed_vma l_paddr;		/* (physical) address of line number	*/
4212159047fSniklas   }     l_addr;
4222159047fSniklas   unsigned long l_lnno;		/* line number		*/
4232159047fSniklas };
4242159047fSniklas 
4252159047fSniklas /********************** SYMBOLS **********************/
4262159047fSniklas 
4272159047fSniklas #define SYMNMLEN	8	/* # characters in a symbol name	*/
4282159047fSniklas #define FILNMLEN	14	/* # characters in a file name		*/
4292159047fSniklas #define DIMNUM		4	/* # array dimensions in auxiliary entry */
4302159047fSniklas 
4312159047fSniklas struct internal_syment
4322159047fSniklas {
4332159047fSniklas   union
4342159047fSniklas   {
4352159047fSniklas     char _n_name[SYMNMLEN];	/* old COFF version		*/
4362159047fSniklas     struct
4372159047fSniklas     {
4382159047fSniklas       long _n_zeroes;		/* new == 0			*/
4392159047fSniklas       long _n_offset;		/* offset into string table	*/
4402159047fSniklas     }      _n_n;
4412159047fSniklas     char *_n_nptr[2];		/* allows for overlaying	*/
4422159047fSniklas   }     _n;
443c074d1c9Sdrahn   bfd_vma n_value;		/* value of symbol		*/
4442159047fSniklas   short n_scnum;		/* section number		*/
4452159047fSniklas   unsigned short n_flags;	/* copy of flags from filhdr	*/
4462159047fSniklas   unsigned short n_type;	/* type and derived type	*/
4472159047fSniklas   unsigned char n_sclass;	/* storage class		*/
4482159047fSniklas   unsigned char n_numaux;	/* number of aux. entries	*/
4492159047fSniklas };
4502159047fSniklas 
4512159047fSniklas #define n_name		_n._n_name
4522159047fSniklas #define n_zeroes	_n._n_n._n_zeroes
4532159047fSniklas #define n_offset	_n._n_n._n_offset
4542159047fSniklas 
4552159047fSniklas /* Relocatable symbols have number of the section in which they are defined,
4562159047fSniklas    or one of the following:  */
4572159047fSniklas 
4582159047fSniklas #define N_UNDEF	((short)0)	/* undefined symbol */
4592159047fSniklas #define N_ABS	((short)-1)	/* value of symbol is absolute */
4602159047fSniklas #define N_DEBUG	((short)-2)	/* debugging symbol -- value is meaningless */
4612159047fSniklas #define N_TV	((short)-3)	/* indicates symbol needs preload transfer vector */
4622159047fSniklas #define P_TV	((short)-4)	/* indicates symbol needs postload transfer vector*/
4632159047fSniklas 
464c074d1c9Sdrahn /* Type of a symbol, in low N bits of the word.  */
465c074d1c9Sdrahn 
4662159047fSniklas #define T_NULL		0
4672159047fSniklas #define T_VOID		1	/* function argument (only used by compiler) */
4682159047fSniklas #define T_CHAR		2	/* character		*/
4692159047fSniklas #define T_SHORT		3	/* short integer	*/
4702159047fSniklas #define T_INT		4	/* integer		*/
4712159047fSniklas #define T_LONG		5	/* long integer		*/
4722159047fSniklas #define T_FLOAT		6	/* floating point	*/
4732159047fSniklas #define T_DOUBLE	7	/* double word		*/
4742159047fSniklas #define T_STRUCT	8	/* structure 		*/
4752159047fSniklas #define T_UNION		9	/* union 		*/
4762159047fSniklas #define T_ENUM		10	/* enumeration 		*/
4772159047fSniklas #define T_MOE		11	/* member of enumeration*/
4782159047fSniklas #define T_UCHAR		12	/* unsigned character	*/
4792159047fSniklas #define T_USHORT	13	/* unsigned short	*/
4802159047fSniklas #define T_UINT		14	/* unsigned integer	*/
4812159047fSniklas #define T_ULONG		15	/* unsigned long	*/
4822159047fSniklas #define T_LNGDBL	16	/* long double		*/
4832159047fSniklas 
484c074d1c9Sdrahn /* Derived types, in n_type.  */
485c074d1c9Sdrahn 
4862159047fSniklas #define DT_NON		(0)	/* no derived type */
4872159047fSniklas #define DT_PTR		(1)	/* pointer */
4882159047fSniklas #define DT_FCN		(2)	/* function */
4892159047fSniklas #define DT_ARY		(3)	/* array */
4902159047fSniklas 
4912159047fSniklas #define BTYPE(x)	((x) & N_BTMASK)
492b305b0f1Sespie #define DTYPE(x)	(((x) & N_TMASK) >> N_BTSHFT)
4932159047fSniklas 
494b305b0f1Sespie #define ISPTR(x) \
495b305b0f1Sespie   (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_PTR << N_BTSHFT))
496b305b0f1Sespie #define ISFCN(x) \
497b305b0f1Sespie   (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_FCN << N_BTSHFT))
498b305b0f1Sespie #define ISARY(x) \
499b305b0f1Sespie   (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_ARY << N_BTSHFT))
500b305b0f1Sespie #define ISTAG(x) \
501b305b0f1Sespie   ((x) == C_STRTAG || (x) == C_UNTAG || (x) == C_ENTAG)
502b305b0f1Sespie #define DECREF(x) \
503b305b0f1Sespie   ((((x) >> N_TSHIFT) & ~ N_BTMASK) | ((x) & N_BTMASK))
5042159047fSniklas 
5052159047fSniklas union internal_auxent
5062159047fSniklas {
5072159047fSniklas   struct
5082159047fSniklas   {
5092159047fSniklas 
5102159047fSniklas     union
5112159047fSniklas     {
5122159047fSniklas       long l;			/* str, un, or enum tag indx */
5132159047fSniklas       struct coff_ptr_struct *p;
5142159047fSniklas     }     x_tagndx;
5152159047fSniklas 
5162159047fSniklas     union
5172159047fSniklas     {
5182159047fSniklas       struct
5192159047fSniklas       {
5202159047fSniklas 	unsigned short x_lnno;	/* declaration line number */
5212159047fSniklas 	unsigned short x_size;	/* str/union/array size */
5222159047fSniklas       }      x_lnsz;
5232159047fSniklas       long x_fsize;		/* size of function */
5242159047fSniklas     }     x_misc;
5252159047fSniklas 
5262159047fSniklas     union
5272159047fSniklas     {
5282159047fSniklas       struct
5292159047fSniklas       {				/* if ISFCN, tag, or .bb */
530c074d1c9Sdrahn 	bfd_signed_vma x_lnnoptr;		/* ptr to fcn line # */
5312159047fSniklas 	union
5322159047fSniklas 	{			/* entry ndx past block end */
5332159047fSniklas 	  long l;
5342159047fSniklas 	  struct coff_ptr_struct *p;
5352159047fSniklas 	}     x_endndx;
5362159047fSniklas       }      x_fcn;
5372159047fSniklas 
5382159047fSniklas       struct
5392159047fSniklas       {				/* if ISARY, up to 4 dimen. */
5402159047fSniklas 	unsigned short x_dimen[DIMNUM];
5412159047fSniklas       }      x_ary;
5422159047fSniklas     }     x_fcnary;
5432159047fSniklas 
5442159047fSniklas     unsigned short x_tvndx;	/* tv index */
5452159047fSniklas   }      x_sym;
5462159047fSniklas 
5472159047fSniklas   union
5482159047fSniklas   {
5492159047fSniklas     char x_fname[FILNMLEN];
5502159047fSniklas     struct
5512159047fSniklas     {
5522159047fSniklas       long x_zeroes;
5532159047fSniklas       long x_offset;
5542159047fSniklas     }      x_n;
5552159047fSniklas   }     x_file;
5562159047fSniklas 
5572159047fSniklas   struct
5582159047fSniklas   {
5592159047fSniklas     long x_scnlen;		/* section length */
5602159047fSniklas     unsigned short x_nreloc;	/* # relocation entries */
5612159047fSniklas     unsigned short x_nlinno;	/* # line numbers */
562c88b1d6cSniklas     unsigned long x_checksum;	/* section COMDAT checksum for PE */
563c88b1d6cSniklas     unsigned short x_associated; /* COMDAT associated section index for PE */
564c88b1d6cSniklas     unsigned char x_comdat;	/* COMDAT selection number for PE */
5652159047fSniklas   }      x_scn;
5662159047fSniklas 
5672159047fSniklas   struct
5682159047fSniklas   {
5692159047fSniklas     long x_tvfill;		/* tv fill value */
5702159047fSniklas     unsigned short x_tvlen;	/* length of .tv */
5712159047fSniklas     unsigned short x_tvran[2];	/* tv range */
5722159047fSniklas   }      x_tv;			/* info about .tv section (in auxent of symbol .tv)) */
5732159047fSniklas 
5742159047fSniklas   /******************************************
5752159047fSniklas    * RS/6000-specific auxent - last auxent for every external symbol
5762159047fSniklas    ******************************************/
5772159047fSniklas   struct
5782159047fSniklas   {
5792159047fSniklas     union
5802159047fSniklas       {				/* csect length or enclosing csect */
581c074d1c9Sdrahn 	bfd_signed_vma l;
5822159047fSniklas 	struct coff_ptr_struct *p;
5832159047fSniklas       } x_scnlen;
5842159047fSniklas     long x_parmhash;		/* parm type hash index */
5852159047fSniklas     unsigned short x_snhash;	/* sect num with parm hash */
5862159047fSniklas     unsigned char x_smtyp;	/* symbol align and type */
5872159047fSniklas     /* 0-4 - Log 2 of alignment */
5882159047fSniklas     /* 5-7 - symbol type */
5892159047fSniklas     unsigned char x_smclas;	/* storage mapping class */
5902159047fSniklas     long x_stab;		/* dbx stab info index */
5912159047fSniklas     unsigned short x_snstab;	/* sect num with dbx stab */
5922159047fSniklas   }      x_csect;		/* csect definition information */
5932159047fSniklas 
5942159047fSniklas /* x_smtyp values:  */
5952159047fSniklas 
5962159047fSniklas #define	SMTYP_ALIGN(x)	((x) >> 3)	/* log2 of alignment */
5972159047fSniklas #define	SMTYP_SMTYP(x)	((x) & 0x7)	/* symbol type */
5982159047fSniklas /* Symbol type values:  */
5992159047fSniklas #define	XTY_ER	0		/* External reference */
6002159047fSniklas #define	XTY_SD	1		/* Csect definition */
6012159047fSniklas #define	XTY_LD	2		/* Label definition */
6022159047fSniklas #define XTY_CM	3		/* .BSS */
6032159047fSniklas #define	XTY_EM	4		/* Error message */
6042159047fSniklas #define	XTY_US	5		/* "Reserved for internal use" */
6052159047fSniklas 
6062159047fSniklas /* x_smclas values:  */
6072159047fSniklas 
6082159047fSniklas #define	XMC_PR	0		/* Read-only program code */
6092159047fSniklas #define	XMC_RO	1		/* Read-only constant */
6102159047fSniklas #define	XMC_DB	2		/* Read-only debug dictionary table */
6112159047fSniklas #define	XMC_TC	3		/* Read-write general TOC entry */
6122159047fSniklas #define	XMC_UA	4		/* Read-write unclassified */
6132159047fSniklas #define	XMC_RW	5		/* Read-write data */
6142159047fSniklas #define	XMC_GL	6		/* Read-only global linkage */
6152159047fSniklas #define	XMC_XO	7		/* Read-only extended operation */
6162159047fSniklas #define	XMC_SV	8		/* Read-only supervisor call */
6172159047fSniklas #define	XMC_BS	9		/* Read-write BSS */
6182159047fSniklas #define	XMC_DS	10		/* Read-write descriptor csect */
6192159047fSniklas #define	XMC_UC	11		/* Read-write unnamed Fortran common */
6202159047fSniklas #define	XMC_TI	12		/* Read-only traceback index csect */
6212159047fSniklas #define	XMC_TB	13		/* Read-only traceback table csect */
6222159047fSniklas /* 		14	??? */
6232159047fSniklas #define	XMC_TC0	15		/* Read-write TOC anchor */
6242159047fSniklas #define XMC_TD	16		/* Read-write data in TOC */
6252159047fSniklas 
6262159047fSniklas   /******************************************
6272159047fSniklas    *  I960-specific *2nd* aux. entry formats
6282159047fSniklas    ******************************************/
6292159047fSniklas   struct
6302159047fSniklas   {
6312159047fSniklas     /* This is a very old typo that keeps getting propagated. */
6322159047fSniklas #define x_stdindx x_stindx
6332159047fSniklas     long x_stindx;		/* sys. table entry */
6342159047fSniklas   }      x_sc;			/* system call entry */
6352159047fSniklas 
6362159047fSniklas   struct
6372159047fSniklas   {
6382159047fSniklas     unsigned long x_balntry;	/* BAL entry point */
6392159047fSniklas   }      x_bal;			/* BAL-callable function */
6402159047fSniklas 
6412159047fSniklas   struct
6422159047fSniklas   {
6432159047fSniklas     unsigned long x_timestamp;	/* time stamp */
6442159047fSniklas     char x_idstring[20];	/* producer identity string */
6452159047fSniklas   }      x_ident;		/* Producer ident info */
6462159047fSniklas 
6472159047fSniklas };
6482159047fSniklas 
6492159047fSniklas /********************** RELOCATION DIRECTIVES **********************/
6502159047fSniklas 
6512159047fSniklas struct internal_reloc
6522159047fSniklas {
6532159047fSniklas   bfd_vma r_vaddr;		/* Virtual address of reference */
6542159047fSniklas   long r_symndx;		/* Index into symbol table	*/
6552159047fSniklas   unsigned short r_type;	/* Relocation type		*/
6562159047fSniklas   unsigned char r_size;		/* Used by RS/6000 and ECOFF	*/
6572159047fSniklas   unsigned char r_extern;	/* Used by ECOFF		*/
6582159047fSniklas   unsigned long r_offset;	/* Used by Alpha ECOFF, SPARC, others */
6592159047fSniklas };
6602159047fSniklas 
661*272a140bSkettenis /* X86-64 relocations.  */
662*272a140bSkettenis #define R_AMD64_ABS 		 0 /* Reference is absolute, no relocation is necessary.  */
663*272a140bSkettenis #define R_AMD64_DIR64		 1 /* 64-bit address (VA).  */
664*272a140bSkettenis #define R_AMD64_DIR32		 2 /* 32-bit address (VA) R_DIR32.  */
665*272a140bSkettenis #define R_AMD64_IMAGEBASE	 3 /* 32-bit absolute ref w/o base R_IMAGEBASE.  */
666*272a140bSkettenis #define R_AMD64_PCRLONG		 4 /* 32-bit relative address from byte following reloc R_PCRLONG.  */
667*272a140bSkettenis #define R_AMD64_PCRLONG_1	 5 /* 32-bit relative address from byte distance 1 from reloc.  */
668*272a140bSkettenis #define R_AMD64_PCRLONG_2	 6 /* 32-bit relative address from byte distance 2 from reloc.  */
669*272a140bSkettenis #define R_AMD64_PCRLONG_3	 7 /* 32-bit relative address from byte distance 3 from reloc.  */
670*272a140bSkettenis #define R_AMD64_PCRLONG_4	 8 /* 32-bit relative address from byte distance 4 from reloc.  */
671*272a140bSkettenis #define R_AMD64_PCRLONG_5	 9 /* 32-bit relative address from byte distance 5 from reloc.  */
672*272a140bSkettenis #define R_AMD64_SECTION		10 /* Section index.  */
673*272a140bSkettenis #define R_AMD64_SECREL		11 /* 32 bit offset from base of section containing target R_SECREL.  */
674*272a140bSkettenis #define R_AMD64_SECREL7		12 /* 7 bit unsigned offset from base of section containing target.  */
675*272a140bSkettenis #define R_AMD64_TOKEN		13 /* 32 bit metadata token.  */
676*272a140bSkettenis #define R_AMD64_PCRQUAD		14 /* Pseude PC64 relocation - Note: not specified by MS/AMD but need for gas pc-relative 64bit wide relocation generated by ELF.  */
677*272a140bSkettenis 
678*272a140bSkettenis /* i386 Relocations.  */
679*272a140bSkettenis 
680b305b0f1Sespie #define R_DIR16 	 1
681c074d1c9Sdrahn #define R_REL24          5
682b305b0f1Sespie #define R_DIR32 	 6
683b305b0f1Sespie #define R_IMAGEBASE	 7
684*272a140bSkettenis #define R_SECREL32	11
685b305b0f1Sespie #define R_RELBYTE	15
686b305b0f1Sespie #define R_RELWORD	16
687b305b0f1Sespie #define R_RELLONG	17
688b305b0f1Sespie #define R_PCRBYTE	18
689b305b0f1Sespie #define R_PCRWORD	19
690b305b0f1Sespie #define R_PCRLONG	20
691c074d1c9Sdrahn #define R_PCR24         21
692b305b0f1Sespie #define R_IPRSHORT	24
693b305b0f1Sespie #define R_IPRLONG	26
694b305b0f1Sespie #define R_GETSEG	29
695b305b0f1Sespie #define R_GETPA 	30
696b305b0f1Sespie #define R_TAGWORD	31
697b305b0f1Sespie #define R_JUMPTARG	32	/* strange 29k 00xx00xx reloc */
698c074d1c9Sdrahn #define R_PARTLS16      32
699c074d1c9Sdrahn #define R_PARTMS8       33
7002159047fSniklas 
7012159047fSniklas #define R_PCR16L       128
7022159047fSniklas #define R_PCR26L       129
7032159047fSniklas #define R_VRT16        130
7042159047fSniklas #define R_HVRT16       131
7052159047fSniklas #define R_LVRT16       132
7062159047fSniklas #define R_VRT32        133
7072159047fSniklas 
7082159047fSniklas 
709c88b1d6cSniklas /* This reloc identifies mov.b instructions with a 16bit absolute
710c88b1d6cSniklas    address.  The linker tries to turn insns with this reloc into
711c88b1d6cSniklas    an absolute 8-bit address.  */
712c88b1d6cSniklas #define R_MOV16B1    	0x41
713c88b1d6cSniklas 
714c88b1d6cSniklas /* This reloc identifies mov.b instructions which had a 16bit
715c88b1d6cSniklas    absolute address which have been shortened into a 8-bit
716c88b1d6cSniklas    absolute address.  */
717c88b1d6cSniklas #define R_MOV16B2 	0x42
718c88b1d6cSniklas 
719c88b1d6cSniklas /* This reloc identifies jmp insns with a 16bit target address;
720c88b1d6cSniklas    the linker tries to turn these insns into bra insns with
721c88b1d6cSniklas    an 8bit pc-relative target.  */
722c88b1d6cSniklas #define R_JMP1     	0x43
723c88b1d6cSniklas 
724c88b1d6cSniklas /* This reloc identifies a bra with an 8-bit pc-relative
725c074d1c9Sdrahn    target that was formerly a jmp insn with a 16bit target.  */
726c88b1d6cSniklas #define R_JMP2 		0x44
727c88b1d6cSniklas 
728c88b1d6cSniklas /* ??? */
7292159047fSniklas #define R_RELLONG_NEG  	0x45
7302159047fSniklas 
731c88b1d6cSniklas /* This reloc identifies jmp insns with a 24bit target address;
732c88b1d6cSniklas    the linker tries to turn these insns into bra insns with
733c88b1d6cSniklas    an 8bit pc-relative target.  */
734c88b1d6cSniklas #define R_JMPL1     	0x46
7352159047fSniklas 
736c88b1d6cSniklas /* This reloc identifies a bra with an 8-bit pc-relative
737c074d1c9Sdrahn    target that was formerly a jmp insn with a 24bit target.  */
738c88b1d6cSniklas #define R_JMPL2		0x47
739c88b1d6cSniklas 
740c88b1d6cSniklas /* This reloc identifies mov.b instructions with a 24bit absolute
741c88b1d6cSniklas    address.  The linker tries to turn insns with this reloc into
742c88b1d6cSniklas    an absolute 8-bit address.  */
743c88b1d6cSniklas 
744c88b1d6cSniklas #define R_MOV24B1    	0x48
745c88b1d6cSniklas 
746c88b1d6cSniklas /* This reloc identifies mov.b instructions which had a 24bit
747c88b1d6cSniklas    absolute address which have been shortened into a 8-bit
748c88b1d6cSniklas    absolute address.  */
749c88b1d6cSniklas #define R_MOV24B2 	0x49
750c88b1d6cSniklas 
751c88b1d6cSniklas /* An h8300 memory indirect jump/call.  Forces the address of the jump/call
752c88b1d6cSniklas    target into the function vector (in page zero), and the address of the
753c88b1d6cSniklas    vector entry to be placed in the jump/call instruction.  */
754c88b1d6cSniklas #define R_MEM_INDIRECT	0x4a
755c88b1d6cSniklas 
756c88b1d6cSniklas /* This reloc identifies a 16bit pc-relative branch target which was
757c88b1d6cSniklas    shortened into an 8bit pc-relative branch target.  */
758c88b1d6cSniklas #define R_PCRWORD_B	0x4b
759c88b1d6cSniklas 
760c88b1d6cSniklas /* This reloc identifies mov.[wl] instructions with a 32/24 bit
761c88b1d6cSniklas    absolute address; the linker may turn this into a mov.[wl]
762c88b1d6cSniklas    insn with a 16bit absolute address.  */
763c88b1d6cSniklas #define R_MOVL1    	0x4c
764c88b1d6cSniklas 
765c074d1c9Sdrahn /* This reloc identifies mov.[wl] insns which formerly had
766b305b0f1Sespie    a 32/24bit absolute address and now have a 16bit absolute address.  */
767c88b1d6cSniklas #define R_MOVL2 	0x4d
7682159047fSniklas 
7690c6d0228Sniklas /* This reloc identifies a bCC:8 which will have it's condition
7700c6d0228Sniklas    inverted and its target redirected to the target of the branch
7710c6d0228Sniklas    in the following insn.  */
7720c6d0228Sniklas #define R_BCC_INV	0x4e
7730c6d0228Sniklas 
7740c6d0228Sniklas /* This reloc identifies a jmp instruction that has been deleted.  */
7750c6d0228Sniklas #define R_JMP_DEL	0x4f
7760c6d0228Sniklas 
7772159047fSniklas /* Z8k modes */
7782159047fSniklas #define R_IMM16   0x01		/* 16 bit abs */
7792159047fSniklas #define R_JR	  0x02		/* jr  8 bit disp */
7802159047fSniklas #define R_IMM4L   0x23		/* low nibble */
7812159047fSniklas #define R_IMM8    0x22		/* 8 bit abs */
7822159047fSniklas #define R_IMM32   R_RELLONG	/* 32 bit abs */
7832159047fSniklas #define R_CALL    R_DA		/* Absolute address which could be a callr */
7842159047fSniklas #define R_JP	  R_DA		/* Absolute address which could be a jp */
7852159047fSniklas #define R_REL16   0x04		/* 16 bit PC rel */
7862159047fSniklas #define R_CALLR	  0x05		/* callr 12 bit disp */
7872159047fSniklas #define R_SEG     0x10		/* set if in segmented mode */
7882159047fSniklas #define R_IMM4H   0x24		/* high nibble */
7892159047fSniklas #define R_DISP7   0x25          /* djnz displacement */
7902159047fSniklas 
791*272a140bSkettenis /* Z80 modes */
792*272a140bSkettenis #define R_OFF8    0x32		/* 8 bit signed abs, for (i[xy]+d) */
793*272a140bSkettenis #define R_IMM24   0x33          /* 24 bit abs */
794*272a140bSkettenis /* R_JR, R_IMM8, R_IMM16, R_IMM32 - as for Z8k */
795*272a140bSkettenis 
7962159047fSniklas /* H8500 modes */
7972159047fSniklas 
7982159047fSniklas #define R_H8500_IMM8  	1		/*  8 bit immediate 	*/
7992159047fSniklas #define R_H8500_IMM16 	2		/* 16 bit immediate	*/
8002159047fSniklas #define R_H8500_PCREL8 	3		/*  8 bit pcrel 	*/
8012159047fSniklas #define R_H8500_PCREL16 4		/* 16 bit pcrel 	*/
8022159047fSniklas #define R_H8500_HIGH8  	5		/* high 8 bits of 24 bit address */
8032159047fSniklas #define R_H8500_LOW16 	7		/* low 16 bits of 24 bit immediate */
8042159047fSniklas #define R_H8500_IMM24	6		/* 24 bit immediate */
8052159047fSniklas #define R_H8500_IMM32   8               /* 32 bit immediate */
8062159047fSniklas #define R_H8500_HIGH16  9		/* high 16 bits of 32 bit immediate */
8072159047fSniklas 
8082159047fSniklas /* W65 modes */
8092159047fSniklas 
8102159047fSniklas #define R_W65_ABS8	1  /* addr & 0xff 		*/
8112159047fSniklas #define R_W65_ABS16	2  /* addr & 0xffff 		*/
8122159047fSniklas #define R_W65_ABS24	3  /* addr & 0xffffff 		*/
8132159047fSniklas 
8142159047fSniklas #define R_W65_ABS8S8    4  /* (addr >> 8) & 0xff 	*/
8152159047fSniklas #define R_W65_ABS8S16   5  /* (addr >> 16) & 0xff 	*/
8162159047fSniklas 
8172159047fSniklas #define R_W65_ABS16S8   6  /* (addr >> 8) & 0ffff 	*/
8182159047fSniklas #define R_W65_ABS16S16  7  /* (addr >> 16) & 0ffff 	*/
8192159047fSniklas 
8202159047fSniklas #define R_W65_PCR8	8
8212159047fSniklas #define R_W65_PCR16	9
8222159047fSniklas 
8232159047fSniklas #define R_W65_DP       10  /* direct page 8 bits only   */
8242159047fSniklas 
825c88b1d6cSniklas #endif /* GNU_COFF_INTERNAL_H */
826