aboutsummaryrefslogtreecommitdiffstats
path: root/output/outform.h
blob: 9d068dbfedd0c3adf44a29e2c59dae3179b8d81e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
/* ----------------------------------------------------------------------- *
 *
 *   Copyright 1996-2011 The NASM Authors - All Rights Reserved
 *   See the file AUTHORS included with the NASM distribution for
 *   the specific copyright holders.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following
 *   conditions are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *
 *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ----------------------------------------------------------------------- */

/*
 * outform.h    header file for binding output format drivers to the
 *              remainder of the code in the Netwide Assembler
 */

/*
 * This header file allows configuration of which output formats
 * get compiled into the NASM binary. You can configure by defining
 * various preprocessor symbols beginning with "OF_", either on the
 * compiler command line or at the top of this file.
 *
 * OF_ONLY                -- only include specified object formats
 * OF_name                -- ensure that output format 'name' is included
 * OF_NO_name             -- remove output format 'name'
 * OF_DOS                 -- ensure that 'obj', 'bin', 'win32' & 'win64' are included.
 * OF_UNIX                -- ensure that 'aout', 'aoutb', 'coff', 'elf32' & 'elf64' are in.
 * OF_OTHERS              -- ensure that 'bin', 'as86', 'rdf' 'macho32' & 'macho64' are in.
 * OF_ALL                 -- ensure that all formats are included.
 *                           note that this doesn't include 'dbg', which is
 *                           only really useful if you're doing development
 *                           work on NASM. Define OF_DBG if you want this.
 *
 * OF_DEFAULT=of_name     -- ensure that 'name' is the default format.
 *
 * eg: -DOF_UNIX -DOF_ELF32 -DOF_DEFAULT=of_elf32 would be a suitable config
 * for an average linux system.
 *
 * Default config = -DOF_ALL -DOF_DEFAULT=of_bin
 *
 * You probably only want to set these options while compiling 'nasm.c'. */

#ifndef NASM_OUTFORM_H
#define NASM_OUTFORM_H

#include "nasm.h"

/* -------------- USER MODIFIABLE PART ---------------- */

/*
 * Insert #defines here in accordance with the configuration
 * instructions above.
 *
 * E.g.
 *
 * #define OF_ONLY
 * #define OF_OBJ
 * #define OF_BIN
 *
 * for a 16-bit DOS assembler with no extraneous formats.
 */

/* ------------ END USER MODIFIABLE PART -------------- */

/* ====configurable info begins here==== */
/* formats configurable:
 * bin,obj,elf32,elf64,aout,aoutb,coff,win32,as86,rdf2,macho32,macho64 */

/* process options... */

#ifndef OF_ONLY
#ifndef OF_ALL
#define OF_ALL                  /* default is to have all formats */
#endif
#endif

#ifdef OF_ALL                   /* set all formats on... */
#ifndef OF_BIN
#define OF_BIN
#endif
#ifndef OF_OBJ
#define OF_OBJ
#endif
#ifndef OF_ELF32
#define OF_ELF32
#endif
#ifndef OF_ELFX32
#define OF_ELFX32
#endif
#ifndef OF_ELF64
#define OF_ELF64
#endif
#ifndef OF_COFF
#define OF_COFF
#endif
#ifndef OF_AOUT
#define OF_AOUT
#endif
#ifndef OF_AOUTB
#define OF_AOUTB
#endif
#ifndef OF_WIN32
#define OF_WIN32
#endif
#ifndef OF_WIN64
#define OF_WIN64
#endif
#ifndef OF_AS86
#define OF_AS86
#endif
#ifndef OF_RDF2
#define OF_RDF2
#endif
#ifndef OF_IEEE
#define OF_IEEE
#endif
#ifndef OF_MACHO32
#define OF_MACHO32
#endif
#ifndef OF_MACHO64
#define OF_MACHO64
#endif
#ifndef OF_DBG
#define OF_DBG
#endif
#endif                          /* OF_ALL */

/* turn on groups of formats specified.... */
#ifdef OF_DOS
#ifndef OF_OBJ
#define OF_OBJ
#endif
#ifndef OF_BIN
#define OF_BIN
#endif
#ifndef OF_COFF
#define OF_COFF                 /* COFF is used by DJGPP */
#endif
#ifndef OF_WIN32
#define OF_WIN32
#endif
#ifndef OF_WIN64
#define OF_WIN64
#endif
#endif

#ifdef OF_UNIX
#ifndef OF_AOUT
#define OF_AOUT
#endif
#ifndef OF_AOUTB
#define OF_AOUTB
#endif
#ifndef OF_COFF
#define OF_COFF
#endif
#ifndef OF_ELF32
#define OF_ELF32
#endif
#ifndef OF_ELF64
#define OF_ELF64
#endif
#ifndef OF_ELFX32
#define OF_ELFX32
#endif
#endif

