1 /* $NetBSD: exec_ecoff.h,v 1.12 2000/11/21 00:37:56 jdolecek Exp $ */
4 * Copyright (c) 1994 Adam Glass
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
33 #ifndef _SYS_EXEC_ECOFF_H_
34 #define _SYS_EXEC_ECOFF_H_
36 #include <machine/ecoff_machdep.h>
38 struct ecoff_filehdr
{
39 ECOFF_USHORT f_magic
; /* magic number */
40 ECOFF_USHORT f_nscns
; /* # of sections */
41 ECOFF_UINT f_timdat
; /* time and date stamp */
42 ECOFF_ULONG f_symptr
; /* file offset of symbol table */
43 ECOFF_UINT f_nsyms
; /* # of symbol table entries */
44 ECOFF_USHORT f_opthdr
; /* sizeof the optional header */
45 ECOFF_USHORT f_flags
; /* flags??? */
48 struct ecoff_aouthdr
{
56 ECOFF_ULONG text_start
;
57 ECOFF_ULONG data_start
;
58 ECOFF_ULONG bss_start
;
62 struct ecoff_scnhdr
{ /* needed for size info */
63 char s_name
[8]; /* name */
64 ECOFF_ULONG s_paddr
; /* physical addr? for ROMing?*/
65 ECOFF_ULONG s_vaddr
; /* virtual addr? */
66 ECOFF_ULONG s_size
; /* size */
67 ECOFF_ULONG s_scnptr
; /* file offset of raw data */
68 ECOFF_ULONG s_relptr
; /* file offset of reloc data */
69 ECOFF_ULONG s_lnnoptr
; /* file offset of line data */
70 ECOFF_USHORT s_nreloc
; /* # of relocation entries */
71 ECOFF_USHORT s_nlnno
; /* # of line entries */
72 ECOFF_UINT s_flags
; /* flags */
75 struct ecoff_exechdr
{
76 struct ecoff_filehdr f
;
77 struct ecoff_aouthdr a
;
80 #define ECOFF_HDR_SIZE (sizeof(struct ecoff_exechdr))
82 #define ECOFF_OMAGIC 0407
83 #define ECOFF_NMAGIC 0410
84 #define ECOFF_ZMAGIC 0413
86 #define ECOFF_ROUND(value, by) \
87 (((value) + (by) - 1) & ~((by) - 1))
89 #define ECOFF_BLOCK_ALIGN(ep, value) \
90 ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_ROUND((value), ECOFF_LDPGSZ) : \
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)))
98 #define ECOFF_DATOFF(ep) \
99 (ECOFF_BLOCK_ALIGN((ep), ECOFF_TXTOFF(ep) + (ep)->a.tsize))
101 #define ECOFF_SEGMENT_ALIGN(ep, value) \
102 (ECOFF_ROUND((value), ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \
103 ECOFF_SEGMENT_ALIGNMENT(ep))))
106 int exec_ecoff_makecmds
__P((struct proc
*, struct exec_package
*));
107 int exec_ecoff_setup_stack
__P((struct proc
*, struct exec_package
*));
108 int cpu_exec_ecoff_probe
__P((struct proc
*, struct exec_package
*));
109 void cpu_exec_ecoff_setregs
__P((struct proc
*, struct exec_package
*,
112 int exec_ecoff_prep_omagic
__P((struct proc
*, struct exec_package
*,
113 struct ecoff_exechdr
*, struct vnode
*));
114 int exec_ecoff_prep_nmagic
__P((struct proc
*, struct exec_package
*,
115 struct ecoff_exechdr
*, struct vnode
*));
116 int exec_ecoff_prep_zmagic
__P((struct proc
*, struct exec_package
*,
117 struct ecoff_exechdr
*, struct vnode
*));
120 #endif /* !_SYS_EXEC_ECOFF_H_ */