xref: /minix/sys/sys/exec_ecoff.h (revision 6c8f7fc3)
1 /*	$NetBSD: exec_ecoff.h,v 1.20 2009/12/10 14:13:54 matt Exp $	*/
2 
3 /*
4  * Copyright (c) 1994 Adam Glass
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Adam Glass.
18  * 4. 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	_SYS_EXEC_ECOFF_H_
34 #define	_SYS_EXEC_ECOFF_H_
35 
36 #include <machine/ecoff_machdep.h>
37 
38 struct ecoff_filehdr {
39 	u_short f_magic;	/* magic number */
40 	u_short f_nscns;	/* # of sections */
41 	u_int   f_timdat;	/* time and date stamp */
42 	u_long  f_symptr;	/* file offset of symbol table */
43 	u_int   f_nsyms;	/* # of symbol table entries */
44 	u_short f_opthdr;	/* sizeof the optional header */
45 	u_short f_flags;	/* flags??? */
46 };
47 
48 struct ecoff_aouthdr {
49 	u_short magic;
50 	u_short vstamp;
51 	ECOFF_PAD
52 	u_long  tsize;
53 	u_long  dsize;
54 	u_long  bsize;
55 	u_long  entry;
56 	u_long  text_start;
57 	u_long  data_start;
58 	u_long  bss_start;
59 	ECOFF_MACHDEP;
60 };
61 
62 struct ecoff_scnhdr {		/* needed for size info */
63 	char	s_name[8];	/* name */
64 	u_long  s_paddr;	/* physical addr? for ROMing?*/
65 	u_long  s_vaddr;	/* virtual addr? */
66 	u_long  s_size;		/* size */
67 	u_long  s_scnptr;	/* file offset of raw data */
68 	u_long  s_relptr;	/* file offset of reloc data */
69 	u_long  s_lnnoptr;	/* file offset of line data */
70 	u_short s_nreloc;	/* # of relocation entries */
71 	u_short s_nlnno;	/* # of line entries */
72 	u_int   s_flags;	/* flags */
73 };
74 
75 struct ecoff_exechdr {
76 	struct ecoff_filehdr f;
77 	struct ecoff_aouthdr a;
78 };
79 
80 #define ECOFF_HDR_SIZE (sizeof(struct ecoff_exechdr))
81 
82 #define ECOFF_OMAGIC 0407
83 #define ECOFF_NMAGIC 0410
84 #define ECOFF_ZMAGIC 0413
85 
86 #define ECOFF_ROUND(value, by) \
87         (((value) + (by) - 1) & ~((by) - 1))
88 
89 #define ECOFF_BLOCK_ALIGN(ep, value) \
90         ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_ROUND((value), ECOFF_LDPGSZ) : \
91 	 (value))
92 
93 #define ECOFF_TXTOFF(ep) \
94         ((ep)->a.magic == ECOFF_ZMAGIC ? 0 : \
95 	 ECOFF_ROUND(ECOFF_HDR_SIZE + (ep)->f.f_nscns * \
96 		     sizeof(struct ecoff_scnhdr), ECOFF_SEGMENT_ALIGNMENT(ep)))
97 
98 #define ECOFF_DATOFF(ep) \
99         (ECOFF_BLOCK_ALIGN((ep), ECOFF_TXTOFF(ep) + (ep)->a.tsize))
100 
101 #define ECOFF_SEGMENT_ALIGN(ep, value) \
102         (ECOFF_ROUND((value), ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \
103          ECOFF_SEGMENT_ALIGNMENT(ep))))
104 
105 #ifdef _KERNEL
106 int	exec_ecoff_makecmds(struct lwp *, struct exec_package *);
107 int	cpu_exec_ecoff_probe(struct lwp *, struct exec_package *);
108 void	cpu_exec_ecoff_setregs(struct lwp *, struct exec_package *, vaddr_t);
109 
110 int	exec_ecoff_prep_omagic(struct lwp *, struct exec_package *,
111 	    struct ecoff_exechdr *, struct vnode *);
112 int	exec_ecoff_prep_nmagic(struct lwp *, struct exec_package *,
113 	    struct ecoff_exechdr *, struct vnode *);
114 int	exec_ecoff_prep_zmagic(struct lwp *, struct exec_package *,
115 	    struct ecoff_exechdr *, struct vnode *);
116 
117 #endif /* _KERNEL */
118 #endif /* !_SYS_EXEC_ECOFF_H_ */
119