#ifdef OF_OTHERS
#ifndef OF_BIN
#define OF_BIN
#endif
#ifndef OF_AS86
#define OF_AS86
#endif
#ifndef OF_RDF2
#define OF_RDF2
#endif
#ifndef OF_IEEE
#define OF_IEEE
#endif
#ifndef OF_MACHO32
#define OF_MACHO32
#endif
#ifndef OF_MACHO64
#define OF_MACHO64
#endif
#endif

/* finally... override any format specifically specified to be off */
#ifdef OF_NO_BIN
#undef OF_BIN
#endif
#ifdef OF_NO_OBJ
#undef OF_OBJ
#endif
#ifdef OF_NO_ELF32
#undef OF_ELF32
#endif
#ifdef OF_NO_ELF64
#undef OF_ELF64
#endif
#ifdef OF_NO_ELFX32
#undef OF_ELFX32
#endif
#ifdef OF_NO_AOUT
#undef OF_AOUT
#endif
#ifdef OF_NO_AOUTB
#undef OF_AOUTB
#endif
#ifdef OF_NO_COFF
#undef OF_COFF
#endif
#ifdef OF_NO_WIN32
#undef OF_WIN32
#endif
#ifdef OF_NO_WIN64
#undef OF_WIN64
#endif
#ifdef OF_NO_AS86
#undef OF_AS86
#endif
#ifdef OF_NO_RDF2
#undef OF_RDF2
#endif
#ifdef OF_NO_IEEE
#undef OF_IEEE
#endif
#ifdef OF_NO_MACHO32
#undef OF_MACHO32
#endif
#ifdef OF_NO_MACHO64
#undef OF_MACHO64
#endif
#ifdef OF_NO_DBG
#undef OF_DBG
#endif

#ifndef OF_DEFAULT
#define OF_DEFAULT of_bin
#endif

extern const struct ofmt of_bin;
extern const struct ofmt of_ith;
extern const struct ofmt of_srec;
extern const struct ofmt of_aout;
extern const struct ofmt of_aoutb;
extern const struct ofmt of_coff;
extern const struct ofmt of_elf32;
extern const struct ofmt of_elfx32;
extern const struct ofmt of_elf64;
extern const struct ofmt of_as86;
extern const struct ofmt of_obj;
extern const struct ofmt of_win32;
extern const struct ofmt of_win64;
extern const struct ofmt of_rdf2;
extern const struct ofmt of_ieee;
extern const struct ofmt of_macho32;
extern const struct ofmt of_macho64;
extern const struct ofmt of_dbg;

#ifdef BUILD_DRIVERS_ARRAY      /* only if included from outform.c */

/*
 * pull in the externs for the different formats, then make the
 * drivers array based on the above defines
 */

static const struct ofmt * const drivers[] = {
#ifdef OF_BIN
    &of_bin,
    &of_ith,
    &of_srec,
#endif
#ifdef OF_AOUT
    &of_aout,
#endif
#ifdef OF_AOUTB
    &of_aoutb,
#endif
#ifdef OF_COFF
    &of_coff,
#endif
#ifdef OF_ELF32
    &of_elf32,
#endif
#ifdef OF_ELF64
    &of_elf64,
#endif
#ifdef OF_ELFX32
    &of_elfx32,
#endif
#ifdef OF_AS86
    &of_as86,
#endif
#ifdef OF_OBJ
    &of_obj,
#endif
#ifdef OF_WIN32
    &of_win32,
#endif
#ifdef OF_WIN64
    &of_win64,
#endif
#ifdef OF_RDF2
    &of_rdf2,
#endif
#ifdef OF_IEEE
    &of_ieee,
#endif
#ifdef OF_MACHO32
    &of_macho32,
#endif
#ifdef OF_MACHO64
    &of_macho64,
#endif
#ifdef OF_DBG
    &of_dbg,
#endif

    NULL
};

static const struct ofmt_alias ofmt_aliases[] = {
#ifdef OF_ELF32
    {
        "elf",
        "ELF (short name for ELF32)",
        &of_elf32,
    },
#endif
#ifdef OF_MACHO32
    {
        "macho",
        "MACHO (short name for MACHO32)",
        &of_macho32,
    },
#endif
#ifdef OF_WIN32
    {
        "win",
        "WIN (short name for WIN32)",
        &of_win32,
    },
#endif
    { NULL, NULL, NULL }
};

#endif /* BUILD_DRIVERS_ARRAY */

const struct ofmt *ofmt_find(const char *name, const struct ofmt_alias **ofmt_alias);
const struct dfmt *dfmt_find(const struct ofmt *, const char *);
void ofmt_list(const struct ofmt *, FILE *);
void dfmt_list(FILE *);
extern const struct dfmt null_debug_form;

#endif /* NASM_OUTFORM_H */