xref: /csrg-svn/sys/sparc/include/exec.h (revision 56209)
155119Storek /*
255119Storek  * Copyright (c) 1992 The Regents of the University of California.
355119Storek  * All rights reserved.
455119Storek  *
555119Storek  * This software was developed by the Computer Systems Engineering group
655119Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
755119Storek  * contributed to Berkeley.
855119Storek  *
955501Sbostic  * All advertising materials mentioning features or use of this software
1055501Sbostic  * must display the following acknowledgement:
1155501Sbostic  *	This product includes software developed by the University of
1255501Sbostic  *	California, Lawrence Berkeley Laboratories.
1355501Sbostic  *
1455119Storek  * %sccs.include.redist.c%
1555119Storek  *
16*56209Storek  *	@(#)exec.h	7.3 (Berkeley) 09/05/92
1755119Storek  *
18*56209Storek  * from: $Header: exec.h,v 1.8 92/09/06 01:35:41 torek Exp $
1955119Storek  */
2055119Storek 
2155119Storek /*
2255119Storek  * __LDPGSZ is the page size used by the linker and by exec().
2355119Storek  * It may be some multiple of the ``normal'' page size, so that, e.g.,
2455119Storek  * the same binaries can be run on hardware with different page sizes
2555119Storek  * that otherwise use the same instruction set.  It must be no larger
2655119Storek  * than CLBYTES (in param.h).
2755119Storek  */
2855119Storek #define	__LDPGSZ	8192
2955119Storek 
3055119Storek /* Valid magic number check. */
3155119Storek #define	N_BADMAG(ex) \
3255119Storek 	((ex).a_magic != ZMAGIC && (ex).a_magic != NMAGIC && \
3355119Storek 	    (ex).a_magic != OMAGIC)
3455119Storek 
3555119Storek /*
3655119Storek  * N_TXTADDR is the address of the first executable instruction: that is,
3755119Storek  * the place the pc could begin after an a.out is loaded, in order to run
3855119Storek  * the instructions in that a.out.  The pc will actually be set to ex.a_entry
3955119Storek  * but this is the first place it could possibly reference.
4055119Storek  *
4155119Storek  * On the SPARC, binaries begin at __LDPGSZ, i.e., page 1.
4255119Storek  */
4355119Storek #define N_TXTADDR(ex)	8192
4455119Storek 
4555119Storek /* Address of the bottom of the data segment. */
4655119Storek #define N_DATADDR(ex) \
47*56209Storek 	(N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text : \
48*56209Storek 	    (((ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1))))
4955119Storek 
5055119Storek /*
5155119Storek  * N_TXTOFF is the offset within an a.out file of the first executable
5255119Storek  * instruction: that is, the offset in the a.out of the byte that winds
5355119Storek  * up at N_TXTADDR.
5455119Storek  *
5555119Storek  * On the SPARC, the a.out header is included in the executable when running
5655119Storek  * a ZMAGIC file (but not for OMAGIC and NMAGIC).
5755119Storek  */
5855119Storek #define	N_TXTOFF(ex)	((ex).a_magic == ZMAGIC ? 0 : sizeof(struct exec))
5955119Storek 
6055119Storek /* Data segment offset. */
6155119Storek #define	N_DATOFF(ex) \
6255119Storek 	(N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \
63*56209Storek 	    (((ex).a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1))))
6455119Storek 
6555119Storek /* Symbol table offset. */
6655119Storek #define N_SYMOFF(ex) \
6755119Storek 	(N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
6855119Storek 	    (ex).a_drsize)
6955119Storek 
7055119Storek /* String table offset. */
7155119Storek #define	N_STROFF(ex) 	(N_SYMOFF(ex) + (ex).a_syms)
7255119Storek 
7355119Storek /* Description of the object file header (a.out format). */
7455119Storek struct exec {
7555119Storek 	u_char	a_dynamic:1;	/* dynamically linked */
7655119Storek 	u_char	a_toolversion:7;/* Sun toolset version	XXX */
7755119Storek 
7855119Storek #define	MID_ZERO	0	/* unknown - implementation dependent */
7955119Storek #define	MID_SUN010	1	/* sun 68010/68020 binary */
8055119Storek #define	MID_SUN020	2	/* sun 68020-only binary */
8155119Storek #define	MID_SUN_SPARC	3	/* sparc binary */
8255119Storek #define	MID_HP200	200	/* hp200 (68010) BSD binary */
8355119Storek #define	MID_HP300	300	/* hp300 (68020+68881) BSD binary */
8455119Storek #define	MID_HPUX	0x20C	/* hp200/300 HP-UX binary */
8555119Storek #define	MID_HPUX800     0x20B   /* hp800 HP-UX binary */
8655119Storek 	u_char	a_mid;		/* machine ID */
8755119Storek 
8855119Storek #define	OMAGIC	0407		/* old impure format */
8955119Storek #define	NMAGIC	0410		/* read-only text */
9055119Storek #define	ZMAGIC	0413		/* demand load format */
9155119Storek 	u_short	a_magic;	/* magic number */
9255119Storek 
9355119Storek 	u_long	a_text;		/* text segment size */
9455119Storek 	u_long	a_data;		/* initialized data size */
9555119Storek 	u_long	a_bss;		/* uninitialized data size */
9655119Storek 	u_long	a_syms;		/* symbol table size */
9755119Storek 	u_long	a_entry;	/* entry point */
9855119Storek 	u_long	a_trsize;	/* text relocation size */
9955119Storek 	u_long	a_drsize;	/* data relocation size */
10055119Storek };
10155119Storek #define	a_machtype	a_mid	/* SUN compatibility */
102