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