xref: /original-bsd/sys/i386/include/exec.h (revision 8a8e718f)
1402357a8Sbostic /*-
2*8a8e718fSbostic  * Copyright (c) 1992, 1993
3*8a8e718fSbostic  *	The Regents of the University of California.  All rights reserved.
4402357a8Sbostic  *
5402357a8Sbostic  * %sccs.include.redist.c%
6402357a8Sbostic  *
7*8a8e718fSbostic  *	@(#)exec.h	8.1 (Berkeley) 06/11/93
8402357a8Sbostic  */
9402357a8Sbostic 
10402357a8Sbostic /* Size of a page in an object file. */
11402357a8Sbostic #define	__LDPGSZ	4096
12402357a8Sbostic 
13402357a8Sbostic /* Valid magic number check. */
14402357a8Sbostic #define	N_BADMAG(ex) \
15402357a8Sbostic 	((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \
16402357a8Sbostic 	    (ex).a_magic != ZMAGIC)
17402357a8Sbostic 
18402357a8Sbostic /* Address of the bottom of the text segment. */
19402357a8Sbostic #define N_TXTADDR(X)	0
20402357a8Sbostic 
21402357a8Sbostic /* Address of the bottom of the data segment. */
22402357a8Sbostic #define N_DATADDR(ex) \
23402357a8Sbostic 	(N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \
24402357a8Sbostic 	: __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
25402357a8Sbostic 
26402357a8Sbostic /* Text segment offset. */
27402357a8Sbostic #define	N_TXTOFF(ex) \
28402357a8Sbostic 	((ex).a_magic == ZMAGIC ? __LDPGSZ : sizeof(struct exec))
29402357a8Sbostic 
30402357a8Sbostic /* Data segment offset. */
31402357a8Sbostic #define	N_DATOFF(ex) \
32402357a8Sbostic 	(N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \
33402357a8Sbostic 	__LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
34402357a8Sbostic 
35402357a8Sbostic /* Symbol table offset. */
36402357a8Sbostic #define N_SYMOFF(ex) \
37402357a8Sbostic 	(N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
38402357a8Sbostic 	    (ex).a_drsize)
39402357a8Sbostic 
40402357a8Sbostic /* String table offset. */
41402357a8Sbostic #define	N_STROFF(ex) 	(N_SYMOFF(ex) + (ex).a_syms)
42402357a8Sbostic 
43402357a8Sbostic /* Description of the object file header (a.out format). */
44402357a8Sbostic struct exec {
45402357a8Sbostic #define	OMAGIC	0407		/* old impure format */
46402357a8Sbostic #define	NMAGIC	0410		/* read-only text */
47402357a8Sbostic #define	ZMAGIC	0413		/* demand load format */
48402357a8Sbostic 	long	a_magic;	/* magic number */
49402357a8Sbostic 
50402357a8Sbostic 	u_long	a_text;		/* text segment size */
51402357a8Sbostic 	u_long	a_data;		/* initialized data size */
52402357a8Sbostic 	u_long	a_bss;		/* uninitialized data size */
53402357a8Sbostic 	u_long	a_syms;		/* symbol table size */
54402357a8Sbostic 	u_long	a_entry;	/* entry point */
55402357a8Sbostic 	u_long	a_trsize;	/* text relocation size */
56402357a8Sbostic 	u_long	a_drsize;	/* data relocation size */
57402357a8Sbostic };
58