Commit | Line | Data |
---|---|---|
6f86c72f SL |
1 | /* a.out.h 4.1 83/05/03 */ |
2 | ||
3 | /* | |
4 | * Header prepended to each a.out file. | |
5 | */ | |
6 | struct exec { | |
7 | long a_magic; /* magic number */ | |
8 | unsigned long a_text; /* size of text segment */ | |
9 | unsigned long a_data; /* size of initialized data */ | |
10 | unsigned long a_bss; /* size of uninitialized data */ | |
11 | unsigned long a_syms; /* size of symbol table */ | |
12 | unsigned long a_entry; /* entry point */ | |
13 | unsigned long a_trsize; /* size of text relocation */ | |
14 | unsigned long a_drsize; /* size of data relocation */ | |
15 | }; | |
16 | ||
17 | #define OMAGIC 0407 /* old impure format */ | |
18 | #define NMAGIC 0410 /* read-only text */ | |
19 | #define ZMAGIC 0413 /* demand load format */ | |
20 | ||
21 | /* | |
22 | * Macros which take exec structures as arguments and tell whether | |
23 | * the file has a reasonable magic number or offsets to text|symbols|strings. | |
24 | */ | |
25 | #define N_BADMAG(x) \ | |
26 | (((x).a_magic)!=OMAGIC && ((x).a_magic)!=NMAGIC && ((x).a_magic)!=ZMAGIC) | |
27 | ||
28 | #define N_TXTOFF(x) \ | |
29 | ((x).a_magic==ZMAGIC ? 1024 : sizeof (struct exec)) | |
30 | #define N_SYMOFF(x) \ | |
31 | (N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize) | |
32 | #define N_STROFF(x) \ | |
33 | (N_SYMOFF(x) + (x).a_syms) | |
34 | ||
35 | /* | |
36 | * Format of a relocation datum. | |
37 | */ | |
38 | struct relocation_info { | |
39 | int r_address; /* address which is relocated */ | |
40 | unsigned int r_symbolnum:24, /* local symbol ordinal */ | |
41 | r_pcrel:1, /* was relocated pc relative already */ | |
42 | r_length:2, /* 0=byte, 1=word, 2=long */ | |
43 | r_extern:1, /* does not include value of sym referenced */ | |
44 | :4; /* nothing, yet */ | |
45 | }; | |
46 | ||
47 | /* | |
48 | * Format of a symbol table entry; this file is included by <a.out.h> | |
49 | * and should be used if you aren't interested the a.out header | |
50 | * or relocation information. | |
51 | */ | |
52 | struct nlist { | |
53 | union { | |
54 | char *n_name; /* for use when in-core */ | |
55 | long n_strx; /* index into file string table */ | |
56 | } n_un; | |
57 | unsigned char n_type; /* type flag, i.e. N_TEXT etc; see below */ | |
58 | char n_other; /* unused */ | |
59 | short n_desc; /* see <stab.h> */ | |
60 | unsigned long n_value; /* value of this symbol (or sdb offset) */ | |
61 | }; | |
62 | #define n_hash n_desc /* used internally by ld */ | |
63 | ||
64 | /* | |
65 | * Simple values for n_type. | |
66 | */ | |
67 | #define N_UNDF 0x0 /* undefined */ | |
68 | #define N_ABS 0x2 /* absolute */ | |
69 | #define N_TEXT 0x4 /* text */ | |
70 | #define N_DATA 0x6 /* data */ | |
71 | #define N_BSS 0x8 /* bss */ | |
72 | #define N_COMM 0x12 /* common (internal to ld) */ | |
73 | #define N_FN 0x1f /* file name symbol */ | |
74 | ||
75 | #define N_EXT 01 /* external bit, or'ed in */ | |
76 | #define N_TYPE 0x1e /* mask for all the type bits */ | |
77 | ||
78 | /* | |
79 | * Sdb entries have some of the N_STAB bits set. | |
80 | * These are given in <stab.h> | |
81 | */ | |
82 | #define N_STAB 0xe0 /* if any of these bits set, a SDB entry */ | |
83 | ||
84 | /* | |
85 | * Format for namelist values. | |
86 | */ | |
87 | #define N_FORMAT "%08x" |