laag-nasm 2.13.03.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +57 -0
  3. data/LICENSE.txt +29 -0
  4. data/README.org +34 -0
  5. data/ext/laag/nasm/extconf.rb +16 -0
  6. data/laag-nasm.gemspec +20 -0
  7. data/lib/laag/nasm.rb +29 -0
  8. data/patches/Makefile.in.patch +13 -0
  9. data/vendor/repo.or.cz/nasm/.gitignore +102 -0
  10. data/vendor/repo.or.cz/nasm/AUTHORS +137 -0
  11. data/vendor/repo.or.cz/nasm/CHANGES +2 -0
  12. data/vendor/repo.or.cz/nasm/ChangeLog +2905 -0
  13. data/vendor/repo.or.cz/nasm/INSTALL +102 -0
  14. data/vendor/repo.or.cz/nasm/LICENSE +29 -0
  15. data/vendor/repo.or.cz/nasm/Makefile.in +855 -0
  16. data/vendor/repo.or.cz/nasm/Mkfiles/README +46 -0
  17. data/vendor/repo.or.cz/nasm/Mkfiles/msvc.mak +732 -0
  18. data/vendor/repo.or.cz/nasm/Mkfiles/openwcom.mak +706 -0
  19. data/vendor/repo.or.cz/nasm/README +23 -0
  20. data/vendor/repo.or.cz/nasm/SubmittingPatches +116 -0
  21. data/vendor/repo.or.cz/nasm/TODO +376 -0
  22. data/vendor/repo.or.cz/nasm/aclocal.m4 +139 -0
  23. data/vendor/repo.or.cz/nasm/asm/assemble.c +2957 -0
  24. data/vendor/repo.or.cz/nasm/asm/assemble.h +54 -0
  25. data/vendor/repo.or.cz/nasm/asm/directiv.c +566 -0
  26. data/vendor/repo.or.cz/nasm/asm/directiv.dat +92 -0
  27. data/vendor/repo.or.cz/nasm/asm/error.c +202 -0
  28. data/vendor/repo.or.cz/nasm/asm/eval.c +1014 -0
  29. data/vendor/repo.or.cz/nasm/asm/eval.h +49 -0
  30. data/vendor/repo.or.cz/nasm/asm/exprdump.c +79 -0
  31. data/vendor/repo.or.cz/nasm/asm/exprlib.c +200 -0
  32. data/vendor/repo.or.cz/nasm/asm/float.c +952 -0
  33. data/vendor/repo.or.cz/nasm/asm/float.h +54 -0
  34. data/vendor/repo.or.cz/nasm/asm/labels.c +540 -0
  35. data/vendor/repo.or.cz/nasm/asm/listing.c +346 -0
  36. data/vendor/repo.or.cz/nasm/asm/listing.h +113 -0
  37. data/vendor/repo.or.cz/nasm/asm/nasm.c +1855 -0
  38. data/vendor/repo.or.cz/nasm/asm/parser.c +1167 -0
  39. data/vendor/repo.or.cz/nasm/asm/parser.h +45 -0
  40. data/vendor/repo.or.cz/nasm/asm/phash.pl +109 -0
  41. data/vendor/repo.or.cz/nasm/asm/pptok.dat +96 -0
  42. data/vendor/repo.or.cz/nasm/asm/pptok.pl +271 -0
  43. data/vendor/repo.or.cz/nasm/asm/pragma.c +218 -0
  44. data/vendor/repo.or.cz/nasm/asm/preproc-nop.c +188 -0
  45. data/vendor/repo.or.cz/nasm/asm/preproc.c +5459 -0
  46. data/vendor/repo.or.cz/nasm/asm/preproc.h +55 -0
  47. data/vendor/repo.or.cz/nasm/asm/quote.c +479 -0
  48. data/vendor/repo.or.cz/nasm/asm/quote.h +44 -0
  49. data/vendor/repo.or.cz/nasm/asm/rdstrnum.c +68 -0
  50. data/vendor/repo.or.cz/nasm/asm/segalloc.c +51 -0
  51. data/vendor/repo.or.cz/nasm/asm/stdscan.c +345 -0
  52. data/vendor/repo.or.cz/nasm/asm/stdscan.h +49 -0
  53. data/vendor/repo.or.cz/nasm/asm/strfunc.c +359 -0
  54. data/vendor/repo.or.cz/nasm/asm/tokens.dat +135 -0
  55. data/vendor/repo.or.cz/nasm/asm/tokhash.pl +284 -0
  56. data/vendor/repo.or.cz/nasm/autogen.sh +9 -0
  57. data/vendor/repo.or.cz/nasm/common/common.c +122 -0
  58. data/vendor/repo.or.cz/nasm/config/msvc.h +192 -0
  59. data/vendor/repo.or.cz/nasm/config/unknown.h +51 -0
  60. data/vendor/repo.or.cz/nasm/config/watcom.h +74 -0
  61. data/vendor/repo.or.cz/nasm/configure.ac +253 -0
  62. data/vendor/repo.or.cz/nasm/contrib/MSVC6.txt +25 -0
  63. data/vendor/repo.or.cz/nasm/contrib/VSrules/nasm.README +16 -0
  64. data/vendor/repo.or.cz/nasm/contrib/VSrules/nasm.rules +79 -0
  65. data/vendor/repo.or.cz/nasm/disasm/disasm.c +1735 -0
  66. data/vendor/repo.or.cz/nasm/disasm/disasm.h +49 -0
  67. data/vendor/repo.or.cz/nasm/disasm/ndisasm.c +397 -0
  68. data/vendor/repo.or.cz/nasm/disasm/sync.c +132 -0
  69. data/vendor/repo.or.cz/nasm/disasm/sync.h +45 -0
  70. data/vendor/repo.or.cz/nasm/doc/Makefile.in +86 -0
  71. data/vendor/repo.or.cz/nasm/doc/README +20 -0
  72. data/vendor/repo.or.cz/nasm/doc/afmmetrics.ph +102 -0
  73. data/vendor/repo.or.cz/nasm/doc/changes.src +2588 -0
  74. data/vendor/repo.or.cz/nasm/doc/findfont.ph +180 -0
  75. data/vendor/repo.or.cz/nasm/doc/genps.pl +1294 -0
  76. data/vendor/repo.or.cz/nasm/doc/inslist.pl +108 -0
  77. data/vendor/repo.or.cz/nasm/doc/internal.doc +290 -0
  78. data/vendor/repo.or.cz/nasm/doc/local.css +1 -0
  79. data/vendor/repo.or.cz/nasm/doc/nasmdoc.css +150 -0
  80. data/vendor/repo.or.cz/nasm/doc/nasmdoc.src +8309 -0
  81. data/vendor/repo.or.cz/nasm/doc/nasmlogo.eps +212 -0
  82. data/vendor/repo.or.cz/nasm/doc/nasmlogw.png +0 -0
  83. data/vendor/repo.or.cz/nasm/doc/psfonts.ph +53 -0
  84. data/vendor/repo.or.cz/nasm/doc/pspdf.pl +98 -0
  85. data/vendor/repo.or.cz/nasm/doc/pswidth.ph +25 -0
  86. data/vendor/repo.or.cz/nasm/doc/rdsrc.pl +1111 -0
  87. data/vendor/repo.or.cz/nasm/doc/ttfmetrics.ph +63 -0
  88. data/vendor/repo.or.cz/nasm/headers/c +33 -0
  89. data/vendor/repo.or.cz/nasm/headers/doc +33 -0
  90. data/vendor/repo.or.cz/nasm/headers/mac +33 -0
  91. data/vendor/repo.or.cz/nasm/headers/perl +33 -0
  92. data/vendor/repo.or.cz/nasm/include/compiler.h +277 -0
  93. data/vendor/repo.or.cz/nasm/include/disp8.h +45 -0
  94. data/vendor/repo.or.cz/nasm/include/error.h +135 -0
  95. data/vendor/repo.or.cz/nasm/include/hashtbl.h +85 -0
  96. data/vendor/repo.or.cz/nasm/include/iflag.h +173 -0
  97. data/vendor/repo.or.cz/nasm/include/insns.h +76 -0
  98. data/vendor/repo.or.cz/nasm/include/labels.h +60 -0
  99. data/vendor/repo.or.cz/nasm/include/md5.h +21 -0
  100. data/vendor/repo.or.cz/nasm/include/nasm.h +1246 -0
  101. data/vendor/repo.or.cz/nasm/include/nasmint.h +219 -0
  102. data/vendor/repo.or.cz/nasm/include/nasmlib.h +524 -0
  103. data/vendor/repo.or.cz/nasm/include/opflags.h +271 -0
  104. data/vendor/repo.or.cz/nasm/include/perfhash.h +52 -0
  105. data/vendor/repo.or.cz/nasm/include/raa.h +46 -0
  106. data/vendor/repo.or.cz/nasm/include/rbtree.h +51 -0
  107. data/vendor/repo.or.cz/nasm/include/rdoff.h +169 -0
  108. data/vendor/repo.or.cz/nasm/include/saa.h +94 -0
  109. data/vendor/repo.or.cz/nasm/include/strlist.h +55 -0
  110. data/vendor/repo.or.cz/nasm/include/tables.h +70 -0
  111. data/vendor/repo.or.cz/nasm/include/ver.h +47 -0
  112. data/vendor/repo.or.cz/nasm/install-sh +250 -0
  113. data/vendor/repo.or.cz/nasm/macros/altreg.mac +107 -0
  114. data/vendor/repo.or.cz/nasm/macros/fp.mac +54 -0
  115. data/vendor/repo.or.cz/nasm/macros/ifunc.mac +48 -0
  116. data/vendor/repo.or.cz/nasm/macros/macros.pl +294 -0
  117. data/vendor/repo.or.cz/nasm/macros/smartalign.mac +189 -0
  118. data/vendor/repo.or.cz/nasm/macros/standard.mac +226 -0
  119. data/vendor/repo.or.cz/nasm/misc/Doxyfile +752 -0
  120. data/vendor/repo.or.cz/nasm/misc/Nindent +18 -0
  121. data/vendor/repo.or.cz/nasm/misc/README +2 -0
  122. data/vendor/repo.or.cz/nasm/misc/c16.mac +82 -0
  123. data/vendor/repo.or.cz/nasm/misc/c32.mac +52 -0
  124. data/vendor/repo.or.cz/nasm/misc/crcgen.c +44 -0
  125. data/vendor/repo.or.cz/nasm/misc/exebin.mac +57 -0
  126. data/vendor/repo.or.cz/nasm/misc/exebin2.mac +114 -0
  127. data/vendor/repo.or.cz/nasm/misc/fmtinsns.pl +40 -0
  128. data/vendor/repo.or.cz/nasm/misc/genfma.pl +63 -0
  129. data/vendor/repo.or.cz/nasm/misc/hints.txt +26 -0
  130. data/vendor/repo.or.cz/nasm/misc/magic +6 -0
  131. data/vendor/repo.or.cz/nasm/misc/myC32.mac +121 -0
  132. data/vendor/repo.or.cz/nasm/misc/nasm.sl +320 -0
  133. data/vendor/repo.or.cz/nasm/misc/nasmstab +296 -0
  134. data/vendor/repo.or.cz/nasm/misc/omfdump.c +517 -0
  135. data/vendor/repo.or.cz/nasm/misc/pmw.bat +9 -0
  136. data/vendor/repo.or.cz/nasm/misc/proc32.ash +441 -0
  137. data/vendor/repo.or.cz/nasm/misc/scitech.mac +1223 -0
  138. data/vendor/repo.or.cz/nasm/misc/xcrcgen.c +80 -0
  139. data/vendor/repo.or.cz/nasm/nasm.spec.in +83 -0
  140. data/vendor/repo.or.cz/nasm/nasm.spec.sed +3 -0
  141. data/vendor/repo.or.cz/nasm/nasm.txt +306 -0
  142. data/vendor/repo.or.cz/nasm/nasmlib/badenum.c +43 -0
  143. data/vendor/repo.or.cz/nasm/nasmlib/bsi.c +77 -0
  144. data/vendor/repo.or.cz/nasm/nasmlib/crc64.c +189 -0
  145. data/vendor/repo.or.cz/nasm/nasmlib/file.c +259 -0
  146. data/vendor/repo.or.cz/nasm/nasmlib/file.h +128 -0
  147. data/vendor/repo.or.cz/nasm/nasmlib/filename.c +69 -0
  148. data/vendor/repo.or.cz/nasm/nasmlib/hashtbl.c +232 -0
  149. data/vendor/repo.or.cz/nasm/nasmlib/ilog2.c +168 -0
  150. data/vendor/repo.or.cz/nasm/nasmlib/malloc.c +108 -0
  151. data/vendor/repo.or.cz/nasm/nasmlib/md5c.c +247 -0
  152. data/vendor/repo.or.cz/nasm/nasmlib/mmap.c +139 -0
  153. data/vendor/repo.or.cz/nasm/nasmlib/path.c +186 -0
  154. data/vendor/repo.or.cz/nasm/nasmlib/perfhash.c +55 -0
  155. data/vendor/repo.or.cz/nasm/nasmlib/perfhash.pl +362 -0
  156. data/vendor/repo.or.cz/nasm/nasmlib/raa.c +173 -0
  157. data/vendor/repo.or.cz/nasm/nasmlib/rbtree.c +119 -0
  158. data/vendor/repo.or.cz/nasm/nasmlib/readnum.c +172 -0
  159. data/vendor/repo.or.cz/nasm/nasmlib/realpath.c +135 -0
  160. data/vendor/repo.or.cz/nasm/nasmlib/saa.c +431 -0
  161. data/vendor/repo.or.cz/nasm/nasmlib/srcfile.c +128 -0
  162. data/vendor/repo.or.cz/nasm/nasmlib/string.c +242 -0
  163. data/vendor/repo.or.cz/nasm/nasmlib/strlist.c +100 -0
  164. data/vendor/repo.or.cz/nasm/nasmlib/ver.c +51 -0
  165. data/vendor/repo.or.cz/nasm/nasmlib/zerobuf.c +42 -0
  166. data/vendor/repo.or.cz/nasm/ndisasm.txt +94 -0
  167. data/vendor/repo.or.cz/nasm/nsis/NASMMultiUser.nsh +478 -0
  168. data/vendor/repo.or.cz/nasm/nsis/getpearch.pl +76 -0
  169. data/vendor/repo.or.cz/nasm/nsis/nasm-un.ico +0 -0
  170. data/vendor/repo.or.cz/nasm/nsis/nasm.ico +0 -0
  171. data/vendor/repo.or.cz/nasm/nsis/nasm.nsi +241 -0
  172. data/vendor/repo.or.cz/nasm/output/codeview.c +814 -0
  173. data/vendor/repo.or.cz/nasm/output/dwarf.h +566 -0
  174. data/vendor/repo.or.cz/nasm/output/elf.h +537 -0
  175. data/vendor/repo.or.cz/nasm/output/legacy.c +112 -0
  176. data/vendor/repo.or.cz/nasm/output/nulldbg.c +93 -0
  177. data/vendor/repo.or.cz/nasm/output/nullout.c +51 -0
  178. data/vendor/repo.or.cz/nasm/output/outaout.c +954 -0
  179. data/vendor/repo.or.cz/nasm/output/outaout.mac +37 -0
  180. data/vendor/repo.or.cz/nasm/output/outas86.c +650 -0
  181. data/vendor/repo.or.cz/nasm/output/outas86.mac +37 -0
  182. data/vendor/repo.or.cz/nasm/output/outbin.c +1713 -0
  183. data/vendor/repo.or.cz/nasm/output/outbin.mac +40 -0
  184. data/vendor/repo.or.cz/nasm/output/outcoff.c +1242 -0
  185. data/vendor/repo.or.cz/nasm/output/outcoff.mac +43 -0
  186. data/vendor/repo.or.cz/nasm/output/outdbg.c +425 -0
  187. data/vendor/repo.or.cz/nasm/output/outelf.c +3370 -0
  188. data/vendor/repo.or.cz/nasm/output/outelf.h +156 -0
  189. data/vendor/repo.or.cz/nasm/output/outelf.mac +41 -0
  190. data/vendor/repo.or.cz/nasm/output/outform.c +120 -0
  191. data/vendor/repo.or.cz/nasm/output/outform.h +379 -0
  192. data/vendor/repo.or.cz/nasm/output/outieee.c +1528 -0
  193. data/vendor/repo.or.cz/nasm/output/outlib.c +58 -0
  194. data/vendor/repo.or.cz/nasm/output/outlib.h +63 -0
  195. data/vendor/repo.or.cz/nasm/output/outmacho.c +2387 -0
  196. data/vendor/repo.or.cz/nasm/output/outmacho.mac +49 -0
  197. data/vendor/repo.or.cz/nasm/output/outobj.c +2725 -0
  198. data/vendor/repo.or.cz/nasm/output/outobj.mac +49 -0
  199. data/vendor/repo.or.cz/nasm/output/outrdf.mac +40 -0
  200. data/vendor/repo.or.cz/nasm/output/outrdf2.c +791 -0
  201. data/vendor/repo.or.cz/nasm/output/outrdf2.mac +43 -0
  202. data/vendor/repo.or.cz/nasm/output/pecoff.h +532 -0
  203. data/vendor/repo.or.cz/nasm/output/stabs.h +144 -0
  204. data/vendor/repo.or.cz/nasm/perllib/crc64.ph +158 -0
  205. data/vendor/repo.or.cz/nasm/perllib/gensv.pl +34 -0
  206. data/vendor/repo.or.cz/nasm/perllib/phash.ph +200 -0
  207. data/vendor/repo.or.cz/nasm/perllib/random_sv_vectors.ph +67 -0
  208. data/vendor/repo.or.cz/nasm/rdoff/README +185 -0
  209. data/vendor/repo.or.cz/nasm/rdoff/collectn.c +44 -0
  210. data/vendor/repo.or.cz/nasm/rdoff/collectn.h +22 -0
  211. data/vendor/repo.or.cz/nasm/rdoff/doc/Makefile +37 -0
  212. data/vendor/repo.or.cz/nasm/rdoff/doc/rdoff.texi +137 -0
  213. data/vendor/repo.or.cz/nasm/rdoff/doc/v1-v2.txt +62 -0
  214. data/vendor/repo.or.cz/nasm/rdoff/hash.c +122 -0
  215. data/vendor/repo.or.cz/nasm/rdoff/hash.h +17 -0
  216. data/vendor/repo.or.cz/nasm/rdoff/ldrdf.1 +41 -0
  217. data/vendor/repo.or.cz/nasm/rdoff/ldrdf.c +1395 -0
  218. data/vendor/repo.or.cz/nasm/rdoff/ldsegs.h +59 -0
  219. data/vendor/repo.or.cz/nasm/rdoff/rdf2bin.1 +65 -0
  220. data/vendor/repo.or.cz/nasm/rdoff/rdf2bin.c +431 -0
  221. data/vendor/repo.or.cz/nasm/rdoff/rdf2com.1 +1 -0
  222. data/vendor/repo.or.cz/nasm/rdoff/rdf2ihx.1 +1 -0
  223. data/vendor/repo.or.cz/nasm/rdoff/rdf2ith.1 +1 -0
  224. data/vendor/repo.or.cz/nasm/rdoff/rdf2srec.1 +1 -0
  225. data/vendor/repo.or.cz/nasm/rdoff/rdfdump.1 +24 -0
  226. data/vendor/repo.or.cz/nasm/rdoff/rdfdump.c +347 -0
  227. data/vendor/repo.or.cz/nasm/rdoff/rdflib.1 +39 -0
  228. data/vendor/repo.or.cz/nasm/rdoff/rdflib.c +434 -0
  229. data/vendor/repo.or.cz/nasm/rdoff/rdfload.c +213 -0
  230. data/vendor/repo.or.cz/nasm/rdoff/rdfload.h +29 -0
  231. data/vendor/repo.or.cz/nasm/rdoff/rdfutils.h +165 -0
  232. data/vendor/repo.or.cz/nasm/rdoff/rdlar.c +492 -0
  233. data/vendor/repo.or.cz/nasm/rdoff/rdlar.h +34 -0
  234. data/vendor/repo.or.cz/nasm/rdoff/rdlib.c +290 -0
  235. data/vendor/repo.or.cz/nasm/rdoff/rdlib.h +62 -0
  236. data/vendor/repo.or.cz/nasm/rdoff/rdoff.c +621 -0
  237. data/vendor/repo.or.cz/nasm/rdoff/rdx.1 +21 -0
  238. data/vendor/repo.or.cz/nasm/rdoff/rdx.c +90 -0
  239. data/vendor/repo.or.cz/nasm/rdoff/segtab.c +172 -0
  240. data/vendor/repo.or.cz/nasm/rdoff/segtab.h +45 -0
  241. data/vendor/repo.or.cz/nasm/rdoff/symtab.c +159 -0
  242. data/vendor/repo.or.cz/nasm/rdoff/symtab.h +55 -0
  243. data/vendor/repo.or.cz/nasm/rdoff/test/Makefile +10 -0
  244. data/vendor/repo.or.cz/nasm/rdoff/test/makelib.sh +14 -0
  245. data/vendor/repo.or.cz/nasm/rdoff/test/rdfseg.asm +20 -0
  246. data/vendor/repo.or.cz/nasm/rdoff/test/rdfseg2.asm +12 -0
  247. data/vendor/repo.or.cz/nasm/rdoff/test/rdftest1.asm +54 -0
  248. data/vendor/repo.or.cz/nasm/rdoff/test/rdftest2.asm +33 -0
  249. data/vendor/repo.or.cz/nasm/rdoff/test/rdtlib.asm +48 -0
  250. data/vendor/repo.or.cz/nasm/rdoff/test/rdtmain.asm +47 -0
  251. data/vendor/repo.or.cz/nasm/rdoff/test/testlib.asm +18 -0
  252. data/vendor/repo.or.cz/nasm/stdlib/snprintf.c +29 -0
  253. data/vendor/repo.or.cz/nasm/stdlib/strlcpy.c +51 -0
  254. data/vendor/repo.or.cz/nasm/stdlib/strnlen.c +46 -0
  255. data/vendor/repo.or.cz/nasm/stdlib/vsnprintf.c +51 -0
  256. data/vendor/repo.or.cz/nasm/test/Makefile +106 -0
  257. data/vendor/repo.or.cz/nasm/test/_file_.asm +5 -0
  258. data/vendor/repo.or.cz/nasm/test/_version.asm +2 -0
  259. data/vendor/repo.or.cz/nasm/test/a32offs.asm +9 -0
  260. data/vendor/repo.or.cz/nasm/test/absolute.asm +40 -0
  261. data/vendor/repo.or.cz/nasm/test/addr64x.asm +18 -0
  262. data/vendor/repo.or.cz/nasm/test/align13.asm +19 -0
  263. data/vendor/repo.or.cz/nasm/test/align13s.asm +20 -0
  264. data/vendor/repo.or.cz/nasm/test/alonesym-obj.asm +166 -0
  265. data/vendor/repo.or.cz/nasm/test/andbyte.asm +15 -0
  266. data/vendor/repo.or.cz/nasm/test/aoutso.asm +99 -0
  267. data/vendor/repo.or.cz/nasm/test/aouttest.asm +86 -0
  268. data/vendor/repo.or.cz/nasm/test/aouttest.c +36 -0
  269. data/vendor/repo.or.cz/nasm/test/avx.asm +46 -0
  270. data/vendor/repo.or.cz/nasm/test/avx005.asm +529 -0
  271. data/vendor/repo.or.cz/nasm/test/avx2.asm +1608 -0
  272. data/vendor/repo.or.cz/nasm/test/avx512cd.asm +106 -0
  273. data/vendor/repo.or.cz/nasm/test/avx512er.asm +144 -0
  274. data/vendor/repo.or.cz/nasm/test/avx512f.asm +7000 -0
  275. data/vendor/repo.or.cz/nasm/test/avx512pf.asm +88 -0
  276. data/vendor/repo.or.cz/nasm/test/bcd.asm +23 -0
  277. data/vendor/repo.or.cz/nasm/test/binexe.asm +35 -0
  278. data/vendor/repo.or.cz/nasm/test/bintest.asm +59 -0
  279. data/vendor/repo.or.cz/nasm/test/bisect.sh +22 -0
  280. data/vendor/repo.or.cz/nasm/test/br1879590.asm +25 -0
  281. data/vendor/repo.or.cz/nasm/test/br2003451.asm +17 -0
  282. data/vendor/repo.or.cz/nasm/test/br2030823.asm +7 -0
  283. data/vendor/repo.or.cz/nasm/test/br2148476.asm +221 -0
  284. data/vendor/repo.or.cz/nasm/test/br2222615.asm +19 -0
  285. data/vendor/repo.or.cz/nasm/test/br2496848.asm +42 -0
  286. data/vendor/repo.or.cz/nasm/test/br3005117.asm +26 -0
  287. data/vendor/repo.or.cz/nasm/test/br3026808.asm +20 -0
  288. data/vendor/repo.or.cz/nasm/test/br3028880.asm +8 -0
  289. data/vendor/repo.or.cz/nasm/test/br3041451.asm +59 -0
  290. data/vendor/repo.or.cz/nasm/test/br3058845.asm +14 -0
  291. data/vendor/repo.or.cz/nasm/test/br3066383.asm +70 -0
  292. data/vendor/repo.or.cz/nasm/test/br3074517.asm +12 -0
  293. data/vendor/repo.or.cz/nasm/test/br3092924.asm +25 -0
  294. data/vendor/repo.or.cz/nasm/test/br3104312.asm +11 -0
  295. data/vendor/repo.or.cz/nasm/test/br3109604.asm +9 -0
  296. data/vendor/repo.or.cz/nasm/test/br3174983.asm +9 -0
  297. data/vendor/repo.or.cz/nasm/test/br3187743.asm +7 -0
  298. data/vendor/repo.or.cz/nasm/test/br3189064.asm +7 -0
  299. data/vendor/repo.or.cz/nasm/test/br3200749.asm +9 -0
  300. data/vendor/repo.or.cz/nasm/test/br3385573.asm +11 -0
  301. data/vendor/repo.or.cz/nasm/test/br3392252.asm +43 -0
  302. data/vendor/repo.or.cz/nasm/test/br3392259.asm +8 -0
  303. data/vendor/repo.or.cz/nasm/test/br3392363.asm +4 -0
  304. data/vendor/repo.or.cz/nasm/test/br3392392.asm +16 -0
  305. data/vendor/repo.or.cz/nasm/test/br3392396.asm +5 -0
  306. data/vendor/repo.or.cz/nasm/test/br3392411.asm +22 -0
  307. data/vendor/repo.or.cz/nasm/test/br3392418.asm +3 -0
  308. data/vendor/repo.or.cz/nasm/test/br3392439.asm +25 -0
  309. data/vendor/repo.or.cz/nasm/test/br3392442.asm +6 -0
  310. data/vendor/repo.or.cz/nasm/test/br560575.asm +17 -0
  311. data/vendor/repo.or.cz/nasm/test/br560873.asm +27 -0
  312. data/vendor/repo.or.cz/nasm/test/br890790.asm +7 -0
  313. data/vendor/repo.or.cz/nasm/test/br890790_i.asm +1 -0
  314. data/vendor/repo.or.cz/nasm/test/br978756.asm +7 -0
  315. data/vendor/repo.or.cz/nasm/test/changed.asm +383 -0
  316. data/vendor/repo.or.cz/nasm/test/cofftest.asm +85 -0
  317. data/vendor/repo.or.cz/nasm/test/cofftest.c +35 -0
  318. data/vendor/repo.or.cz/nasm/test/crc32.asm +37 -0
  319. data/vendor/repo.or.cz/nasm/test/cv8struc.asm +14 -0
  320. data/vendor/repo.or.cz/nasm/test/dtbcd.asm +72 -0
  321. data/vendor/repo.or.cz/nasm/test/elf64so.asm +118 -0
  322. data/vendor/repo.or.cz/nasm/test/elfso.asm +100 -0
  323. data/vendor/repo.or.cz/nasm/test/elftest.asm +87 -0
  324. data/vendor/repo.or.cz/nasm/test/elftest.c +38 -0
  325. data/vendor/repo.or.cz/nasm/test/elftest64.c +43 -0
  326. data/vendor/repo.or.cz/nasm/test/elif.asm +39 -0
  327. data/vendor/repo.or.cz/nasm/test/expimp.asm +90 -0
  328. data/vendor/repo.or.cz/nasm/test/far64.asm +10 -0
  329. data/vendor/repo.or.cz/nasm/test/float.asm +186 -0
  330. data/vendor/repo.or.cz/nasm/test/float8.asm +135 -0
  331. data/vendor/repo.or.cz/nasm/test/floatb.asm +35 -0
  332. data/vendor/repo.or.cz/nasm/test/floatexp.asm +382 -0
  333. data/vendor/repo.or.cz/nasm/test/floatize.asm +19 -0
  334. data/vendor/repo.or.cz/nasm/test/floattest.asm +28 -0
  335. data/vendor/repo.or.cz/nasm/test/floatx.asm +525 -0
  336. data/vendor/repo.or.cz/nasm/test/fpu.asm +127 -0
  337. data/vendor/repo.or.cz/nasm/test/fwdopt.asm +133 -0
  338. data/vendor/repo.or.cz/nasm/test/fwdoptpp.asm +150 -0
  339. data/vendor/repo.or.cz/nasm/test/gas2nasm.py +104 -0
  340. data/vendor/repo.or.cz/nasm/test/gather.asm +11 -0
  341. data/vendor/repo.or.cz/nasm/test/gotoff64.asm +25 -0
  342. data/vendor/repo.or.cz/nasm/test/hexfp.asm +25 -0
  343. data/vendor/repo.or.cz/nasm/test/hle.asm +19 -0
  344. data/vendor/repo.or.cz/nasm/test/ifelse.asm +46 -0
  345. data/vendor/repo.or.cz/nasm/test/ifenv.asm +31 -0
  346. data/vendor/repo.or.cz/nasm/test/ifmacro.asm +413 -0
  347. data/vendor/repo.or.cz/nasm/test/iftoken.asm +317 -0
  348. data/vendor/repo.or.cz/nasm/test/iftoken.pl +32 -0
  349. data/vendor/repo.or.cz/nasm/test/ilog2.asm +271 -0
  350. data/vendor/repo.or.cz/nasm/test/imacro.asm +8 -0
  351. data/vendor/repo.or.cz/nasm/test/imm.asm +23 -0
  352. data/vendor/repo.or.cz/nasm/test/imm64.asm +61 -0
  353. data/vendor/repo.or.cz/nasm/test/immwarn.asm +91 -0
  354. data/vendor/repo.or.cz/nasm/test/imul.asm +117 -0
  355. data/vendor/repo.or.cz/nasm/test/inc1.asm +6 -0
  356. data/vendor/repo.or.cz/nasm/test/inc2.asm +8 -0
  357. data/vendor/repo.or.cz/nasm/test/incbin.asm +7 -0
  358. data/vendor/repo.or.cz/nasm/test/incbin.data +2 -0
  359. data/vendor/repo.or.cz/nasm/test/inctest.asm +15 -0
  360. data/vendor/repo.or.cz/nasm/test/insnlbl.asm +12 -0
  361. data/vendor/repo.or.cz/nasm/test/invlpga.asm +11 -0
  362. data/vendor/repo.or.cz/nasm/test/jmp64.asm +19 -0
  363. data/vendor/repo.or.cz/nasm/test/lar_lsl.asm +124 -0
  364. data/vendor/repo.or.cz/nasm/test/larlsl.asm +23 -0
  365. data/vendor/repo.or.cz/nasm/test/lnxhello.asm +54 -0
  366. data/vendor/repo.or.cz/nasm/test/local.asm +19 -0
  367. data/vendor/repo.or.cz/nasm/test/loopoffs.asm +12 -0
  368. data/vendor/repo.or.cz/nasm/test/lwp.asm +213 -0
  369. data/vendor/repo.or.cz/nasm/test/macro-defaults.asm +64 -0
  370. data/vendor/repo.or.cz/nasm/test/macroerr.asm +12 -0
  371. data/vendor/repo.or.cz/nasm/test/macroerr.inc +3 -0
  372. data/vendor/repo.or.cz/nasm/test/mmxsize.asm +38 -0
  373. data/vendor/repo.or.cz/nasm/test/movd.asm +12 -0
  374. data/vendor/repo.or.cz/nasm/test/movd64.asm +15 -0
  375. data/vendor/repo.or.cz/nasm/test/movimm.asm +28 -0
  376. data/vendor/repo.or.cz/nasm/test/movnti.asm +10 -0
  377. data/vendor/repo.or.cz/nasm/test/mpx-64.asm +120 -0
  378. data/vendor/repo.or.cz/nasm/test/mpx.asm +89 -0
  379. data/vendor/repo.or.cz/nasm/test/multisection.asm +96 -0
  380. data/vendor/repo.or.cz/nasm/test/nasmformat.asm +17 -0
  381. data/vendor/repo.or.cz/nasm/test/new +9 -0
  382. data/vendor/repo.or.cz/nasm/test/newrdwr.asm +24 -0
  383. data/vendor/repo.or.cz/nasm/test/nop.asm +17 -0
  384. data/vendor/repo.or.cz/nasm/test/nullfile.asm +4 -0
  385. data/vendor/repo.or.cz/nasm/test/objexe.asm +30 -0
  386. data/vendor/repo.or.cz/nasm/test/objlink.c +33 -0
  387. data/vendor/repo.or.cz/nasm/test/objtest.asm +85 -0
  388. data/vendor/repo.or.cz/nasm/test/optimization.asm +104 -0
  389. data/vendor/repo.or.cz/nasm/test/org.asm +18 -0
  390. data/vendor/repo.or.cz/nasm/test/paste.asm +12 -0
  391. data/vendor/repo.or.cz/nasm/test/pcrel.asm +52 -0
  392. data/vendor/repo.or.cz/nasm/test/perf/label.pl +18 -0
  393. data/vendor/repo.or.cz/nasm/test/perf/macro.pl +18 -0
  394. data/vendor/repo.or.cz/nasm/test/perf/token.pl +23 -0
  395. data/vendor/repo.or.cz/nasm/test/performtest.pl +192 -0
  396. data/vendor/repo.or.cz/nasm/test/pextrw.asm +3 -0
  397. data/vendor/repo.or.cz/nasm/test/pinsr16.asm +53 -0
  398. data/vendor/repo.or.cz/nasm/test/pinsr32.asm +53 -0
  399. data/vendor/repo.or.cz/nasm/test/pinsr64.asm +68 -0
  400. data/vendor/repo.or.cz/nasm/test/popcnt.asm +32 -0
  401. data/vendor/repo.or.cz/nasm/test/ppindirect.asm +42 -0
  402. data/vendor/repo.or.cz/nasm/test/pragma.asm +12 -0
  403. data/vendor/repo.or.cz/nasm/test/prefix66.asm +28 -0
  404. data/vendor/repo.or.cz/nasm/test/ptr.asm +4 -0
  405. data/vendor/repo.or.cz/nasm/test/pushseg.asm +17 -0
  406. data/vendor/repo.or.cz/nasm/test/r13.asm +15 -0
  407. data/vendor/repo.or.cz/nasm/test/radix.asm +54 -0
  408. data/vendor/repo.or.cz/nasm/test/rdpid.asm +21 -0
  409. data/vendor/repo.or.cz/nasm/test/reldef.asm +57 -0
  410. data/vendor/repo.or.cz/nasm/test/relocs.asm +20 -0
  411. data/vendor/repo.or.cz/nasm/test/riprel.asm +5357 -0
  412. data/vendor/repo.or.cz/nasm/test/riprel.pl +29 -0
  413. data/vendor/repo.or.cz/nasm/test/riprel2.asm +11 -0
  414. data/vendor/repo.or.cz/nasm/test/sha-64.asm +30 -0
  415. data/vendor/repo.or.cz/nasm/test/sha.asm +31 -0
  416. data/vendor/repo.or.cz/nasm/test/smartalign16.asm +36 -0
  417. data/vendor/repo.or.cz/nasm/test/smartalign32.asm +36 -0
  418. data/vendor/repo.or.cz/nasm/test/smartalign64.asm +36 -0
  419. data/vendor/repo.or.cz/nasm/test/splitea.asm +11 -0
  420. data/vendor/repo.or.cz/nasm/test/sreg.asm +65 -0
  421. data/vendor/repo.or.cz/nasm/test/strlen.asm +5 -0
  422. data/vendor/repo.or.cz/nasm/test/struc.asm +33 -0
  423. data/vendor/repo.or.cz/nasm/test/test67.asm +38 -0
  424. data/vendor/repo.or.cz/nasm/test/testdos.asm +13 -0
  425. data/vendor/repo.or.cz/nasm/test/testnos3.asm +973 -0
  426. data/vendor/repo.or.cz/nasm/test/time.asm +11 -0
  427. data/vendor/repo.or.cz/nasm/test/times.asm +21 -0
  428. data/vendor/repo.or.cz/nasm/test/timesneg.asm +3 -0
  429. data/vendor/repo.or.cz/nasm/test/tmap.nas +1447 -0
  430. data/vendor/repo.or.cz/nasm/test/uscore.asm +15 -0
  431. data/vendor/repo.or.cz/nasm/test/utf.asm +82 -0
  432. data/vendor/repo.or.cz/nasm/test/vaesenc.asm +22 -0
  433. data/vendor/repo.or.cz/nasm/test/vex.asm +9 -0
  434. data/vendor/repo.or.cz/nasm/test/vgather.asm +76 -0
  435. data/vendor/repo.or.cz/nasm/test/vmread.asm +26 -0
  436. data/vendor/repo.or.cz/nasm/test/weirdpaste.asm +29 -0
  437. data/vendor/repo.or.cz/nasm/test/xchg.asm +96 -0
  438. data/vendor/repo.or.cz/nasm/test/xcrypt.asm +24 -0
  439. data/vendor/repo.or.cz/nasm/test/xmm0.asm +12 -0
  440. data/vendor/repo.or.cz/nasm/test/zerobyte.asm +22 -0
  441. data/vendor/repo.or.cz/nasm/tools/cleanfile +176 -0
  442. data/vendor/repo.or.cz/nasm/tools/cleanpatch +258 -0
  443. data/vendor/repo.or.cz/nasm/tools/mkdep.pl +261 -0
  444. data/vendor/repo.or.cz/nasm/tools/release +105 -0
  445. data/vendor/repo.or.cz/nasm/tools/syncfiles.pl +137 -0
  446. data/vendor/repo.or.cz/nasm/tools/tag-release +58 -0
  447. data/vendor/repo.or.cz/nasm/version +1 -0
  448. data/vendor/repo.or.cz/nasm/version.pl +189 -0
  449. data/vendor/repo.or.cz/nasm/x86/disp8.c +131 -0
  450. data/vendor/repo.or.cz/nasm/x86/insns-iflags.ph +280 -0
  451. data/vendor/repo.or.cz/nasm/x86/insns.dat +5371 -0
  452. data/vendor/repo.or.cz/nasm/x86/insns.pl +1043 -0
  453. data/vendor/repo.or.cz/nasm/x86/regs.dat +138 -0
  454. data/vendor/repo.or.cz/nasm/x86/regs.pl +204 -0
  455. metadata +520 -0
