xref: /csrg-svn/sys/i386/include/exec.h (revision 53002)
1*53002Sbostic /*-
2*53002Sbostic  * Copyright (c) 1992 The Regents of the University of California.
3*53002Sbostic  * All rights reserved.
4*53002Sbostic  *
5*53002Sbostic  * %sccs.include.redist.c%
6*53002Sbostic  *
7*53002Sbostic  *	@(#)exec.h	7.1 (Berkeley) 03/18/92
8*53002Sbostic  */
9*53002Sbostic 
10*53002Sbostic /* Size of a page in an object file. */
11*53002Sbostic #define	__LDPGSZ	4096
12*53002Sbostic 
13*53002Sbostic /* Valid magic number check. */
14*53002Sbostic #define	N_BADMAG(ex) \
15*53002Sbostic 	((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \
16*53002Sbostic 	    (ex).a_magic != ZMAGIC)
17*53002Sbostic 
18*53002Sbostic /* Address of the bottom of the text segment. */
19*53002Sbostic #define N_TXTADDR(X)	0
20*53002Sbostic 
21*53002Sbostic /* Address of the bottom of the data segment. */
22*53002Sbostic #define N_DATADDR(ex) \
23*53002Sbostic 	(N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \
24*53002Sbostic 	: __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
25*53002Sbostic 
26*53002Sbostic /* Text segment offset. */
27*53002Sbostic #define	N_TXTOFF(ex) \
28*53002Sbostic 	((ex).a_magic == ZMAGIC ? __LDPGSZ : sizeof(struct exec))
29*53002Sbostic 
30*53002Sbostic /* Data segment offset. */
31*53002Sbostic #define	N_DATOFF(ex) \
32*53002Sbostic 	(N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \
33*53002Sbostic 	__LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
34*53002Sbostic 
35*53002Sbostic /* Symbol table offset. */
36*53002Sbostic #define N_SYMOFF(ex) \
37*53002Sbostic 	(N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
38*53002Sbostic 	    (ex).a_drsize)
39*53002Sbostic 
40*53002Sbostic /* String table offset. */
41*53002Sbostic #define	N_STROFF(ex) 	(N_SYMOFF(ex) + (ex).a_syms)
42*53002Sbostic 
43*53002Sbostic /* Description of the object file header (a.out format). */
44*53002Sbostic struct exec {
45*53002Sbostic #define	OMAGIC	0407		/* old impure format */
46*53002Sbostic #define	NMAGIC	0410		/* read-only text */
47*53002Sbostic #define	ZMAGIC	0413		/* demand load format */
48*53002Sbostic 	long	a_magic;	/* magic number */
49*53002Sbostic 
50*53002Sbostic 	u_long	a_text;		/* text segment size */
51*53002Sbostic 	u_long	a_data;		/* initialized data size */
52*53002Sbostic 	u_long	a_bss;		/* uninitialized data size */
53*53002Sbostic 	u_long	a_syms;		/* symbol table size */
54*53002Sbostic 	u_long	a_entry;	/* entry point */
55*53002Sbostic 	u_long	a_trsize;	/* text relocation size */
56*53002Sbostic 	u_long	a_drsize;	/* data relocation size */
57*53002Sbostic };
58