xref: /netbsd/sys/arch/sh3/include/coff_machdep.h (revision 6550d01e)
1 /*	$NetBSD: coff_machdep.h,v 1.6 2002/04/28 17:10:33 uch Exp $	*/
2 
3 /*
4  * Copyright (c) 1994, 1995 Scott Bartram
5  * All rights reserved.
6  *
7  * adapted from sys/sys/exec_ecoff.h
8  * based on Intel iBCS2
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _SH3_COFF_MACHDEP_H_
34 #define	_SH3_COFF_MACHDEP_H_
35 
36 /* f_magic flags */
37 #define	COFF_MAGIC_SH3_BIG	0x500
38 #define	COFF_MAGIC_SH3_LITTLE	0x550
39 
40 /* magic */
41 #define	COFF_OMAGIC	0444	/* text not write-protected; data seg
42 				   is contiguous with text */
43 #define	COFF_NMAGIC	0410	/* text is write-protected; data starts
44 				   at next seg following text */
45 #define	COFF_ZMAGIC	0000	/* text and data segs are aligned for
46 				   direct paging */
47 #define	COFF_SMAGIC	0443	/* shared lib */
48 
49 #define	COFF_LDPGSZ 4096
50 
51 #define	COFF_SEGMENT_ALIGNMENT(fp, ap)					\
52     (((fp)->f_flags & COFF_F_EXEC) == 0 ? 4 : 16)
53 
54 #ifndef _BYTE_ORDER
55 #error Define _BYTE_ORDER!
56 #endif
57 
58 #if _BYTE_ORDER == BIG_ENDIAN
59 #define	COFF_BADMAG(ex) ((ex)->f_magic != COFF_MAGIC_SH3_BIG)
60 #endif
61 #if _BYTE_ORDER == LITTLE_ENDIAN
62 #define	COFF_BADMAG(ex) ((ex)->f_magic != COFF_MAGIC_SH3_LITTLE)
63 #endif
64 
65 #define	IBCS2_HIGH_SYSCALL(n)		(((n) & 0x7f) == 0x28)
66 #define	IBCS2_CVT_HIGH_SYSCALL(n)	(((n) >> 8) + 128)
67 
68 #ifdef DEBUG_COFF
69 #define	DPRINTF(a)      printf a;
70 #else
71 #define	DPRINTF(a)
72 #endif
73 
74 #define	COFF_ES_SYMNMLEN	8
75 #define	COFF_ES_SYMENTSZ	18
76 
77 struct external_syment {
78 	union {
79 		char e_name[COFF_ES_SYMNMLEN];
80 		struct {
81 			char e_zeroes[4];
82 			char e_offset[4];
83 		} e;
84 	} e;
85 	char e_value[4];
86 	char e_scnum[2];
87 	char e_type[2];
88 	char e_sclass[1];
89 	char e_numaux[1];
90 };
91 
92 #endif /* !_SH3_COFF_MACHDEP_H_ */
93 
94