@@ -0,0 +1,1528 @@
1
+ /* ----------------------------------------------------------------------- *
2
+ *
3
+ * Copyright 1996-2016 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
+ /*
35
+ * outieee.c output routines for the Netwide Assembler to produce
36
+ * IEEE-std object files
37
+ */
38
+
39
+ /* notes: I have tried to make this correspond to the IEEE version
40
+ * of the standard, specifically the primary ASCII version. It should
41
+ * be trivial to create the binary version given this source (which is
42
+ * one of MANY things that have to be done to make this correspond to
43
+ * the hp-microtek version of the standard).
44
+ *
45
+ * 16-bit support is assumed to use 24-bit addresses
46
+ * The linker can sort out segmentation-specific stuff
47
+ * if it keeps track of externals
48
+ * in terms of being relative to section bases
49
+ *
50
+ * A non-standard variable type, the 'Yn' variable, has been introduced.
51
+ * Basically it is a reference to extern 'n'- denoting the low limit
52
+ * (L-variable) of the section that extern 'n' is defined in. Like the
53
+ * x variable, there may be no explicit assignment to it, it is derived
54
+ * from the public definition corresponding to the extern name. This
55
+ * is required because the one thing the mufom guys forgot to do well was
56
+ * take into account segmented architectures.
57
+ *
58
+ * I use comment classes for various things and these are undefined by
59
+ * the standard.
60
+ *
61
+ * Debug info should be considered totally non-standard (local labels are
62
+ * standard but linenum records are not covered by the standard.
63
+ * Type defs have the standard format but absolute meanings for ordinal
64
+ * types are not covered by the standard.)
65
+ *
66
+ * David Lindauer, LADsoft
67
+ */
68
+ #include "compiler.h"
69
+
70
+ #include <stdio.h>
71
+ #include <stdlib.h>
72
+ #include <string.h>
73
+ #include <time.h>
74
+ #include <stdarg.h> /* Note: we need the ANSI version of stdarg.h */
75
+ #include <ctype.h>
76
+
77
+ #include "nasm.h"
78
+ #include "nasmlib.h"
79
+ #include "error.h"
80
+ #include "ver.h"
81
+
82
+ #include "outform.h"
83
+ #include "outlib.h"
84
+
85
+ #ifdef OF_IEEE
86
+
87
+ #define ARRAY_BOT 0x1
88
+
89
+ static char ieee_infile[FILENAME_MAX];
90
+ static int ieee_uppercase;
91
+
92
+ static bool any_segs;
93
+ static int arrindex;
94
+
95
+ #define HUNKSIZE 1024 /* Size of the data hunk */
96
+ #define EXT_BLKSIZ 512
97
+ #define LDPERLINE 32 /* bytes per line in output */
98
+
99
+ struct ieeeSection;
100
+
101
+ struct LineNumber {
102
+ struct LineNumber *next;
103
+ struct ieeeSection *segment;
104
+ int32_t offset;
105
+ int32_t lineno;
106
+ };
107
+
108
+ static struct FileName {
109
+ struct FileName *next;
110
+ char *name;
111
+ int32_t index;
112
+ } *fnhead, **fntail;
113
+
114
+ static struct Array {
115
+ struct Array *next;
116
+ unsigned size;
117
+ int basetype;
118
+ } *arrhead, **arrtail;
119
+
120
+ static struct ieeePublic {
121
+ struct ieeePublic *next;
122
+ char *name;
123
+ int32_t offset;
124
+ int32_t segment; /* only if it's far-absolute */
125
+ int32_t index;
126
+ int type; /* for debug purposes */
127
+ } *fpubhead, **fpubtail, *last_defined;
128
+
129
+ static struct ieeeExternal {
130
+ struct ieeeExternal *next;
131
+ char *name;
132
+ int32_t commonsize;
133
+ } *exthead, **exttail;
134
+
135
+ static int externals;
136
+
137
+ static struct ExtBack {
138
+ struct ExtBack *next;
139
+ int index[EXT_BLKSIZ];
140
+ } *ebhead, **ebtail;
141
+
142
+ /* NOTE: the first segment MUST be the lineno segment */
143
+ static struct ieeeSection {
144
+ struct ieeeSection *next;
145
+ char *name;
146
+ struct ieeeObjData *data, *datacurr;
147
+ struct ieeeFixupp *fptr, *flptr;
148
+ int32_t index; /* the NASM segment id */
149
+ int32_t ieee_index; /* the OBJ-file segment index */
150
+ int32_t currentpos;
151
+ int32_t align; /* can be SEG_ABS + absolute addr */
152
+ int32_t startpos;
153
+ int32_t use32; /* is this segment 32-bit? */
154
+ struct ieeePublic *pubhead, **pubtail, *lochead, **loctail;
155
+ enum {
156
+ CMB_PRIVATE = 0,
157
+ CMB_PUBLIC = 2,
158
+ CMB_COMMON = 6
159
+ } combine;
160
+ } *seghead, **segtail, *ieee_seg_needs_update;
161
+
162
+ struct ieeeObjData {
163
+ struct ieeeObjData *next;
164
+ uint8_t data[HUNKSIZE];
165
+ };
166
+
167
+ struct ieeeFixupp {
168
+ struct ieeeFixupp *next;
169
+ enum {
170
+ FT_SEG = 0,
171
+ FT_REL = 1,
172
+ FT_OFS = 2,
173
+ FT_EXT = 3,
174
+ FT_WRT = 4,
175
+ FT_EXTREL = 5,
176
+ FT_EXTWRT = 6,
177
+ FT_EXTSEG = 7
178
+ } ftype;
179
+ int16_t size;
180
+ int32_t id1;
181
+ int32_t id2;
182
+ int32_t offset;
183
+ int32_t addend;
184
+ };
185
+
186
+ static int32_t ieee_entry_seg, ieee_entry_ofs;
187
+ static int checksum;
188
+
189
+ extern const struct ofmt of_ieee;
190
+ static const struct dfmt ladsoft_debug_form;
191
+
192
+ static void ieee_data_new(struct ieeeSection *);
193
+ static void ieee_write_fixup(int32_t, int32_t, struct ieeeSection *,
194
+ int, uint64_t, int32_t);
195
+ static void ieee_install_fixup(struct ieeeSection *, struct ieeeFixupp *);
196
+ static int32_t ieee_segment(char *, int, int *);
197
+ static void ieee_write_file(void);
198
+ static void ieee_write_byte(struct ieeeSection *, int);
199
+ static void ieee_write_word(struct ieeeSection *, int);
200
+ static void ieee_write_dword(struct ieeeSection *, int32_t);
201
+ static void ieee_putascii(char *, ...);
202
+ static void ieee_putcs(int);
203
+ static int32_t ieee_putld(int32_t, int32_t, uint8_t *);
204
+ static int32_t ieee_putlr(struct ieeeFixupp *);
205
+ static void ieee_unqualified_name(char *, char *);
206
+
207
+ /*
208
+ * pup init
209
+ */
210
+ static void ieee_init(void)
211
+ {
212
+ any_segs = false;
213
+ fpubhead = NULL;
214
+ fpubtail = &fpubhead;
215
+ exthead = NULL;
216
+ exttail = &exthead;
217
+ externals = 1;
218
+ ebhead = NULL;
219
+ ebtail = &ebhead;
220
+ seghead = ieee_seg_needs_update = NULL;
221
+ segtail = &seghead;
222
+ ieee_entry_seg = NO_SEG;
223
+ ieee_uppercase = false;
224
+ checksum = 0;
225
+ }
226
+
227
+ /*
228
+ * Rundown
229
+ */
230
+ static void ieee_cleanup(void)
231
+ {
232
+ ieee_write_file();
233
+ dfmt->cleanup();
234
+ while (seghead) {
235
+ struct ieeeSection *segtmp = seghead;
236
+ seghead = seghead->next;
237
+ while (segtmp->pubhead) {
238
+ struct ieeePublic *pubtmp = segtmp->pubhead;
239
+ segtmp->pubhead = pubtmp->next;
240
+ nasm_free(pubtmp);
241
+ }
242
+ while (segtmp->fptr) {
243
+ struct ieeeFixupp *fixtmp = segtmp->fptr;
244
+ segtmp->fptr = fixtmp->next;
245
+ nasm_free(fixtmp);
246
+ }
247
+ while (segtmp->data) {
248
+ struct ieeeObjData *dattmp = segtmp->data;
249
+ segtmp->data = dattmp->next;
250
+ nasm_free(dattmp);
251
+ }
252
+ nasm_free(segtmp);
253
+ }
254
+ while (fpubhead) {
255
+ struct ieeePublic *pubtmp = fpubhead;
256
+ fpubhead = fpubhead->next;
257
+ nasm_free(pubtmp);
258
+ }
259
+ while (exthead) {
260
+ struct ieeeExternal *exttmp = exthead;
261
+ exthead = exthead->next;
262
+ nasm_free(exttmp);
263
+ }
264
+ while (ebhead) {
265
+ struct ExtBack *ebtmp = ebhead;
266
+ ebhead = ebhead->next;
267
+ nasm_free(ebtmp);
268
+ }
269
+ }
270
+
271
+ /*
272
+ * callback for labels
273
+ */
274
+ static void ieee_deflabel(char *name, int32_t segment,
275
+ int64_t offset, int is_global, char *special)
276
+ {
277
+ /*
278
+ * We have three cases:
279
+ *
280
+ * (i) `segment' is a segment-base. If so, set the name field
281
+ * for the segment structure it refers to, and then
282
+ * return.
283
+ *
284
+ * (ii) `segment' is one of our segments, or a SEG_ABS segment.
285
+ * Save the label position for later output of a PUBDEF record.
286
+ *
287
+ *
288
+ * (iii) `segment' is not one of our segments. Save the label
289
+ * position for later output of an EXTDEF.
290
+ */
291
+ struct ieeeExternal *ext;
292
+ struct ExtBack *eb;
293
+ struct ieeeSection *seg;
294
+ int i;
295
+
296
+ if (special) {
297
+ nasm_error(ERR_NONFATAL, "unrecognised symbol type `%s'", special);
298
+ }
299
+ /*
300
+ * First check for the double-period, signifying something
301
+ * unusual.
302
+ */
303
+ if (name[0] == '.' && name[1] == '.' && name[2] != '@') {
304
+ if (!strcmp(name, "..start")) {
305
+ ieee_entry_seg = segment;
306
+ ieee_entry_ofs = offset;
307
+ }
308
+ return;
309
+ }
310
+
311
+ /*
312
+ * Case (i):
313
+ */
314
+ if (ieee_seg_needs_update) {
315
+ ieee_seg_needs_update->name = name;
316
+ return;
317
+ }
318
+ if (segment < SEG_ABS && segment != NO_SEG && segment % 2)
319
+ return;
320
+
321
+ /*
322
+ * case (ii)
323
+ */
324
+ if (segment >= SEG_ABS) {
325
+ /*
326
+ * SEG_ABS subcase of (ii).
327
+ */
328
+ if (is_global) {
329
+ struct ieeePublic *pub;
330
+
331
+ pub = *fpubtail = nasm_malloc(sizeof(*pub));
332
+ fpubtail = &pub->next;
333
+ pub->next = NULL;
334
+ pub->name = name;
335
+ pub->offset = offset;
336
+ pub->segment = segment & ~SEG_ABS;
337
+ }
338
+ return;
339
+ }
340
+
341
+ for (seg = seghead; seg && is_global; seg = seg->next)
342
+ if (seg->index == segment) {
343
+ struct ieeePublic *pub;
344
+
345
+ last_defined = pub = *seg->pubtail = nasm_malloc(sizeof(*pub));
346
+ seg->pubtail = &pub->next;
347
+ pub->next = NULL;
348
+ pub->name = name;
349
+ pub->offset = offset;
350
+ pub->index = seg->ieee_index;
351
+ pub->segment = -1;
352
+ return;
353
+ }
354
+
355
+ /*
356
+ * Case (iii).
357
+ */
358
+ if (is_global) {
359
+ ext = *exttail = nasm_malloc(sizeof(*ext));
360
+ ext->next = NULL;
361
+ exttail = &ext->next;
362
+ ext->name = name;
363
+ if (is_global == 2)
364
+ ext->commonsize = offset;
365
+ else
366
+ ext->commonsize = 0;
367
+ i = segment / 2;
368
+ eb = ebhead;
369
+ if (!eb) {
370
+ eb = *ebtail = nasm_zalloc(sizeof(*eb));
371
+ eb->next = NULL;
372
+ ebtail = &eb->next;
373
+ }
374
+ while (i > EXT_BLKSIZ) {
375
+ if (eb && eb->next)
376
+ eb = eb->next;
377
+ else {
378
+ eb = *ebtail = nasm_zalloc(sizeof(*eb));
379
+ eb->next = NULL;
380
+ ebtail = &eb->next;
381
+ }
382
+ i -= EXT_BLKSIZ;
383
+ }
384
+ eb->index[i] = externals++;
385
+ }
386
+
387
+ }
388
+
389
+ /*
390
+ * Put data out
391
+ */
392
+ static void ieee_out(int32_t segto, const void *data,
393
+ enum out_type type, uint64_t size,
394
+ int32_t segment, int32_t wrt)
395
+ {
396
+ const uint8_t *ucdata;
397
+ int32_t ldata;
398
+ struct ieeeSection *seg;
399
+
400
+ /*
401
+ * handle absolute-assembly (structure definitions)
402
+ */
403
+ if (segto == NO_SEG) {
404
+ if (type != OUT_RESERVE)
405
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
406
+ " space");
407
+ return;
408
+ }
409
+
410
+ /*
411
+ * If `any_segs' is still false, we must define a default
412
+ * segment.
413
+ */
414
+ if (!any_segs) {
415
+ int tempint; /* ignored */
416
+ if (segto != ieee_segment("__NASMDEFSEG", 2, &tempint))
417
+ nasm_panic(0, "strange segment conditions in IEEE driver");
418
+ }
419
+
420
+ /*
421
+ * Find the segment we are targetting.
422
+ */
423
+ for (seg = seghead; seg; seg = seg->next)
424
+ if (seg->index == segto)
425
+ break;
426
+ if (!seg)
427
+ nasm_panic(0, "code directed to nonexistent segment?");
428
+
429
+ if (type == OUT_RAWDATA) {
430
+ ucdata = data;
431
+ while (size--)
432
+ ieee_write_byte(seg, *ucdata++);
433
+ } else if (type == OUT_ADDRESS || type == OUT_REL2ADR ||
434
+ type == OUT_REL4ADR) {
435
+ if (type == OUT_ADDRESS)
436
+ size = abs((int)size);
437
+ else if (segment == NO_SEG)
438
+ nasm_error(ERR_NONFATAL, "relative call to absolute address not"
439
+ " supported by IEEE format");
440
+ ldata = *(int64_t *)data;
441
+ if (type == OUT_REL2ADR)
442
+ ldata += (size - 2);
443
+ if (type == OUT_REL4ADR)
444
+ ldata += (size - 4);
445
+ ieee_write_fixup(segment, wrt, seg, size, type, ldata);
446
+ if (size == 2)
447
+ ieee_write_word(seg, ldata);
448
+ else
449
+ ieee_write_dword(seg, ldata);
450
+ } else if (type == OUT_RESERVE) {
451
+ while (size--)
452
+ ieee_write_byte(seg, 0);
453
+ }
454
+ }
455
+
456
+ static void ieee_data_new(struct ieeeSection *segto)
457
+ {
458
+
459
+ if (!segto->data)
460
+ segto->data = segto->datacurr =
461
+ nasm_malloc(sizeof(*(segto->datacurr)));
462
+ else
463
+ segto->datacurr = segto->datacurr->next =
464
+ nasm_malloc(sizeof(*(segto->datacurr)));
465
+ segto->datacurr->next = NULL;
466
+ }
467
+
468
+ /*
469
+ * this routine is unalduterated bloatware. I usually don't do this
470
+ * but I might as well see what it is like on a harmless program.
471
+ * If anyone wants to optimize this is a good canditate!
472
+ */
473
+ static void ieee_write_fixup(int32_t segment, int32_t wrt,
474
+ struct ieeeSection *segto, int size,
475
+ uint64_t realtype, int32_t offset)
476
+ {
477
+ struct ieeeSection *target;
478
+ struct ieeeFixupp s;
479
+
480
+ /* Don't put a fixup for things NASM can calculate */
481
+ if (wrt == NO_SEG && segment == NO_SEG)
482
+ return;
483
+
484
+ s.ftype = -1;
485
+ /* if it is a WRT offset */
486
+ if (wrt != NO_SEG) {
487
+ s.ftype = FT_WRT;
488
+ s.addend = offset;
489
+ if (wrt >= SEG_ABS)
490
+ s.id1 = -(wrt - SEG_ABS);
491
+ else {
492
+ if (wrt % 2 && realtype != OUT_REL2ADR
493
+ && realtype != OUT_REL4ADR) {
494
+ wrt--;
495
+
496
+ for (target = seghead; target; target = target->next)
497
+ if (target->index == wrt)
498
+ break;
499
+ if (target) {
500
+ s.id1 = target->ieee_index;
501
+ for (target = seghead; target; target = target->next)
502
+ if (target->index == segment)
503
+ break;
504
+
505
+ if (target)
506
+ s.id2 = target->ieee_index;
507
+ else {
508
+ /*
509
+ * Now we assume the segment field is being used
510
+ * to hold an extern index
511
+ */
512
+ int32_t i = segment / 2;
513
+ struct ExtBack *eb = ebhead;
514
+ while (i > EXT_BLKSIZ) {
515
+ if (eb)
516
+ eb = eb->next;
517
+ else
518
+ break;
519
+ i -= EXT_BLKSIZ;
520
+ }
521
+ /* if we have an extern decide the type and make a record
522
+ */
523
+ if (eb) {
524
+ s.ftype = FT_EXTWRT;
525
+ s.addend = 0;
526
+ s.id2 = eb->index[i];
527
+ } else
528
+ nasm_error(ERR_NONFATAL,
529
+ "Source of WRT must be an offset");
530
+ }
531
+
532
+ } else
533
+ nasm_panic(0,
534
+ "unrecognised WRT value in ieee_write_fixup");
535
+ } else
536
+ nasm_error(ERR_NONFATAL, "target of WRT must be a section ");
537
+ }
538
+ s.size = size;
539
+ ieee_install_fixup(segto, &s);
540
+ return;
541
+ }
542
+ /* Pure segment fixup ? */
543
+ if (segment != NO_SEG) {
544
+ s.ftype = FT_SEG;
545
+ s.id1 = 0;
546
+ if (segment >= SEG_ABS) {
547
+ /* absolute far segment fixup */
548
+ s.id1 = -(segment - ~SEG_ABS);
549
+ } else if (segment % 2) {
550
+ /* fixup to named segment */
551
+ /* look it up */
552
+ for (target = seghead; target; target = target->next)
553
+ if (target->index == segment - 1)
554
+ break;
555
+ if (target)
556
+ s.id1 = target->ieee_index;
557
+ else {
558
+ /*
559
+ * Now we assume the segment field is being used
560
+ * to hold an extern index
561
+ */
562
+ int32_t i = segment / 2;
563
+ struct ExtBack *eb = ebhead;
564
+ while (i > EXT_BLKSIZ) {
565
+ if (eb)
566
+ eb = eb->next;
567
+ else
568
+ break;
569
+ i -= EXT_BLKSIZ;
570
+ }
571
+ /* if we have an extern decide the type and make a record
572
+ */
573
+ if (eb) {
574
+ if (realtype == OUT_REL2ADR || realtype == OUT_REL4ADR) {
575
+ nasm_panic(0,
576
+ "Segment of a rel not supported in ieee_write_fixup");
577
+ } else {
578
+ /* If we want the segment */
579
+ s.ftype = FT_EXTSEG;
580
+ s.addend = 0;
581
+ s.id1 = eb->index[i];
582
+ }
583
+
584
+ } else
585
+ /* If we get here the seg value doesn't make sense */
586
+ nasm_panic(0,
587
+ "unrecognised segment value in ieee_write_fixup");
588
+ }
589
+
590
+ } else {
591
+ /* Assume we are offsetting directly from a section
592
+ * So look up the target segment
593
+ */
594
+ for (target = seghead; target; target = target->next)
595
+ if (target->index == segment)
596
+ break;
597
+ if (target) {
598
+ if (realtype == OUT_REL2ADR || realtype == OUT_REL4ADR) {
599
+ /* PC rel to a known offset */
600
+ s.id1 = target->ieee_index;
601
+ s.ftype = FT_REL;
602
+ s.size = size;
603
+ s.addend = offset;
604
+ } else {
605
+ /* We were offsetting from a seg */
606
+ s.id1 = target->ieee_index;
607
+ s.ftype = FT_OFS;
608
+ s.size = size;
609
+ s.addend = offset;
610
+ }
611
+ } else {
612
+ /*
613
+ * Now we assume the segment field is being used
614
+ * to hold an extern index
615
+ */
616
+ int32_t i = segment / 2;
617
+ struct ExtBack *eb = ebhead;
618
+ while (i > EXT_BLKSIZ) {
619
+ if (eb)
620
+ eb = eb->next;
621
+ else
622
+ break;
623
+ i -= EXT_BLKSIZ;
624
+ }
625
+ /* if we have an extern decide the type and make a record
626
+ */
627
+ if (eb) {
628
+ if (realtype == OUT_REL2ADR || realtype == OUT_REL4ADR) {
629
+ s.ftype = FT_EXTREL;
630
+ s.addend = 0;
631
+ s.id1 = eb->index[i];
632
+ } else {
633
+ /* else we want the external offset */
634
+ s.ftype = FT_EXT;
635
+ s.addend = 0;
636
+ s.id1 = eb->index[i];
637
+ }
638
+
639
+ } else
640
+ /* If we get here the seg value doesn't make sense */
641
+ nasm_panic(0,
642
+ "unrecognised segment value in ieee_write_fixup");
643
+ }
644
+ }
645
+ if (size != 2 && s.ftype == FT_SEG)
646
+ nasm_error(ERR_NONFATAL, "IEEE format can only handle 2-byte"
647
+ " segment base references");
648
+ s.size = size;
649
+ ieee_install_fixup(segto, &s);
650
+ return;
651
+ }
652
+ /* should never get here */
653
+ }
654
+ static void ieee_install_fixup(struct ieeeSection *seg,
655
+ struct ieeeFixupp *fix)
656
+ {
657
+ struct ieeeFixupp *f;
658
+ f = nasm_malloc(sizeof(struct ieeeFixupp));
659
+ memcpy(f, fix, sizeof(struct ieeeFixupp));
660
+ f->offset = seg->currentpos;
661
+ seg->currentpos += fix->size;
662
+ f->next = NULL;
663
+ if (seg->fptr)
664
+ seg->flptr = seg->flptr->next = f;
665
+ else
666
+ seg->fptr = seg->flptr = f;
667
+
668
+ }
669
+
670
+ /*
671
+ * segment registry
672
+ */
673
+ static int32_t ieee_segment(char *name, int pass, int *bits)
674
+ {
675
+ /*
676
+ * We call the label manager here to define a name for the new
677
+ * segment, and when our _own_ label-definition stub gets
678
+ * called in return, it should register the new segment name
679
+ * using the pointer it gets passed. That way we save memory,
680
+ * by sponging off the label manager.
681
+ */
682
+ if (!name) {
683
+ *bits = 16;
684
+ if (!any_segs)
685
+ return 0;
686
+ return seghead->index;
687
+ } else {
688
+ struct ieeeSection *seg;
689
+ int ieee_idx, attrs;
690
+ bool rn_error;
691
+ char *p;
692
+
693
+ /*
694
+ * Look for segment attributes.
695
+ */
696
+ attrs = 0;
697
+ while (*name == '.')
698
+ name++; /* hack, but a documented one */
699
+ p = name;
700
+ while (*p && !nasm_isspace(*p))
701
+ p++;
702
+ if (*p) {
703
+ *p++ = '\0';
704
+ while (*p && nasm_isspace(*p))
705
+ *p++ = '\0';
706
+ }
707
+ while (*p) {
708
+ while (*p && !nasm_isspace(*p))
709
+ p++;
710
+ if (*p) {
711
+ *p++ = '\0';
712
+ while (*p && nasm_isspace(*p))
713
+ *p++ = '\0';
714
+ }
715
+
716
+ attrs++;
717
+ }
718
+
719
+ ieee_idx = 1;
720
+ for (seg = seghead; seg; seg = seg->next) {
721
+ ieee_idx++;
722
+ if (!strcmp(seg->name, name)) {
723
+ if (attrs > 0 && pass == 1)
724
+ nasm_error(ERR_WARNING, "segment attributes specified on"
725
+ " redeclaration of segment: ignoring");
726
+ if (seg->use32)
727
+ *bits = 32;
728
+ else
729
+ *bits = 16;
730
+ return seg->index;
731
+ }
732
+ }
733
+
734
+ *segtail = seg = nasm_malloc(sizeof(*seg));
735
+ seg->next = NULL;
736
+ segtail = &seg->next;
737
+ seg->index = seg_alloc();
738
+ seg->ieee_index = ieee_idx;
739
+ any_segs = true;
740
+ seg->name = NULL;
741
+ seg->currentpos = 0;
742
+ seg->align = 1; /* default */
743
+ seg->use32 = *bits == 32; /* default to user spec */
744
+ seg->combine = CMB_PUBLIC; /* default */
745
+ seg->pubhead = NULL;
746
+ seg->pubtail = &seg->pubhead;
747
+ seg->data = NULL;
748
+ seg->fptr = NULL;
749
+ seg->lochead = NULL;
750
+ seg->loctail = &seg->lochead;
751
+
752
+ /*
753
+ * Process the segment attributes.
754
+ */
755
+ p = name;
756
+ while (attrs--) {
757
+ p += strlen(p);
758
+ while (!*p)
759
+ p++;
760
+
761
+ /*
762
+ * `p' contains a segment attribute.
763
+ */
764
+ if (!nasm_stricmp(p, "private"))
765
+ seg->combine = CMB_PRIVATE;
766
+ else if (!nasm_stricmp(p, "public"))
767
+ seg->combine = CMB_PUBLIC;
768
+ else if (!nasm_stricmp(p, "common"))
769
+ seg->combine = CMB_COMMON;
770
+ else if (!nasm_stricmp(p, "use16"))
771
+ seg->use32 = false;
772
+ else if (!nasm_stricmp(p, "use32"))
773
+ seg->use32 = true;
774
+ else if (!nasm_strnicmp(p, "align=", 6)) {
775
+ seg->align = readnum(p + 6, &rn_error);
776
+ if (seg->align == 0)
777
+ seg->align = 1;
778
+ if (rn_error) {
779
+ seg->align = 1;
780
+ nasm_error(ERR_NONFATAL, "segment alignment should be"
781
+ " numeric");
782
+ }
783
+ switch (seg->align) {
784
+ case 1: /* BYTE */
785
+ case 2: /* WORD */
786
+ case 4: /* DWORD */
787
+ case 16: /* PARA */
788
+ case 256: /* PAGE */
789
+ case 8:
790
+ case 32:
791
+ case 64:
792
+ case 128:
793
+ break;
794
+ default:
795
+ nasm_error(ERR_NONFATAL, "invalid alignment value %d",
796
+ seg->align);
797
+ seg->align = 1;
798
+ break;
799
+ }
800
+ } else if (!nasm_strnicmp(p, "absolute=", 9)) {
801
+ seg->align = SEG_ABS + readnum(p + 9, &rn_error);
802
+ if (rn_error)
803
+ nasm_error(ERR_NONFATAL, "argument to `absolute' segment"
804
+ " attribute should be numeric");
805
+ }
806
+ }
807
+
808
+ ieee_seg_needs_update = seg;
809
+ if (seg->align >= SEG_ABS)
810
+ define_label(name, NO_SEG, seg->align - SEG_ABS,
811
+ NULL, false, false);
812
+ else
813
+ define_label(name, seg->index + 1, 0L, NULL, false, false);
814
+ ieee_seg_needs_update = NULL;
815
+
816
+ if (seg->use32)
817
+ *bits = 32;
818
+ else
819
+ *bits = 16;
820
+ return seg->index;
821
+ }
822
+ }
823
+
824
+ /*
825
+ * directives supported
826
+ */
827
+ static enum directive_result
828
+ ieee_directive(enum directive directive, char *value, int pass)
829
+ {
830
+
831
+ (void)value;
832
+ (void)pass;
833
+
834
+ switch (directive) {
835
+ case D_UPPERCASE:
836
+ ieee_uppercase = true;
837
+ return DIRR_OK;
838
+
839
+ default:
840
+ return DIRR_UNKNOWN;
841
+ }
842
+ }
843
+
844
+ static void ieee_sectalign(int32_t seg, unsigned int value)
845
+ {
846
+ struct ieeeSection *s;
847
+
848
+ list_for_each(s, seghead) {
849
+ if (s->index == seg)
850
+ break;
851
+ }
852
+
853
+ /*
854
+ * 256 is maximum there, note it may happen
855
+ * that align is issued on "absolute" segment
856
+ * it's fine since SEG_ABS > 256 and we never
857
+ * get escape this test
858
+ */
859
+ if (!s || !is_power2(value) || value > 256)
860
+ return;
861
+
862
+ if ((unsigned int)s->align < value)
863
+ s->align = value;
864
+ }
865
+
866
+ /*
867
+ * Return segment data
868
+ */
869
+ static int32_t ieee_segbase(int32_t segment)
870
+ {
871
+ struct ieeeSection *seg;
872
+
873
+ /*
874
+ * Find the segment in our list.
875
+ */
876
+ for (seg = seghead; seg; seg = seg->next)
877
+ if (seg->index == segment - 1)
878
+ break;
879
+
880
+ if (!seg)
881
+ return segment; /* not one of ours - leave it alone */
882
+
883
+ if (seg->align >= SEG_ABS)
884
+ return seg->align; /* absolute segment */
885
+
886
+ return segment; /* no special treatment */
887
+ }
888
+
889
+ /*
890
+ * filename
891
+ */
892
+ static void ieee_filename(char *inname, char *outname)
893
+ {
894
+ strcpy(ieee_infile, inname);
895
+ standard_extension(inname, outname, ".o");
896
+ }
897
+
898
+ static void ieee_write_file(void)
899
+ {
900
+ const struct tm * const thetime = &official_compile_time.local;
901
+ struct FileName *fn;
902
+ struct ieeeSection *seg;
903
+ struct ieeePublic *pub, *loc;
904
+ struct ieeeExternal *ext;
905
+ struct ieeeObjData *data;
906
+ struct ieeeFixupp *fix;
907
+ struct Array *arr;
908
+ int i;
909
+ const bool debuginfo = (dfmt == &ladsoft_debug_form);
910
+
911
+ /*
912
+ * Write the module header
913
+ */
914
+ ieee_putascii("MBFNASM,%02X%s.\n", strlen(ieee_infile), ieee_infile);
915
+
916
+ /*
917
+ * Write the NASM boast comment.
918
+ */
919
+ ieee_putascii("CO0,%02X%s.\n", strlen(nasm_comment), nasm_comment);
920
+
921
+ /*
922
+ * write processor-specific information
923
+ */
924
+ ieee_putascii("AD8,4,L.\n");
925
+
926
+ /*
927
+ * date and time
928
+ */
929
+ ieee_putascii("DT%04d%02d%02d%02d%02d%02d.\n",
930
+ 1900 + thetime->tm_year, thetime->tm_mon + 1,
931
+ thetime->tm_mday, thetime->tm_hour, thetime->tm_min,
932
+ thetime->tm_sec);
933
+ /*
934
+ * if debugging, dump file names
935
+ */
936
+ for (fn = fnhead; fn && debuginfo; fn = fn->next) {
937
+ ieee_putascii("C0105,%02X%s.\n", strlen(fn->name), fn->name);
938
+ }
939
+
940
+ ieee_putascii("CO101,07ENDHEAD.\n");
941
+ /*
942
+ * the standard doesn't specify when to put checksums,
943
+ * we'll just do it periodically.
944
+ */
945
+ ieee_putcs(false);
946
+
947
+ /*
948
+ * Write the section headers
949
+ */
950
+ seg = seghead;
951
+ if (!debuginfo && !strcmp(seg->name, "??LINE"))
952
+ seg = seg->next;
953
+ while (seg) {
954
+ char buf[256];
955
+ char attrib;
956
+ switch (seg->combine) {
957
+ case CMB_PUBLIC:
958
+ default:
959
+ attrib = 'C';
960
+ break;
961
+ case CMB_PRIVATE:
962
+ attrib = 'S';
963
+ break;
964
+ case CMB_COMMON:
965
+ attrib = 'M';
966
+ break;
967
+ }
968
+ ieee_unqualified_name(buf, seg->name);
969
+ if (seg->align >= SEG_ABS) {
970
+ ieee_putascii("ST%X,A,%02X%s.\n", seg->ieee_index,
971
+ strlen(buf), buf);
972
+ ieee_putascii("ASL%X,%lX.\n", seg->ieee_index,
973
+ (seg->align - SEG_ABS) * 16);
974
+ } else {
975
+ ieee_putascii("ST%X,%c,%02X%s.\n", seg->ieee_index, attrib,
976
+ strlen(buf), buf);
977
+ ieee_putascii("SA%X,%lX.\n", seg->ieee_index, seg->align);
978
+ ieee_putascii("ASS%X,%X.\n", seg->ieee_index,
979
+ seg->currentpos);
980
+ }
981
+ seg = seg->next;
982
+ }
983
+ /*
984
+ * write the start address if there is one
985
+ */
986
+ if (ieee_entry_seg) {
987
+ for (seg = seghead; seg; seg = seg->next)
988
+ if (seg->index == ieee_entry_seg)
989
+ break;
990
+ if (!seg)
991
+ nasm_panic(0, "Start address records are incorrect");
992
+ else
993
+ ieee_putascii("ASG,R%X,%lX,+.\n", seg->ieee_index,
994
+ ieee_entry_ofs);
995
+ }
996
+
997
+ ieee_putcs(false);
998
+ /*
999
+ * Write the publics
1000
+ */
1001
+ i = 1;
1002
+ for (seg = seghead; seg; seg = seg->next) {
1003
+ for (pub = seg->pubhead; pub; pub = pub->next) {
1004
+ char buf[256];
1005
+ ieee_unqualified_name(buf, pub->name);
1006
+ ieee_putascii("NI%X,%02X%s.\n", i, strlen(buf), buf);
1007
+ if (pub->segment == -1)
1008
+ ieee_putascii("ASI%X,R%X,%lX,+.\n", i, pub->index,
1009
+ pub->offset);
1010
+ else
1011
+ ieee_putascii("ASI%X,%lX,%lX,+.\n", i, pub->segment * 16,
1012
+ pub->offset);
1013
+ if (debuginfo) {
1014
+ if (pub->type >= 0x100)
1015
+ ieee_putascii("ATI%X,T%X.\n", i, pub->type - 0x100);
1016
+ else
1017
+ ieee_putascii("ATI%X,%X.\n", i, pub->type);
1018
+ }
1019
+ i++;
1020
+ }
1021
+ }
1022
+ pub = fpubhead;
1023
+ i = 1;
1024
+ while (pub) {
1025
+ char buf[256];
1026
+ ieee_unqualified_name(buf, pub->name);
1027
+ ieee_putascii("NI%X,%02X%s.\n", i, strlen(buf), buf);
1028
+ if (pub->segment == -1)
1029
+ ieee_putascii("ASI%X,R%X,%lX,+.\n", i, pub->index,
1030
+ pub->offset);
1031
+ else
1032
+ ieee_putascii("ASI%X,%lX,%lX,+.\n", i, pub->segment * 16,
1033
+ pub->offset);
1034
+ if (debuginfo) {
1035
+ if (pub->type >= 0x100)
1036
+ ieee_putascii("ATI%X,T%X.\n", i, pub->type - 0x100);
1037
+ else
1038
+ ieee_putascii("ATI%X,%X.\n", i, pub->type);
1039
+ }
1040
+ i++;
1041
+ pub = pub->next;
1042
+ }
1043
+ /*
1044
+ * Write the externals
1045
+ */
1046
+ ext = exthead;
1047
+ i = 1;
1048
+ while (ext) {
1049
+ char buf[256];
1050
+ ieee_unqualified_name(buf, ext->name);
1051
+ ieee_putascii("NX%X,%02X%s.\n", i++, strlen(buf), buf);
1052
+ ext = ext->next;
1053
+ }
1054
+ ieee_putcs(false);
1055
+
1056
+ /*
1057
+ * IEEE doesn't have a standard pass break record
1058
+ * so use the ladsoft variant
1059
+ */
1060
+ ieee_putascii("CO100,06ENDSYM.\n");
1061
+
1062
+ /*
1063
+ * now put types
1064
+ */
1065
+ i = ARRAY_BOT;
1066
+ for (arr = arrhead; arr && debuginfo; arr = arr->next) {
1067
+ ieee_putascii("TY%X,20,%X,%lX.\n", i++, arr->basetype,
1068
+ arr->size);
1069
+ }
1070
+ /*
1071
+ * now put locals
1072
+ */
1073
+ i = 1;
1074
+ for (seg = seghead; seg && debuginfo; seg = seg->next) {
1075
+ for (loc = seg->lochead; loc; loc = loc->next) {
1076
+ char buf[256];
1077
+ ieee_unqualified_name(buf, loc->name);
1078
+ ieee_putascii("NN%X,%02X%s.\n", i, strlen(buf), buf);
1079
+ if (loc->segment == -1)
1080
+ ieee_putascii("ASN%X,R%X,%lX,+.\n", i, loc->index,
1081
+ loc->offset);
1082
+ else
1083
+ ieee_putascii("ASN%X,%lX,%lX,+.\n", i, loc->segment * 16,
1084
+ loc->offset);
1085
+ if (debuginfo) {
1086
+ if (loc->type >= 0x100)
1087
+ ieee_putascii("ATN%X,T%X.\n", i, loc->type - 0x100);
1088
+ else
1089
+ ieee_putascii("ATN%X,%X.\n", i, loc->type);
1090
+ }
1091
+ i++;
1092
+ }
1093
+ }
1094
+
1095
+ /*
1096
+ * put out section data;
1097
+ */
1098
+ seg = seghead;
1099
+ if (!debuginfo && !strcmp(seg->name, "??LINE"))
1100
+ seg = seg->next;
1101
+ while (seg) {
1102
+ if (seg->currentpos) {
1103
+ int32_t size, org = 0;
1104
+ data = seg->data;
1105
+ ieee_putascii("SB%X.\n", seg->ieee_index);
1106
+ fix = seg->fptr;
1107
+ while (fix) {
1108
+ size = HUNKSIZE - (org % HUNKSIZE);
1109
+ size =
1110
+ size + org >
1111
+ seg->currentpos ? seg->currentpos - org : size;
1112
+ size = fix->offset - org > size ? size : fix->offset - org;
1113
+ org = ieee_putld(org, org + size, data->data);
1114
+ if (org % HUNKSIZE == 0)
1115
+ data = data->next;
1116
+ if (org == fix->offset) {
1117
+ org += ieee_putlr(fix);
1118
+ fix = fix->next;
1119
+ }
1120
+ }
1121
+ while (org < seg->currentpos && data) {
1122
+ size =
1123
+ seg->currentpos - org >
1124
+ HUNKSIZE ? HUNKSIZE : seg->currentpos - org;
1125
+ org = ieee_putld(org, org + size, data->data);
1126
+ data = data->next;
1127
+ }
1128
+ ieee_putcs(false);
1129
+
1130
+ }
1131
+ seg = seg->next;
1132
+ }
1133
+ /*
1134
+ * module end record
1135
+ */
1136
+ ieee_putascii("ME.\n");
1137
+ }
1138
+
1139
+ static void ieee_write_byte(struct ieeeSection *seg, int data)
1140
+ {
1141
+ int temp;
1142
+ if (!(temp = seg->currentpos++ % HUNKSIZE))
1143
+ ieee_data_new(seg);
1144
+ seg->datacurr->data[temp] = data;
1145
+ }
1146
+
1147
+ static void ieee_write_word(struct ieeeSection *seg, int data)
1148
+ {
1149
+ ieee_write_byte(seg, data & 0xFF);
1150
+ ieee_write_byte(seg, (data >> 8) & 0xFF);
1151
+ }
1152
+
1153
+ static void ieee_write_dword(struct ieeeSection *seg, int32_t data)
1154
+ {
1155
+ ieee_write_byte(seg, data & 0xFF);
1156
+ ieee_write_byte(seg, (data >> 8) & 0xFF);
1157
+ ieee_write_byte(seg, (data >> 16) & 0xFF);
1158
+ ieee_write_byte(seg, (data >> 24) & 0xFF);
1159
+ }
1160
+ static void ieee_putascii(char *format, ...)
1161
+ {
1162
+ char buffer[256];
1163
+ int i, l;
1164
+ va_list ap;
1165
+
1166
+ va_start(ap, format);
1167
+ vsnprintf(buffer, sizeof(buffer), format, ap);
1168
+ l = strlen(buffer);
1169
+ for (i = 0; i < l; i++)
1170
+ if ((uint8_t)buffer[i] > 31)
1171
+ checksum += buffer[i];
1172
+ va_end(ap);
1173
+ fputs(buffer, ofile);
1174
+ }
1175
+
1176
+ /*
1177
+ * put out a checksum record */
1178
+ static void ieee_putcs(int toclear)
1179
+ {
1180
+ if (toclear) {
1181
+ ieee_putascii("CS.\n");
1182
+ } else {
1183
+ checksum += 'C';
1184
+ checksum += 'S';
1185
+ ieee_putascii("CS%02X.\n", checksum & 127);
1186
+ }
1187
+ checksum = 0;
1188
+ }
1189
+
1190
+ static int32_t ieee_putld(int32_t start, int32_t end, uint8_t *buf)
1191
+ {
1192
+ int32_t val;
1193
+ if (start == end)
1194
+ return (start);
1195
+ val = start % HUNKSIZE;
1196
+ /* fill up multiple lines */
1197
+ while (end - start >= LDPERLINE) {
1198
+ int i;
1199
+ ieee_putascii("LD");
1200
+ for (i = 0; i < LDPERLINE; i++) {
1201
+ ieee_putascii("%02X", buf[val++]);
1202
+ start++;
1203
+ }
1204
+ ieee_putascii(".\n");
1205
+ }
1206
+ /* if no partial lines */
1207
+ if (start == end)
1208
+ return (start);
1209
+ /* make a partial line */
1210
+ ieee_putascii("LD");
1211
+ while (start < end) {
1212
+ ieee_putascii("%02X", buf[val++]);
1213
+ start++;
1214
+ }
1215
+ ieee_putascii(".\n");
1216
+ return (start);
1217
+ }
1218
+ static int32_t ieee_putlr(struct ieeeFixupp *p)
1219
+ {
1220
+ /*
1221
+ * To deal with the vagaries of segmentation the LADsoft linker
1222
+ * defines two types of segments: absolute and virtual. Note that
1223
+ * 'absolute' in this context is a different thing from the IEEE
1224
+ * definition of an absolute segment type, which is also supported. If a
1225
+ * sement is linked in virtual mode the low limit (L-var) is
1226
+ * subtracted from each R,X, and P variable which appears in an
1227
+ * expression, so that we can have relative offsets. Meanwhile
1228
+ * in the ABSOLUTE mode this subtraction is not done and
1229
+ * so we can use absolute offsets from 0. In the LADsoft linker
1230
+ * this configuration is not done in the assemblker source but in
1231
+ * a source the linker reads. Generally this type of thing only
1232
+ * becomes an issue if real mode code is used. A pure 32-bit linker could
1233
+ * get away without defining the virtual mode...
1234
+ */
1235
+ char buf[40];
1236
+ int32_t size = p->size;
1237
+ switch (p->ftype) {
1238
+ case FT_SEG:
1239
+ if (p->id1 < 0)
1240
+ sprintf(buf, "%"PRIX32"", -p->id1);
1241
+ else
1242
+ sprintf(buf, "L%"PRIX32",10,/", p->id1);
1243
+ break;
1244
+ case FT_OFS:
1245
+ sprintf(buf, "R%"PRIX32",%"PRIX32",+", p->id1, p->addend);
1246
+ break;
1247
+ case FT_REL:
1248
+ sprintf(buf, "R%"PRIX32",%"PRIX32",+,P,-,%X,-", p->id1, p->addend, p->size);
1249
+ break;
1250
+
1251
+ case FT_WRT:
1252
+ if (p->id2 < 0)
1253
+ sprintf(buf, "R%"PRIX32",%"PRIX32",+,L%"PRIX32",+,%"PRIX32",-", p->id2, p->addend,
1254
+ p->id2, -p->id1 * 16);
1255
+ else
1256
+ sprintf(buf, "R%"PRIX32",%"PRIX32",+,L%"PRIX32",+,L%"PRIX32",-", p->id2, p->addend,
1257
+ p->id2, p->id1);
1258
+ break;
1259
+ case FT_EXT:
1260
+ sprintf(buf, "X%"PRIX32"", p->id1);
1261
+ break;
1262
+ case FT_EXTREL:
1263
+ sprintf(buf, "X%"PRIX32",P,-,%"PRIX32",-", p->id1, size);
1264
+ break;
1265
+ case FT_EXTSEG:
1266
+ /* We needed a non-ieee hack here.
1267
+ * We introduce the Y variable, which is the low
1268
+ * limit of the native segment the extern resides in
1269
+ */
1270
+ sprintf(buf, "Y%"PRIX32",10,/", p->id1);
1271
+ break;
1272
+ case FT_EXTWRT:
1273
+ if (p->id2 < 0)
1274
+ sprintf(buf, "X%"PRIX32",Y%"PRIX32",+,%"PRIX32",-", p->id2, p->id2,
1275
+ -p->id1 * 16);
1276
+ else
1277
+ sprintf(buf, "X%"PRIX32",Y%"PRIX32",+,L%"PRIX32",-", p->id2, p->id2, p->id1);
1278
+ break;
1279
+ }
1280
+ ieee_putascii("LR(%s,%"PRIX32").\n", buf, size);
1281
+
1282
+ return (size);
1283
+ }
1284
+
1285
+ /* Dump all segment data (text and fixups )*/
1286
+
1287
+ static void ieee_unqualified_name(char *dest, char *source)
1288
+ {
1289
+ if (ieee_uppercase) {
1290
+ while (*source)
1291
+ *dest++ = toupper(*source++);
1292
+ *dest = 0;
1293
+ } else
1294
+ strcpy(dest, source);
1295
+ }
1296
+ static void dbgls_init(void)
1297
+ {
1298
+ int tempint;
1299
+
1300
+ fnhead = NULL;
1301
+ fntail = &fnhead;
1302
+ arrindex = ARRAY_BOT;
1303
+ arrhead = NULL;
1304
+ arrtail = &arrhead;
1305
+ ieee_segment("??LINE", 2, &tempint);
1306
+ any_segs = false;
1307
+ }
1308
+ static void dbgls_cleanup(void)
1309
+ {
1310
+ struct ieeeSection *segtmp;
1311
+ while (fnhead) {
1312
+ struct FileName *fntemp = fnhead;
1313
+ fnhead = fnhead->next;
1314
+ nasm_free(fntemp->name);
1315
+ nasm_free(fntemp);
1316
+ }
1317
+ for (segtmp = seghead; segtmp; segtmp = segtmp->next) {
1318
+ while (segtmp->lochead) {
1319
+ struct ieeePublic *loctmp = segtmp->lochead;
1320
+ segtmp->lochead = loctmp->next;
1321
+ nasm_free(loctmp->name);
1322
+ nasm_free(loctmp);
1323
+ }
1324
+ }
1325
+ while (arrhead) {
1326
+ struct Array *arrtmp = arrhead;
1327
+ arrhead = arrhead->next;
1328
+ nasm_free(arrtmp);
1329
+ }
1330
+ }
1331
+
1332
+ /*
1333
+ * because this routine is not bracketed in
1334
+ * the main program, this routine will be called even if there
1335
+ * is no request for debug info
1336
+ * so, we have to make sure the ??LINE segment is avaialbe
1337
+ * as the first segment when this debug format is selected
1338
+ */
1339
+ static void dbgls_linnum(const char *lnfname, int32_t lineno, int32_t segto)
1340
+ {
1341
+ struct FileName *fn;
1342
+ struct ieeeSection *seg;
1343
+ int i = 0;
1344
+ if (segto == NO_SEG)
1345
+ return;
1346
+
1347
+ /*
1348
+ * If `any_segs' is still false, we must define a default
1349
+ * segment.
1350
+ */
1351
+ if (!any_segs) {
1352
+ int tempint; /* ignored */
1353
+ if (segto != ieee_segment("__NASMDEFSEG", 2, &tempint))
1354
+ nasm_panic(0, "strange segment conditions in OBJ driver");
1355
+ }
1356
+
1357
+ /*
1358
+ * Find the segment we are targetting.
1359
+ */
1360
+ for (seg = seghead; seg; seg = seg->next)
1361
+ if (seg->index == segto)
1362
+ break;
1363
+ if (!seg)
1364
+ nasm_panic(0, "lineno directed to nonexistent segment?");
1365
+
1366
+ for (fn = fnhead; fn; fn = fn->next) {
1367
+ if (!nasm_stricmp(lnfname, fn->name))
1368
+ break;
1369
+ i++;
1370
+ }
1371
+ if (!fn) {
1372
+ fn = nasm_malloc(sizeof(*fn));
1373
+ fn->name = nasm_malloc(strlen(lnfname) + 1);
1374
+ fn->index = i;
1375
+ strcpy(fn->name, lnfname);
1376
+ fn->next = NULL;
1377
+ *fntail = fn;
1378
+ fntail = &fn->next;
1379
+ }
1380
+ ieee_write_byte(seghead, fn->index);
1381
+ ieee_write_word(seghead, lineno);
1382
+ ieee_write_fixup(segto, NO_SEG, seghead, 4, OUT_ADDRESS,
1383
+ seg->currentpos);
1384
+
1385
+ }
1386
+ static void dbgls_deflabel(char *name, int32_t segment,
1387
+ int64_t offset, int is_global, char *special)
1388
+ {
1389
+ struct ieeeSection *seg;
1390
+
1391
+ /* Keep compiler from warning about special */
1392
+ (void)special;
1393
+
1394
+ /*
1395
+ * Note: ..[^@] special symbols are filtered in labels.c
1396
+ */
1397
+
1398
+ /*
1399
+ * If it's a special-retry from pass two, discard it.
1400
+ */
1401
+ if (is_global == 3)
1402
+ return;
1403
+
1404
+ /*
1405
+ * Case (i):
1406
+ */
1407
+ if (ieee_seg_needs_update)
1408
+ return;
1409
+ if (segment < SEG_ABS && segment != NO_SEG && segment % 2)
1410
+ return;
1411
+
1412
+ if (segment >= SEG_ABS || segment == NO_SEG) {
1413
+ return;
1414
+ }
1415
+
1416
+ /*
1417
+ * If `any_segs' is still false, we might need to define a
1418
+ * default segment, if they're trying to declare a label in
1419
+ * `first_seg'. But the label should exist due to a prior
1420
+ * call to ieee_deflabel so we can skip that.
1421
+ */
1422
+
1423
+ for (seg = seghead; seg; seg = seg->next)
1424
+ if (seg->index == segment) {
1425
+ struct ieeePublic *loc;
1426
+ /*
1427
+ * Case (ii). Maybe MODPUB someday?
1428
+ */
1429
+ if (!is_global) {
1430
+ last_defined = loc = nasm_malloc(sizeof(*loc));
1431
+ *seg->loctail = loc;
1432
+ seg->loctail = &loc->next;
1433
+ loc->next = NULL;
1434
+ loc->name = nasm_strdup(name);
1435
+ loc->offset = offset;
1436
+ loc->segment = -1;
1437
+ loc->index = seg->ieee_index;
1438
+ }
1439
+ }
1440
+ }
1441
+ static void dbgls_typevalue(int32_t type)
1442
+ {
1443
+ int elem = TYM_ELEMENTS(type);
1444
+ type = TYM_TYPE(type);
1445
+
1446
+ if (!last_defined)
1447
+ return;
1448
+
1449
+ switch (type) {
1450
+ case TY_BYTE:
1451
+ last_defined->type = 1; /* uint8_t */
1452
+ break;
1453
+ case TY_WORD:
1454
+ last_defined->type = 3; /* unsigned word */
1455
+ break;
1456
+ case TY_DWORD:
1457
+ last_defined->type = 5; /* unsigned dword */
1458
+ break;
1459
+ case TY_FLOAT:
1460
+ last_defined->type = 9; /* float */
1461
+ break;
1462
+ case TY_QWORD:
1463
+ last_defined->type = 10; /* qword */
1464
+ break;
1465
+ case TY_TBYTE:
1466
+ last_defined->type = 11; /* TBYTE */
1467
+ break;
1468
+ default:
1469
+ last_defined->type = 0x10; /* near label */
1470
+ break;
1471
+ }
1472
+
1473
+ if (elem > 1) {
1474
+ struct Array *arrtmp = nasm_malloc(sizeof(*arrtmp));
1475
+ int vtype = last_defined->type;
1476
+ arrtmp->size = elem;
1477
+ arrtmp->basetype = vtype;
1478
+ arrtmp->next = NULL;
1479
+ last_defined->type = arrindex++ + 0x100;
1480
+ *arrtail = arrtmp;
1481
+ arrtail = &(arrtmp->next);
1482
+ }
1483
+ last_defined = NULL;
1484
+ }
1485
+ static void dbgls_output(int output_type, void *param)
1486
+ {
1487
+ (void)output_type;
1488
+ (void)param;
1489
+ }
1490
+ static const struct dfmt ladsoft_debug_form = {
1491
+ "LADsoft Debug Records",
1492
+ "ladsoft",
1493
+ dbgls_init,
1494
+ dbgls_linnum,
1495
+ dbgls_deflabel,
1496
+ null_debug_directive,
1497
+ dbgls_typevalue,
1498
+ dbgls_output,
1499
+ dbgls_cleanup,
1500
+ NULL /* pragma list */
1501
+ };
1502
+ static const struct dfmt * const ladsoft_debug_arr[3] = {
1503
+ &ladsoft_debug_form,
1504
+ &null_debug_form,
1505
+ NULL
1506
+ };
1507
+ const struct ofmt of_ieee = {
1508
+ "IEEE-695 (LADsoft variant) object file format",
1509
+ "ieee",
1510
+ OFMT_TEXT,
1511
+ 32,
1512
+ ladsoft_debug_arr,
1513
+ &ladsoft_debug_form,
1514
+ NULL,
1515
+ ieee_init,
1516
+ nasm_do_legacy_output,
1517
+ ieee_out,
1518
+ ieee_deflabel,
1519
+ ieee_segment,
1520
+ ieee_sectalign,
1521
+ ieee_segbase,
1522
+ ieee_directive,
1523
+ ieee_filename,
1524
+ ieee_cleanup,
1525
+ NULL /* pragma list */
1526
+ };
1527
+
1528
+ #endif /* OF_IEEE */