xref: /freebsd-12.1/sys/amd64/include/exec.h (revision 6cda32c0)
1*6cda32c0SRodney W. Grimes /*-
2*6cda32c0SRodney W. Grimes  * Copyright (c) 1992, 1993
3*6cda32c0SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
4*6cda32c0SRodney W. Grimes  *
5*6cda32c0SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
6*6cda32c0SRodney W. Grimes  * modification, are permitted provided that the following conditions
7*6cda32c0SRodney W. Grimes  * are met:
8*6cda32c0SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
9*6cda32c0SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
10*6cda32c0SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
11*6cda32c0SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
12*6cda32c0SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
13*6cda32c0SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
14*6cda32c0SRodney W. Grimes  *    must display the following acknowledgement:
15*6cda32c0SRodney W. Grimes  *	This product includes software developed by the University of
16*6cda32c0SRodney W. Grimes  *	California, Berkeley and its contributors.
17*6cda32c0SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
18*6cda32c0SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
19*6cda32c0SRodney W. Grimes  *    without specific prior written permission.
20*6cda32c0SRodney W. Grimes  *
21*6cda32c0SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22*6cda32c0SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23*6cda32c0SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24*6cda32c0SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25*6cda32c0SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26*6cda32c0SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27*6cda32c0SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28*6cda32c0SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29*6cda32c0SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30*6cda32c0SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*6cda32c0SRodney W. Grimes  * SUCH DAMAGE.
32*6cda32c0SRodney W. Grimes  *
33*6cda32c0SRodney W. Grimes  *	@(#)exec.h	8.1 (Berkeley) 6/11/93
34*6cda32c0SRodney W. Grimes  */
35*6cda32c0SRodney W. Grimes 
36*6cda32c0SRodney W. Grimes /* Size of a page in an object file. */
37*6cda32c0SRodney W. Grimes #define	__LDPGSZ	4096
38*6cda32c0SRodney W. Grimes 
39*6cda32c0SRodney W. Grimes /* Valid magic number check. */
40*6cda32c0SRodney W. Grimes #define	N_BADMAG(ex) \
41*6cda32c0SRodney W. Grimes 	((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \
42*6cda32c0SRodney W. Grimes 	    (ex).a_magic != ZMAGIC)
43*6cda32c0SRodney W. Grimes 
44*6cda32c0SRodney W. Grimes /* Address of the bottom of the text segment. */
45*6cda32c0SRodney W. Grimes #define N_TXTADDR(X)	0
46*6cda32c0SRodney W. Grimes 
47*6cda32c0SRodney W. Grimes /* Address of the bottom of the data segment. */
48*6cda32c0SRodney W. Grimes #define N_DATADDR(ex) \
49*6cda32c0SRodney W. Grimes 	(N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \
50*6cda32c0SRodney W. Grimes 	: __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
51*6cda32c0SRodney W. Grimes 
52*6cda32c0SRodney W. Grimes /* Text segment offset. */
53*6cda32c0SRodney W. Grimes #define	N_TXTOFF(ex) \
54*6cda32c0SRodney W. Grimes 	((ex).a_magic == ZMAGIC ? __LDPGSZ : sizeof(struct exec))
55*6cda32c0SRodney W. Grimes 
56*6cda32c0SRodney W. Grimes /* Data segment offset. */
57*6cda32c0SRodney W. Grimes #define	N_DATOFF(ex) \
58*6cda32c0SRodney W. Grimes 	(N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \
59*6cda32c0SRodney W. Grimes 	__LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
60*6cda32c0SRodney W. Grimes 
61*6cda32c0SRodney W. Grimes /* Symbol table offset. */
62*6cda32c0SRodney W. Grimes #define N_SYMOFF(ex) \
63*6cda32c0SRodney W. Grimes 	(N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
64*6cda32c0SRodney W. Grimes 	    (ex).a_drsize)
65*6cda32c0SRodney W. Grimes 
66*6cda32c0SRodney W. Grimes /* String table offset. */
67*6cda32c0SRodney W. Grimes #define	N_STROFF(ex) 	(N_SYMOFF(ex) + (ex).a_syms)
68*6cda32c0SRodney W. Grimes 
69*6cda32c0SRodney W. Grimes /* Description of the object file header (a.out format). */
70*6cda32c0SRodney W. Grimes struct exec {
71*6cda32c0SRodney W. Grimes #define	OMAGIC	0407		/* old impure format */
72*6cda32c0SRodney W. Grimes #define	NMAGIC	0410		/* read-only text */
73*6cda32c0SRodney W. Grimes #define	ZMAGIC	0413		/* demand load format */
74*6cda32c0SRodney W. Grimes 	long	a_magic;	/* magic number */
75*6cda32c0SRodney W. Grimes 
76*6cda32c0SRodney W. Grimes 	u_long	a_text;		/* text segment size */
77*6cda32c0SRodney W. Grimes 	u_long	a_data;		/* initialized data size */
78*6cda32c0SRodney W. Grimes 	u_long	a_bss;		/* uninitialized data size */
79*6cda32c0SRodney W. Grimes 	u_long	a_syms;		/* symbol table size */
80*6cda32c0SRodney W. Grimes 	u_long	a_entry;	/* entry point */
81*6cda32c0SRodney W. Grimes 	u_long	a_trsize;	/* text relocation size */
82*6cda32c0SRodney W. Grimes 	u_long	a_drsize;	/* data relocation size */
83*6cda32c0SRodney W. Grimes };
84