makefile:
[gem5.git] / base / exec_ecoff.h
1 /* $Id$ */
2
3 /*
4 * Taken from NetBSD sys/exec_ecoff.h
5 */
6
7 /* $NetBSD: exec_ecoff.h,v 1.13 2003/01/18 09:53:18 thorpej Exp $ */
8
9 /*
10 * Copyright (c) 1994 Adam Glass
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by Adam Glass.
24 * 4. The name of the author may not be used to endorse or promote products
25 * derived from this software without specific prior written permission
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _SYS_EXEC_ECOFF_H_
40 #define _SYS_EXEC_ECOFF_H_
41
42 #include "ecoff_machdep.h"
43
44 struct ecoff_filehdr {
45 coff_ushort f_magic; /* magic number */
46 coff_ushort f_nscns; /* # of sections */
47 coff_uint f_timdat; /* time and date stamp */
48 coff_ulong f_symptr; /* file offset of symbol table */
49 coff_uint f_nsyms; /* # of symbol table entries */
50 coff_ushort f_opthdr; /* sizeof the optional header */
51 coff_ushort f_flags; /* flags??? */
52 };
53
54 struct ecoff_aouthdr {
55 coff_ushort magic;
56 coff_ushort vstamp;
57 ECOFF_PAD
58 coff_ulong tsize;
59 coff_ulong dsize;
60 coff_ulong bsize;
61 coff_ulong entry;
62 coff_ulong text_start;
63 coff_ulong data_start;
64 coff_ulong bss_start;
65 ECOFF_MACHDEP;
66 };
67
68 struct ecoff_scnhdr { /* needed for size info */
69 char s_name[8]; /* name */
70 coff_ulong s_paddr; /* physical addr? for ROMing?*/
71 coff_ulong s_vaddr; /* virtual addr? */
72 coff_ulong s_size; /* size */
73 coff_ulong s_scnptr; /* file offset of raw data */
74 coff_ulong s_relptr; /* file offset of reloc data */
75 coff_ulong s_lnnoptr; /* file offset of line data */
76 coff_ushort s_nreloc; /* # of relocation entries */
77 coff_ushort s_nlnno; /* # of line entries */
78 coff_uint s_flags; /* flags */
79 };
80
81 struct ecoff_exechdr {
82 struct ecoff_filehdr f;
83 struct ecoff_aouthdr a;
84 };
85
86 #define ECOFF_HDR_SIZE (sizeof(struct ecoff_exechdr))
87
88 #define ECOFF_OMAGIC 0407
89 #define ECOFF_NMAGIC 0410
90 #define ECOFF_ZMAGIC 0413
91
92 #define ECOFF_ROUND(value, by) \
93 (((value) + (by) - 1) & ~((by) - 1))
94
95 #define ECOFF_BLOCK_ALIGN(ep, value) \
96 ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_ROUND((value), ECOFF_LDPGSZ) : \
97 (value))
98
99 #define ECOFF_TXTOFF(ep) \
100 ((ep)->a.magic == ECOFF_ZMAGIC ? 0 : \
101 ECOFF_ROUND(ECOFF_HDR_SIZE + (ep)->f.f_nscns * \
102 sizeof(struct ecoff_scnhdr), ECOFF_SEGMENT_ALIGNMENT(ep)))
103
104 #define ECOFF_DATOFF(ep) \
105 (ECOFF_BLOCK_ALIGN((ep), ECOFF_TXTOFF(ep) + (ep)->a.tsize))
106
107 #define ECOFF_SEGMENT_ALIGN(ep, value) \
108 (ECOFF_ROUND((value), ((ep)->a.magic == ECOFF_ZMAGIC ? ECOFF_LDPGSZ : \
109 ECOFF_SEGMENT_ALIGNMENT(ep))))
110
111 #endif /* !_SYS_EXEC_ECOFF_H_ */