xref: /original-bsd/sys/sys/exec.h (revision 363e6ee6)
1 /*-
2  * Copyright (c) 1982, 1986 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)exec.h	7.7 (Berkeley) 11/20/91
8  */
9 
10 #ifndef	_EXEC_H_
11 #define	_EXEC_H_
12 
13 #ifndef COFF
14 /* Header prepended to each a.out file. */
15 struct exec {
16 #if !defined(vax) && !defined(tahoe) && !defined(i386)
17 unsigned short	a_mid;		/* machine ID */
18 unsigned short	a_magic;	/* magic number */
19 #else
20 	 long	a_magic;	/* magic number */
21 #endif
22 unsigned long	a_text;		/* text segment size */
23 unsigned long	a_data;		/* initialized data size */
24 unsigned long	a_bss;		/* uninitialized data size */
25 unsigned long	a_syms;		/* symbol table size */
26 unsigned long	a_entry;	/* entry point */
27 unsigned long	a_trsize;	/* text relocation size */
28 unsigned long	a_drsize;	/* data relocation size */
29 };
30 #define	a_machtype	a_mid	/* SUN compatibility */
31 #endif /* COFF */
32 
33 /* a_magic */
34 #define	OMAGIC		0407	/* old impure format */
35 #define	NMAGIC		0410	/* read-only text */
36 #define	ZMAGIC		0413	/* demand load format */
37 
38 #if !defined(vax) && !defined(tahoe) && !defined(i386)
39 /* a_mid */
40 #define	MID_ZERO	0	/* unknown - implementation dependent */
41 #define	MID_SUN010	1	/* sun 68010/68020 binary */
42 #define	MID_SUN020	2	/* sun 68020-only binary */
43 #define	MID_HP200	200	/* hp200 (68010) BSD binary */
44 #define	MID_HP300	300	/* hp300 (68020+68881) BSD binary */
45 #define	MID_HPUX	0x20C	/* hp200/300 HP-UX binary */
46 #define	MID_HPUX800     0x20B   /* hp800 HP-UX binary */
47 #endif
48 
49 #ifdef COFF
50 /*
51  * procAOUT.h --
52  *
53  *	The a.out format for an object file.
54  *
55  * Copyright (C) 1989 Digital Equipment Corporation.
56  * Permission to use, copy, modify, and distribute this software and
57  * its documentation for any purpose and without fee is hereby granted,
58  * provided that the above copyright notice appears in all copies.
59  * Digital Equipment Corporation makes no representations about the
60  * suitability of this software for any purpose.  It is provided "as is"
61  * without express or implied warranty.
62  *
63  * $Header: /sprite/src/kernel/proc/ds3100.md/RCS/procMach.h,v 9.3 90/02/20 15:35:50 shirriff Exp $ SPRITE (Berkeley)
64  */
65 
66 /*
67  * File header magic number.
68  */
69 #define	COFF_MAGIC	0x0162
70 
71 /*
72  * Description of the file.
73  */
74 typedef struct {
75     unsigned short	magic;		/* The magic number. */
76     unsigned short	numSections;	/* The number of sections. */
77     long		timeDateStamp;	/* Time and date stamp. */
78     long		symPtr;		/* File pointer to symbolic header. */
79     long		numSyms;	/* Size of symbolic header. */
80     unsigned short	optHeader;	/* Size of optional header. */
81     unsigned short	flags;		/* Flags. */
82 } ProcFileHeader;
83 
84 /*
85  * A.out header.
86  */
87 typedef struct {
88     short		magic;		/* Magic number. */
89     short		verStamp;	/* Version stamp. */
90     long		codeSize;	/* Code size in bytes. */
91     long		heapSize;	/* Initialized data size in bytes. */
92     long		bssSize;	/* Uninitialized data size in bytes. */
93     long		entry;		/* Entry point. */
94     long		codeStart;	/* Base of code used for this file. */
95     long		heapStart;	/* Base of heap used for this file. */
96     long		bssStart;	/* Base of bss used for this file. */
97     long		gprMask;	/* General purpose register mask. */
98     long		cprMask[4];	/* Co-processor register masks. */
99     long		gpValue;	/* The gp value for this object. */
100 } ProcAOUTHeader;
101 
102 /*
103  * Section header.
104  */
105 typedef struct {
106     char		name[8];	/* Section name. */
107     long		physAddr;	/* Section physical address. */
108     long		virtAddr;	/* Section virtual address. */
109     long		size;		/* Section size. */
110     long		sectionPtr;	/* File pointer to section data.  */
111     long		relocPtr;	/* File pointer to relocation data.  */
112     long		lnnoPtr;	/* File pointer to gp tables. */
113     unsigned short	numReloc;	/* Number of relocation entries. */
114     unsigned short	numLnno;	/* Numberof gp tables. */
115     long		flags;		/* Section flags. */
116 } ProcSectionHeader;
117 
118 /*
119  * The header at the beginning of each file.
120  */
121 struct exec {
122     ProcFileHeader	ex_fhdr;
123     ProcAOUTHeader	ex_aout;
124 };
125 #define a_magic	ex_aout.magic
126 #define a_text	ex_aout.codeSize
127 #define a_data	ex_aout.heapSize
128 #define a_bss	ex_aout.bssSize
129 #define a_entry	ex_aout.entry
130 
131 /*
132  * Determine the offset of the text segment in the file, given the header.
133  * (This is the same function as N_TXTOFF)
134  */
135 #define N_TXTOFF(hdr) \
136     ( ((hdr).ex_aout.magic == ZMAGIC) ? 0 : \
137 	((sizeof(struct exec) + \
138 	    (hdr).ex_fhdr.numSections*sizeof(ProcSectionHeader) + \
139 	    ((hdr).ex_aout.verStamp < 23 ? 7 : 15)) & \
140 		~((long)(((hdr).ex_aout.verStamp < 23 ? 7 : 15))) ) )
141 
142 #define N_DATAOFF(x) \
143     (N_TXTOFF(x) + (x).ex_aout.codeSize)
144 
145 #endif /* COFF */
146 #endif /* !_EXEC_H_ */
147