diff options
Diffstat (limited to 'src/include/a.out.h')
-rw-r--r-- | src/include/a.out.h | 220 |
1 files changed, 220 insertions, 0 deletions
diff --git a/src/include/a.out.h b/src/include/a.out.h new file mode 100644 index 0000000..3e67974 --- /dev/null +++ b/src/include/a.out.h | |||
@@ -0,0 +1,220 @@ | |||
1 | #ifndef _A_OUT_H | ||
2 | #define _A_OUT_H | ||
3 | |||
4 | #define __GNU_EXEC_MACROS__ | ||
5 | |||
6 | struct exec { | ||
7 | unsigned long a_magic; /* Use macros N_MAGIC, etc for access */ | ||
8 | unsigned a_text; /* length of text, in bytes */ | ||
9 | unsigned a_data; /* length of data, in bytes */ | ||
10 | unsigned a_bss; /* length of uninitialized data area for file, in bytes */ | ||
11 | unsigned a_syms; /* length of symbol table data in file, in bytes */ | ||
12 | unsigned a_entry; /* start address */ | ||
13 | unsigned a_trsize; /* length of relocation info for text, in bytes */ | ||
14 | unsigned a_drsize; /* length of relocation info for data, in bytes */ | ||
15 | }; | ||
16 | |||
17 | #ifndef N_MAGIC | ||
18 | #define N_MAGIC(exec) ((exec).a_magic) | ||
19 | #endif | ||
20 | |||
21 | #ifndef OMAGIC | ||
22 | /* Code indicating object file or impure executable. */ | ||
23 | #define OMAGIC 0407 | ||
24 | /* Code indicating pure executable. */ | ||
25 | #define NMAGIC 0410 | ||
26 | /* Code indicating demand-paged executable. */ | ||
27 | #define ZMAGIC 0413 | ||
28 | #endif /* not OMAGIC */ | ||
29 | |||
30 | #ifndef N_BADMAG | ||
31 | #define N_BADMAG(x) \ | ||
32 | (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ | ||
33 | && N_MAGIC(x) != ZMAGIC) | ||
34 | #endif | ||
35 | |||
36 | #define _N_BADMAG(x) \ | ||
37 | (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ | ||
38 | && N_MAGIC(x) != ZMAGIC) | ||
39 | |||
40 | #define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec)) | ||
41 | |||
42 | #ifndef N_TXTOFF | ||
43 | #define N_TXTOFF(x) \ | ||
44 | (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec)) | ||
45 | #endif | ||
46 | |||
47 | #ifndef N_DATOFF | ||
48 | #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) | ||
49 | #endif | ||
50 | |||
51 | #ifndef N_TRELOFF | ||
52 | #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) | ||
53 | #endif | ||
54 | |||
55 | #ifndef N_DRELOFF | ||
56 | #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize) | ||
57 | #endif | ||
58 | |||
59 | #ifndef N_SYMOFF | ||
60 | #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize) | ||
61 | #endif | ||
62 | |||
63 | #ifndef N_STROFF | ||
64 | #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms) | ||
65 | #endif | ||
66 | |||
67 | /* Address of text segment in memory after it is loaded. */ | ||
68 | #ifndef N_TXTADDR | ||
69 | #define N_TXTADDR(x) 0 | ||
70 | #endif | ||
71 | |||
72 | /* Address of data segment in memory after it is loaded. | ||
73 | Note that it is up to you to define SEGMENT_SIZE | ||
74 | on machines not listed here. */ | ||
75 | #if defined(vax) || defined(hp300) || defined(pyr) | ||
76 | #define SEGMENT_SIZE PAGE_SIZE | ||
77 | #endif | ||
78 | #ifdef hp300 | ||
79 | #define PAGE_SIZE 4096 | ||
80 | #endif | ||
81 | #ifdef sony | ||
82 | #define SEGMENT_SIZE 0x2000 | ||
83 | #endif /* Sony. */ | ||
84 | #ifdef is68k | ||
85 | #define SEGMENT_SIZE 0x20000 | ||
86 | #endif | ||
87 | #if defined(m68k) && defined(PORTAR) | ||
88 | #define PAGE_SIZE 0x400 | ||
89 | #define SEGMENT_SIZE PAGE_SIZE | ||
90 | #endif | ||
91 | |||
92 | #define PAGE_SIZE 4096 | ||
93 | #define SEGMENT_SIZE 1024 | ||
94 | |||
95 | #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) | ||
96 | |||
97 | #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) | ||
98 | |||
99 | #ifndef N_DATADDR | ||
100 | #define N_DATADDR(x) \ | ||
101 | (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \ | ||
102 | : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x)))) | ||
103 | #endif | ||
104 | |||
105 | /* Address of bss segment in memory after it is loaded. */ | ||
106 | #ifndef N_BSSADDR | ||
107 | #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) | ||
108 | #endif | ||
109 | |||
110 | #ifndef N_NLIST_DECLARED | ||
111 | struct nlist { | ||
112 | union { | ||
113 | char *n_name; | ||
114 | struct nlist *n_next; | ||
115 | long n_strx; | ||
116 | } n_un; | ||
117 | unsigned char n_type; | ||
118 | char n_other; | ||
119 | short n_desc; | ||
120 | unsigned long n_value; | ||
121 | }; | ||
122 | #endif | ||
123 | |||
124 | #ifndef N_UNDF | ||
125 | #define N_UNDF 0 | ||
126 | #endif | ||
127 | #ifndef N_ABS | ||
128 | #define N_ABS 2 | ||
129 | #endif | ||
130 | #ifndef N_TEXT | ||
131 | #define N_TEXT 4 | ||
132 | #endif | ||
133 | #ifndef N_DATA | ||
134 | #define N_DATA 6 | ||
135 | #endif | ||
136 | #ifndef N_BSS | ||
137 | #define N_BSS 8 | ||
138 | #endif | ||
139 | #ifndef N_COMM | ||
140 | #define N_COMM 18 | ||
141 | #endif | ||
142 | #ifndef N_FN | ||
143 | #define N_FN 15 | ||
144 | #endif | ||
145 | |||
146 | #ifndef N_EXT | ||
147 | #define N_EXT 1 | ||
148 | #endif | ||
149 | #ifndef N_TYPE | ||
150 | #define N_TYPE 036 | ||
151 | #endif | ||
152 | #ifndef N_STAB | ||
153 | #define N_STAB 0340 | ||
154 | #endif | ||
155 | |||
156 | /* The following type indicates the definition of a symbol as being | ||
157 | an indirect reference to another symbol. The other symbol | ||
158 | appears as an undefined reference, immediately following this symbol. | ||
159 | |||
160 | Indirection is asymmetrical. The other symbol's value will be used | ||
161 | to satisfy requests for the indirect symbol, but not vice versa. | ||
162 | If the other symbol does not have a definition, libraries will | ||
163 | be searched to find a definition. */ | ||
164 | #define N_INDR 0xa | ||
165 | |||
166 | /* The following symbols refer to set elements. | ||
167 | All the N_SET[ATDB] symbols with the same name form one set. | ||
168 | Space is allocated for the set in the text section, and each set | ||
169 | element's value is stored into one word of the space. | ||
170 | The first word of the space is the length of the set (number of elements). | ||
171 | |||
172 | The address of the set is made into an N_SETV symbol | ||
173 | whose name is the same as the name of the set. | ||
174 | This symbol acts like a N_DATA global symbol | ||
175 | in that it can satisfy undefined external references. */ | ||
176 | |||
177 | /* These appear as input to LD, in a .o file. */ | ||
178 | #define N_SETA 0x14 /* Absolute set element symbol */ | ||
179 | #define N_SETT 0x16 /* Text set element symbol */ | ||
180 | #define N_SETD 0x18 /* Data set element symbol */ | ||
181 | #define N_SETB 0x1A /* Bss set element symbol */ | ||
182 | |||
183 | /* This is output from LD. */ | ||
184 | #define N_SETV 0x1C /* Pointer to set vector in data area. */ | ||
185 | |||
186 | #ifndef N_RELOCATION_INFO_DECLARED | ||
187 | |||
188 | /* This structure describes a single relocation to be performed. | ||
189 | The text-relocation section of the file is a vector of these structures, | ||
190 | all of which apply to the text section. | ||
191 | Likewise, the data-relocation section applies to the data section. */ | ||
192 | |||
193 | struct relocation_info | ||
194 | { | ||
195 | /* Address (within segment) to be relocated. */ | ||
196 | int r_address; | ||
197 | /* The meaning of r_symbolnum depends on r_extern. */ | ||
198 | unsigned int r_symbolnum:24; | ||
199 | /* Nonzero means value is a pc-relative offset | ||
200 | and it should be relocated for changes in its own address | ||
201 | as well as for changes in the symbol or section specified. */ | ||
202 | unsigned int r_pcrel:1; | ||
203 | /* Length (as exponent of 2) of the field to be relocated. | ||
204 | Thus, a value of 2 indicates 1<<2 bytes. */ | ||
205 | unsigned int r_length:2; | ||
206 | /* 1 => relocate with value of symbol. | ||
207 | r_symbolnum is the index of the symbol | ||
208 | in file's the symbol table. | ||
209 | 0 => relocate with the address of a segment. | ||
210 | r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS | ||
211 | (the N_EXT bit may be set also, but signifies nothing). */ | ||
212 | unsigned int r_extern:1; | ||
213 | /* Four bits that aren't used, but when writing an object file | ||
214 | it is desirable to clear them. */ | ||
215 | unsigned int r_pad:4; | ||
216 | }; | ||
217 | #endif /* no N_RELOCATION_INFO_DECLARED. */ | ||
218 | |||
219 | |||
220 | #endif /* __A_OUT_GNU_H__ */ | ||