xref: /openbsd/gnu/usr.bin/binutils/include/coff/i960.h (revision b55d4692)
1*b55d4692Sfgsch /* coff information for 80960.  Origins: Intel corp, natch.
2*b55d4692Sfgsch 
3*b55d4692Sfgsch    Copyright 2001 Free Software Foundation, Inc.
4*b55d4692Sfgsch 
5*b55d4692Sfgsch    This program is free software; you can redistribute it and/or modify
6*b55d4692Sfgsch    it under the terms of the GNU General Public License as published by
7*b55d4692Sfgsch    the Free Software Foundation; either version 2 of the License, or
8*b55d4692Sfgsch    (at your option) any later version.
9*b55d4692Sfgsch 
10*b55d4692Sfgsch    This program is distributed in the hope that it will be useful,
11*b55d4692Sfgsch    but WITHOUT ANY WARRANTY; without even the implied warranty of
12*b55d4692Sfgsch    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*b55d4692Sfgsch    GNU General Public License for more details.
14*b55d4692Sfgsch 
15*b55d4692Sfgsch    You should have received a copy of the GNU General Public License
16*b55d4692Sfgsch    along with this program; if not, write to the Free Software
17*b55d4692Sfgsch    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
182159047fSniklas 
192159047fSniklas /* NOTE: Tagentries (cf TAGBITS) are no longer used by the 960 */
202159047fSniklas 
212159047fSniklas /********************** FILE HEADER **********************/
222159047fSniklas 
232159047fSniklas struct external_filehdr {
242159047fSniklas 	char f_magic[2];	/* magic number			*/
252159047fSniklas 	char f_nscns[2];	/* number of sections		*/
262159047fSniklas 	char f_timdat[4];	/* time & date stamp		*/
272159047fSniklas 	char f_symptr[4];	/* file pointer to symtab	*/
282159047fSniklas 	char f_nsyms[4];	/* number of symtab entries	*/
292159047fSniklas 	char f_opthdr[2];	/* sizeof(optional hdr)		*/
302159047fSniklas 	char f_flags[2];	/* flags			*/
312159047fSniklas };
322159047fSniklas 
332159047fSniklas #define OMAGIC      (0407)	/* old impure format. data immediately
342159047fSniklas                                    follows text. both sections are rw. */
352159047fSniklas #define NMAGIC      (0410)	/* split i&d, read-only text */
362159047fSniklas 
372159047fSniklas /*
382159047fSniklas *	Intel 80960 (I960) processor flags.
392159047fSniklas *	F_I960TYPE == mask for processor type field.
402159047fSniklas */
412159047fSniklas 
422159047fSniklas #define	F_I960TYPE	(0xf000)
432159047fSniklas #define	F_I960CORE	(0x1000)
442159047fSniklas #define	F_I960KB	(0x2000)
452159047fSniklas #define	F_I960SB	(0x2000)
462159047fSniklas #define	F_I960MC	(0x3000)
472159047fSniklas #define	F_I960XA	(0x4000)
482159047fSniklas #define	F_I960CA	(0x5000)
492159047fSniklas #define	F_I960KA	(0x6000)
502159047fSniklas #define	F_I960SA	(0x6000)
51c88b1d6cSniklas #define F_I960JX	(0x7000)
52c88b1d6cSniklas #define F_I960HX	(0x8000)
532159047fSniklas 
542159047fSniklas 
552159047fSniklas /** i80960 Magic Numbers
562159047fSniklas */
572159047fSniklas 
582159047fSniklas #define I960ROMAGIC	(0x160)	/* read-only text segments */
592159047fSniklas #define I960RWMAGIC	(0x161)	/* read-write text segments */
602159047fSniklas 
612159047fSniklas #define I960BADMAG(x) (((x).f_magic!=I960ROMAGIC) && ((x).f_magic!=I960RWMAGIC))
622159047fSniklas 
632159047fSniklas #define	FILHDR	struct external_filehdr
642159047fSniklas #define	FILHSZ	20
652159047fSniklas 
662159047fSniklas /********************** AOUT "OPTIONAL HEADER" **********************/
672159047fSniklas 
682159047fSniklas typedef struct {
692159047fSniklas 	unsigned long	phys_addr;
702159047fSniklas 	unsigned long	bitarray;
712159047fSniklas } TAGBITS;
722159047fSniklas 
732159047fSniklas 
742159047fSniklas 
752159047fSniklas typedef struct
762159047fSniklas {
772159047fSniklas   char 	magic[2];		/* type of file				*/
782159047fSniklas   char	vstamp[2];		/* version stamp			*/
792159047fSniklas   char	tsize[4];		/* text size in bytes, padded to FW bdry*/
802159047fSniklas   char	dsize[4];		/* initialized data "  "		*/
812159047fSniklas   char	bsize[4];		/* uninitialized data "   "		*/
822159047fSniklas   char	entry[4];		/* entry pt.				*/
832159047fSniklas   char 	text_start[4];		/* base of text used for this file */
842159047fSniklas   char 	data_start[4];		/* base of data used for this file */
852159047fSniklas   char	tagentries[4];		/* number of tag entries to follow */
862159047fSniklas }
872159047fSniklas AOUTHDR;
882159047fSniklas 
892159047fSniklas /* return a pointer to the tag bits array */
902159047fSniklas 
912159047fSniklas #define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1))
922159047fSniklas 
932159047fSniklas /* compute size of a header */
942159047fSniklas 
952159047fSniklas /*#define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))*/
960c6d0228Sniklas #define AOUTSZ 32
970c6d0228Sniklas #define AOUTHDRSZ 32
982159047fSniklas 
992159047fSniklas 
1002159047fSniklas /********************** SECTION HEADER **********************/
1012159047fSniklas 
1022159047fSniklas 
1032159047fSniklas struct external_scnhdr {
1042159047fSniklas 	char		s_name[8];	/* section name			*/
1052159047fSniklas 	char		s_paddr[4];	/* physical address, aliased s_nlib */
1062159047fSniklas 	char		s_vaddr[4];	/* virtual address		*/
1072159047fSniklas 	char		s_size[4];	/* section size			*/
1082159047fSniklas 	char		s_scnptr[4];	/* file ptr to raw data for section */
1092159047fSniklas 	char		s_relptr[4];	/* file ptr to relocation	*/
1102159047fSniklas 	char		s_lnnoptr[4];	/* file ptr to line numbers	*/
1112159047fSniklas 	char		s_nreloc[2];	/* number of relocation entries	*/
1122159047fSniklas 	char		s_nlnno[2];	/* number of line number entries*/
1132159047fSniklas 	char		s_flags[4];	/* flags			*/
1142159047fSniklas 	char 		s_align[4];	/* section alignment		*/
1152159047fSniklas };
1162159047fSniklas 
1172159047fSniklas 
1182159047fSniklas #define	SCNHDR	struct external_scnhdr
1190c6d0228Sniklas #define	SCNHSZ	44
1202159047fSniklas 
1212159047fSniklas /*
1222159047fSniklas  * names of "special" sections
1232159047fSniklas  */
1242159047fSniklas #define _TEXT   ".text"
1252159047fSniklas #define _DATA   ".data"
1262159047fSniklas #define _BSS    ".bss"
1272159047fSniklas 
1282159047fSniklas /********************** LINE NUMBERS **********************/
1292159047fSniklas 
1302159047fSniklas /* 1 line number entry for every "breakpointable" source line in a section.
1312159047fSniklas  * Line numbers are grouped on a per function basis; first entry in a function
1322159047fSniklas  * grouping will have l_lnno = 0 and in place of physical address will be the
1332159047fSniklas  * symbol table index of the function name.
1342159047fSniklas  */
1352159047fSniklas struct external_lineno {
1362159047fSniklas 	union {
1372159047fSniklas 		char l_symndx[4];	/* function name symbol index, iff l_lnno == 0*/
1382159047fSniklas 		char l_paddr[4];	/* (physical) address of line number	*/
1392159047fSniklas 	} l_addr;
1402159047fSniklas 	char l_lnno[2];		/* line number		*/
1412159047fSniklas 	char padding[2];	/* force alignment	*/
1422159047fSniklas };
1432159047fSniklas 
1442159047fSniklas 
1452159047fSniklas #define	LINENO	struct external_lineno
1462159047fSniklas #define	LINESZ	8
1472159047fSniklas 
1482159047fSniklas 
1492159047fSniklas /********************** SYMBOLS **********************/
1502159047fSniklas 
1512159047fSniklas #define E_SYMNMLEN	8	/* # characters in a symbol name	*/
1522159047fSniklas #define E_FILNMLEN	14	/* # characters in a file name		*/
1532159047fSniklas #define E_DIMNUM	4	/* # array dimensions in auxiliary entry */
1542159047fSniklas 
1552159047fSniklas struct external_syment
1562159047fSniklas {
1572159047fSniklas   union {
1582159047fSniklas     char e_name[E_SYMNMLEN];
1592159047fSniklas     struct {
1602159047fSniklas       char e_zeroes[4];
1612159047fSniklas       char e_offset[4];
1622159047fSniklas     } e;
1632159047fSniklas   } e;
1642159047fSniklas   char e_value[4];
1652159047fSniklas   char e_scnum[2];
1662159047fSniklas   char e_flags[2];
1672159047fSniklas   char e_type[4];
1682159047fSniklas   char e_sclass[1];
1692159047fSniklas   char e_numaux[1];
1702159047fSniklas   char pad2[2];
1712159047fSniklas };
1722159047fSniklas 
1732159047fSniklas 
1742159047fSniklas 
1752159047fSniklas 
1762159047fSniklas #define N_BTMASK	(0x1f)
1772159047fSniklas #define N_TMASK		(0x60)
1782159047fSniklas #define N_BTSHFT	(5)
1792159047fSniklas #define N_TSHIFT	(2)
1802159047fSniklas 
1812159047fSniklas union external_auxent {
1822159047fSniklas 	struct {
1832159047fSniklas 		char x_tagndx[4];	/* str, un, or enum tag indx */
1842159047fSniklas 		union {
1852159047fSniklas 			struct {
1862159047fSniklas 			    char  x_lnno[2]; /* declaration line number */
1872159047fSniklas 			    char  x_size[2]; /* str/union/array size */
1882159047fSniklas 			} x_lnsz;
1892159047fSniklas 			char x_fsize[4];	/* size of function */
1902159047fSniklas 		} x_misc;
1912159047fSniklas 		union {
1922159047fSniklas 			struct {		/* if ISFCN, tag, or .bb */
1932159047fSniklas 			    char x_lnnoptr[4];	/* ptr to fcn line # */
1942159047fSniklas 			    char x_endndx[4];	/* entry ndx past block end */
1952159047fSniklas 			} x_fcn;
1962159047fSniklas 			struct {		/* if ISARY, up to 4 dimen. */
1972159047fSniklas 			    char x_dimen[E_DIMNUM][2];
1982159047fSniklas 			} x_ary;
1992159047fSniklas 		} x_fcnary;
2002159047fSniklas 		char x_tvndx[2];		/* tv index */
2012159047fSniklas 	} x_sym;
2022159047fSniklas 
2032159047fSniklas 	union {
2042159047fSniklas 		char x_fname[E_FILNMLEN];
2052159047fSniklas 		struct {
2062159047fSniklas 			char x_zeroes[4];
2072159047fSniklas 			char x_offset[4];
2082159047fSniklas 		} x_n;
2092159047fSniklas 	} x_file;
2102159047fSniklas 
2112159047fSniklas 	struct {
2122159047fSniklas 		char x_scnlen[4];			/* section length */
2132159047fSniklas 		char x_nreloc[2];	/* # relocation entries */
2142159047fSniklas 		char x_nlinno[2];	/* # line numbers */
2152159047fSniklas 	} x_scn;
2162159047fSniklas 
2172159047fSniklas         struct {
2182159047fSniklas 		char x_tvfill[4];	/* tv fill value */
2192159047fSniklas 		char x_tvlen[2];	/* length of .tv */
2202159047fSniklas 		char x_tvran[2][2];	/* tv range */
2212159047fSniklas 	} x_tv;		/* info about .tv section (in auxent of symbol .tv)) */
2222159047fSniklas 
2232159047fSniklas 	/******************************************
2242159047fSniklas 	 *  I960-specific *2nd* aux. entry formats
2252159047fSniklas 	 ******************************************/
2262159047fSniklas 	struct {
2272159047fSniklas 	  /* This is a very old typo that keeps getting propagated. */
2282159047fSniklas #define x_stdindx x_stindx
2292159047fSniklas 		char x_stindx[4];	/* sys. table entry */
2302159047fSniklas 	} x_sc;	/* system call entry */
2312159047fSniklas 
2322159047fSniklas 	struct {
2332159047fSniklas 		char x_balntry[4]; /* BAL entry point */
2342159047fSniklas 	} x_bal; /* BAL-callable function */
2352159047fSniklas 
2362159047fSniklas         struct {
2372159047fSniklas 		char x_timestamp[4];	        /* time stamp */
2382159047fSniklas 		char 	x_idstring[20];	        /* producer identity string */
2392159047fSniklas 	} x_ident;	                        /* Producer ident info */
2402159047fSniklas 
2412159047fSniklas };
2422159047fSniklas 
2432159047fSniklas 
2442159047fSniklas 
2452159047fSniklas #define	SYMENT	struct external_syment
2460c6d0228Sniklas #define	SYMESZ	24
2472159047fSniklas #define	AUXENT	union external_auxent
2480c6d0228Sniklas #define	AUXESZ	24
2492159047fSniklas 
2502159047fSniklas #	define _ETEXT	"_etext"
2512159047fSniklas 
2522159047fSniklas /********************** RELOCATION DIRECTIVES **********************/
2532159047fSniklas 
2542159047fSniklas struct external_reloc {
2552159047fSniklas   char r_vaddr[4];
2562159047fSniklas   char r_symndx[4];
2572159047fSniklas   char r_type[2];
2582159047fSniklas   char pad[2];
2592159047fSniklas };
2602159047fSniklas 
2616a4c786fSespie /* r_type values for the i960.  */
2622159047fSniklas 
2636a4c786fSespie /* The i960 uses R_RELLONG, which is defined in internal.h as 0x11.
2646a4c786fSespie    It is an absolute 32 bit relocation.  */
2652159047fSniklas 
2666a4c786fSespie #define R_IPRMED 	(0x19)	/* 24-bit ip-relative relocation */
2676a4c786fSespie #define R_OPTCALL	(0x1b)	/* 32-bit optimizable call (leafproc/sysproc) */
2686a4c786fSespie #define R_OPTCALLX	(0x1c)	/* 64-bit optimizable call (leafproc/sysproc) */
2696a4c786fSespie 
2706a4c786fSespie /* The following relocation types are defined use by relaxing linkers,
2716a4c786fSespie    which convert 32 bit calls (which require a 64 bit instruction)
2726a4c786fSespie    into 24 bit calls (which require a 32 bit instruction) when
2736a4c786fSespie    possible.  It will be possible whenever the target of the call is
2746a4c786fSespie    within a 24 bit range of the call instruction.
2756a4c786fSespie 
2766a4c786fSespie    It is always safe to ignore these relocations.  They only serve to
2776a4c786fSespie    mark points which the relaxing linker will have to consider.  The
2786a4c786fSespie    assembler must ensure that the correct code is generated even if
2796a4c786fSespie    the relocations are ignored.  In particular, this means that the
2806a4c786fSespie    R_IPR13 relocation may not appear with an external symbol.  */
2816a4c786fSespie 
2826a4c786fSespie #define R_IPR13		(0x1d)	/* 13 bit ip-relative branch */
2836a4c786fSespie #define R_ALIGN		(0x1e)  /* alignment marker.  This has no
2846a4c786fSespie 				   associated symbol.  Instead, the
2856a4c786fSespie 				   r_symndx field indicates the
2866a4c786fSespie 				   require alignment at this point in
2876a4c786fSespie 				   the file.  It must be a power of 2.  */
2882159047fSniklas 
2892159047fSniklas #define RELOC struct external_reloc
2902159047fSniklas #define RELSZ 12
2912159047fSniklas 
292