Home | History | Annotate | Line # | Download | only in include
      1 /*	$NetBSD: coff_machdep.h,v 1.7 2026/01/09 15:40:20 nia 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 #include <sys/endian.h>
     37 
     38 /* f_magic flags */
     39 #define	COFF_MAGIC_SH3_BIG	0x500
     40 #define	COFF_MAGIC_SH3_LITTLE	0x550
     41 
     42 /* magic */
     43 #define	COFF_OMAGIC	0444	/* text not write-protected; data seg
     44 				   is contiguous with text */
     45 #define	COFF_NMAGIC	0410	/* text is write-protected; data starts
     46 				   at next seg following text */
     47 #define	COFF_ZMAGIC	0000	/* text and data segs are aligned for
     48 				   direct paging */
     49 #define	COFF_SMAGIC	0443	/* shared lib */
     50 
     51 #define	COFF_LDPGSZ 4096
     52 
     53 #define	COFF_SEGMENT_ALIGNMENT(fp, ap)					\
     54     (((fp)->f_flags & COFF_F_EXEC) == 0 ? 4 : 16)
     55 
     56 #ifndef BYTE_ORDER
     57 #error Define BYTE_ORDER!
     58 #endif
     59 
     60 #if BYTE_ORDER == BIG_ENDIAN
     61 #define	COFF_BADMAG(ex) ((ex)->f_magic != COFF_MAGIC_SH3_BIG)
     62 #endif
     63 #if BYTE_ORDER == LITTLE_ENDIAN
     64 #define	COFF_BADMAG(ex) ((ex)->f_magic != COFF_MAGIC_SH3_LITTLE)
     65 #endif
     66 
     67 #define	IBCS2_HIGH_SYSCALL(n)		(((n) & 0x7f) == 0x28)
     68 #define	IBCS2_CVT_HIGH_SYSCALL(n)	(((n) >> 8) + 128)
     69 
     70 #ifdef DEBUG_COFF
     71 #define	DPRINTF(a)      printf a;
     72 #else
     73 #define	DPRINTF(a)
     74 #endif
     75 
     76 #define	COFF_ES_SYMNMLEN	8
     77 #define	COFF_ES_SYMENTSZ	18
     78 
     79 struct external_syment {
     80 	union {
     81 		char e_name[COFF_ES_SYMNMLEN];
     82 		struct {
     83 			char e_zeroes[4];
     84 			char e_offset[4];
     85 		} e;
     86 	} e;
     87 	char e_value[4];
     88 	char e_scnum[2];
     89 	char e_type[2];
     90 	char e_sclass[1];
     91 	char e_numaux[1];
     92 };
     93 
     94 #endif /* !_SH3_COFF_MACHDEP_H_ */
     95 
     96