2 * Copyright (c) 1992, 1993
\r
3 * The Regents of the University of California. All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
8 * 1. Redistributions of source code must retain the above copyright
\r
9 * notice, this list of conditions and the following disclaimer.
\r
10 * 2. Redistributions in binary form must reproduce the above copyright
\r
11 * notice, this list of conditions and the following disclaimer in the
\r
12 * documentation and/or other materials provided with the distribution.
\r
13 * 3. All advertising materials mentioning features or use of this software
\r
14 * must display the following acknowledgement:
\r
15 * This product includes software developed by the University of
\r
16 * California, Berkeley and its contributors.
\r
17 * 4. Neither the name of the University nor the names of its contributors
\r
18 * may be used to endorse or promote products derived from this software
\r
19 * without specific prior written permission.
\r
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
\r
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
\r
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
\r
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\r
33 * from: @(#)exec.h 8.1 (Berkeley) 6/11/93
\r
34 * $FreeBSD: src/sys/i386/boot/dosboot/imgact.h,v 1.5 1999/08/28 00:43:23 peter Exp $
\r
35 * $DragonFly: src/sys/i386/boot/dosboot/Attic/imgact.h,v 1.2 2003/06/17 04:28:34 dillon Exp $
\r
38 #ifndef _IMGACT_AOUT_H_
\r
39 #define _IMGACT_AOUT_H_
\r
41 #define N_GETMAGIC(ex) \
\r
42 ( (ex).a_midmag & 0xffff )
\r
43 #define N_GETMID(ex) \
\r
44 ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \
\r
45 ((ex).a_midmag >> 16) & 0x03ff )
\r
46 #define N_GETFLAG(ex) \
\r
47 ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \
\r
48 ((ex).a_midmag >> 26) & 0x3f )
\r
49 #define N_SETMAGIC(ex,mag,mid,flag) \
\r
50 ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
\r
53 #define N_GETMAGIC_NET(ex) \
\r
54 (ntohl((ex).a_midmag) & 0xffff)
\r
55 #define N_GETMID_NET(ex) \
\r
56 ((ntohl((ex).a_midmag) >> 16) & 0x03ff)
\r
57 #define N_GETFLAG_NET(ex) \
\r
58 ((ntohl((ex).a_midmag) >> 26) & 0x3f)
\r
59 #define N_SETMAGIC_NET(ex,mag,mid,flag) \
\r
60 ( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
\r
61 (((mag)&0xffff)) ) )
\r
63 #define N_ALIGN(ex,x) \
\r
64 (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \
\r
65 N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \
\r
66 ((x) + __LDPGSZ - 1) & ~(__LDPGSZ - 1) : (x))
\r
68 /* Valid magic number check. */
\r
69 #define N_BADMAG(ex) \
\r
70 (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
\r
71 N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC /*&& \
\r
72 N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
\r
73 N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC*/)
\r
76 /* Address of the bottom of the text segment. */
\r
77 #define N_TXTADDR(ex) \
\r
78 ((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \
\r
79 N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
\r
81 /* Address of the bottom of the data segment. */
\r
82 #define N_DATADDR(ex) \
\r
83 N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text)
\r
85 /* Text segment offset. */
\r
86 #define N_TXTOFF(ex) \
\r
87 (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC /*|| \
\r
88 N_GETMAGIC_NET(ex) == ZMAGIC*/) ? 0 : sizeof(struct exec))
\r
90 /* Data segment offset. */
\r
91 #define N_DATOFF(ex) \
\r
92 N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
\r
94 /* Relocation table offset. */
\r
95 #define N_RELOFF(ex) \
\r
96 N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data)
\r
98 /* Symbol table offset. */
\r
99 #define N_SYMOFF(ex) \
\r
100 (N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
\r
102 /* String table offset. */
\r
103 #define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
\r
106 * Header prepended to each a.out file.
\r
107 * only manipulate the a_midmag field via the
\r
108 * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
\r
112 unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
\r
113 unsigned long a_text; /* text segment size */
\r
114 unsigned long a_data; /* initialized data size */
\r
115 unsigned long a_bss; /* uninitialized data size */
\r
116 unsigned long a_syms; /* symbol table size */
\r
117 unsigned long a_entry; /* entry point */
\r
118 unsigned long a_trsize; /* text relocation size */
\r
119 unsigned long a_drsize; /* data relocation size */
\r
121 #define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */
\r
124 #define OMAGIC 0407 /* old impure format */
\r
125 #define NMAGIC 0410 /* read-only text */
\r
126 #define ZMAGIC 0413 /* demand load format */
\r
127 #define QMAGIC 0314 /* "compact" demand load format */
\r
130 #define MID_ZERO 0 /* unknown - implementation dependent */
\r
131 #define MID_SUN010 1 /* sun 68010/68020 binary */
\r
132 #define MID_SUN020 2 /* sun 68020-only binary */
\r
133 #define MID_I386 134 /* i386 BSD binary */
\r
134 #define MID_SPARC 138 /* sparc */
\r
135 #define MID_HP200 200 /* hp200 (68010) BSD binary */
\r
136 #define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
\r
137 #define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
\r
138 #define MID_HPUX800 0x20B /* hp800 HP-UX binary */
\r
143 #define EX_PIC 0x10 /* contains position independant code */
\r
144 #define EX_DYNAMIC 0x20 /* contains run-time link-edit info */
\r
145 #define EX_DPMASK 0x30 /* mask for the above */
\r
147 #endif /* !_IMGACT_AOUT_H_ */
\r