outform.h 8.1 KB

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