1 /* coff information for TI TMS320C80 (MVP)
2 
3    Copyright (C) 2001-2018 Free Software Foundation, Inc.
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
18    MA 02110-1301, USA.  */
19 
20 #define DO_NOT_DEFINE_FILHDR
21 #define DO_NOT_DEFINE_SCNHDR
22 #define L_LNNO_SIZE 2
23 #include "coff/external.h"
24 
25 /********************** FILE HEADER **********************/
26 
27 struct external_filehdr
28   {
29     char f_magic[2];	/* magic number			*/
30     char f_nscns[2];	/* number of sections		*/
31     char f_timdat[4];	/* time & date stamp		*/
32     char f_symptr[4];	/* file pointer to symtab	*/
33     char f_nsyms[4];	/* number of symtab entries	*/
34     char f_opthdr[2];	/* sizeof(optional hdr)		*/
35     char f_flags[2];	/* flags			*/
36     char f_target_id[2];/* target id (TIc80 specific)	*/
37 };
38 
39 #define	TIC80_ARCH_MAGIC	0x0C1	/* Goes in the file header magic number field */
40 #define TIC80_TARGET_ID		0x95	/* Goes in the target id field */
41 
42 #define TIC80BADMAG(x) ((x).f_magic != TIC80_ARCH_MAGIC)
43 
44 #define	FILHDR	struct external_filehdr
45 #define	FILHSZ	22
46 
47 #define TIC80_AOUTHDR_MAGIC	0x108	/* Goes in the optional file header magic number field */
48 
49 /********************** SECTION HEADER **********************/
50 
51 struct external_scnhdr
52 {
53 	char		s_name[8];	/* section name			*/
54 	char		s_paddr[4];	/* physical address, aliased s_nlib */
55 	char		s_vaddr[4];	/* virtual address		*/
56 	char		s_size[4];	/* section size			*/
57 	char		s_scnptr[4];	/* file ptr to raw data for section */
58 	char		s_relptr[4];	/* file ptr to relocation	*/
59 	char		s_lnnoptr[4];	/* file ptr to line numbers	*/
60 	char		s_nreloc[2];	/* number of relocation entries	*/
61 	char		s_nlnno[2];	/* number of line number entries*/
62 	char		s_flags[2];	/* flags			*/
63 	char		s_reserved[1];	/* reserved (TIc80 specific)	*/
64 	char		s_mempage[1];	/* memory page number (TIc80)	*/
65 };
66 
67 /* Names of "special" sections.  */
68 #define _TEXT	".text"
69 #define _DATA	".data"
70 #define _BSS	".bss"
71 #define _CINIT	".cinit"
72 #define _CONST	".const"
73 #define _SWITCH	".switch"
74 #define _STACK	".stack"
75 #define _SYSMEM	".sysmem"
76 
77 #define	SCNHDR	struct external_scnhdr
78 #define	SCNHSZ	40
79 
80 /* FIXME - need to correlate external_auxent with
81    TIc80 Code Generation Tools User's Guide, CG:A-25 */
82 
83 /********************** RELOCATION DIRECTIVES **********************/
84 
85 /* The external reloc has an offset field, because some of the reloc
86    types on the h8 don't have room in the instruction for the entire
87    offset - eg the strange jump and high page addressing modes.  */
88 
89 struct external_reloc
90 {
91   char r_vaddr[4];
92   char r_symndx[4];
93   char r_reserved[2];
94   char r_type[2];
95 };
96 
97 #define RELOC struct external_reloc
98 #define RELSZ 12
99 
100 /* TIc80 relocation types. */
101 
102 #define R_ABS		0x00		/* Absolute address - no relocation */
103 #define R_RELLONGX	0x11		/* PP: 32 bits, direct */
104 #define R_PPBASE	0x34		/* PP: Global base address type */
105 #define R_PPLBASE	0x35		/* PP: Local base address type */
106 #define R_PP15		0x38		/* PP: Global 15 bit offset */
107 #define R_PP15W		0x39		/* PP: Global 15 bit offset divided by 4 */
108 #define R_PP15H		0x3A		/* PP: Global 15 bit offset divided by 2 */
109 #define R_PP16B		0x3B		/* PP: Global 16 bit offset for bytes */
110 #define R_PPL15		0x3C		/* PP: Local 15 bit offset */
111 #define R_PPL15W	0x3D		/* PP: Local 15 bit offset divided by 4 */
112 #define R_PPL15H	0x3E		/* PP: Local 15 bit offset divided by 2 */
113 #define R_PPL16B	0x3F		/* PP: Local 16 bit offset for bytes */
114 #define R_PPN15		0x40		/* PP: Global 15 bit negative offset */
115 #define R_PPN15W	0x41		/* PP: Global 15 bit negative offset divided by 4 */
116 #define R_PPN15H	0x42		/* PP: Global 15 bit negative offset divided by 2 */
117 #define R_PPN16B	0x43		/* PP: Global 16 bit negative byte offset */
118 #define R_PPLN15	0x44		/* PP: Local 15 bit negative offset */
119 #define R_PPLN15W	0x45		/* PP: Local 15 bit negative offset divided by 4 */
120 #define R_PPLN15H	0x46		/* PP: Local 15 bit negative offset divided by 2 */
121 #define R_PPLN16B	0x47		/* PP: Local 16 bit negative byte offset */
122 #define R_MPPCR15W	0x4E		/* MP: 15 bit PC-relative divided by 4 */
123 #define R_MPPCR		0x4F		/* MP: 32 bit PC-relative divided by 4 */
124