Can now load the entire executable, doesn't run
[userspace_emu.git] / x_exec.h
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/10/93
34  */
35
36 /* note: this file normally goes in the machine-specific dir and is included
37  * from the generic file, hence doesn't normally have multi include protection
38  */
39 #ifndef x_EXEC_H
40 #define x_EXEC_H
41
42 #include <endian.h>
43 #include "xify.h"
44
45 /* Size of a page in an object file. */
46 #define x___LDPGSZ      4096
47
48 /* Valid magic number check. */
49 #define x_N_BADMAG(x_ex) \
50         ((x_ex).x_a_magic != x_NMAGIC && (x_ex).x_a_magic != x_OMAGIC && \
51             (x_ex).x_a_magic != x_ZMAGIC)
52
53 /* Address of the bottom of the text segment. */
54 #define x_N_TXTADDR(x_X)        0
55
56 /* Address of the bottom of the data segment. */
57 #define x_N_DATADDR(x_ex) \
58         (x_N_TXTADDR(x_ex) + ((x_ex).x_a_magic == x_OMAGIC ? (x_ex).x_a_text \
59         : x___LDPGSZ + ((x_ex).x_a_text - 1 & ~(x___LDPGSZ - 1))))
60
61 /* Text segment offset. */
62 #define x_N_TXTOFF(x_ex) \
63         ((x_ex).x_a_magic == x_ZMAGIC ? x___LDPGSZ : sizeof(struct x_exec))
64
65 /* Data segment offset. */
66 #define x_N_DATOFF(x_ex) \
67         (x_N_TXTOFF(x_ex) + ((x_ex).x_a_magic != x_ZMAGIC ? (x_ex).x_a_text : \
68         x___LDPGSZ + ((x_ex).x_a_text - 1 & ~(x___LDPGSZ - 1))))
69
70 /* Symbol table offset. */
71 #define x_N_SYMOFF(x_ex) \
72         (x_N_TXTOFF(x_ex) + (x_ex).x_a_text + (x_ex).x_a_data + (x_ex).x_a_trsize + \
73             (x_ex).x_a_drsize)
74
75 /* String table offset. */
76 #define x_N_STROFF(x_ex)        (x_N_SYMOFF(x_ex) + (x_ex).x_a_syms)
77
78 /* Description of the object file header (a.out format). */
79 struct x_exec {
80 #if __BYTE_ORDER == __LITTLE_ENDIAN
81         x_u_long        x_a_drsize;     /* data relocation size */
82         x_u_long        x_a_trsize;     /* text relocation size */
83         x_u_long        x_a_entry;      /* entry point */
84         x_u_long        x_a_syms;               /* symbol table size */
85         x_u_long        x_a_bss;                /* uninitialized data size */
86         x_u_long        x_a_data;               /* initialized data size */
87         x_u_long        x_a_text;               /* text segment size */
88
89         x_u_short       x_a_magic;      /* magic number */
90 #define x_ZMAGIC        0413            /* demand load format */
91 #define x_NMAGIC        0410            /* read-only text */
92 #define x_OMAGIC        0407            /* old impure format */
93
94         x_u_short       x_a_mid;                /* machine ID */
95 #define x_MID_HPUX800     0x20B   /* hp800 HP-UX binary */
96 #define x_MID_HPUX      0x20C   /* hp200/300 HP-UX binary */
97 #define x_MID_HP300     300     /* hp300 (68020+68881) BSD binary */
98 #define x_MID_HP200     200     /* hp200 (68010) BSD binary */
99 #define x_MID_SUN_SPARC 3       /* sparc binary */
100 #define x_MID_SUN020    2       /* sun 68020-only binary */
101 #define x_MID_SUN010    1       /* sun 68010/68020 binary */
102 #define x_MID_ZERO      0       /* unknown - implementation dependent */
103 #else
104 #define x_MID_ZERO      0       /* unknown - implementation dependent */
105 #define x_MID_SUN010    1       /* sun 68010/68020 binary */
106 #define x_MID_SUN020    2       /* sun 68020-only binary */
107 #define x_MID_SUN_SPARC 3       /* sparc binary */
108 #define x_MID_HP200     200     /* hp200 (68010) BSD binary */
109 #define x_MID_HP300     300     /* hp300 (68020+68881) BSD binary */
110 #define x_MID_HPUX      0x20C   /* hp200/300 HP-UX binary */
111 #define x_MID_HPUX800     0x20B   /* hp800 HP-UX binary */
112         x_u_short       x_a_mid;                /* machine ID */
113
114 #define x_OMAGIC        0407            /* old impure format */
115 #define x_NMAGIC        0410            /* read-only text */
116 #define x_ZMAGIC        0413            /* demand load format */
117         x_u_short       x_a_magic;      /* magic number */
118
119         x_u_long        x_a_text;               /* text segment size */
120         x_u_long        x_a_data;               /* initialized data size */
121         x_u_long        x_a_bss;                /* uninitialized data size */
122         x_u_long        x_a_syms;               /* symbol table size */
123         x_u_long        x_a_entry;      /* entry point */
124         x_u_long        x_a_trsize;     /* text relocation size */
125         x_u_long        x_a_drsize;     /* data relocation size */
126 #endif
127 };
128 #define x_a_machtype    x_a_mid /* SUN compatibility */
129
130 #endif