xref: /original-bsd/include/a.out.h (revision 37492ebb)
1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)a.out.h	5.8 (Berkeley) 09/06/91
8  */
9 
10 #ifndef	_AOUT_H_
11 #define	_AOUT_H_
12 
13 #include <sys/exec.h>
14 
15 #if defined(hp300) || defined(i386) || defined(mips)
16 #define	__LDPGSZ	4096
17 #endif
18 #if defined(tahoe) || defined(vax)
19 #define	__LDPGSZ	1024
20 #endif
21 
22 /* Valid magic number check. */
23 #define	N_BADMAG(ex) \
24 	((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \
25 	    (ex).a_magic != ZMAGIC)
26 
27 /* Address of the bottom of the text segment. */
28 #ifndef mips
29 #define N_TXTADDR(X)	0
30 
31 /* Address of the bottom of the data segment. */
32 #define N_DATADDR(ex) \
33 	(N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \
34 	: __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
35 
36 /* Text segment offset. */
37 #define	N_TXTOFF(ex) \
38 	((ex).a_magic == ZMAGIC ? __LDPGSZ : sizeof(struct exec))
39 
40 /* Data segment offset. */
41 #define	N_DATOFF(ex) \
42 	(N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \
43 	__LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
44 
45 /* Symbol table offset. */
46 #define N_SYMOFF(ex) \
47 	(N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
48 	    (ex).a_drsize)
49 
50 /* String table offset. */
51 #define	N_STROFF(ex) 	(N_SYMOFF(ex) + (ex).a_syms)
52 
53 /* Relocation format. */
54 struct relocation_info {
55 	int r_address;			/* offset in text or data segment */
56 	unsigned int r_symbolnum : 24,	/* ordinal number of add symbol */
57 			 r_pcrel :  1,	/* 1 if value should be pc-relative */
58 			r_length :  2,	/* log base 2 of value's width */
59 			r_extern :  1,	/* 1 if need to add symbol to value */
60 				 :  4;	/* reserved */
61 };
62 #else /* mips */
63 #define N_TXTADDR(X)	0x400000
64 #endif /* mips */
65 
66 #define _AOUT_INCLUDE_
67 #include <nlist.h>
68 
69 #endif /* !_AOUT_H_ */
70