Debian Codegraph @

output/outform.h

raw
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /* Copyright 1996-2022 The NASM Authors - All Rights Reserved */
3
4 /*
5 * outform.h header file for binding output format drivers to the
6 * remainder of the code in the Netwide Assembler
7 */
8
9 /*
10 * This header file allows configuration of which output formats
11 * get compiled into the NASM binary. You can configure by defining
12 * various preprocessor symbols beginning with "OF_", either on the
13 * compiler command line or at the top of this file.
14 *
15 * OF_ONLY -- only include specified object formats
16 * OF_name -- ensure that output format 'name' is included
17 * OF_NO_name -- remove output format 'name'
18 * OF_DOS -- ensure that 'obj', 'obj2', 'bin', 'win32' & 'win64' are included.
19 * OF_UNIX -- ensure that 'aout', 'aoutb', 'coff', 'elf32' & 'elf64' are in.
20 * OF_OTHERS -- ensure that 'bin', 'as86', 'rdf' 'macho32' & 'macho64' are in.
21 * OF_ALL -- ensure that all formats are included.
22 * note that this doesn't include 'dbg', which is
23 * only really useful if you're doing development
24 * work on NASM. Define OF_DBG if you want this.
25 *
26 * OF_DEFAULT=of_name -- ensure that 'name' is the default format.
27 *
28 * eg: -DOF_UNIX -DOF_ELF32 -DOF_DEFAULT=of_elf32 would be a suitable config
29 * for an average linux system.
30 *
31 * Default config = -DOF_ALL -DOF_DEFAULT=of_bin
32 *
33 * You probably only want to set these options while compiling 'nasm.c'. */
34
35 #ifndef NASM_OUTFORM_H
36 #define NASM_OUTFORM_H
37
38 #include "nasm.h"
39
40 /* -------------- USER MODIFIABLE PART ---------------- */
41
42 /*
43 * Insert #defines here in accordance with the configuration
44 * instructions above.
45 *
46 * E.g.
47 *
48 * #define OF_ONLY
49 * #define OF_OBJ
50 * #define OF_BIN
51 *
52 * for a 16-bit DOS assembler with no extraneous formats.
53 */
54
55 /* ------------ END USER MODIFIABLE PART -------------- */
56
57 /* ====configurable info begins here==== */
58 /* formats configurable:
59 * bin,obj,obj2,elf32,elf64,aout,aoutb,coff,win32,as86,rdf2,macho32,macho64 */
60
61 /* process options... */
62
63 #ifndef OF_ONLY
64 #ifndef OF_ALL
65 #define OF_ALL /* default is to have all formats */
66 #endif
67 #endif
68
69 #ifdef OF_ALL /* set all formats on... */
70 #ifndef OF_BIN
71 #define OF_BIN
72 #endif
73 #ifndef OF_OBJ
74 #define OF_OBJ
75 #endif
76 #ifndef OF_OBJ2
77 #define OF_OBJ2
78 #endif
79 #ifndef OF_ELF32
80 #define OF_ELF32
81 #endif
82 #ifndef OF_ELFX32
83 #define OF_ELFX32
84 #endif
85 #ifndef OF_ELF64
86 #define OF_ELF64
87 #endif
88 #ifndef OF_COFF
89 #define OF_COFF
90 #endif
91 #ifndef OF_AOUT
92 #define OF_AOUT
93 #endif
94 #ifndef OF_AOUTB
95 #define OF_AOUTB
96 #endif
97 #ifndef OF_WIN32
98 #define OF_WIN32
99 #endif
100 #ifndef OF_WIN64
101 #define OF_WIN64
102 #endif
103 #ifndef OF_AS86
104 #define OF_AS86
105 #endif
106 #ifndef OF_IEEE
107 #define OF_IEEE
108 #endif
109 #ifndef OF_MACHO32
110 #define OF_MACHO32
111 #endif
112 #ifndef OF_MACHO64
113 #define OF_MACHO64
114 #endif
115 #ifndef OF_DBG
116 #define OF_DBG
117 #endif
118 #endif /* OF_ALL */
119
120 /* turn on groups of formats specified.... */
121 #ifdef OF_DOS
122 #ifndef OF_OBJ
123 #define OF_OBJ
124 #endif
125 #ifndef OF_OBJ2
126 #define OF_OBJ2
127 #endif
128 #ifndef OF_BIN
129 #define OF_BIN
130 #endif
131 #ifndef OF_COFF
132 #define OF_COFF /* COFF is used by DJGPP */
133 #endif
134 #ifndef OF_WIN32
135 #define OF_WIN32
136 #endif
137 #ifndef OF_WIN64
138 #define OF_WIN64
139 #endif
140 #endif
141
142 #ifdef OF_UNIX
143 #ifndef OF_AOUT
144 #define OF_AOUT
145 #endif
146 #ifndef OF_AOUTB
147 #define OF_AOUTB
148 #endif
149 #ifndef OF_COFF
150 #define OF_COFF
151 #endif
152 #ifndef OF_ELF32
153 #define OF_ELF32
154 #endif
155 #ifndef OF_ELF64
156 #define OF_ELF64
157 #endif
158 #ifndef OF_ELFX32
159 #define OF_ELFX32
160 #endif
161 #endif
162
163 #ifdef OF_OTHERS
164 #ifndef OF_BIN
165 #define OF_BIN
166 #endif
167 #ifndef OF_AS86
168 #define OF_AS86
169 #endif
170 #ifndef OF_IEEE
171 #define OF_IEEE
172 #endif
173 #ifndef OF_MACHO32
174 #define OF_MACHO32
175 #endif
176 #ifndef OF_MACHO64
177 #define OF_MACHO64
178 #endif
179 #endif
180
181 /* finally... override any format specifically specified to be off */
182 #ifdef OF_NO_BIN
183 #undef OF_BIN
184 #endif
185 #ifdef OF_NO_OBJ
186 #undef OF_OBJ
187 #endif
188 #ifdef OF_NO_OBJ2
189 #undef OF_OBJ2
190 #endif
191 #ifdef OF_NO_ELF32
192 #undef OF_ELF32
193 #endif
194 #ifdef OF_NO_ELF64
195 #undef OF_ELF64
196 #endif
197 #ifdef OF_NO_ELFX32
198 #undef OF_ELFX32
199 #endif
200 #ifdef OF_NO_AOUT
201 #undef OF_AOUT
202 #endif
203 #ifdef OF_NO_AOUTB
204 #undef OF_AOUTB
205 #endif
206 #ifdef OF_NO_COFF
207 #undef OF_COFF
208 #endif
209 #ifdef OF_NO_WIN32
210 #undef OF_WIN32
211 #endif
212 #ifdef OF_NO_WIN64
213 #undef OF_WIN64
214 #endif
215 #ifdef OF_NO_AS86
216 #undef OF_AS86
217 #endif
218 #ifdef OF_NO_IEEE
219 #undef OF_IEEE
220 #endif
221 #ifdef OF_NO_MACHO32
222 #undef OF_MACHO32
223 #endif
224 #ifdef OF_NO_MACHO64
225 #undef OF_MACHO64
226 #endif
227 #ifdef OF_NO_DBG
228 #undef OF_DBG
229 #endif
230
231 #ifndef OF_DEFAULT
232 #define OF_DEFAULT of_bin
233 #endif
234
235 extern const struct ofmt of_bin;
236 extern const struct ofmt of_ith;
237 extern const struct ofmt of_srec;
238 extern const struct ofmt of_aout;
239 extern const struct ofmt of_aoutb;
240 extern const struct ofmt of_coff;
241 extern const struct ofmt of_elf32;
242 extern const struct ofmt of_elfx32;
243 extern const struct ofmt of_elf64;
244 extern const struct ofmt of_as86;
245 extern const struct ofmt of_obj;
246 extern const struct ofmt of_obj2;
247 extern const struct ofmt of_win32;
248 extern const struct ofmt of_win64;
249 extern const struct ofmt of_ieee;
250 extern const struct ofmt of_macho32;
251 extern const struct ofmt of_macho64;
252 extern const struct ofmt of_dbg;
253
254 #ifdef BUILD_DRIVERS_ARRAY /* only if included from outform.c */
255
256 /*
257 * pull in the externs for the different formats, then make the
258 * drivers array based on the above defines
259 */
260
261 static const struct ofmt * const drivers[] = {
262 #ifdef OF_BIN
263 &of_bin,
264 &of_ith,
265 &of_srec,
266 #endif
267 #ifdef OF_AOUT
268 &of_aout,
269 #endif
270 #ifdef OF_AOUTB
271 &of_aoutb,
272 #endif
273 #ifdef OF_COFF
274 &of_coff,
275 #endif
276 #ifdef OF_ELF32
277 &of_elf32,
278 #endif
279 #ifdef OF_ELF64
280 &of_elf64,
281 #endif
282 #ifdef OF_ELFX32
283 &of_elfx32,
284 #endif
285 #ifdef OF_AS86
286 &of_as86,
287 #endif
288 #ifdef OF_OBJ
289 &of_obj,
290 #endif
291 #ifdef OF_OBJ2
292 &of_obj2,
293 #endif
294 #ifdef OF_WIN32
295 &of_win32,
296 #endif
297 #ifdef OF_WIN64
298 &of_win64,
299 #endif
300 #ifdef OF_IEEE
301 &of_ieee,
302 #endif
303 #ifdef OF_MACHO32
304 &of_macho32,
305 #endif
306 #ifdef OF_MACHO64
307 &of_macho64,
308 #endif
309 #ifdef OF_DBG
310 &of_dbg,
311 #endif
312
313 NULL
314 };
315
316 static const struct ofmt_alias ofmt_aliases[] = {
317 #ifdef OF_ELF32
318 { "elf", &of_elf32 },
319 #endif
320 #ifdef OF_MACHO32
321 { "macho", &of_macho32 },
322 #endif
323 #ifdef OF_WIN32
324 { "win", &of_win32 },
325 #endif
326 { NULL, NULL }
327 };
328
329 #endif /* BUILD_DRIVERS_ARRAY */
330
331 const struct ofmt *ofmt_find(const char *name, const struct ofmt_alias **ofmt_alias);
332 const struct dfmt * pure_func dfmt_find(const struct ofmt *, const char *);
333 void ofmt_list(const struct ofmt *, FILE *);
334 void dfmt_list(FILE *);
335 extern const struct dfmt null_debug_form;
336
337 #endif /* NASM_OUTFORM_H */