xref: /original-bsd/include/a.out.h (revision 3588a932)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)a.out.h	5.4 (Berkeley) 12/17/90
7  */
8 
9 /*
10  * Definitions of the a.out header
11  * and magic numbers are shared with
12  * the kernel.
13  */
14 #include <sys/exec.h>
15 
16 /*
17  * Macros which take exec structures as arguments and tell whether
18  * the file has a reasonable magic number or offsets to text|symbols|strings.
19  */
20 #define	N_BADMAG(x) \
21     (((x).a_magic)!=OMAGIC && ((x).a_magic)!=NMAGIC && ((x).a_magic)!=ZMAGIC)
22 
23 #if defined(vax) || defined(tahoe)
24 #define	N_TXTOFF(x) \
25 	((x).a_magic == ZMAGIC ? 1024 : sizeof (struct exec))
26 #endif
27 
28 #if defined(hp300) || defined(i386)
29 #define	N_TXTOFF(x) \
30 	((x).a_magic == ZMAGIC ? 4096 : sizeof (struct exec))
31 #endif
32 
33 #define N_SYMOFF(x) \
34 	(N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize)
35 
36 #define	N_STROFF(x) \
37 	(N_SYMOFF(x) + (x).a_syms)
38 
39 /*
40  * Format of a relocation datum.
41  */
42 struct relocation_info {
43 	int	r_address;	/* address which is relocated */
44 unsigned int	r_symbolnum:24,	/* local symbol ordinal */
45 		r_pcrel:1, 	/* was relocated pc relative already */
46 		r_length:2,	/* 0=byte, 1=word, 2=long */
47 		r_extern:1,	/* does not include value of sym referenced */
48 		:4;		/* nothing, yet */
49 };
50 
51 /*
52  * Format of a symbol table entry; this file is included by <a.out.h>
53  * and should be used if you aren't interested the a.out header
54  * or relocation information.
55  */
56 struct	nlist {
57 	union {
58 		char	*n_name;	/* for use when in-core */
59 		long	n_strx;		/* index into file string table */
60 	} n_un;
61 unsigned char	n_type;		/* type flag, i.e. N_TEXT etc; see below */
62 	char	n_other;	/* unused */
63 	short	n_desc;		/* see <stab.h> */
64 unsigned long	n_value;	/* value of this symbol (or sdb offset) */
65 };
66 #define	n_hash	n_desc		/* used internally by ld */
67 
68 /*
69  * Simple values for n_type.
70  */
71 #define	N_UNDF	0x0		/* undefined */
72 #define	N_ABS	0x2		/* absolute */
73 #define	N_TEXT	0x4		/* text */
74 #define	N_DATA	0x6		/* data */
75 #define	N_BSS	0x8		/* bss */
76 #define	N_COMM	0x12		/* common (internal to ld) */
77 #define	N_FN	0x1e		/* file name symbol */
78 
79 #define	N_EXT	01		/* external bit, or'ed in */
80 #define	N_TYPE	0x1e		/* mask for all the type bits */
81 
82 /*
83  * Sdb entries have some of the N_STAB bits set.
84  * These are given in <stab.h>
85  */
86 #define	N_STAB	0xe0		/* if any of these bits set, a SDB entry */
87 
88 /*
89  * Format for namelist values.
90  */
91 #define	N_FORMAT	"%08x"
92