]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/kgzip/i386_a.out.h
This commit was generated by cvs2svn to compensate for changes in r120489,
[FreeBSD/FreeBSD.git] / usr.sbin / kgzip / i386_a.out.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  *      from: @(#)exec.h        8.1 (Berkeley) 6/11/93
34  * from: FreeBSD: src/sys/sys/imgact_aout.h,v 1.18 2002/09/05 07:54:03 bde Exp $
35  * $FreeBSD$
36  */
37
38 #ifndef _I386_AOUT_H_
39 #define _I386_AOUT_H_
40
41 #include <sys/types.h>
42 #include "endian.h"
43
44 #define __I386_LDPGSZ   4096
45
46 #define I386_N_GETMAGIC(ex) \
47         ( LE32TOH((ex).a_midmag) & 0xffff )
48 #define I386_N_SETMAGIC(ex,mag,mid,flag) \
49         ( (ex).a_midmag = HTOLE32((((flag) & 0x3f) <<26) | \
50         (((mid) & 0x03ff) << 16) | \
51         ((mag) & 0xffff)) )
52
53 #define I386_N_ALIGN(ex,x) \
54         (I386_N_GETMAGIC(ex) == ZMAGIC || I386_N_GETMAGIC(ex) == QMAGIC ? \
55          ((x) + __I386_LDPGSZ - 1) & ~(uint32_t)(__I386_LDPGSZ - 1) : (x))
56
57 /* Valid magic number check. */
58 #define I386_N_BADMAG(ex) \
59         (I386_N_GETMAGIC(ex) != OMAGIC && I386_N_GETMAGIC(ex) != NMAGIC && \
60          I386_N_GETMAGIC(ex) != ZMAGIC && I386_N_GETMAGIC(ex) != QMAGIC)
61
62
63 /* Address of the bottom of the text segment. */
64 /*
65  * This can not be done right.  Abuse a_entry in some cases to handle kernels.
66  */
67 #define I386_N_TXTADDR(ex) \
68         ((I386_N_GETMAGIC(ex) == OMAGIC || I386_N_GETMAGIC(ex) == NMAGIC || \
69         I386_N_GETMAGIC(ex) == ZMAGIC) ? \
70         (LE32TOH((ex).a_entry) < LE32TOH((ex).a_text) ? 0 : \
71         LE32TOH((ex).a_entry) & ~__I386_LDPGSZ) : __I386_LDPGSZ)
72
73 /* Address of the bottom of the data segment. */
74 #define I386_N_DATADDR(ex) \
75         I386_N_ALIGN(ex, I386_N_TXTADDR(ex) + LE32TOH((ex).a_text))
76
77 /* Text segment offset. */
78 #define I386_N_TXTOFF(ex) \
79         (I386_N_GETMAGIC(ex) == ZMAGIC ? __I386_LDPGSZ : \
80         (I386_N_GETMAGIC(ex) == QMAGIC ? 0 : sizeof(struct exec)))
81
82 /* Data segment offset. */
83 #define I386_N_DATOFF(ex) \
84         I386_N_ALIGN(ex, I386_N_TXTOFF(ex) + LE32TOH((ex).a_text))
85
86 /* Relocation table offset. */
87 #define I386_N_RELOFF(ex) \
88         I386_N_ALIGN(ex, I386_N_DATOFF(ex) + LE32TOH((ex).a_data))
89
90 /* Symbol table offset. */
91 #define I386_N_SYMOFF(ex) \
92         (I386_N_RELOFF(ex) + LE32TOH((ex).a_trsize) + LE32TOH((ex).a_drsize))
93
94 /* String table offset. */
95 #define I386_N_STROFF(ex)       (I386_N_SYMOFF(ex) + LE32TOH((ex).a_syms))
96
97 /*
98  * Header prepended to each a.out file.
99  * only manipulate the a_midmag field via the
100  * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
101  */
102
103 struct i386_exec {
104      uint32_t   a_midmag;       /* flags<<26 | mid<<16 | magic */
105      uint32_t   a_text;         /* text segment size */
106      uint32_t   a_data;         /* initialized data size */
107      uint32_t   a_bss;          /* uninitialized data size */
108      uint32_t   a_syms;         /* symbol table size */
109      uint32_t   a_entry;        /* entry point */
110      uint32_t   a_trsize;       /* text relocation size */
111      uint32_t   a_drsize;       /* data relocation size */
112 };
113 #define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */
114
115 /* a_magic */
116 #define OMAGIC          0407    /* old impure format */
117 #define NMAGIC          0410    /* read-only text */
118 #define ZMAGIC          0413    /* demand load format */
119 #define QMAGIC          0314    /* "compact" demand load format */
120
121 /* a_mid */
122 #define MID_ZERO        0       /* unknown - implementation dependent */
123 #define MID_SUN010      1       /* sun 68010/68020 binary */
124 #define MID_SUN020      2       /* sun 68020-only binary */
125 #define MID_I386        134     /* i386 BSD binary */
126 #define MID_SPARC       138     /* sparc */
127 #define MID_HP200       200     /* hp200 (68010) BSD binary */
128 #define MID_HP300       300     /* hp300 (68020+68881) BSD binary */
129 #define MID_HPUX        0x20C   /* hp200/300 HP-UX binary */
130 #define MID_HPUX800     0x20B   /* hp800 HP-UX binary */
131
132 /*
133  * a_flags
134  */
135 #define EX_PIC          0x10    /* contains position independent code */
136 #define EX_DYNAMIC      0x20    /* contains run-time link-edit info */
137 #define EX_DPMASK       0x30    /* mask for the above */
138
139 #endif /* !_I386_AOUT_H_ */