xref: /csrg-svn/sys/news3400/include/exec.h (revision 53899)
1*53899Smckusick /*-
2*53899Smckusick  * Copyright (c) 1992 The Regents of the University of California.
3*53899Smckusick  * All rights reserved.
4*53899Smckusick  *
5*53899Smckusick  * %sccs.include.redist.c%
6*53899Smckusick  *
7*53899Smckusick  *	@(#)exec.h	7.1 (Berkeley) 06/04/92
8*53899Smckusick  */
9*53899Smckusick 
10*53899Smckusick /*
11*53899Smckusick  * Portions of this file are subject to the following copyright notice:
12*53899Smckusick  *
13*53899Smckusick  * Copyright (C) 1989 Digital Equipment Corporation.
14*53899Smckusick  * Permission to use, copy, modify, and distribute this software and
15*53899Smckusick  * its documentation for any purpose and without fee is hereby granted,
16*53899Smckusick  * provided that the above copyright notice appears in all copies.
17*53899Smckusick  * Digital Equipment Corporation makes no representations about the
18*53899Smckusick  * suitability of this software for any purpose.  It is provided "as is"
19*53899Smckusick  * without express or implied warranty.
20*53899Smckusick  */
21*53899Smckusick 
22*53899Smckusick /*
23*53899Smckusick  * /sprite/src/kernel/proc/ds3100.md/RCS/procMach.h,v 9.3 90/02/20 15:35:50
24*53899Smckusick  * shirriff Exp $ SPRITE (Berkeley)
25*53899Smckusick  */
26*53899Smckusick 
27*53899Smckusick /* Size of a page in an object file. */
28*53899Smckusick #define	__LDPGSZ	4096
29*53899Smckusick 
30*53899Smckusick /* Valid magic number check. */
31*53899Smckusick #define	N_BADMAG(ex) \
32*53899Smckusick 	((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \
33*53899Smckusick 	    (ex).a_magic != ZMAGIC)
34*53899Smckusick 
35*53899Smckusick /* Address of the bottom of the text segment. */
36*53899Smckusick #define N_TXTADDR(ex)	0x400000
37*53899Smckusick 
38*53899Smckusick /* Address of the bottom of the data segment. */
39*53899Smckusick /* NOT DEFINED FOR THE MIPS. */
40*53899Smckusick 
41*53899Smckusick /* Text segment offset. */
42*53899Smckusick #define	__N_TXTOFF_ROUND(ex) \
43*53899Smckusick 	((ex).ex_aout.verStamp < 23 ? 7 : 15)
44*53899Smckusick #define	N_TXTOFF(ex) \
45*53899Smckusick 	((ex).ex_aout.magic == ZMAGIC ? 0 : (sizeof(struct exec) + \
46*53899Smckusick 	    (ex).ex_fhdr.numSections * sizeof(ProcSectionHeader) + \
47*53899Smckusick 	    __N_TXTOFF_ROUND(ex)) & ~__N_TXTOFF_ROUND(ex))
48*53899Smckusick 
49*53899Smckusick /* Data segment offset. */
50*53899Smckusick #define N_DATAOFF(ex) \
51*53899Smckusick 	(N_TXTOFF(ex) + (ex).ex_aout.codeSize)
52*53899Smckusick 
53*53899Smckusick /* Symbol table offset. */
54*53899Smckusick #define	N_SYMOFF(ex) \
55*53899Smckusick 	((ex).symPtr)
56*53899Smckusick 
57*53899Smckusick /* String table offset. */
58*53899Smckusick /* NOT DEFINED FOR THE MIPS. */
59*53899Smckusick 
60*53899Smckusick /*
61*53899Smckusick  * XXX
62*53899Smckusick  * The ProcFileHeader structure and the ProcAOUTHeader structure should be
63*53899Smckusick  * folded together into a single struct exec.
64*53899Smckusick  */
65*53899Smckusick 
66*53899Smckusick /* Description of the COFF section. */
67*53899Smckusick typedef struct {
68*53899Smckusick #if BYTE_ORDER == BIG_ENDIAN
69*53899Smckusick #	define	COFF_MAGIC	0x0160
70*53899Smckusick #else
71*53899Smckusick #	define	COFF_MAGIC	0x0162
72*53899Smckusick #endif
73*53899Smckusick 	u_short	magic;		/* The magic number. */
74*53899Smckusick 
75*53899Smckusick 	u_short	numSections;	/* The number of sections. */
76*53899Smckusick 	long	timeDateStamp;	/* Time and date stamp. */
77*53899Smckusick 	long	symPtr;		/* File pointer to symbolic header. */
78*53899Smckusick 	long	numSyms;	/* Size of symbolic header. */
79*53899Smckusick 	u_short	optHeader;	/* Size of optional header. */
80*53899Smckusick 	u_short	flags;		/* Flags. */
81*53899Smckusick } ProcFileHeader;
82*53899Smckusick 
83*53899Smckusick /* Description of the a.out section. */
84*53899Smckusick typedef struct {
85*53899Smckusick #define	OMAGIC	0407		/* old impure format */
86*53899Smckusick #define	NMAGIC	0410		/* read-only text */
87*53899Smckusick #define	ZMAGIC	0413		/* demand load format */
88*53899Smckusick 	short	magic;		/* Magic number. */
89*53899Smckusick 
90*53899Smckusick 	short	verStamp;	/* Version stamp. */
91*53899Smckusick 	long	codeSize;	/* Code size in bytes. */
92*53899Smckusick 	long	heapSize;	/* Initialized data size in bytes. */
93*53899Smckusick 	long	bssSize;	/* Uninitialized data size in bytes. */
94*53899Smckusick 	long	entry;		/* Entry point. */
95*53899Smckusick 	long	codeStart;	/* Base of code used for this file. */
96*53899Smckusick 	long	heapStart;	/* Base of heap used for this file. */
97*53899Smckusick 	long	bssStart;	/* Base of bss used for this file. */
98*53899Smckusick 	long	gprMask;	/* General purpose register mask. */
99*53899Smckusick 	long	cprMask[4];	/* Co-processor register masks. */
100*53899Smckusick 	long	gpValue;	/* The gp value for this object. */
101*53899Smckusick } ProcAOUTHeader;
102*53899Smckusick 
103*53899Smckusick /* Section header. */
104*53899Smckusick typedef struct {
105*53899Smckusick 	char	name[8];	/* Section name. */
106*53899Smckusick 	long	physAddr;	/* Section physical address. */
107*53899Smckusick 	long	virtAddr;	/* Section virtual address. */
108*53899Smckusick 	long	size;		/* Section size. */
109*53899Smckusick 	long	sectionPtr;	/* File pointer to section data. */
110*53899Smckusick 	long	relocPtr;	/* File pointer to relocation data. */
111*53899Smckusick 	long	lnnoPtr;	/* File pointer to gp tables. */
112*53899Smckusick 	u_short	numReloc;	/* Number of relocation entries. */
113*53899Smckusick 	u_short	numLnno;	/* Numberof gp tables. */
114*53899Smckusick 	long	flags;		/* Section flags. */
115*53899Smckusick } ProcSectionHeader;
116*53899Smckusick 
117*53899Smckusick /* Description of the object file header. */
118*53899Smckusick struct exec {
119*53899Smckusick 	ProcFileHeader	ex_fhdr;
120*53899Smckusick 	ProcAOUTHeader	ex_aout;
121*53899Smckusick };
122*53899Smckusick #define a_magic	ex_aout.magic
123*53899Smckusick #define a_text	ex_aout.codeSize
124*53899Smckusick #define a_data	ex_aout.heapSize
125*53899Smckusick #define a_bss	ex_aout.bssSize
126*53899Smckusick #define a_entry	ex_aout.entry
127*53899Smckusick #define a_syms	ex_fhdr.numSyms
128