xref: /original-bsd/include/a.out.h (revision 241757c4)
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.2 (Berkeley) 04/07/87
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 #define	N_TXTOFF(x) \
24 	((x).a_magic==ZMAGIC ? 1024 : sizeof (struct exec))
25 #define N_SYMOFF(x) \
26 	(N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize)
27 #define	N_STROFF(x) \
28 	(N_SYMOFF(x) + (x).a_syms)
29 
30 /*
31  * Format of a relocation datum.
32  */
33 struct relocation_info {
34 	int	r_address;	/* address which is relocated */
35 unsigned int	r_symbolnum:24,	/* local symbol ordinal */
36 		r_pcrel:1, 	/* was relocated pc relative already */
37 		r_length:2,	/* 0=byte, 1=word, 2=long */
38 		r_extern:1,	/* does not include value of sym referenced */
39 		:4;		/* nothing, yet */
40 };
41 
42 /*
43  * Format of a symbol table entry; this file is included by <a.out.h>
44  * and should be used if you aren't interested the a.out header
45  * or relocation information.
46  */
47 struct	nlist {
48 	union {
49 		char	*n_name;	/* for use when in-core */
50 		long	n_strx;		/* index into file string table */
51 	} n_un;
52 unsigned char	n_type;		/* type flag, i.e. N_TEXT etc; see below */
53 	char	n_other;	/* unused */
54 	short	n_desc;		/* see <stab.h> */
55 unsigned long	n_value;	/* value of this symbol (or sdb offset) */
56 };
57 #define	n_hash	n_desc		/* used internally by ld */
58 
59 /*
60  * Simple values for n_type.
61  */
62 #define	N_UNDF	0x0		/* undefined */
63 #define	N_ABS	0x2		/* absolute */
64 #define	N_TEXT	0x4		/* text */
65 #define	N_DATA	0x6		/* data */
66 #define	N_BSS	0x8		/* bss */
67 #define	N_COMM	0x12		/* common (internal to ld) */
68 #define	N_FN	0x1e		/* file name symbol */
69 
70 #define	N_EXT	01		/* external bit, or'ed in */
71 #define	N_TYPE	0x1e		/* mask for all the type bits */
72 
73 /*
74  * Sdb entries have some of the N_STAB bits set.
75  * These are given in <stab.h>
76  */
77 #define	N_STAB	0xe0		/* if any of these bits set, a SDB entry */
78 
79 /*
80  * Format for namelist values.
81  */
82 #define	N_FORMAT	"%08x"
83