|
|
1.1 root 1: /* @(#)a.out.h 1.1 85/12/18 SMI; from UCB 4.1 83/05/03 */
2:
3: /*
4: * format of the exec header
5: * known by kernel and by user programs
6: */
7: struct exec {
8: #ifdef sun
9: unsigned short a_machtype; /* machine type */
10: unsigned short a_magic; /* magic number */
11: #else
12: unsigned long a_magic; /* magic number */
13: #endif
14: unsigned long a_text; /* size of text segment */
15: unsigned long a_data; /* size of initialized data */
16: unsigned long a_bss; /* size of uninitialized data */
17: unsigned long a_syms; /* size of symbol table */
18: unsigned long a_entry; /* entry point */
19: unsigned long a_trsize; /* size of text relocation */
20: unsigned long a_drsize; /* size of data relocation */
21: };
22:
23: #define OMAGIC 0407 /* old impure format */
24: #define NMAGIC 0410 /* read-only text */
25: #define ZMAGIC 0413 /* demand load format */
26:
27: /* machine types */
28:
29: #ifdef sun
30: #define M_OLDSUN2 0 /* old sun-2 executable files */
31: #define M_68010 1 /* runs on either 68010 or 68020 */
32: #define M_68020 2 /* runs only on 68020 */
33: #endif sun
34:
35: /*
36: * memory management parameters
37: */
38:
39: #ifdef sun
40: #define PAGSIZ 0x2000
41: #define SEGSIZ 0x20000
42: #define OLD_PAGSIZ 0x800 /* THIS DISAPPEARS IN RELEASE 4.0 */
43: #define OLD_SEGSIZ 0x8000 /* THIS DISAPPEARS IN RELEASE 4.0 */
44: #endif sun
45:
46: #ifdef vax
47: #define PAGSIZ 1024
48: #define SEGSIZ PAGSIZ
49: #endif vax
50:
51: /*
52: * returns 1 if an object file type is invalid, i.e., if the other macros
53: * defined below will not yield the correct offsets. Note that a file may
54: * have N_BADMAG(x) = 0 and may be fully linked, but still may not be
55: * executable.
56: */
57:
58: #define N_BADMAG(x) \
59: ((x).a_magic!=OMAGIC && (x).a_magic!=NMAGIC && (x).a_magic!=ZMAGIC)
60:
61: /*
62: * relocation parameters. These are architecture-dependent
63: * and can be deduced from the machine type. They are used
64: * to calculate offsets of segments within the object file;
65: * See N_TXTOFF(x), etc. below.
66: */
67:
68: #ifdef sun
69: #define N_PAGSIZ(x) \
70: ((x).a_machtype == M_OLDSUN2? OLD_PAGSIZ : PAGSIZ)
71: #define N_SEGSIZ(x) \
72: ((x).a_machtype == M_OLDSUN2? OLD_SEGSIZ : SEGSIZ)
73: #endif sun
74:
75: #ifdef vax
76: #define N_PAGSIZ(x) PAGSIZ
77: #define N_SEGSIZ(x) SEGSIZ
78: #endif vax
79:
80: /*
81: * offsets of various sections of an object file.
82: */
83:
84: #ifdef sun
85: #define N_TXTOFF(x) \
86: /* text segment */ \
87: ( (x).a_machtype == M_OLDSUN2 \
88: ? ((x).a_magic==ZMAGIC ? N_PAGSIZ(x) : sizeof (struct exec)) \
89: : ((x).a_magic==ZMAGIC ? 0 : sizeof (struct exec)) )
90: #endif sun
91:
92: #ifdef vax
93: #define N_TXTOFF(x) \
94: ((x).a_magic==ZMAGIC ? PAGSIZ : sizeof (struct exec))
95: #endif vax
96:
97:
98: #define N_SYMOFF(x) \
99: /* symbol table */ \
100: (N_TXTOFF(x)+(x).a_text+(x).a_data+(x).a_trsize+(x).a_drsize)
101:
102: #define N_STROFF(x) \
103: /* string table */ \
104: (N_SYMOFF(x) + (x).a_syms)
105:
106: /*
107: * Macros which take exec structures as arguments and tell where the
108: * various pieces will be loaded.
109: */
110:
111: #ifdef sun
112: #define N_TXTADDR(x) \
113: ((x).a_machtype == M_OLDSUN2? N_SEGSIZ(x) : N_PAGSIZ(x))
114: #endif sun
115:
116: #ifdef vax
117: #define TXTRELOC 0
118: #define N_TXTADDR(x) TXTRELOC
119: #endif vax
120:
121: #define N_DATADDR(x) \
122: (((x).a_magic==OMAGIC)? (N_TXTADDR(x)+(x).a_text) \
123: : (N_SEGSIZ(x)+((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZ(x)-1))))
124:
125: #define N_BSSADDR(x) (N_DATADDR(x)+(x).a_data)
126:
127: /*
128: * Format of a relocation datum.
129: */
130:
131: struct relocation_info {
132: long r_address; /* address which is relocated */
133: unsigned int r_symbolnum:24, /* local symbol ordinal */
134: r_pcrel:1, /* was relocated pc relative already */
135: r_length:2, /* 0=byte, 1=word, 2=long */
136: r_extern:1, /* does not include value of sym referenced */
137: :4; /* nothing, yet */
138: };
139:
140: /*
141: * Format of a symbol table entry
142: */
143: struct nlist {
144: union {
145: char *n_name; /* for use when in-core */
146: long n_strx; /* index into file string table */
147: } n_un;
148: unsigned char n_type; /* type flag (N_TEXT,..) */
149: char n_other; /* unused */
150: short n_desc; /* see <stab.h> */
151: unsigned long n_value; /* value of symbol (or sdb offset) */
152: };
153:
154: /*
155: * Simple values for n_type.
156: */
157: #define N_UNDF 0x0 /* undefined */
158: #define N_ABS 0x2 /* absolute */
159: #define N_TEXT 0x4 /* text */
160: #define N_DATA 0x6 /* data */
161: #define N_BSS 0x8 /* bss */
162: #define N_COMM 0x12 /* common (internal to ld) */
163: #define N_FN 0x1f /* file name symbol */
164:
165: #define N_EXT 01 /* external bit, or'ed in */
166: #define N_TYPE 0x1e /* mask for all the type bits */
167:
168: /*
169: * Dbx entries have some of the N_STAB bits set.
170: * These are given in <stab.h>
171: */
172: #define N_STAB 0xe0 /* if any of these bits set, a dbx symbol */
173:
174: /*
175: * Format for namelist values.
176: */
177: #define N_FORMAT "%08x"
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.