/[gxemul]/upstream/0.4.4/src/include/exec_aout.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/0.4.4/src/include/exec_aout.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations)
Mon Oct 8 16:21:26 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 7355 byte(s)
0.4.4
1 /* gxemul: $Id: exec_aout.h,v 1.3 2005/03/05 12:34:02 debug Exp $ */
2
3 #ifndef __EXEC_AOUT_H
4 #define __EXEC_AOUT_H
5
6 /* $OpenBSD: exec_aout.h,v 1.9 1998/04/25 06:28:14 niklas Exp $ */
7 /* $NetBSD: exec_aout.h,v 1.15 1996/05/18 17:20:54 christos Exp $ */
8
9 /*
10 * Copyright (c) 1993, 1994 Christopher G. Demetriou
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 Christopher G. Demetriou.
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 N_PAGSIZ
40 #define N_PAGSIZ(ex) (__LDPGSZ)
41 #endif
42
43 /*
44 * Header prepended to each a.out file.
45 * only manipulate the a_midmag field via the
46 * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros below.
47 */
48 struct exec {
49 uint32_t a_midmag; /* htonl(flags<<26|mid<<16|magic) */
50 uint32_t a_text; /* text segment size */
51 uint32_t a_data; /* initialized data size */
52 uint32_t a_bss; /* uninitialized data size */
53 uint32_t a_syms; /* symbol table size */
54 uint32_t a_entry; /* entry point */
55 uint32_t a_trsize; /* text relocation size */
56 uint32_t a_drsize; /* data relocation size */
57 };
58
59 /* a_magic */
60 #define OMAGIC 0407 /* old impure format */
61 #define NMAGIC 0410 /* read-only text */
62 #define ZMAGIC 0413 /* demand load format */
63 #define QMAGIC 0314 /* "compact" demand load format; deprecated */
64
65 /*
66 * a_mid - keep sorted in numerical order for sanity's sake
67 * ensure that: 0 < mid < 0x3ff
68 */
69 #define MID_ZERO 0 /* unknown - implementation dependent */
70 #define MID_SUN010 1 /* sun 68010/68020 binary */
71 #define MID_SUN020 2 /* sun 68020-only binary */
72 #define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */
73 #define MID_ROMPAOS 104 /* old IBM RT */
74 #define MID_I386 134 /* i386 BSD binary */
75 #define MID_M68K 135 /* m68k BSD binary with 8K page sizes */
76 #define MID_M68K4K 136 /* DO NOT USE: m68k BSD binary with 4K page sizes */
77 #define MID_NS32532 137 /* ns32532 */
78 #define MID_SPARC 138 /* sparc */
79 #define MID_PMAX 139 /* pmax */
80 #define MID_VAX 140 /* vax */
81 #define MID_ALPHA 141 /* Alpha BSD binary */
82 #define MID_MIPS 142 /* big-endian MIPS */
83 #define MID_ARM6 143 /* ARM6 */
84 #define MID_ROMP 149 /* IBM RT */
85 #define MID_M88K 151 /* m88k BSD binary */
86 #define MID_HP200 200 /* hp200 (68010) BSD binary */
87 #define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
88 #define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
89 #define MID_HPUX800 0x20B /* hp800 HP-UX binary */
90
91 /*
92 * a_flags
93 */
94 #define EX_DYNAMIC 0x20
95 #define EX_PIC 0x10
96 #define EX_DPMASK 0x30
97 /*
98 * Interpretation of the (a_flags & EX_DPMASK) bits:
99 *
100 * 00 traditional executable or object file
101 * 01 object file contains PIC code (set by `as -k')
102 * 10 dynamic executable
103 * 11 position independent executable image
104 * (eg. a shared library)
105 *
106 */
107
108 /*
109 * The a.out structure's a_midmag field is a network-byteorder encoding
110 * of this int
111 * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM
112 * Where `F' is 6 bits of flag like EX_DYNAMIC,
113 * `m' is 10 bits of machine-id like MID_I386, and
114 * `M' is 16 bits worth of magic number, ie. ZMAGIC.
115 * The macros below will set/get the needed fields.
116 */
117 #define N_GETMAGIC(ex) \
118 ( (((ex).a_midmag)&0xffff0000) ? (ntohl(((ex).a_midmag))&0xffff) : ((ex).a_midmag))
119 #define N_GETMAGIC2(ex) \
120 ( (((ex).a_midmag)&0xffff0000) ? (ntohl(((ex).a_midmag))&0xffff) : \
121 (((ex).a_midmag) | 0x10000) )
122 #define N_GETMID(ex) \
123 ( (((ex).a_midmag)&0xffff0000) ? ((ntohl(((ex).a_midmag))>>16)&0x03ff) : MID_ZERO )
124 #define N_GETFLAG(ex) \
125 ( (((ex).a_midmag)&0xffff0000) ? ((ntohl(((ex).a_midmag))>>26)&0x3f) : 0 )
126 #define N_SETMAGIC(ex,mag,mid,flag) \
127 ( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
128 (((mag)&0xffff)) ) )
129
130 #define N_ALIGN(ex,x) \
131 (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC ? \
132 ((x) + __LDPGSZ - 1) & ~(__LDPGSZ - 1) : (x))
133
134 /* Valid magic number check. */
135 #define N_BADMAG(ex) \
136 (N_GETMAGIC(ex) != NMAGIC && N_GETMAGIC(ex) != OMAGIC && \
137 N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC)
138
139 /* Address of the bottom of the text segment. */
140 #define N_TXTADDR(ex) (N_GETMAGIC2(ex) == (ZMAGIC|0x10000) ? 0 : __LDPGSZ)
141
142 /* Address of the bottom of the data segment. */
143 #define N_DATADDR(ex) \
144 (N_GETMAGIC(ex) == OMAGIC ? N_TXTADDR(ex) + (ex).a_text : \
145 (N_TXTADDR(ex) + (ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1))
146
147 /* Address of the bottom of the bss segment. */
148 #define N_BSSADDR(ex) \
149 (N_DATADDR(ex) + (ex).a_data)
150
151 /* Text segment offset. */
152 #define N_TXTOFF(ex) \
153 ( N_GETMAGIC2(ex)==ZMAGIC || N_GETMAGIC2(ex)==(QMAGIC|0x10000) ? \
154 0 : (N_GETMAGIC2(ex)==(ZMAGIC|0x10000) ? __LDPGSZ : \
155 sizeof(struct exec)) )
156
157 /* Data segment offset. */
158 #define N_DATOFF(ex) \
159 N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
160
161 /* Text relocation table offset. */
162 #define N_TRELOFF(ex) \
163 (N_DATOFF(ex) + (ex).a_data)
164
165 /* Data relocation table offset. */
166 #define N_DRELOFF(ex) \
167 (N_TRELOFF(ex) + (ex).a_trsize)
168
169 /* Symbol table offset. */
170 #define N_SYMOFF(ex) \
171 (N_DRELOFF(ex) + (ex).a_drsize)
172
173 /* String table offset. */
174 #define N_STROFF(ex) \
175 (N_SYMOFF(ex) + (ex).a_syms)
176
177
178 #ifdef _KERNEL
179
180 /* the "a.out" format's entry in the exec switch */
181 int exec_aout_makecmds __P((struct proc *, struct exec_package *));
182
183 /* functions which prepare various a.out executable types */
184 /*
185 * MI portion
186 */
187 int exec_aout_prep_zmagic __P((struct proc *, struct exec_package *));
188 int exec_aout_prep_nmagic __P((struct proc *, struct exec_package *));
189 int exec_aout_prep_omagic __P((struct proc *, struct exec_package *));
190
191 /* For compatibility modules */
192 int exec_aout_prep_oldzmagic __P((struct proc *, struct exec_package *));
193 int exec_aout_prep_oldnmagic __P((struct proc *, struct exec_package *));
194 int exec_aout_prep_oldomagic __P((struct proc *, struct exec_package *));
195
196 /*
197 * MD portion
198 */
199 int cpu_exec_aout_makecmds __P((struct proc *, struct exec_package *));
200
201 #endif /* _KERNEL */
202
203 #endif /* __EXEC_AOUT_H */
204

  ViewVC Help
Powered by ViewVC 1.1.26