BSD 4_3_Reno release
[unix-history] / usr / include / a.out.h
CommitLineData
bb0cfa24
DF
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 *
1c15e888 6 * @(#)a.out.h 5.3 (Berkeley) 6/24/90
bb0cfa24 7 */
6f86c72f
SL
8
9/*
8715e60f
SL
10 * Definitions of the a.out header
11 * and magic numbers are shared with
12 * the kernel.
6f86c72f 13 */
8715e60f 14#include <sys/exec.h>
6f86c72f
SL
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
bad2f352 23#if defined(vax) || defined(tahoe)
6f86c72f 24#define N_TXTOFF(x) \
bad2f352
KB
25 ((x).a_magic == ZMAGIC ? 1024 : sizeof (struct exec))
26#endif
27
1c15e888 28#if defined(hp300)
bad2f352 29#define N_TXTOFF(x) \
1c15e888 30 ((x).a_magic == ZMAGIC ? 4096 : sizeof (struct exec))
bad2f352
KB
31#endif
32
6f86c72f
SL
33#define N_SYMOFF(x) \
34 (N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize)
bad2f352 35
6f86c72f
SL
36#define N_STROFF(x) \
37 (N_SYMOFF(x) + (x).a_syms)
38
39/*
40 * Format of a relocation datum.
41 */
42struct relocation_info {
43 int r_address; /* address which is relocated */
44unsigned 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 */
56struct nlist {
57 union {
58 char *n_name; /* for use when in-core */
59 long n_strx; /* index into file string table */
60 } n_un;
61unsigned char n_type; /* type flag, i.e. N_TEXT etc; see below */
62 char n_other; /* unused */
63 short n_desc; /* see <stab.h> */
64unsigned 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) */
9822e909 77#define N_FN 0x1e /* file name symbol */
6f86c72f
SL
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"