BSD 4_4_Lite1 release
[unix-history] / usr / src / sys / sparc / include / exec.h
CommitLineData
68608c33 1/*
ad787160
C
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
68608c33
CT
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *
b480239a
KB
9 * All advertising materials mentioning features or use of this software
10 * must display the following acknowledgement:
11 * This product includes software developed by the University of
1869bdc0 12 * California, Lawrence Berkeley Laboratory.
b480239a 13 *
ad787160
C
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by the University of
25 * California, Berkeley and its contributors.
26 * 4. Neither the name of the University nor the names of its contributors
27 * may be used to endorse or promote products derived from this software
28 * without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
68608c33 41 *
ad787160 42 * @(#)exec.h 8.1 (Berkeley) 6/11/93
68608c33 43 *
1869bdc0 44 * from: $Header: exec.h,v 1.9 93/04/20 11:14:45 torek Exp $
68608c33
CT
45 */
46
47/*
48 * __LDPGSZ is the page size used by the linker and by exec().
49 * It may be some multiple of the ``normal'' page size, so that, e.g.,
50 * the same binaries can be run on hardware with different page sizes
51 * that otherwise use the same instruction set. It must be no larger
52 * than CLBYTES (in param.h).
53 */
54#define __LDPGSZ 8192
55
56/* Valid magic number check. */
57#define N_BADMAG(ex) \
58 ((ex).a_magic != ZMAGIC && (ex).a_magic != NMAGIC && \
59 (ex).a_magic != OMAGIC)
60
61/*
62 * N_TXTADDR is the address of the first executable instruction: that is,
63 * the place the pc could begin after an a.out is loaded, in order to run
64 * the instructions in that a.out. The pc will actually be set to ex.a_entry
65 * but this is the first place it could possibly reference.
66 *
67 * On the SPARC, binaries begin at __LDPGSZ, i.e., page 1.
68 */
69#define N_TXTADDR(ex) 8192
70
71/* Address of the bottom of the data segment. */
72#define N_DATADDR(ex) \
b36a531c
CT
73 (N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text : \
74 (((ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1))))
68608c33
CT
75
76/*
77 * N_TXTOFF is the offset within an a.out file of the first executable
78 * instruction: that is, the offset in the a.out of the byte that winds
79 * up at N_TXTADDR.
80 *
81 * On the SPARC, the a.out header is included in the executable when running
82 * a ZMAGIC file (but not for OMAGIC and NMAGIC).
83 */
84#define N_TXTOFF(ex) ((ex).a_magic == ZMAGIC ? 0 : sizeof(struct exec))
85
86/* Data segment offset. */
87#define N_DATOFF(ex) \
88 (N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \
b36a531c 89 (((ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1))))
68608c33
CT
90
91/* Symbol table offset. */
92#define N_SYMOFF(ex) \
93 (N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
94 (ex).a_drsize)
95
96/* String table offset. */
97#define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
98
99/* Description of the object file header (a.out format). */
100struct exec {
101 u_char a_dynamic:1; /* dynamically linked */
102 u_char a_toolversion:7;/* Sun toolset version XXX */
103
104#define MID_ZERO 0 /* unknown - implementation dependent */
105#define MID_SUN010 1 /* sun 68010/68020 binary */
106#define MID_SUN020 2 /* sun 68020-only binary */
107#define MID_SUN_SPARC 3 /* sparc binary */
108#define MID_HP200 200 /* hp200 (68010) BSD binary */
109#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
110#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
111#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
112 u_char a_mid; /* machine ID */
113
114#define OMAGIC 0407 /* old impure format */
115#define NMAGIC 0410 /* read-only text */
116#define ZMAGIC 0413 /* demand load format */
117 u_short a_magic; /* magic number */
118
119 u_long a_text; /* text segment size */
120 u_long a_data; /* initialized data size */
121 u_long a_bss; /* uninitialized data size */
122 u_long a_syms; /* symbol table size */
123 u_long a_entry; /* entry point */
124 u_long a_trsize; /* text relocation size */
125 u_long a_drsize; /* data relocation size */
126};
127#define a_machtype a_mid /* SUN compatibility */