xref: /csrg-svn/sys/i386/include/exec.h (revision 63359)
153002Sbostic /*-
2*63359Sbostic  * Copyright (c) 1992, 1993
3*63359Sbostic  *	The Regents of the University of California.  All rights reserved.
453002Sbostic  *
553002Sbostic  * %sccs.include.redist.c%
653002Sbostic  *
7*63359Sbostic  *	@(#)exec.h	8.1 (Berkeley) 06/11/93
853002Sbostic  */
953002Sbostic 
1053002Sbostic /* Size of a page in an object file. */
1153002Sbostic #define	__LDPGSZ	4096
1253002Sbostic 
1353002Sbostic /* Valid magic number check. */
1453002Sbostic #define	N_BADMAG(ex) \
1553002Sbostic 	((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \
1653002Sbostic 	    (ex).a_magic != ZMAGIC)
1753002Sbostic 
1853002Sbostic /* Address of the bottom of the text segment. */
1953002Sbostic #define N_TXTADDR(X)	0
2053002Sbostic 
2153002Sbostic /* Address of the bottom of the data segment. */
2253002Sbostic #define N_DATADDR(ex) \
2353002Sbostic 	(N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \
2453002Sbostic 	: __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
2553002Sbostic 
2653002Sbostic /* Text segment offset. */
2753002Sbostic #define	N_TXTOFF(ex) \
2853002Sbostic 	((ex).a_magic == ZMAGIC ? __LDPGSZ : sizeof(struct exec))
2953002Sbostic 
3053002Sbostic /* Data segment offset. */
3153002Sbostic #define	N_DATOFF(ex) \
3253002Sbostic 	(N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \
3353002Sbostic 	__LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
3453002Sbostic 
3553002Sbostic /* Symbol table offset. */
3653002Sbostic #define N_SYMOFF(ex) \
3753002Sbostic 	(N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
3853002Sbostic 	    (ex).a_drsize)
3953002Sbostic 
4053002Sbostic /* String table offset. */
4153002Sbostic #define	N_STROFF(ex) 	(N_SYMOFF(ex) + (ex).a_syms)
4253002Sbostic 
4353002Sbostic /* Description of the object file header (a.out format). */
4453002Sbostic struct exec {
4553002Sbostic #define	OMAGIC	0407		/* old impure format */
4653002Sbostic #define	NMAGIC	0410		/* read-only text */
4753002Sbostic #define	ZMAGIC	0413		/* demand load format */
4853002Sbostic 	long	a_magic;	/* magic number */
4953002Sbostic 
5053002Sbostic 	u_long	a_text;		/* text segment size */
5153002Sbostic 	u_long	a_data;		/* initialized data size */
5253002Sbostic 	u_long	a_bss;		/* uninitialized data size */
5353002Sbostic 	u_long	a_syms;		/* symbol table size */
5453002Sbostic 	u_long	a_entry;	/* entry point */
5553002Sbostic 	u_long	a_trsize;	/* text relocation size */
5653002Sbostic 	u_long	a_drsize;	/* data relocation size */
5753002Sbostic };
58