laag-nasm 2.13.03.2

Sign up to get free protection for your applications and to get access to all the features.
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,112 @@
1
+ /* ----------------------------------------------------------------------- *
2
+ *
3
+ * Copyright 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
+ * output/legacy.c
36
+ *
37
+ * Mangle a struct out_data to match the rather bizarre legacy
38
+ * backend interface.
39
+ *
40
+ * The "data" parameter for the output function points to a "int64_t",
41
+ * containing the address of the target in question, unless the type is
42
+ * OUT_RAWDATA, in which case it points to an "uint8_t"
43
+ * array.
44
+ *
45
+ * Exceptions are OUT_RELxADR, which denote an x-byte relocation
46
+ * which will be a relative jump. For this we need to know the
47
+ * distance in bytes from the start of the relocated record until
48
+ * the end of the containing instruction. _This_ is what is stored
49
+ * in the size part of the parameter, in this case.
50
+ *
51
+ * Also OUT_RESERVE denotes reservation of N bytes of BSS space,
52
+ * and the contents of the "data" parameter is irrelevant.
53
+ */
54
+
55
+ #include "nasm.h"
56
+ #include "outlib.h"
57
+
58
+ void nasm_do_legacy_output(const struct out_data *data)
59
+ {
60
+ const void *dptr = data->data;
61
+ enum out_type type = data->type;
62
+ int32_t tsegment = data->tsegment;
63
+ int32_t twrt = data->twrt;
64
+ uint64_t size = data->size;
65
+
66
+ switch (data->type) {
67
+ case OUT_RELADDR:
68
+ switch (data->size) {
69
+ case 1:
70
+ type = OUT_REL1ADR;
71
+ break;
72
+ case 2:
73
+ type = OUT_REL2ADR;
74
+ break;
75
+ case 4:
76
+ type = OUT_REL4ADR;
77
+ break;
78
+ case 8:
79
+ type = OUT_REL8ADR;
80
+ break;
81
+ default:
82
+ panic();
83
+ break;
84
+ }
85
+
86
+ dptr = &data->toffset;
87
+ size = data->relbase - data->offset;
88
+ break;
89
+
90
+ case OUT_SEGMENT:
91
+ type = OUT_ADDRESS;
92
+ dptr = &zero_buffer;
93
+ size = (data->sign == OUT_SIGNED) ? -data->size : data->size;
94
+ break;
95
+
96
+ case OUT_ADDRESS:
97
+ dptr = &data->toffset;
98
+ size = (data->sign == OUT_SIGNED) ? -data->size : data->size;
99
+ break;
100
+
101
+ case OUT_RAWDATA:
102
+ case OUT_RESERVE:
103
+ tsegment = twrt = NO_SEG;
104
+ break;
105
+
106
+ default:
107
+ panic();
108
+ break;
109
+ }
110
+
111
+ ofmt->legacy_output(data->segment, dptr, type, size, tsegment, twrt);
112
+ }
@@ -0,0 +1,93 @@
1
+ /* ----------------------------------------------------------------------- *
2
+ *
3
+ * Copyright 1996-2014 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
+ #include "nasm.h"
35
+ #include "nasmlib.h"
36
+ #include "outlib.h"
37
+
38
+ void null_debug_init(void)
39
+ {
40
+ }
41
+
42
+ void null_debug_linenum(const char *filename, int32_t linenumber, int32_t segto)
43
+ {
44
+ (void)filename;
45
+ (void)linenumber;
46
+ (void)segto;
47
+ }
48
+
49
+ void null_debug_deflabel(char *name, int32_t segment, int64_t offset,
50
+ int is_global, char *special)
51
+ {
52
+ (void)name;
53
+ (void)segment;
54
+ (void)offset;
55
+ (void)is_global;
56
+ (void)special;
57
+ }
58
+
59
+ void null_debug_directive(const char *directive, const char *params)
60
+ {
61
+ (void)directive;
62
+ (void)params;
63
+ }
64
+
65
+ void null_debug_typevalue(int32_t type)
66
+ {
67
+ (void)type;
68
+ }
69
+
70
+ void null_debug_output(int type, void *param)
71
+ {
72
+ (void)type;
73
+ (void)param;
74
+ }
75
+
76
+ void null_debug_cleanup(void)
77
+ {
78
+ }
79
+
80
+ const struct dfmt null_debug_form = {
81
+ "Null debug format",
82
+ "null",
83
+ null_debug_init,
84
+ null_debug_linenum,
85
+ null_debug_deflabel,
86
+ null_debug_directive,
87
+ null_debug_typevalue,
88
+ null_debug_output,
89
+ null_debug_cleanup,
90
+ NULL /* pragma list */
91
+ };
92
+
93
+ const struct dfmt * const null_debug_arr[2] = { &null_debug_form, NULL };
@@ -0,0 +1,51 @@
1
+ /* ----------------------------------------------------------------------- *
2
+ *
3
+ * Copyright 1996-2009 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
+ #include "nasm.h"
35
+ #include "nasmlib.h"
36
+ #include "outlib.h"
37
+
38
+ enum directive_result
39
+ null_directive(enum directive directive, char *value, int pass)
40
+ {
41
+ (void)directive;
42
+ (void)value;
43
+ (void)pass;
44
+ return DIRR_UNKNOWN;
45
+ }
46
+
47
+ void null_sectalign(int32_t seg, unsigned int value)
48
+ {
49
+ (void)seg;
50
+ (void)value;
51
+ }
@@ -0,0 +1,954 @@
1
+ /* ----------------------------------------------------------------------- *
2
+ *
3
+ * Copyright 1996-2013 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
+ * outaout.c output routines for the Netwide Assembler to produce
36
+ * Linux a.out object files
37
+ */
38
+
39
+ #include "compiler.h"
40
+
41
+ #include <stdio.h>
42
+ #include <stdlib.h>
43
+ #include <string.h>
44
+ #include <ctype.h>
45
+
46
+ #include "nasm.h"
47
+ #include "nasmlib.h"
48
+ #include "error.h"
49
+ #include "saa.h"
50
+ #include "raa.h"
51
+ #include "stdscan.h"
52
+ #include "eval.h"
53
+ #include "outform.h"
54
+ #include "outlib.h"
55
+
56
+ #if defined OF_AOUT || defined OF_AOUTB
57
+
58
+ #define RELTYPE_ABSOLUTE 0x00
59
+ #define RELTYPE_RELATIVE 0x01
60
+ #define RELTYPE_GOTPC 0x01 /* no explicit GOTPC in a.out */
61
+ #define RELTYPE_GOTOFF 0x10
62
+ #define RELTYPE_GOT 0x10 /* distinct from GOTOFF bcos sym not sect */
63
+ #define RELTYPE_PLT 0x21
64
+ #define RELTYPE_SYMFLAG 0x08
65
+
66
+ struct Reloc {
67
+ struct Reloc *next;
68
+ int32_t address; /* relative to _start_ of section */
69
+ int32_t symbol; /* symbol number or -ve section id */
70
+ int bytes; /* 2 or 4 */
71
+ int reltype; /* see above */
72
+ };
73
+
74
+ struct Symbol {
75
+ int32_t strpos; /* string table position of name */
76
+ int type; /* symbol type - see flags below */
77
+ int32_t value; /* address, or COMMON variable size */
78
+ int32_t size; /* size for data or function exports */
79
+ int32_t segment; /* back-reference used by gsym_reloc */
80
+ struct Symbol *next; /* list of globals in each section */
81
+ struct Symbol *nextfwd; /* list of unresolved-size symbols */
82
+ char *name; /* for unresolved-size symbols */
83
+ int32_t symnum; /* index into symbol table */
84
+ };
85
+
86
+ /*
87
+ * Section IDs - used in Reloc.symbol when negative, and in
88
+ * Symbol.type when positive.
89
+ */
90
+ #define SECT_ABS 2 /* absolute value */
91
+ #define SECT_TEXT 4 /* text section */
92
+ #define SECT_DATA 6 /* data section */
93
+ #define SECT_BSS 8 /* bss section */
94
+ #define SECT_MASK 0xE /* mask out any of the above */
95
+
96
+ /*
97
+ * More flags used in Symbol.type.
98
+ */
99
+ #define SYM_GLOBAL 1 /* it's a global symbol */
100
+ #define SYM_DATA 0x100 /* used for shared libs */
101
+ #define SYM_FUNCTION 0x200 /* used for shared libs */
102
+ #define SYM_WITH_SIZE 0x4000 /* not output; internal only */
103
+
104
+ /*
105
+ * Bit more explanation of symbol types: SECT_xxx denotes a local
106
+ * symbol. SECT_xxx|SYM_GLOBAL denotes a global symbol, defined in
107
+ * this module. Just SYM_GLOBAL, with zero value, denotes an
108
+ * external symbol referenced in this module. And just SYM_GLOBAL,
109
+ * but with a non-zero value, declares a C `common' variable, of
110
+ * size `value'.
111
+ */
112
+
113
+ struct Section {
114
+ struct SAA *data;
115
+ uint32_t len, size, nrelocs;
116
+ int32_t index;
117
+ struct Reloc *head, **tail;
118
+ struct Symbol *gsyms, *asym;
119
+ };
120
+
121
+ static struct Section stext, sdata, sbss;
122
+
123
+ static struct SAA *syms;
124
+ static uint32_t nsyms;
125
+
126
+ static struct RAA *bsym;
127
+
128
+ static struct SAA *strs;
129
+ static uint32_t strslen;
130
+
131
+ static struct Symbol *fwds;
132
+
133
+ static int bsd;
134
+ static int is_pic;
135
+
136
+ static void aout_write(void);
137
+ static void aout_write_relocs(struct Reloc *);
138
+ static void aout_write_syms(void);
139
+ static void aout_sect_write(struct Section *, const uint8_t *,
140
+ uint32_t);
141
+ static void aout_pad_sections(void);
142
+ static void aout_fixup_relocs(struct Section *);
143
+
144
+ /*
145
+ * Special section numbers which are used to define special
146
+ * symbols, which can be used with WRT to provide PIC relocation
147
+ * types.
148
+ */
149
+ static int32_t aout_gotpc_sect, aout_gotoff_sect;
150
+ static int32_t aout_got_sect, aout_plt_sect;
151
+ static int32_t aout_sym_sect;
152
+
153
+ static void aoutg_init(void)
154
+ {
155
+ stext.data = saa_init(1L);
156
+ stext.head = NULL;
157
+ stext.tail = &stext.head;
158
+ sdata.data = saa_init(1L);
159
+ sdata.head = NULL;
160
+ sdata.tail = &sdata.head;
161
+ stext.len = stext.size = sdata.len = sdata.size = sbss.len = 0;
162
+ stext.nrelocs = sdata.nrelocs = 0;
163
+ stext.gsyms = sdata.gsyms = sbss.gsyms = NULL;
164
+ stext.index = seg_alloc();
165
+ sdata.index = seg_alloc();
166
+ sbss.index = seg_alloc();
167
+ stext.asym = sdata.asym = sbss.asym = NULL;
168
+ syms = saa_init((int32_t)sizeof(struct Symbol));
169
+ nsyms = 0;
170
+ bsym = raa_init();
171
+ strs = saa_init(1L);
172
+ strslen = 0;
173
+ fwds = NULL;
174
+ }
175
+
176
+ #ifdef OF_AOUT
177
+
178
+ static void aout_init(void)
179
+ {
180
+ bsd = false;
181
+ aoutg_init();
182
+
183
+ aout_gotpc_sect = aout_gotoff_sect = aout_got_sect =
184
+ aout_plt_sect = aout_sym_sect = NO_SEG;
185
+ }
186
+
187
+ #endif
188
+
189
+ #ifdef OF_AOUTB
190
+
191
+ extern const struct ofmt of_aoutb;
192
+
193
+ static void aoutb_init(void)
194
+ {
195
+ bsd = true;
196
+ aoutg_init();
197
+
198
+ is_pic = 0x00; /* may become 0x40 */
199
+
200
+ aout_gotpc_sect = seg_alloc();
201
+ define_label("..gotpc", aout_gotpc_sect + 1, 0L, NULL, false, false);
202
+ aout_gotoff_sect = seg_alloc();
203
+ define_label("..gotoff", aout_gotoff_sect + 1, 0L, NULL, false, false);
204
+ aout_got_sect = seg_alloc();
205
+ define_label("..got", aout_got_sect + 1, 0L, NULL, false, false);
206
+ aout_plt_sect = seg_alloc();
207
+ define_label("..plt", aout_plt_sect + 1, 0L, NULL, false, false);
208
+ aout_sym_sect = seg_alloc();
209
+ define_label("..sym", aout_sym_sect + 1, 0L, NULL, false, false);
210
+ }
211
+
212
+ #endif
213
+
214
+ static void aout_cleanup(void)
215
+ {
216
+ struct Reloc *r;
217
+
218
+ aout_pad_sections();
219
+ aout_fixup_relocs(&stext);
220
+ aout_fixup_relocs(&sdata);
221
+ aout_write();
222
+ saa_free(stext.data);
223
+ while (stext.head) {
224
+ r = stext.head;
225
+ stext.head = stext.head->next;
226
+ nasm_free(r);
227
+ }
228
+ saa_free(sdata.data);
229
+ while (sdata.head) {
230
+ r = sdata.head;
231
+ sdata.head = sdata.head->next;
232
+ nasm_free(r);
233
+ }
234
+ saa_free(syms);
235
+ raa_free(bsym);
236
+ saa_free(strs);
237
+ }
238
+
239
+ static int32_t aout_section_names(char *name, int pass, int *bits)
240
+ {
241
+
242
+ (void)pass;
243
+
244
+ /*
245
+ * Default to 32 bits.
246
+ */
247
+ if (!name) {
248
+ *bits = 32;
249
+ return stext.index;
250
+ }
251
+
252
+ if (!strcmp(name, ".text"))
253
+ return stext.index;
254
+ else if (!strcmp(name, ".data"))
255
+ return sdata.index;
256
+ else if (!strcmp(name, ".bss"))
257
+ return sbss.index;
258
+ else
259
+ return NO_SEG;
260
+ }
261
+
262
+ static void aout_deflabel(char *name, int32_t segment, int64_t offset,
263
+ int is_global, char *special)
264
+ {
265
+ int pos = strslen + 4;
266
+ struct Symbol *sym;
267
+ int special_used = false;
268
+
269
+ if (name[0] == '.' && name[1] == '.' && name[2] != '@') {
270
+ /*
271
+ * This is a NASM special symbol. We never allow it into
272
+ * the a.out symbol table, even if it's a valid one. If it
273
+ * _isn't_ a valid one, we should barf immediately.
274
+ */
275
+ if (strcmp(name, "..gotpc") && strcmp(name, "..gotoff") &&
276
+ strcmp(name, "..got") && strcmp(name, "..plt") &&
277
+ strcmp(name, "..sym"))
278
+ nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
279
+ return;
280
+ }
281
+
282
+ if (is_global == 3) {
283
+ struct Symbol **s;
284
+ /*
285
+ * Fix up a forward-reference symbol size from the first
286
+ * pass.
287
+ */
288
+ for (s = &fwds; *s; s = &(*s)->nextfwd)
289
+ if (!strcmp((*s)->name, name)) {
290
+ struct tokenval tokval;
291
+ expr *e;
292
+ char *p = special;
293
+
294
+ p = nasm_skip_spaces(nasm_skip_word(p));
295
+ stdscan_reset();
296
+ stdscan_set(p);
297
+ tokval.t_type = TOKEN_INVALID;
298
+ e = evaluate(stdscan, NULL, &tokval, NULL, 1, NULL);
299
+ if (e) {
300
+ if (!is_simple(e))
301
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
302
+ " expression as symbol size");
303
+ else
304
+ (*s)->size = reloc_value(e);
305
+ }
306
+
307
+ /*
308
+ * Remove it from the list of unresolved sizes.
309
+ */
310
+ nasm_free((*s)->name);
311
+ *s = (*s)->nextfwd;
312
+ return;
313
+ }
314
+ return; /* it wasn't an important one */
315
+ }
316
+
317
+ saa_wbytes(strs, name, (int32_t)(1 + strlen(name)));
318
+ strslen += 1 + strlen(name);
319
+
320
+ sym = saa_wstruct(syms);
321
+
322
+ sym->strpos = pos;
323
+ sym->type = is_global ? SYM_GLOBAL : 0;
324
+ sym->segment = segment;
325
+ if (segment == NO_SEG)
326
+ sym->type |= SECT_ABS;
327
+ else if (segment == stext.index) {
328
+ sym->type |= SECT_TEXT;
329
+ if (is_global) {
330
+ sym->next = stext.gsyms;
331
+ stext.gsyms = sym;
332
+ } else if (!stext.asym)
333
+ stext.asym = sym;
334
+ } else if (segment == sdata.index) {
335
+ sym->type |= SECT_DATA;
336
+ if (is_global) {
337
+ sym->next = sdata.gsyms;
338
+ sdata.gsyms = sym;
339
+ } else if (!sdata.asym)
340
+ sdata.asym = sym;
341
+ } else if (segment == sbss.index) {
342
+ sym->type |= SECT_BSS;
343
+ if (is_global) {
344
+ sym->next = sbss.gsyms;
345
+ sbss.gsyms = sym;
346
+ } else if (!sbss.asym)
347
+ sbss.asym = sym;
348
+ } else
349
+ sym->type = SYM_GLOBAL;
350
+ if (is_global == 2)
351
+ sym->value = offset;
352
+ else
353
+ sym->value = (sym->type == SYM_GLOBAL ? 0 : offset);
354
+
355
+ if (is_global && sym->type != SYM_GLOBAL) {
356
+ /*
357
+ * Global symbol exported _from_ this module. We must check
358
+ * the special text for type information.
359
+ */
360
+
361
+ if (special) {
362
+ int n = strcspn(special, " ");
363
+
364
+ if (!nasm_strnicmp(special, "function", n))
365
+ sym->type |= SYM_FUNCTION;
366
+ else if (!nasm_strnicmp(special, "data", n) ||
367
+ !nasm_strnicmp(special, "object", n))
368
+ sym->type |= SYM_DATA;
369
+ else
370
+ nasm_error(ERR_NONFATAL, "unrecognised symbol type `%.*s'",
371
+ n, special);
372
+ if (special[n]) {
373
+ struct tokenval tokval;
374
+ expr *e;
375
+ int fwd = false;
376
+ char *saveme = stdscan_get();
377
+
378
+ if (!bsd) {
379
+ nasm_error(ERR_NONFATAL, "Linux a.out does not support"
380
+ " symbol size information");
381
+ } else {
382
+ while (special[n] && nasm_isspace(special[n]))
383
+ n++;
384
+ /*
385
+ * We have a size expression; attempt to
386
+ * evaluate it.
387
+ */
388
+ sym->type |= SYM_WITH_SIZE;
389
+ stdscan_reset();
390
+ stdscan_set(special + n);
391
+ tokval.t_type = TOKEN_INVALID;
392
+ e = evaluate(stdscan, NULL, &tokval, &fwd, 0, NULL);
393
+ if (fwd) {
394
+ sym->nextfwd = fwds;
395
+ fwds = sym;
396
+ sym->name = nasm_strdup(name);
397
+ } else if (e) {
398
+ if (!is_simple(e))
399
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
400
+ " expression as symbol size");
401
+ else
402
+ sym->size = reloc_value(e);
403
+ }
404
+ }
405
+ stdscan_set(saveme);
406
+ }
407
+ special_used = true;
408
+ }
409
+ }
410
+
411
+ /*
412
+ * define the references from external-symbol segment numbers
413
+ * to these symbol records.
414
+ */
415
+ if (segment != NO_SEG && segment != stext.index &&
416
+ segment != sdata.index && segment != sbss.index)
417
+ bsym = raa_write(bsym, segment, nsyms);
418
+ sym->symnum = nsyms;
419
+
420
+ nsyms++;
421
+ if (sym->type & SYM_WITH_SIZE)
422
+ nsyms++; /* and another for the size */
423
+
424
+ if (special && !special_used)
425
+ nasm_error(ERR_NONFATAL, "no special symbol features supported here");
426
+ }
427
+
428
+ static void aout_add_reloc(struct Section *sect, int32_t segment,
429
+ int reltype, int bytes)
430
+ {
431
+ struct Reloc *r;
432
+
433
+ r = *sect->tail = nasm_malloc(sizeof(struct Reloc));
434
+ sect->tail = &r->next;
435
+ r->next = NULL;
436
+
437
+ r->address = sect->len;
438
+ r->symbol = (segment == NO_SEG ? -SECT_ABS :
439
+ segment == stext.index ? -SECT_TEXT :
440
+ segment == sdata.index ? -SECT_DATA :
441
+ segment == sbss.index ? -SECT_BSS :
442
+ raa_read(bsym, segment));
443
+ r->reltype = reltype;
444
+ if (r->symbol >= 0)
445
+ r->reltype |= RELTYPE_SYMFLAG;
446
+ r->bytes = bytes;
447
+
448
+ sect->nrelocs++;
449
+ }
450
+
451
+ /*
452
+ * This routine deals with ..got and ..sym relocations: the more
453
+ * complicated kinds. In shared-library writing, some relocations
454
+ * with respect to global symbols must refer to the precise symbol
455
+ * rather than referring to an offset from the base of the section
456
+ * _containing_ the symbol. Such relocations call to this routine,
457
+ * which searches the symbol list for the symbol in question.
458
+ *
459
+ * RELTYPE_GOT references require the _exact_ symbol address to be
460
+ * used; RELTYPE_ABSOLUTE references can be at an offset from the
461
+ * symbol. The boolean argument `exact' tells us this.
462
+ *
463
+ * Return value is the adjusted value of `addr', having become an
464
+ * offset from the symbol rather than the section. Should always be
465
+ * zero when returning from an exact call.
466
+ *
467
+ * Limitation: if you define two symbols at the same place,
468
+ * confusion will occur.
469
+ *
470
+ * Inefficiency: we search, currently, using a linked list which
471
+ * isn't even necessarily sorted.
472
+ */
473
+ static int32_t aout_add_gsym_reloc(struct Section *sect,
474
+ int32_t segment, int32_t offset,
475
+ int type, int bytes, int exact)
476
+ {
477
+ struct Symbol *sym, *sm, *shead;
478
+ struct Reloc *r;
479
+
480
+ /*
481
+ * First look up the segment to find whether it's text, data,
482
+ * bss or an external symbol.
483
+ */
484
+ shead = NULL;
485
+ if (segment == stext.index)
486
+ shead = stext.gsyms;
487
+ else if (segment == sdata.index)
488
+ shead = sdata.gsyms;
489
+ else if (segment == sbss.index)
490
+ shead = sbss.gsyms;
491
+ if (!shead) {
492
+ if (exact && offset != 0)
493
+ nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol"
494
+ " for this reference");
495
+ else
496
+ aout_add_reloc(sect, segment, type, bytes);
497
+ return offset;
498
+ }
499
+
500
+ if (exact) {
501
+ /*
502
+ * Find a symbol pointing _exactly_ at this one.
503
+ */
504
+ list_for_each(sym, shead)
505
+ if (sym->value == offset)
506
+ break;
507
+ } else {
508
+ /*
509
+ * Find the nearest symbol below this one.
510
+ */
511
+ sym = NULL;
512
+ list_for_each(sm, shead)
513
+ if (sm->value <= offset && (!sym || sm->value > sym->value))
514
+ sym = sm;
515
+ }
516
+ if (!sym && exact) {
517
+ nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol"
518
+ " for this reference");
519
+ return 0;
520
+ }
521
+
522
+ r = *sect->tail = nasm_malloc(sizeof(struct Reloc));
523
+ sect->tail = &r->next;
524
+ r->next = NULL;
525
+
526
+ r->address = sect->len;
527
+ r->symbol = sym->symnum;
528
+ r->reltype = type | RELTYPE_SYMFLAG;
529
+ r->bytes = bytes;
530
+
531
+ sect->nrelocs++;
532
+
533
+ return offset - sym->value;
534
+ }
535
+
536
+ /*
537
+ * This routine deals with ..gotoff relocations. These _must_ refer
538
+ * to a symbol, due to a perversity of *BSD's PIC implementation,
539
+ * and it must be a non-global one as well; so we store `asym', the
540
+ * first nonglobal symbol defined in each section, and always work
541
+ * from that. Relocation type is always RELTYPE_GOTOFF.
542
+ *
543
+ * Return value is the adjusted value of `addr', having become an
544
+ * offset from the `asym' symbol rather than the section.
545
+ */
546
+ static int32_t aout_add_gotoff_reloc(struct Section *sect, int32_t segment,
547
+ int32_t offset, int bytes)
548
+ {
549
+ struct Reloc *r;
550
+ struct Symbol *asym;
551
+
552
+ /*
553
+ * First look up the segment to find whether it's text, data,
554
+ * bss or an external symbol.
555
+ */
556
+ asym = NULL;
557
+ if (segment == stext.index)
558
+ asym = stext.asym;
559
+ else if (segment == sdata.index)
560
+ asym = sdata.asym;
561
+ else if (segment == sbss.index)
562
+ asym = sbss.asym;
563
+ if (!asym)
564
+ nasm_error(ERR_NONFATAL, "`..gotoff' relocations require a non-global"
565
+ " symbol in the section");
566
+
567
+ r = *sect->tail = nasm_malloc(sizeof(struct Reloc));
568
+ sect->tail = &r->next;
569
+ r->next = NULL;
570
+
571
+ r->address = sect->len;
572
+ r->symbol = asym->symnum;
573
+ r->reltype = RELTYPE_GOTOFF;
574
+ r->bytes = bytes;
575
+
576
+ sect->nrelocs++;
577
+
578
+ return offset - asym->value;
579
+ }
580
+
581
+ static void aout_out(int32_t segto, const void *data,
582
+ enum out_type type, uint64_t size,
583
+ int32_t segment, int32_t wrt)
584
+ {
585
+ struct Section *s;
586
+ int32_t addr;
587
+ uint8_t mydata[4], *p;
588
+
589
+ /*
590
+ * handle absolute-assembly (structure definitions)
591
+ */
592
+ if (segto == NO_SEG) {
593
+ if (type != OUT_RESERVE)
594
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
595
+ " space");
596
+ return;
597
+ }
598
+
599
+ if (segto == stext.index)
600
+ s = &stext;
601
+ else if (segto == sdata.index)
602
+ s = &sdata;
603
+ else if (segto == sbss.index)
604
+ s = NULL;
605
+ else {
606
+ nasm_error(ERR_WARNING, "attempt to assemble code in"
607
+ " segment %d: defaulting to `.text'", segto);
608
+ s = &stext;
609
+ }
610
+
611
+ if (!s && type != OUT_RESERVE) {
612
+ nasm_error(ERR_WARNING, "attempt to initialize memory in the"
613
+ " BSS section: ignored");
614
+ sbss.len += realsize(type, size);
615
+ return;
616
+ }
617
+
618
+ memset(mydata, 0, sizeof(mydata));
619
+
620
+ if (type == OUT_RESERVE) {
621
+ if (s) {
622
+ nasm_error(ERR_WARNING, "uninitialized space declared in"
623
+ " %s section: zeroing",
624
+ (segto == stext.index ? "code" : "data"));
625
+ aout_sect_write(s, NULL, size);
626
+ } else
627
+ sbss.len += size;
628
+ } else if (type == OUT_RAWDATA) {
629
+ if (segment != NO_SEG)
630
+ nasm_panic(0, "OUT_RAWDATA with other than NO_SEG");
631
+ aout_sect_write(s, data, size);
632
+ } else if (type == OUT_ADDRESS) {
633
+ int asize = abs((int)size);
634
+ addr = *(int64_t *)data;
635
+ if (segment != NO_SEG) {
636
+ if (segment % 2) {
637
+ nasm_error(ERR_NONFATAL, "a.out format does not support"
638
+ " segment base references");
639
+ } else {
640
+ if (wrt == NO_SEG) {
641
+ aout_add_reloc(s, segment, RELTYPE_ABSOLUTE, asize);
642
+ } else if (!bsd) {
643
+ nasm_error(ERR_NONFATAL,
644
+ "Linux a.out format does not support"
645
+ " any use of WRT");
646
+ wrt = NO_SEG; /* we can at least _try_ to continue */
647
+ } else if (wrt == aout_gotpc_sect + 1) {
648
+ is_pic = 0x40;
649
+ aout_add_reloc(s, segment, RELTYPE_GOTPC, asize);
650
+ } else if (wrt == aout_gotoff_sect + 1) {
651
+ is_pic = 0x40;
652
+ addr = aout_add_gotoff_reloc(s, segment, addr, asize);
653
+ } else if (wrt == aout_got_sect + 1) {
654
+ is_pic = 0x40;
655
+ addr = aout_add_gsym_reloc(s, segment, addr, RELTYPE_GOT,
656
+ asize, true);
657
+ } else if (wrt == aout_sym_sect + 1) {
658
+ addr = aout_add_gsym_reloc(s, segment, addr,
659
+ RELTYPE_ABSOLUTE, asize,
660
+ false);
661
+ } else if (wrt == aout_plt_sect + 1) {
662
+ is_pic = 0x40;
663
+ nasm_error(ERR_NONFATAL,
664
+ "a.out format cannot produce non-PC-"
665
+ "relative PLT references");
666
+ } else {
667
+ nasm_error(ERR_NONFATAL,
668
+ "a.out format does not support this"
669
+ " use of WRT");
670
+ wrt = NO_SEG; /* we can at least _try_ to continue */
671
+ }
672
+ }
673
+ }
674
+ p = mydata;
675
+ if (asize == 2)
676
+ WRITESHORT(p, addr);
677
+ else
678
+ WRITELONG(p, addr);
679
+ aout_sect_write(s, mydata, asize);
680
+ } else if (type == OUT_REL2ADR) {
681
+ if (segment == segto)
682
+ nasm_panic(0, "intra-segment OUT_REL2ADR");
683
+ if (segment != NO_SEG && segment % 2) {
684
+ nasm_error(ERR_NONFATAL, "a.out format does not support"
685
+ " segment base references");
686
+ } else {
687
+ if (wrt == NO_SEG) {
688
+ aout_add_reloc(s, segment, RELTYPE_RELATIVE, 2);
689
+ } else if (!bsd) {
690
+ nasm_error(ERR_NONFATAL, "Linux a.out format does not support"
691
+ " any use of WRT");
692
+ wrt = NO_SEG; /* we can at least _try_ to continue */
693
+ } else if (wrt == aout_plt_sect + 1) {
694
+ is_pic = 0x40;
695
+ aout_add_reloc(s, segment, RELTYPE_PLT, 2);
696
+ } else if (wrt == aout_gotpc_sect + 1 ||
697
+ wrt == aout_gotoff_sect + 1 ||
698
+ wrt == aout_got_sect + 1) {
699
+ nasm_error(ERR_NONFATAL, "a.out format cannot produce PC-"
700
+ "relative GOT references");
701
+ } else {
702
+ nasm_error(ERR_NONFATAL, "a.out format does not support this"
703
+ " use of WRT");
704
+ wrt = NO_SEG; /* we can at least _try_ to continue */
705
+ }
706
+ }
707
+ p = mydata;
708
+ WRITESHORT(p, *(int64_t *)data - (size + s->len));
709
+ aout_sect_write(s, mydata, 2L);
710
+ } else if (type == OUT_REL4ADR) {
711
+ if (segment == segto)
712
+ nasm_panic(0, "intra-segment OUT_REL4ADR");
713
+ if (segment != NO_SEG && segment % 2) {
714
+ nasm_error(ERR_NONFATAL, "a.out format does not support"
715
+ " segment base references");
716
+ } else {
717
+ if (wrt == NO_SEG) {
718
+ aout_add_reloc(s, segment, RELTYPE_RELATIVE, 4);
719
+ } else if (!bsd) {
720
+ nasm_error(ERR_NONFATAL, "Linux a.out format does not support"
721
+ " any use of WRT");
722
+ wrt = NO_SEG; /* we can at least _try_ to continue */
723
+ } else if (wrt == aout_plt_sect + 1) {
724
+ is_pic = 0x40;
725
+ aout_add_reloc(s, segment, RELTYPE_PLT, 4);
726
+ } else if (wrt == aout_gotpc_sect + 1 ||
727
+ wrt == aout_gotoff_sect + 1 ||
728
+ wrt == aout_got_sect + 1) {
729
+ nasm_error(ERR_NONFATAL, "a.out format cannot produce PC-"
730
+ "relative GOT references");
731
+ } else {
732
+ nasm_error(ERR_NONFATAL, "a.out format does not support this"
733
+ " use of WRT");
734
+ wrt = NO_SEG; /* we can at least _try_ to continue */
735
+ }
736
+ }
737
+ p = mydata;
738
+ WRITELONG(p, *(int64_t *)data - (size + s->len));
739
+ aout_sect_write(s, mydata, 4L);
740
+ }
741
+ }
742
+
743
+ static void aout_pad_sections(void)
744
+ {
745
+ static uint8_t pad[] = { 0x90, 0x90, 0x90, 0x90 };
746
+ /*
747
+ * Pad each of the text and data sections with NOPs until their
748
+ * length is a multiple of four. (NOP == 0x90.) Also increase
749
+ * the length of the BSS section similarly.
750
+ */
751
+ aout_sect_write(&stext, pad, (-(int32_t)stext.len) & 3);
752
+ aout_sect_write(&sdata, pad, (-(int32_t)sdata.len) & 3);
753
+ sbss.len = ALIGN(sbss.len, 4);
754
+ }
755
+
756
+ /*
757
+ * a.out files have the curious property that all references to
758
+ * things in the data or bss sections are done by addresses which
759
+ * are actually relative to the start of the _text_ section, in the
760
+ * _file_. (No relation to what happens after linking. No idea why
761
+ * this should be so. It's very strange.) So we have to go through
762
+ * the relocation table, _after_ the final size of each section is
763
+ * known, and fix up the relocations pointed to.
764
+ */
765
+ static void aout_fixup_relocs(struct Section *sect)
766
+ {
767
+ struct Reloc *r;
768
+
769
+ saa_rewind(sect->data);
770
+ list_for_each(r, sect->head) {
771
+ uint8_t *p, *q, blk[4];
772
+ int32_t l;
773
+
774
+ saa_fread(sect->data, r->address, blk, (int32_t)r->bytes);
775
+ p = q = blk;
776
+ l = *p++;
777
+ if (r->bytes > 1) {
778
+ l += ((int32_t)*p++) << 8;
779
+ if (r->bytes == 4) {
780
+ l += ((int32_t)*p++) << 16;
781
+ l += ((int32_t)*p++) << 24;
782
+ }
783
+ }
784
+ if (r->symbol == -SECT_DATA)
785
+ l += stext.len;
786
+ else if (r->symbol == -SECT_BSS)
787
+ l += stext.len + sdata.len;
788
+ if (r->bytes == 4)
789
+ WRITELONG(q, l);
790
+ else if (r->bytes == 2)
791
+ WRITESHORT(q, l);
792
+ else
793
+ *q++ = l & 0xFF;
794
+ saa_fwrite(sect->data, r->address, blk, (int32_t)r->bytes);
795
+ }
796
+ }
797
+
798
+ static void aout_write(void)
799
+ {
800
+ /*
801
+ * Emit the a.out header.
802
+ */
803
+ /* OMAGIC, M_386 or MID_I386, no flags */
804
+ fwriteint32_t(bsd ? 0x07018600 | is_pic : 0x640107L, ofile);
805
+ fwriteint32_t(stext.len, ofile);
806
+ fwriteint32_t(sdata.len, ofile);
807
+ fwriteint32_t(sbss.len, ofile);
808
+ fwriteint32_t(nsyms * 12, ofile); /* length of symbol table */
809
+ fwriteint32_t(0L, ofile); /* object files have no entry point */
810
+ fwriteint32_t(stext.nrelocs * 8, ofile); /* size of text relocs */
811
+ fwriteint32_t(sdata.nrelocs * 8, ofile); /* size of data relocs */
812
+
813
+ /*
814
+ * Write out the code section and the data section.
815
+ */
816
+ saa_fpwrite(stext.data, ofile);
817
+ saa_fpwrite(sdata.data, ofile);
818
+
819
+ /*
820
+ * Write out the relocations.
821
+ */
822
+ aout_write_relocs(stext.head);
823
+ aout_write_relocs(sdata.head);
824
+
825
+ /*
826
+ * Write the symbol table.
827
+ */
828
+ aout_write_syms();
829
+
830
+ /*
831
+ * And the string table.
832
+ */
833
+ fwriteint32_t(strslen + 4, ofile); /* length includes length count */
834
+ saa_fpwrite(strs, ofile);
835
+ }
836
+
837
+ static void aout_write_relocs(struct Reloc *r)
838
+ {
839
+ list_for_each(r, r) {
840
+ uint32_t word2;
841
+
842
+ fwriteint32_t(r->address, ofile);
843
+
844
+ if (r->symbol >= 0)
845
+ word2 = r->symbol;
846
+ else
847
+ word2 = -r->symbol;
848
+ word2 |= r->reltype << 24;
849
+ word2 |= (r->bytes == 1 ? 0 :
850
+ r->bytes == 2 ? 0x2000000L : 0x4000000L);
851
+ fwriteint32_t(word2, ofile);
852
+ }
853
+ }
854
+
855
+ static void aout_write_syms(void)
856
+ {
857
+ uint32_t i;
858
+
859
+ saa_rewind(syms);
860
+ for (i = 0; i < nsyms; i++) {
861
+ struct Symbol *sym = saa_rstruct(syms);
862
+ fwriteint32_t(sym->strpos, ofile);
863
+ fwriteint32_t((int32_t)sym->type & ~SYM_WITH_SIZE, ofile);
864
+ /*
865
+ * Fix up the symbol value now we know the final section
866
+ * sizes.
867
+ */
868
+ if ((sym->type & SECT_MASK) == SECT_DATA)
869
+ sym->value += stext.len;
870
+ if ((sym->type & SECT_MASK) == SECT_BSS)
871
+ sym->value += stext.len + sdata.len;
872
+ fwriteint32_t(sym->value, ofile);
873
+ /*
874
+ * Output a size record if necessary.
875
+ */
876
+ if (sym->type & SYM_WITH_SIZE) {
877
+ fwriteint32_t(sym->strpos, ofile);
878
+ fwriteint32_t(0x0DL, ofile); /* special value: means size */
879
+ fwriteint32_t(sym->size, ofile);
880
+ i++; /* use up another of `nsyms' */
881
+ }
882
+ }
883
+ }
884
+
885
+ static void aout_sect_write(struct Section *sect,
886
+ const uint8_t *data, uint32_t len)
887
+ {
888
+ saa_wbytes(sect->data, data, len);
889
+ sect->len += len;
890
+ }
891
+
892
+ static int32_t aout_segbase(int32_t segment)
893
+ {
894
+ return segment;
895
+ }
896
+
897
+ static void aout_filename(char *inname, char *outname)
898
+ {
899
+ standard_extension(inname, outname, ".o");
900
+ }
901
+
902
+ extern macros_t aout_stdmac[];
903
+
904
+ #endif /* OF_AOUT || OF_AOUTB */
905
+
906
+ #ifdef OF_AOUT
907
+
908
+ const struct ofmt of_aout = {
909
+ "Linux a.out object files",
910
+ "aout",
911
+ 0,
912
+ 32,
913
+ null_debug_arr,
914
+ &null_debug_form,
915
+ aout_stdmac,
916
+ aout_init,
917
+ nasm_do_legacy_output,
918
+ aout_out,
919
+ aout_deflabel,
920
+ aout_section_names,
921
+ null_sectalign,
922
+ aout_segbase,
923
+ null_directive,
924
+ aout_filename,
925
+ aout_cleanup,
926
+ NULL /* pragma list */
927
+ };
928
+
929
+ #endif
930
+
931
+ #ifdef OF_AOUTB
932
+
933
+ const struct ofmt of_aoutb = {
934
+ "NetBSD/FreeBSD a.out object files",
935
+ "aoutb",
936
+ 0,
937
+ 32,
938
+ null_debug_arr,
939
+ &null_debug_form,
940
+ aout_stdmac,
941
+ aoutb_init,
942
+ nasm_do_legacy_output,
943
+ aout_out,
944
+ aout_deflabel,
945
+ aout_section_names,
946
+ null_sectalign,
947
+ aout_segbase,
948
+ null_directive,
949
+ aout_filename,
950
+ aout_cleanup,
951
+ NULL /* pragma list */
952
+ };
953
+
954
+ #endif