Deleted Added
full compact
exec.h (1549) exec.h (1817)
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)exec.h 8.1 (Berkeley) 6/11/93
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)exec.h 8.1 (Berkeley) 6/11/93
34 * $Id$
34 */
35
36#ifndef _EXEC_H_
37#define _EXEC_H_
38
39#define __LDPGSZ 4096
40
41/* Valid magic number check. */
42#define N_BADMAG(ex) \
43 (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
44 N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
45 N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
46 N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
47
48#define N_ALIGN(ex,x) \
49 (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \
50 N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \
51 ((x) + __LDPGSZ - 1) & ~(__LDPGSZ - 1) : (x))
52
53/* Address of the bottom of the text segment. */
54#define N_TXTADDR(ex) \
55 ((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \
56 N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
57
58/* Address of the bottom of the data segment. */
59#define N_DATADDR(ex) \
60 N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text)
61
62#define N_GETMAGIC(ex) \
63 ( (ex).a_midmag & 0xffff )
64#define N_GETMID(ex) \
65 ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \
66 ((ex).a_midmag >> 16) & 0x03ff )
67#define N_GETFLAG(ex) \
68 ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \
69 ((ex).a_midmag >> 26) & 0x3f )
70#define N_SETMAGIC(ex,mag,mid,flag) \
71 ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
72 ((mag) & 0xffff) )
73
74#define N_GETMAGIC_NET(ex) \
75 (ntohl((ex).a_midmag) & 0xffff)
76#define N_GETMID_NET(ex) \
77 ((ntohl((ex).a_midmag) >> 16) & 0x03ff)
78#define N_GETFLAG_NET(ex) \
79 ((ntohl((ex).a_midmag) >> 26) & 0x3f)
80#define N_SETMAGIC_NET(ex,mag,mid,flag) \
81 ( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
82 (((mag)&0xffff)) ) )
83
84/* Text segment offset. */
85#define N_TXTOFF(ex) \
86 (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
87 N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct exec))
88
89/* Data segment offset. */
90#define N_DATOFF(ex) \
91 N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
92
93/* Relocation table offset. */
94#define N_RELOFF(ex) \
95 N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data)
96
97/* Symbol table offset. */
98#define N_SYMOFF(ex) \
99 (N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
100
101/* String table offset. */
102#define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
103
104/*
105 * Header prepended to each a.out file.
106 * only manipulate the a_midmag field via the
107 * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
108 */
109
110struct exec {
111unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
112unsigned long a_text; /* text segment size */
113unsigned long a_data; /* initialized data size */
114unsigned long a_bss; /* uninitialized data size */
115unsigned long a_syms; /* symbol table size */
116unsigned long a_entry; /* entry point */
117unsigned long a_trsize; /* text relocation size */
118unsigned long a_drsize; /* data relocation size */
119};
120#define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */
121
122/* a_magic */
123#define OMAGIC 0407 /* old impure format */
124#define NMAGIC 0410 /* read-only text */
125#define ZMAGIC 0413 /* demand load format */
126#define QMAGIC 0314 /* "compact" demand load format */
127
128#endif /* !_EXEC_H_ */
35 */
36
37#ifndef _EXEC_H_
38#define _EXEC_H_
39
40#define __LDPGSZ 4096
41
42/* Valid magic number check. */
43#define N_BADMAG(ex) \
44 (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
45 N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
46 N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
47 N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
48
49#define N_ALIGN(ex,x) \
50 (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \
51 N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \
52 ((x) + __LDPGSZ - 1) & ~(__LDPGSZ - 1) : (x))
53
54/* Address of the bottom of the text segment. */
55#define N_TXTADDR(ex) \
56 ((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \
57 N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
58
59/* Address of the bottom of the data segment. */
60#define N_DATADDR(ex) \
61 N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text)
62
63#define N_GETMAGIC(ex) \
64 ( (ex).a_midmag & 0xffff )
65#define N_GETMID(ex) \
66 ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \
67 ((ex).a_midmag >> 16) & 0x03ff )
68#define N_GETFLAG(ex) \
69 ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \
70 ((ex).a_midmag >> 26) & 0x3f )
71#define N_SETMAGIC(ex,mag,mid,flag) \
72 ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
73 ((mag) & 0xffff) )
74
75#define N_GETMAGIC_NET(ex) \
76 (ntohl((ex).a_midmag) & 0xffff)
77#define N_GETMID_NET(ex) \
78 ((ntohl((ex).a_midmag) >> 16) & 0x03ff)
79#define N_GETFLAG_NET(ex) \
80 ((ntohl((ex).a_midmag) >> 26) & 0x3f)
81#define N_SETMAGIC_NET(ex,mag,mid,flag) \
82 ( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
83 (((mag)&0xffff)) ) )
84
85/* Text segment offset. */
86#define N_TXTOFF(ex) \
87 (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
88 N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct exec))
89
90/* Data segment offset. */
91#define N_DATOFF(ex) \
92 N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
93
94/* Relocation table offset. */
95#define N_RELOFF(ex) \
96 N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data)
97
98/* Symbol table offset. */
99#define N_SYMOFF(ex) \
100 (N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
101
102/* String table offset. */
103#define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
104
105/*
106 * Header prepended to each a.out file.
107 * only manipulate the a_midmag field via the
108 * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
109 */
110
111struct exec {
112unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
113unsigned long a_text; /* text segment size */
114unsigned long a_data; /* initialized data size */
115unsigned long a_bss; /* uninitialized data size */
116unsigned long a_syms; /* symbol table size */
117unsigned long a_entry; /* entry point */
118unsigned long a_trsize; /* text relocation size */
119unsigned long a_drsize; /* data relocation size */
120};
121#define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */
122
123/* a_magic */
124#define OMAGIC 0407 /* old impure format */
125#define NMAGIC 0410 /* read-only text */
126#define ZMAGIC 0413 /* demand load format */
127#define QMAGIC 0314 /* "compact" demand load format */
128
129#endif /* !_EXEC_H_ */