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