xref: /original-bsd/include/a.out.h (revision 46bf0326)
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.7 (Berkeley) 07/23/91
8  */
9 
10 #ifndef	_AOUT_H_
11 #define	_AOUT_H_
12 
13 #include <sys/exec.h>
14 
15 #if defined(hp300) || defined(i386)
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 #define N_TXTADDR(X)	0
29 
30 /* Address of the bottom of the data segment. */
31 #define N_DATADDR(ex) \
32 	(N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \
33 	: __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
34 
35 /* Text segment offset. */
36 #define	N_TXTOFF(ex) \
37 	((ex).a_magic == ZMAGIC ? __LDPGSZ : sizeof(struct exec))
38 
39 /* Data segment offset. */
40 #define	N_DATOFF(ex) \
41 	(N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text : \
42 	__LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
43 
44 /* Symbol table offset. */
45 #define N_SYMOFF(ex) \
46 	(N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
47 	    (ex).a_drsize)
48 
49 /* String table offset. */
50 #define	N_STROFF(ex) 	(N_SYMOFF(ex) + (ex).a_syms)
51 
52 /* Relocation format. */
53 struct relocation_info {
54 	int r_address;			/* offset in text or data segment */
55 	unsigned int r_symbolnum : 24,	/* ordinal number of add symbol */
56 			 r_pcrel :  1,	/* 1 if value should be pc-relative */
57 			r_length :  2,	/* log base 2 of value's width */
58 			r_extern :  1,	/* 1 if need to add symbol to value */
59 				 :  4;	/* reserved */
60 };
61 
62 #define _AOUT_INCLUDE_
63 #include <nlist.h>
64 
65 #endif /* !_AOUT_H_ */
66