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