laag-nasm 2.13.03.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +57 -0
- data/LICENSE.txt +29 -0
- data/README.org +34 -0
- data/ext/laag/nasm/extconf.rb +16 -0
- data/laag-nasm.gemspec +20 -0
- data/lib/laag/nasm.rb +29 -0
- data/patches/Makefile.in.patch +13 -0
- data/vendor/repo.or.cz/nasm/.gitignore +102 -0
- data/vendor/repo.or.cz/nasm/AUTHORS +137 -0
- data/vendor/repo.or.cz/nasm/CHANGES +2 -0
- data/vendor/repo.or.cz/nasm/ChangeLog +2905 -0
- data/vendor/repo.or.cz/nasm/INSTALL +102 -0
- data/vendor/repo.or.cz/nasm/LICENSE +29 -0
- data/vendor/repo.or.cz/nasm/Makefile.in +855 -0
- data/vendor/repo.or.cz/nasm/Mkfiles/README +46 -0
- data/vendor/repo.or.cz/nasm/Mkfiles/msvc.mak +732 -0
- data/vendor/repo.or.cz/nasm/Mkfiles/openwcom.mak +706 -0
- data/vendor/repo.or.cz/nasm/README +23 -0
- data/vendor/repo.or.cz/nasm/SubmittingPatches +116 -0
- data/vendor/repo.or.cz/nasm/TODO +376 -0
- data/vendor/repo.or.cz/nasm/aclocal.m4 +139 -0
- data/vendor/repo.or.cz/nasm/asm/assemble.c +2957 -0
- data/vendor/repo.or.cz/nasm/asm/assemble.h +54 -0
- data/vendor/repo.or.cz/nasm/asm/directiv.c +566 -0
- data/vendor/repo.or.cz/nasm/asm/directiv.dat +92 -0
- data/vendor/repo.or.cz/nasm/asm/error.c +202 -0
- data/vendor/repo.or.cz/nasm/asm/eval.c +1014 -0
- data/vendor/repo.or.cz/nasm/asm/eval.h +49 -0
- data/vendor/repo.or.cz/nasm/asm/exprdump.c +79 -0
- data/vendor/repo.or.cz/nasm/asm/exprlib.c +200 -0
- data/vendor/repo.or.cz/nasm/asm/float.c +952 -0
- data/vendor/repo.or.cz/nasm/asm/float.h +54 -0
- data/vendor/repo.or.cz/nasm/asm/labels.c +540 -0
- data/vendor/repo.or.cz/nasm/asm/listing.c +346 -0
- data/vendor/repo.or.cz/nasm/asm/listing.h +113 -0
- data/vendor/repo.or.cz/nasm/asm/nasm.c +1855 -0
- data/vendor/repo.or.cz/nasm/asm/parser.c +1167 -0
- data/vendor/repo.or.cz/nasm/asm/parser.h +45 -0
- data/vendor/repo.or.cz/nasm/asm/phash.pl +109 -0
- data/vendor/repo.or.cz/nasm/asm/pptok.dat +96 -0
- data/vendor/repo.or.cz/nasm/asm/pptok.pl +271 -0
- data/vendor/repo.or.cz/nasm/asm/pragma.c +218 -0
- data/vendor/repo.or.cz/nasm/asm/preproc-nop.c +188 -0
- data/vendor/repo.or.cz/nasm/asm/preproc.c +5459 -0
- data/vendor/repo.or.cz/nasm/asm/preproc.h +55 -0
- data/vendor/repo.or.cz/nasm/asm/quote.c +479 -0
- data/vendor/repo.or.cz/nasm/asm/quote.h +44 -0
- data/vendor/repo.or.cz/nasm/asm/rdstrnum.c +68 -0
- data/vendor/repo.or.cz/nasm/asm/segalloc.c +51 -0
- data/vendor/repo.or.cz/nasm/asm/stdscan.c +345 -0
- data/vendor/repo.or.cz/nasm/asm/stdscan.h +49 -0
- data/vendor/repo.or.cz/nasm/asm/strfunc.c +359 -0
- data/vendor/repo.or.cz/nasm/asm/tokens.dat +135 -0
- data/vendor/repo.or.cz/nasm/asm/tokhash.pl +284 -0
- data/vendor/repo.or.cz/nasm/autogen.sh +9 -0
- data/vendor/repo.or.cz/nasm/common/common.c +122 -0
- data/vendor/repo.or.cz/nasm/config/msvc.h +192 -0
- data/vendor/repo.or.cz/nasm/config/unknown.h +51 -0
- data/vendor/repo.or.cz/nasm/config/watcom.h +74 -0
- data/vendor/repo.or.cz/nasm/configure.ac +253 -0
- data/vendor/repo.or.cz/nasm/contrib/MSVC6.txt +25 -0
- data/vendor/repo.or.cz/nasm/contrib/VSrules/nasm.README +16 -0
- data/vendor/repo.or.cz/nasm/contrib/VSrules/nasm.rules +79 -0
- data/vendor/repo.or.cz/nasm/disasm/disasm.c +1735 -0
- data/vendor/repo.or.cz/nasm/disasm/disasm.h +49 -0
- data/vendor/repo.or.cz/nasm/disasm/ndisasm.c +397 -0
- data/vendor/repo.or.cz/nasm/disasm/sync.c +132 -0
- data/vendor/repo.or.cz/nasm/disasm/sync.h +45 -0
- data/vendor/repo.or.cz/nasm/doc/Makefile.in +86 -0
- data/vendor/repo.or.cz/nasm/doc/README +20 -0
- data/vendor/repo.or.cz/nasm/doc/afmmetrics.ph +102 -0
- data/vendor/repo.or.cz/nasm/doc/changes.src +2588 -0
- data/vendor/repo.or.cz/nasm/doc/findfont.ph +180 -0
- data/vendor/repo.or.cz/nasm/doc/genps.pl +1294 -0
- data/vendor/repo.or.cz/nasm/doc/inslist.pl +108 -0
- data/vendor/repo.or.cz/nasm/doc/internal.doc +290 -0
- data/vendor/repo.or.cz/nasm/doc/local.css +1 -0
- data/vendor/repo.or.cz/nasm/doc/nasmdoc.css +150 -0
- data/vendor/repo.or.cz/nasm/doc/nasmdoc.src +8309 -0
- data/vendor/repo.or.cz/nasm/doc/nasmlogo.eps +212 -0
- data/vendor/repo.or.cz/nasm/doc/nasmlogw.png +0 -0
- data/vendor/repo.or.cz/nasm/doc/psfonts.ph +53 -0
- data/vendor/repo.or.cz/nasm/doc/pspdf.pl +98 -0
- data/vendor/repo.or.cz/nasm/doc/pswidth.ph +25 -0
- data/vendor/repo.or.cz/nasm/doc/rdsrc.pl +1111 -0
- data/vendor/repo.or.cz/nasm/doc/ttfmetrics.ph +63 -0
- data/vendor/repo.or.cz/nasm/headers/c +33 -0
- data/vendor/repo.or.cz/nasm/headers/doc +33 -0
- data/vendor/repo.or.cz/nasm/headers/mac +33 -0
- data/vendor/repo.or.cz/nasm/headers/perl +33 -0
- data/vendor/repo.or.cz/nasm/include/compiler.h +277 -0
- data/vendor/repo.or.cz/nasm/include/disp8.h +45 -0
- data/vendor/repo.or.cz/nasm/include/error.h +135 -0
- data/vendor/repo.or.cz/nasm/include/hashtbl.h +85 -0
- data/vendor/repo.or.cz/nasm/include/iflag.h +173 -0
- data/vendor/repo.or.cz/nasm/include/insns.h +76 -0
- data/vendor/repo.or.cz/nasm/include/labels.h +60 -0
- data/vendor/repo.or.cz/nasm/include/md5.h +21 -0
- data/vendor/repo.or.cz/nasm/include/nasm.h +1246 -0
- data/vendor/repo.or.cz/nasm/include/nasmint.h +219 -0
- data/vendor/repo.or.cz/nasm/include/nasmlib.h +524 -0
- data/vendor/repo.or.cz/nasm/include/opflags.h +271 -0
- data/vendor/repo.or.cz/nasm/include/perfhash.h +52 -0
- data/vendor/repo.or.cz/nasm/include/raa.h +46 -0
- data/vendor/repo.or.cz/nasm/include/rbtree.h +51 -0
- data/vendor/repo.or.cz/nasm/include/rdoff.h +169 -0
- data/vendor/repo.or.cz/nasm/include/saa.h +94 -0
- data/vendor/repo.or.cz/nasm/include/strlist.h +55 -0
- data/vendor/repo.or.cz/nasm/include/tables.h +70 -0
- data/vendor/repo.or.cz/nasm/include/ver.h +47 -0
- data/vendor/repo.or.cz/nasm/install-sh +250 -0
- data/vendor/repo.or.cz/nasm/macros/altreg.mac +107 -0
- data/vendor/repo.or.cz/nasm/macros/fp.mac +54 -0
- data/vendor/repo.or.cz/nasm/macros/ifunc.mac +48 -0
- data/vendor/repo.or.cz/nasm/macros/macros.pl +294 -0
- data/vendor/repo.or.cz/nasm/macros/smartalign.mac +189 -0
- data/vendor/repo.or.cz/nasm/macros/standard.mac +226 -0
- data/vendor/repo.or.cz/nasm/misc/Doxyfile +752 -0
- data/vendor/repo.or.cz/nasm/misc/Nindent +18 -0
- data/vendor/repo.or.cz/nasm/misc/README +2 -0
- data/vendor/repo.or.cz/nasm/misc/c16.mac +82 -0
- data/vendor/repo.or.cz/nasm/misc/c32.mac +52 -0
- data/vendor/repo.or.cz/nasm/misc/crcgen.c +44 -0
- data/vendor/repo.or.cz/nasm/misc/exebin.mac +57 -0
- data/vendor/repo.or.cz/nasm/misc/exebin2.mac +114 -0
- data/vendor/repo.or.cz/nasm/misc/fmtinsns.pl +40 -0
- data/vendor/repo.or.cz/nasm/misc/genfma.pl +63 -0
- data/vendor/repo.or.cz/nasm/misc/hints.txt +26 -0
- data/vendor/repo.or.cz/nasm/misc/magic +6 -0
- data/vendor/repo.or.cz/nasm/misc/myC32.mac +121 -0
- data/vendor/repo.or.cz/nasm/misc/nasm.sl +320 -0
- data/vendor/repo.or.cz/nasm/misc/nasmstab +296 -0
- data/vendor/repo.or.cz/nasm/misc/omfdump.c +517 -0
- data/vendor/repo.or.cz/nasm/misc/pmw.bat +9 -0
- data/vendor/repo.or.cz/nasm/misc/proc32.ash +441 -0
- data/vendor/repo.or.cz/nasm/misc/scitech.mac +1223 -0
- data/vendor/repo.or.cz/nasm/misc/xcrcgen.c +80 -0
- data/vendor/repo.or.cz/nasm/nasm.spec.in +83 -0
- data/vendor/repo.or.cz/nasm/nasm.spec.sed +3 -0
- data/vendor/repo.or.cz/nasm/nasm.txt +306 -0
- data/vendor/repo.or.cz/nasm/nasmlib/badenum.c +43 -0
- data/vendor/repo.or.cz/nasm/nasmlib/bsi.c +77 -0
- data/vendor/repo.or.cz/nasm/nasmlib/crc64.c +189 -0
- data/vendor/repo.or.cz/nasm/nasmlib/file.c +259 -0
- data/vendor/repo.or.cz/nasm/nasmlib/file.h +128 -0
- data/vendor/repo.or.cz/nasm/nasmlib/filename.c +69 -0
- data/vendor/repo.or.cz/nasm/nasmlib/hashtbl.c +232 -0
- data/vendor/repo.or.cz/nasm/nasmlib/ilog2.c +168 -0
- data/vendor/repo.or.cz/nasm/nasmlib/malloc.c +108 -0
- data/vendor/repo.or.cz/nasm/nasmlib/md5c.c +247 -0
- data/vendor/repo.or.cz/nasm/nasmlib/mmap.c +139 -0
- data/vendor/repo.or.cz/nasm/nasmlib/path.c +186 -0
- data/vendor/repo.or.cz/nasm/nasmlib/perfhash.c +55 -0
- data/vendor/repo.or.cz/nasm/nasmlib/perfhash.pl +362 -0
- data/vendor/repo.or.cz/nasm/nasmlib/raa.c +173 -0
- data/vendor/repo.or.cz/nasm/nasmlib/rbtree.c +119 -0
- data/vendor/repo.or.cz/nasm/nasmlib/readnum.c +172 -0
- data/vendor/repo.or.cz/nasm/nasmlib/realpath.c +135 -0
- data/vendor/repo.or.cz/nasm/nasmlib/saa.c +431 -0
- data/vendor/repo.or.cz/nasm/nasmlib/srcfile.c +128 -0
- data/vendor/repo.or.cz/nasm/nasmlib/string.c +242 -0
- data/vendor/repo.or.cz/nasm/nasmlib/strlist.c +100 -0
- data/vendor/repo.or.cz/nasm/nasmlib/ver.c +51 -0
- data/vendor/repo.or.cz/nasm/nasmlib/zerobuf.c +42 -0
- data/vendor/repo.or.cz/nasm/ndisasm.txt +94 -0
- data/vendor/repo.or.cz/nasm/nsis/NASMMultiUser.nsh +478 -0
- data/vendor/repo.or.cz/nasm/nsis/getpearch.pl +76 -0
- data/vendor/repo.or.cz/nasm/nsis/nasm-un.ico +0 -0
- data/vendor/repo.or.cz/nasm/nsis/nasm.ico +0 -0
- data/vendor/repo.or.cz/nasm/nsis/nasm.nsi +241 -0
- data/vendor/repo.or.cz/nasm/output/codeview.c +814 -0
- data/vendor/repo.or.cz/nasm/output/dwarf.h +566 -0
- data/vendor/repo.or.cz/nasm/output/elf.h +537 -0
- data/vendor/repo.or.cz/nasm/output/legacy.c +112 -0
- data/vendor/repo.or.cz/nasm/output/nulldbg.c +93 -0
- data/vendor/repo.or.cz/nasm/output/nullout.c +51 -0
- data/vendor/repo.or.cz/nasm/output/outaout.c +954 -0
- data/vendor/repo.or.cz/nasm/output/outaout.mac +37 -0
- data/vendor/repo.or.cz/nasm/output/outas86.c +650 -0
- data/vendor/repo.or.cz/nasm/output/outas86.mac +37 -0
- data/vendor/repo.or.cz/nasm/output/outbin.c +1713 -0
- data/vendor/repo.or.cz/nasm/output/outbin.mac +40 -0
- data/vendor/repo.or.cz/nasm/output/outcoff.c +1242 -0
- data/vendor/repo.or.cz/nasm/output/outcoff.mac +43 -0
- data/vendor/repo.or.cz/nasm/output/outdbg.c +425 -0
- data/vendor/repo.or.cz/nasm/output/outelf.c +3370 -0
- data/vendor/repo.or.cz/nasm/output/outelf.h +156 -0
- data/vendor/repo.or.cz/nasm/output/outelf.mac +41 -0
- data/vendor/repo.or.cz/nasm/output/outform.c +120 -0
- data/vendor/repo.or.cz/nasm/output/outform.h +379 -0
- data/vendor/repo.or.cz/nasm/output/outieee.c +1528 -0
- data/vendor/repo.or.cz/nasm/output/outlib.c +58 -0
- data/vendor/repo.or.cz/nasm/output/outlib.h +63 -0
- data/vendor/repo.or.cz/nasm/output/outmacho.c +2387 -0
- data/vendor/repo.or.cz/nasm/output/outmacho.mac +49 -0
- data/vendor/repo.or.cz/nasm/output/outobj.c +2725 -0
- data/vendor/repo.or.cz/nasm/output/outobj.mac +49 -0
- data/vendor/repo.or.cz/nasm/output/outrdf.mac +40 -0
- data/vendor/repo.or.cz/nasm/output/outrdf2.c +791 -0
- data/vendor/repo.or.cz/nasm/output/outrdf2.mac +43 -0
- data/vendor/repo.or.cz/nasm/output/pecoff.h +532 -0
- data/vendor/repo.or.cz/nasm/output/stabs.h +144 -0
- data/vendor/repo.or.cz/nasm/perllib/crc64.ph +158 -0
- data/vendor/repo.or.cz/nasm/perllib/gensv.pl +34 -0
- data/vendor/repo.or.cz/nasm/perllib/phash.ph +200 -0
- data/vendor/repo.or.cz/nasm/perllib/random_sv_vectors.ph +67 -0
- data/vendor/repo.or.cz/nasm/rdoff/README +185 -0
- data/vendor/repo.or.cz/nasm/rdoff/collectn.c +44 -0
- data/vendor/repo.or.cz/nasm/rdoff/collectn.h +22 -0
- data/vendor/repo.or.cz/nasm/rdoff/doc/Makefile +37 -0
- data/vendor/repo.or.cz/nasm/rdoff/doc/rdoff.texi +137 -0
- data/vendor/repo.or.cz/nasm/rdoff/doc/v1-v2.txt +62 -0
- data/vendor/repo.or.cz/nasm/rdoff/hash.c +122 -0
- data/vendor/repo.or.cz/nasm/rdoff/hash.h +17 -0
- data/vendor/repo.or.cz/nasm/rdoff/ldrdf.1 +41 -0
- data/vendor/repo.or.cz/nasm/rdoff/ldrdf.c +1395 -0
- data/vendor/repo.or.cz/nasm/rdoff/ldsegs.h +59 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdf2bin.1 +65 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdf2bin.c +431 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdf2com.1 +1 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdf2ihx.1 +1 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdf2ith.1 +1 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdf2srec.1 +1 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdfdump.1 +24 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdfdump.c +347 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdflib.1 +39 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdflib.c +434 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdfload.c +213 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdfload.h +29 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdfutils.h +165 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdlar.c +492 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdlar.h +34 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdlib.c +290 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdlib.h +62 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdoff.c +621 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdx.1 +21 -0
- data/vendor/repo.or.cz/nasm/rdoff/rdx.c +90 -0
- data/vendor/repo.or.cz/nasm/rdoff/segtab.c +172 -0
- data/vendor/repo.or.cz/nasm/rdoff/segtab.h +45 -0
- data/vendor/repo.or.cz/nasm/rdoff/symtab.c +159 -0
- data/vendor/repo.or.cz/nasm/rdoff/symtab.h +55 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/Makefile +10 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/makelib.sh +14 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/rdfseg.asm +20 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/rdfseg2.asm +12 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/rdftest1.asm +54 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/rdftest2.asm +33 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/rdtlib.asm +48 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/rdtmain.asm +47 -0
- data/vendor/repo.or.cz/nasm/rdoff/test/testlib.asm +18 -0
- data/vendor/repo.or.cz/nasm/stdlib/snprintf.c +29 -0
- data/vendor/repo.or.cz/nasm/stdlib/strlcpy.c +51 -0
- data/vendor/repo.or.cz/nasm/stdlib/strnlen.c +46 -0
- data/vendor/repo.or.cz/nasm/stdlib/vsnprintf.c +51 -0
- data/vendor/repo.or.cz/nasm/test/Makefile +106 -0
- data/vendor/repo.or.cz/nasm/test/_file_.asm +5 -0
- data/vendor/repo.or.cz/nasm/test/_version.asm +2 -0
- data/vendor/repo.or.cz/nasm/test/a32offs.asm +9 -0
- data/vendor/repo.or.cz/nasm/test/absolute.asm +40 -0
- data/vendor/repo.or.cz/nasm/test/addr64x.asm +18 -0
- data/vendor/repo.or.cz/nasm/test/align13.asm +19 -0
- data/vendor/repo.or.cz/nasm/test/align13s.asm +20 -0
- data/vendor/repo.or.cz/nasm/test/alonesym-obj.asm +166 -0
- data/vendor/repo.or.cz/nasm/test/andbyte.asm +15 -0
- data/vendor/repo.or.cz/nasm/test/aoutso.asm +99 -0
- data/vendor/repo.or.cz/nasm/test/aouttest.asm +86 -0
- data/vendor/repo.or.cz/nasm/test/aouttest.c +36 -0
- data/vendor/repo.or.cz/nasm/test/avx.asm +46 -0
- data/vendor/repo.or.cz/nasm/test/avx005.asm +529 -0
- data/vendor/repo.or.cz/nasm/test/avx2.asm +1608 -0
- data/vendor/repo.or.cz/nasm/test/avx512cd.asm +106 -0
- data/vendor/repo.or.cz/nasm/test/avx512er.asm +144 -0
- data/vendor/repo.or.cz/nasm/test/avx512f.asm +7000 -0
- data/vendor/repo.or.cz/nasm/test/avx512pf.asm +88 -0
- data/vendor/repo.or.cz/nasm/test/bcd.asm +23 -0
- data/vendor/repo.or.cz/nasm/test/binexe.asm +35 -0
- data/vendor/repo.or.cz/nasm/test/bintest.asm +59 -0
- data/vendor/repo.or.cz/nasm/test/bisect.sh +22 -0
- data/vendor/repo.or.cz/nasm/test/br1879590.asm +25 -0
- data/vendor/repo.or.cz/nasm/test/br2003451.asm +17 -0
- data/vendor/repo.or.cz/nasm/test/br2030823.asm +7 -0
- data/vendor/repo.or.cz/nasm/test/br2148476.asm +221 -0
- data/vendor/repo.or.cz/nasm/test/br2222615.asm +19 -0
- data/vendor/repo.or.cz/nasm/test/br2496848.asm +42 -0
- data/vendor/repo.or.cz/nasm/test/br3005117.asm +26 -0
- data/vendor/repo.or.cz/nasm/test/br3026808.asm +20 -0
- data/vendor/repo.or.cz/nasm/test/br3028880.asm +8 -0
- data/vendor/repo.or.cz/nasm/test/br3041451.asm +59 -0
- data/vendor/repo.or.cz/nasm/test/br3058845.asm +14 -0
- data/vendor/repo.or.cz/nasm/test/br3066383.asm +70 -0
- data/vendor/repo.or.cz/nasm/test/br3074517.asm +12 -0
- data/vendor/repo.or.cz/nasm/test/br3092924.asm +25 -0
- data/vendor/repo.or.cz/nasm/test/br3104312.asm +11 -0
- data/vendor/repo.or.cz/nasm/test/br3109604.asm +9 -0
- data/vendor/repo.or.cz/nasm/test/br3174983.asm +9 -0
- data/vendor/repo.or.cz/nasm/test/br3187743.asm +7 -0
- data/vendor/repo.or.cz/nasm/test/br3189064.asm +7 -0
- data/vendor/repo.or.cz/nasm/test/br3200749.asm +9 -0
- data/vendor/repo.or.cz/nasm/test/br3385573.asm +11 -0
- data/vendor/repo.or.cz/nasm/test/br3392252.asm +43 -0
- data/vendor/repo.or.cz/nasm/test/br3392259.asm +8 -0
- data/vendor/repo.or.cz/nasm/test/br3392363.asm +4 -0
- data/vendor/repo.or.cz/nasm/test/br3392392.asm +16 -0
- data/vendor/repo.or.cz/nasm/test/br3392396.asm +5 -0
- data/vendor/repo.or.cz/nasm/test/br3392411.asm +22 -0
- data/vendor/repo.or.cz/nasm/test/br3392418.asm +3 -0
- data/vendor/repo.or.cz/nasm/test/br3392439.asm +25 -0
- data/vendor/repo.or.cz/nasm/test/br3392442.asm +6 -0
- data/vendor/repo.or.cz/nasm/test/br560575.asm +17 -0
- data/vendor/repo.or.cz/nasm/test/br560873.asm +27 -0
- data/vendor/repo.or.cz/nasm/test/br890790.asm +7 -0
- data/vendor/repo.or.cz/nasm/test/br890790_i.asm +1 -0
- data/vendor/repo.or.cz/nasm/test/br978756.asm +7 -0
- data/vendor/repo.or.cz/nasm/test/changed.asm +383 -0
- data/vendor/repo.or.cz/nasm/test/cofftest.asm +85 -0
- data/vendor/repo.or.cz/nasm/test/cofftest.c +35 -0
- data/vendor/repo.or.cz/nasm/test/crc32.asm +37 -0
- data/vendor/repo.or.cz/nasm/test/cv8struc.asm +14 -0
- data/vendor/repo.or.cz/nasm/test/dtbcd.asm +72 -0
- data/vendor/repo.or.cz/nasm/test/elf64so.asm +118 -0
- data/vendor/repo.or.cz/nasm/test/elfso.asm +100 -0
- data/vendor/repo.or.cz/nasm/test/elftest.asm +87 -0
- data/vendor/repo.or.cz/nasm/test/elftest.c +38 -0
- data/vendor/repo.or.cz/nasm/test/elftest64.c +43 -0
- data/vendor/repo.or.cz/nasm/test/elif.asm +39 -0
- data/vendor/repo.or.cz/nasm/test/expimp.asm +90 -0
- data/vendor/repo.or.cz/nasm/test/far64.asm +10 -0
- data/vendor/repo.or.cz/nasm/test/float.asm +186 -0
- data/vendor/repo.or.cz/nasm/test/float8.asm +135 -0
- data/vendor/repo.or.cz/nasm/test/floatb.asm +35 -0
- data/vendor/repo.or.cz/nasm/test/floatexp.asm +382 -0
- data/vendor/repo.or.cz/nasm/test/floatize.asm +19 -0
- data/vendor/repo.or.cz/nasm/test/floattest.asm +28 -0
- data/vendor/repo.or.cz/nasm/test/floatx.asm +525 -0
- data/vendor/repo.or.cz/nasm/test/fpu.asm +127 -0
- data/vendor/repo.or.cz/nasm/test/fwdopt.asm +133 -0
- data/vendor/repo.or.cz/nasm/test/fwdoptpp.asm +150 -0
- data/vendor/repo.or.cz/nasm/test/gas2nasm.py +104 -0
- data/vendor/repo.or.cz/nasm/test/gather.asm +11 -0
- data/vendor/repo.or.cz/nasm/test/gotoff64.asm +25 -0
- data/vendor/repo.or.cz/nasm/test/hexfp.asm +25 -0
- data/vendor/repo.or.cz/nasm/test/hle.asm +19 -0
- data/vendor/repo.or.cz/nasm/test/ifelse.asm +46 -0
- data/vendor/repo.or.cz/nasm/test/ifenv.asm +31 -0
- data/vendor/repo.or.cz/nasm/test/ifmacro.asm +413 -0
- data/vendor/repo.or.cz/nasm/test/iftoken.asm +317 -0
- data/vendor/repo.or.cz/nasm/test/iftoken.pl +32 -0
- data/vendor/repo.or.cz/nasm/test/ilog2.asm +271 -0
- data/vendor/repo.or.cz/nasm/test/imacro.asm +8 -0
- data/vendor/repo.or.cz/nasm/test/imm.asm +23 -0
- data/vendor/repo.or.cz/nasm/test/imm64.asm +61 -0
- data/vendor/repo.or.cz/nasm/test/immwarn.asm +91 -0
- data/vendor/repo.or.cz/nasm/test/imul.asm +117 -0
- data/vendor/repo.or.cz/nasm/test/inc1.asm +6 -0
- data/vendor/repo.or.cz/nasm/test/inc2.asm +8 -0
- data/vendor/repo.or.cz/nasm/test/incbin.asm +7 -0
- data/vendor/repo.or.cz/nasm/test/incbin.data +2 -0
- data/vendor/repo.or.cz/nasm/test/inctest.asm +15 -0
- data/vendor/repo.or.cz/nasm/test/insnlbl.asm +12 -0
- data/vendor/repo.or.cz/nasm/test/invlpga.asm +11 -0
- data/vendor/repo.or.cz/nasm/test/jmp64.asm +19 -0
- data/vendor/repo.or.cz/nasm/test/lar_lsl.asm +124 -0
- data/vendor/repo.or.cz/nasm/test/larlsl.asm +23 -0
- data/vendor/repo.or.cz/nasm/test/lnxhello.asm +54 -0
- data/vendor/repo.or.cz/nasm/test/local.asm +19 -0
- data/vendor/repo.or.cz/nasm/test/loopoffs.asm +12 -0
- data/vendor/repo.or.cz/nasm/test/lwp.asm +213 -0
- data/vendor/repo.or.cz/nasm/test/macro-defaults.asm +64 -0
- data/vendor/repo.or.cz/nasm/test/macroerr.asm +12 -0
- data/vendor/repo.or.cz/nasm/test/macroerr.inc +3 -0
- data/vendor/repo.or.cz/nasm/test/mmxsize.asm +38 -0
- data/vendor/repo.or.cz/nasm/test/movd.asm +12 -0
- data/vendor/repo.or.cz/nasm/test/movd64.asm +15 -0
- data/vendor/repo.or.cz/nasm/test/movimm.asm +28 -0
- data/vendor/repo.or.cz/nasm/test/movnti.asm +10 -0
- data/vendor/repo.or.cz/nasm/test/mpx-64.asm +120 -0
- data/vendor/repo.or.cz/nasm/test/mpx.asm +89 -0
- data/vendor/repo.or.cz/nasm/test/multisection.asm +96 -0
- data/vendor/repo.or.cz/nasm/test/nasmformat.asm +17 -0
- data/vendor/repo.or.cz/nasm/test/new +9 -0
- data/vendor/repo.or.cz/nasm/test/newrdwr.asm +24 -0
- data/vendor/repo.or.cz/nasm/test/nop.asm +17 -0
- data/vendor/repo.or.cz/nasm/test/nullfile.asm +4 -0
- data/vendor/repo.or.cz/nasm/test/objexe.asm +30 -0
- data/vendor/repo.or.cz/nasm/test/objlink.c +33 -0
- data/vendor/repo.or.cz/nasm/test/objtest.asm +85 -0
- data/vendor/repo.or.cz/nasm/test/optimization.asm +104 -0
- data/vendor/repo.or.cz/nasm/test/org.asm +18 -0
- data/vendor/repo.or.cz/nasm/test/paste.asm +12 -0
- data/vendor/repo.or.cz/nasm/test/pcrel.asm +52 -0
- data/vendor/repo.or.cz/nasm/test/perf/label.pl +18 -0
- data/vendor/repo.or.cz/nasm/test/perf/macro.pl +18 -0
- data/vendor/repo.or.cz/nasm/test/perf/token.pl +23 -0
- data/vendor/repo.or.cz/nasm/test/performtest.pl +192 -0
- data/vendor/repo.or.cz/nasm/test/pextrw.asm +3 -0
- data/vendor/repo.or.cz/nasm/test/pinsr16.asm +53 -0
- data/vendor/repo.or.cz/nasm/test/pinsr32.asm +53 -0
- data/vendor/repo.or.cz/nasm/test/pinsr64.asm +68 -0
- data/vendor/repo.or.cz/nasm/test/popcnt.asm +32 -0
- data/vendor/repo.or.cz/nasm/test/ppindirect.asm +42 -0
- data/vendor/repo.or.cz/nasm/test/pragma.asm +12 -0
- data/vendor/repo.or.cz/nasm/test/prefix66.asm +28 -0
- data/vendor/repo.or.cz/nasm/test/ptr.asm +4 -0
- data/vendor/repo.or.cz/nasm/test/pushseg.asm +17 -0
- data/vendor/repo.or.cz/nasm/test/r13.asm +15 -0
- data/vendor/repo.or.cz/nasm/test/radix.asm +54 -0
- data/vendor/repo.or.cz/nasm/test/rdpid.asm +21 -0
- data/vendor/repo.or.cz/nasm/test/reldef.asm +57 -0
- data/vendor/repo.or.cz/nasm/test/relocs.asm +20 -0
- data/vendor/repo.or.cz/nasm/test/riprel.asm +5357 -0
- data/vendor/repo.or.cz/nasm/test/riprel.pl +29 -0
- data/vendor/repo.or.cz/nasm/test/riprel2.asm +11 -0
- data/vendor/repo.or.cz/nasm/test/sha-64.asm +30 -0
- data/vendor/repo.or.cz/nasm/test/sha.asm +31 -0
- data/vendor/repo.or.cz/nasm/test/smartalign16.asm +36 -0
- data/vendor/repo.or.cz/nasm/test/smartalign32.asm +36 -0
- data/vendor/repo.or.cz/nasm/test/smartalign64.asm +36 -0
- data/vendor/repo.or.cz/nasm/test/splitea.asm +11 -0
- data/vendor/repo.or.cz/nasm/test/sreg.asm +65 -0
- data/vendor/repo.or.cz/nasm/test/strlen.asm +5 -0
- data/vendor/repo.or.cz/nasm/test/struc.asm +33 -0
- data/vendor/repo.or.cz/nasm/test/test67.asm +38 -0
- data/vendor/repo.or.cz/nasm/test/testdos.asm +13 -0
- data/vendor/repo.or.cz/nasm/test/testnos3.asm +973 -0
- data/vendor/repo.or.cz/nasm/test/time.asm +11 -0
- data/vendor/repo.or.cz/nasm/test/times.asm +21 -0
- data/vendor/repo.or.cz/nasm/test/timesneg.asm +3 -0
- data/vendor/repo.or.cz/nasm/test/tmap.nas +1447 -0
- data/vendor/repo.or.cz/nasm/test/uscore.asm +15 -0
- data/vendor/repo.or.cz/nasm/test/utf.asm +82 -0
- data/vendor/repo.or.cz/nasm/test/vaesenc.asm +22 -0
- data/vendor/repo.or.cz/nasm/test/vex.asm +9 -0
- data/vendor/repo.or.cz/nasm/test/vgather.asm +76 -0
- data/vendor/repo.or.cz/nasm/test/vmread.asm +26 -0
- data/vendor/repo.or.cz/nasm/test/weirdpaste.asm +29 -0
- data/vendor/repo.or.cz/nasm/test/xchg.asm +96 -0
- data/vendor/repo.or.cz/nasm/test/xcrypt.asm +24 -0
- data/vendor/repo.or.cz/nasm/test/xmm0.asm +12 -0
- data/vendor/repo.or.cz/nasm/test/zerobyte.asm +22 -0
- data/vendor/repo.or.cz/nasm/tools/cleanfile +176 -0
- data/vendor/repo.or.cz/nasm/tools/cleanpatch +258 -0
- data/vendor/repo.or.cz/nasm/tools/mkdep.pl +261 -0
- data/vendor/repo.or.cz/nasm/tools/release +105 -0
- data/vendor/repo.or.cz/nasm/tools/syncfiles.pl +137 -0
- data/vendor/repo.or.cz/nasm/tools/tag-release +58 -0
- data/vendor/repo.or.cz/nasm/version +1 -0
- data/vendor/repo.or.cz/nasm/version.pl +189 -0
- data/vendor/repo.or.cz/nasm/x86/disp8.c +131 -0
- data/vendor/repo.or.cz/nasm/x86/insns-iflags.ph +280 -0
- data/vendor/repo.or.cz/nasm/x86/insns.dat +5371 -0
- data/vendor/repo.or.cz/nasm/x86/insns.pl +1043 -0
- data/vendor/repo.or.cz/nasm/x86/regs.dat +138 -0
- data/vendor/repo.or.cz/nasm/x86/regs.pl +204 -0
- metadata +520 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
Differences between RDOFF versions 1 & 2
|
2
|
+
========================================
|
3
|
+
|
4
|
+
This document is designed primarily for people maintaining code which
|
5
|
+
uses RDOFF version 1, and would like to upgrade that code to work
|
6
|
+
with version 2.
|
7
|
+
|
8
|
+
The main changes are summarised here:
|
9
|
+
|
10
|
+
Overall format
|
11
|
+
==============
|
12
|
+
|
13
|
+
The overall format has changed somewhat since version 1, in order
|
14
|
+
to make RDOFF more flexible. After the file type identifier (which
|
15
|
+
has been changed to 'RDOFF2', obviously), there is now a 4 byte
|
16
|
+
integer describing the length of the object module. This allows
|
17
|
+
multiple objects to be concatenated, while the loader can easily
|
18
|
+
build an index of the locations of each object. This isn't as
|
19
|
+
pointless as it sounds; I'm using RDOFF in a microkernel operating
|
20
|
+
system, and this is the ideal way of loading multiple driver modules
|
21
|
+
at boot time.
|
22
|
+
|
23
|
+
There are also no longer a fixed number of segments; instead there
|
24
|
+
is a list of segments, immediately following the header.
|
25
|
+
Each segment is preceded by a 10 byte header giving information about
|
26
|
+
that segment. This header has the following format:
|
27
|
+
|
28
|
+
Length Description
|
29
|
+
2 Type
|
30
|
+
2 Number
|
31
|
+
2 Reserved
|
32
|
+
4 Length
|
33
|
+
|
34
|
+
'Type' is a number describing what sort of segment it is (eg text, data,
|
35
|
+
comment, debug info). See 'rdoff2.txt' for a list of the segment types.
|
36
|
+
'Number' is the number used to refer to the segment in the header records.
|
37
|
+
Not all segments will be loaded; it is only intended that one code
|
38
|
+
and one data segment will be loaded into memory. It is possible, however,
|
39
|
+
for a loaded segment to contain a reference to an unloaded segment.
|
40
|
+
This is an error, and should be flagged at load time. Or maybe you should
|
41
|
+
load the segment... its up to you, really.
|
42
|
+
|
43
|
+
The segment's data immediately follows the end of the segment header.
|
44
|
+
|
45
|
+
HEADER RECORDS
|
46
|
+
==============
|
47
|
+
|
48
|
+
All of the header records have changed in this version, but not
|
49
|
+
substantially. Each record type has had a content-length code added,
|
50
|
+
a single byte immediately following the type byte. This contains the
|
51
|
+
length of the rest of the record (excluding the type and length bytes,
|
52
|
+
but including the terminating nulls on any strings in the record).
|
53
|
+
|
54
|
+
There are two new record types, Segment Relocation (6), and FAR import (7).
|
55
|
+
The record formats are identical to Relocation (1) and import (2). They are
|
56
|
+
only of real use on systems using segmented architectures. Systems using
|
57
|
+
a flat model should treat FAR import (7) exactly the same as an import (2),
|
58
|
+
and should either flag segment relocation as an error, or attempt to figure
|
59
|
+
out whether it is a reference to a code or data symbol, and set the value
|
60
|
+
referenced to the according selector value. I am opting for the former
|
61
|
+
approach, and would recommend that others working on 32 bit flat systems
|
62
|
+
do the same.
|
@@ -0,0 +1,122 @@
|
|
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
|
+
/*
|
35
|
+
* hash.h Routines to calculate a CRC32 hash value
|
36
|
+
*
|
37
|
+
* These routines donated to the NASM effort by Graeme Defty.
|
38
|
+
*/
|
39
|
+
|
40
|
+
#include "compiler.h"
|
41
|
+
|
42
|
+
#include "hash.h"
|
43
|
+
|
44
|
+
const uint32_t consttab[] = {
|
45
|
+
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
|
46
|
+
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
47
|
+
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
48
|
+
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
49
|
+
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
50
|
+
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
51
|
+
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
|
52
|
+
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
53
|
+
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
54
|
+
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
55
|
+
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
|
56
|
+
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
57
|
+
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
|
58
|
+
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
59
|
+
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
60
|
+
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
61
|
+
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
|
62
|
+
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
63
|
+
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
|
64
|
+
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
65
|
+
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
66
|
+
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
67
|
+
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
|
68
|
+
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
69
|
+
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
70
|
+
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
71
|
+
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
72
|
+
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
73
|
+
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
|
74
|
+
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
75
|
+
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
|
76
|
+
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
77
|
+
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
78
|
+
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
79
|
+
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
80
|
+
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
81
|
+
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
|
82
|
+
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
83
|
+
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
84
|
+
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
85
|
+
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
|
86
|
+
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
87
|
+
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
|
88
|
+
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
89
|
+
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
90
|
+
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
91
|
+
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
|
92
|
+
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
93
|
+
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
|
94
|
+
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
95
|
+
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
96
|
+
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
97
|
+
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
|
98
|
+
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
99
|
+
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
100
|
+
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
101
|
+
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
102
|
+
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
103
|
+
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
|
104
|
+
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
105
|
+
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
|
106
|
+
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
107
|
+
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
108
|
+
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
109
|
+
};
|
110
|
+
|
111
|
+
uint32_t hash(const char *name)
|
112
|
+
{
|
113
|
+
register const char *n;
|
114
|
+
register uint32_t hashval = 0xffffffff;
|
115
|
+
|
116
|
+
for (n = name; *n; n++)
|
117
|
+
hashval = (hashval >> 8) ^ consttab[(hashval ^ *n) & 0xff];
|
118
|
+
|
119
|
+
hashval ^= 0xffffffff;
|
120
|
+
|
121
|
+
return hashval;
|
122
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/* hash.h Routines to calculate a CRC32 hash value
|
2
|
+
*
|
3
|
+
* These routines donated to the NASM effort by Graeme Defty.
|
4
|
+
*
|
5
|
+
* The Netwide Assembler is copyright (C) 1996 Simon Tatham and
|
6
|
+
* Julian Hall. All rights reserved. The software is
|
7
|
+
* redistributable under the license given in the file "LICENSE"
|
8
|
+
* distributed in the NASM archive.
|
9
|
+
*/
|
10
|
+
|
11
|
+
#ifndef RDOFF_HASH_H
|
12
|
+
#define RDOFF_HASH_H 1
|
13
|
+
|
14
|
+
|
15
|
+
uint32_t hash(const char *name);
|
16
|
+
|
17
|
+
#endif
|
@@ -0,0 +1,41 @@
|
|
1
|
+
.TH LDRDF 1 "September 6, 1999" "Debian Project" "Debian Manual"
|
2
|
+
.SH NAME
|
3
|
+
ldrdf \- link RDOFF objects and libraries produced by rdflib(1)
|
4
|
+
.SH SYNOPSIS
|
5
|
+
.B ldrdf
|
6
|
+
.RI "[-o " output-file ]
|
7
|
+
.I object-file\c
|
8
|
+
.RI "... [-l" library "...]"
|
9
|
+
.SH DESCRIPTION
|
10
|
+
.B ldrdf
|
11
|
+
is a version of unix
|
12
|
+
.BR ld (1)
|
13
|
+
(or DOS LINK) for use with RDOFF files. It is capable of linking RDOFF
|
14
|
+
objects, and libraries produced with the
|
15
|
+
.BR rdflib (1)
|
16
|
+
utility.
|
17
|
+
.PP
|
18
|
+
Libraries must be specified with their path as no search is performed.
|
19
|
+
Modules in libraries are not linked to the program unless they are
|
20
|
+
referred to.
|
21
|
+
.SH OPTIONS
|
22
|
+
.TP
|
23
|
+
.RI "-o " output-file
|
24
|
+
Specify an output file. The default output filename is
|
25
|
+
.RI ' aout.rdx '.
|
26
|
+
.TP
|
27
|
+
-v
|
28
|
+
Increase verbosity level. Currently 4 verbosity levels are available:
|
29
|
+
default (which only prints error information), normal (which prints
|
30
|
+
information about the produced object, -v), medium (which prints information
|
31
|
+
about what the program is doing, -v -v) and high (which prints all available
|
32
|
+
information, -v -v -v).
|
33
|
+
.TP
|
34
|
+
-p
|
35
|
+
Change alignment value to which multiple segments combigned into a single
|
36
|
+
segment should be aligned (must be either 1, 2, 4, 8, 16, 32 or 256; default
|
37
|
+
is 16).
|
38
|
+
.SH AUTHORS
|
39
|
+
Julian Hall <jules@earthcorp.com>.
|
40
|
+
.PP
|
41
|
+
This manual page was written by Matej Vela <vela@debian.org>.
|
@@ -0,0 +1,1395 @@
|
|
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
|
+
/*
|
35
|
+
* ldrdf.c - RDOFF Object File linker/loader main program.
|
36
|
+
*/
|
37
|
+
|
38
|
+
/*
|
39
|
+
* TODO:
|
40
|
+
* - enhance search of required export symbols in libraries (now depends
|
41
|
+
* on modules order in library)
|
42
|
+
* - keep a cache of symbol names in each library module so
|
43
|
+
* we don't have to constantly recheck the file
|
44
|
+
* - general performance improvements
|
45
|
+
*
|
46
|
+
* BUGS & LIMITATIONS: this program doesn't support multiple code, data
|
47
|
+
* or bss segments, therefore for 16 bit programs whose code, data or BSS
|
48
|
+
* segment exceeds 64K in size, it will not work. This program probably
|
49
|
+
* won't work if compiled by a 16 bit compiler. Try DJGPP if you're running
|
50
|
+
* under DOS. '#define STINGY_MEMORY' may help a little.
|
51
|
+
*/
|
52
|
+
|
53
|
+
#include "compiler.h"
|
54
|
+
|
55
|
+
#include <stdio.h>
|
56
|
+
#include <stdlib.h>
|
57
|
+
#include <string.h>
|
58
|
+
|
59
|
+
#include "rdfutils.h"
|
60
|
+
#include "symtab.h"
|
61
|
+
#include "collectn.h"
|
62
|
+
#include "rdlib.h"
|
63
|
+
#include "segtab.h"
|
64
|
+
#include "nasmlib.h"
|
65
|
+
|
66
|
+
#define LDRDF_VERSION "1.08"
|
67
|
+
|
68
|
+
/* #define STINGY_MEMORY */
|
69
|
+
|
70
|
+
/* =======================================================================
|
71
|
+
* Types & macros that are private to this program
|
72
|
+
*/
|
73
|
+
|
74
|
+
struct segment_infonode {
|
75
|
+
int dest_seg; /* output segment to be placed into, -1 to
|
76
|
+
skip linking this segment */
|
77
|
+
int32_t reloc; /* segment's relocation factor */
|
78
|
+
};
|
79
|
+
|
80
|
+
struct modulenode {
|
81
|
+
rdffile f; /* the RDOFF file structure */
|
82
|
+
struct segment_infonode seginfo[RDF_MAXSEGS]; /* what are we doing
|
83
|
+
with each segment? */
|
84
|
+
void *header;
|
85
|
+
char *name;
|
86
|
+
struct modulenode *next;
|
87
|
+
int32_t bss_reloc;
|
88
|
+
};
|
89
|
+
|
90
|
+
#include "ldsegs.h"
|
91
|
+
|
92
|
+
/* ==========================================================================
|
93
|
+
* Function prototypes of private utility functions
|
94
|
+
*/
|
95
|
+
|
96
|
+
void processmodule(const char *filename, struct modulenode *mod);
|
97
|
+
int allocnewseg(uint16_t type, uint16_t reserved);
|
98
|
+
int findsegment(uint16_t type, uint16_t reserved);
|
99
|
+
void symtab_add(const char *symbol, int segment, int32_t offset);
|
100
|
+
int symtab_get(const char *symbol, int *segment, int32_t *offset);
|
101
|
+
|
102
|
+
/* =========================================================================
|
103
|
+
* Global data structures.
|
104
|
+
*/
|
105
|
+
|
106
|
+
/* a linked list of modules that will be included in the output */
|
107
|
+
struct modulenode *modules = NULL;
|
108
|
+
struct modulenode *lastmodule = NULL;
|
109
|
+
|
110
|
+
/* a linked list of libraries to be searched for unresolved imported symbols */
|
111
|
+
struct librarynode *libraries = NULL;
|
112
|
+
struct librarynode *lastlib = NULL;
|
113
|
+
|
114
|
+
/* the symbol table */
|
115
|
+
void *symtab = NULL;
|
116
|
+
|
117
|
+
/* objects search path */
|
118
|
+
char *objpath = NULL;
|
119
|
+
|
120
|
+
/* libraries search path */
|
121
|
+
char *libpath = NULL;
|
122
|
+
|
123
|
+
/* file to embed as a generic record */
|
124
|
+
char *generic_rec_file = NULL;
|
125
|
+
|
126
|
+
/* module name to be added at the beginning of output file */
|
127
|
+
char *modname_specified = NULL;
|
128
|
+
|
129
|
+
/* error file */
|
130
|
+
static FILE *error_file;
|
131
|
+
|
132
|
+
/* the header of the output file, built up stage by stage */
|
133
|
+
rdf_headerbuf *newheader = NULL;
|
134
|
+
|
135
|
+
/* The current state of segment allocation, including information about
|
136
|
+
* which output segment numbers have been allocated, and their types and
|
137
|
+
* amount of data which has already been allocated inside them.
|
138
|
+
*/
|
139
|
+
struct SegmentHeaderRec outputseg[RDF_MAXSEGS];
|
140
|
+
int nsegs = 0;
|
141
|
+
int32_t bss_length;
|
142
|
+
|
143
|
+
/* global options which affect how the program behaves */
|
144
|
+
struct ldrdfoptions {
|
145
|
+
int verbose;
|
146
|
+
int align;
|
147
|
+
int dynalink;
|
148
|
+
int strip;
|
149
|
+
int respfile;
|
150
|
+
int stderr_redir;
|
151
|
+
int objpath;
|
152
|
+
int libpath;
|
153
|
+
} options;
|
154
|
+
|
155
|
+
int errorcount = 0; /* determines main program exit status */
|
156
|
+
|
157
|
+
/* =========================================================================
|
158
|
+
* Utility functions
|
159
|
+
*/
|
160
|
+
|
161
|
+
/*
|
162
|
+
* initsegments()
|
163
|
+
*
|
164
|
+
* sets up segments 0, 1, and 2, the initial code data and bss segments
|
165
|
+
*/
|
166
|
+
static void initsegments(void)
|
167
|
+
{
|
168
|
+
nsegs = 3;
|
169
|
+
outputseg[0].type = 1;
|
170
|
+
outputseg[0].number = 0;
|
171
|
+
outputseg[0].reserved = 0;
|
172
|
+
outputseg[0].length = 0;
|
173
|
+
outputseg[1].type = 2;
|
174
|
+
outputseg[1].number = 1;
|
175
|
+
outputseg[1].reserved = 0;
|
176
|
+
outputseg[1].length = 0;
|
177
|
+
outputseg[2].type = 0xFFFF; /* reserved segment type */
|
178
|
+
outputseg[2].number = 2;
|
179
|
+
outputseg[2].reserved = 0;
|
180
|
+
outputseg[2].length = 0;
|
181
|
+
bss_length = 0;
|
182
|
+
}
|
183
|
+
|
184
|
+
/*
|
185
|
+
* loadmodule()
|
186
|
+
*
|
187
|
+
* Determine the characteristics of a module, and decide what to do with
|
188
|
+
* each segment it contains (including determining destination segments and
|
189
|
+
* relocation factors for segments that are kept).
|
190
|
+
*/
|
191
|
+
static void loadmodule(const char *filename)
|
192
|
+
{
|
193
|
+
if (options.verbose)
|
194
|
+
printf("loading `%s'\n", filename);
|
195
|
+
|
196
|
+
/* allocate a new module entry on the end of the modules list */
|
197
|
+
if (!modules) {
|
198
|
+
modules = nasm_malloc(sizeof(*modules));
|
199
|
+
lastmodule = modules;
|
200
|
+
} else {
|
201
|
+
lastmodule->next = nasm_malloc(sizeof(*modules));
|
202
|
+
lastmodule = lastmodule->next;
|
203
|
+
}
|
204
|
+
|
205
|
+
if (!lastmodule) {
|
206
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
207
|
+
exit(1);
|
208
|
+
}
|
209
|
+
|
210
|
+
/* open the file using 'rdfopen', which returns nonzero on error */
|
211
|
+
if (rdfopen(&lastmodule->f, filename) != 0) {
|
212
|
+
rdfperror("ldrdf", filename);
|
213
|
+
exit(1);
|
214
|
+
}
|
215
|
+
|
216
|
+
/*
|
217
|
+
* store information about the module, and determine what segments
|
218
|
+
* it contains, and what we should do with them (determine relocation
|
219
|
+
* factor if we decide to keep them)
|
220
|
+
*/
|
221
|
+
lastmodule->header = NULL;
|
222
|
+
lastmodule->name = nasm_strdup(filename);
|
223
|
+
lastmodule->next = NULL;
|
224
|
+
|
225
|
+
processmodule(filename, lastmodule);
|
226
|
+
}
|
227
|
+
|
228
|
+
/*
|
229
|
+
* processmodule()
|
230
|
+
*
|
231
|
+
* step through each segment, determine what exactly we're doing with
|
232
|
+
* it, and if we intend to keep it, determine (a) which segment to
|
233
|
+
* put it in and (b) whereabouts in that segment it will end up.
|
234
|
+
* (b) is fairly easy, because we're now keeping track of how big each
|
235
|
+
* segment in our output file is...
|
236
|
+
*/
|
237
|
+
void processmodule(const char *filename, struct modulenode *mod)
|
238
|
+
{
|
239
|
+
struct segconfig sconf;
|
240
|
+
int seg, outseg;
|
241
|
+
void *header;
|
242
|
+
rdfheaderrec *hr;
|
243
|
+
int32_t bssamount = 0;
|
244
|
+
int bss_was_referenced = 0;
|
245
|
+
|
246
|
+
memset(&sconf, 0, sizeof sconf);
|
247
|
+
|
248
|
+
for (seg = 0; seg < mod->f.nsegs; seg++) {
|
249
|
+
/*
|
250
|
+
* get the segment configuration for this type from the segment
|
251
|
+
* table. getsegconfig() is a macro, defined in ldsegs.h.
|
252
|
+
*/
|
253
|
+
getsegconfig(sconf, mod->f.seg[seg].type);
|
254
|
+
|
255
|
+
if (options.verbose > 1) {
|
256
|
+
printf("%s %04x [%04x:%10s] ", filename,
|
257
|
+
mod->f.seg[seg].number, mod->f.seg[seg].type,
|
258
|
+
sconf.typedesc);
|
259
|
+
}
|
260
|
+
/*
|
261
|
+
* sconf->dowhat tells us what to do with a segment of this type.
|
262
|
+
*/
|
263
|
+
switch (sconf.dowhat) {
|
264
|
+
case SEG_IGNORE:
|
265
|
+
/*
|
266
|
+
* Set destination segment to -1, to indicate that this segment
|
267
|
+
* should be ignored for the purpose of output, ie it is left
|
268
|
+
* out of the linked executable.
|
269
|
+
*/
|
270
|
+
mod->seginfo[seg].dest_seg = -1;
|
271
|
+
if (options.verbose > 1)
|
272
|
+
printf("IGNORED\n");
|
273
|
+
break;
|
274
|
+
|
275
|
+
case SEG_NEWSEG:
|
276
|
+
/*
|
277
|
+
* The configuration tells us to create a new segment for
|
278
|
+
* each occurrence of this segment type.
|
279
|
+
*/
|
280
|
+
outseg = allocnewseg(sconf.mergetype,
|
281
|
+
mod->f.seg[seg].reserved);
|
282
|
+
mod->seginfo[seg].dest_seg = outseg;
|
283
|
+
mod->seginfo[seg].reloc = 0;
|
284
|
+
outputseg[outseg].length = mod->f.seg[seg].length;
|
285
|
+
if (options.verbose > 1)
|
286
|
+
printf("=> %04x:%08"PRIx32" (+%04"PRIx32")\n", outseg,
|
287
|
+
mod->seginfo[seg].reloc, mod->f.seg[seg].length);
|
288
|
+
break;
|
289
|
+
|
290
|
+
case SEG_MERGE:
|
291
|
+
/*
|
292
|
+
* The configuration tells us to merge the segment with
|
293
|
+
* a previously existing segment of type 'sconf.mergetype',
|
294
|
+
* if one exists. Otherwise a new segment is created.
|
295
|
+
* This is handled transparently by 'findsegment()'.
|
296
|
+
*/
|
297
|
+
outseg = findsegment(sconf.mergetype,
|
298
|
+
mod->f.seg[seg].reserved);
|
299
|
+
mod->seginfo[seg].dest_seg = outseg;
|
300
|
+
|
301
|
+
/*
|
302
|
+
* We need to add alignment to these segments.
|
303
|
+
*/
|
304
|
+
if (outputseg[outseg].length % options.align != 0)
|
305
|
+
outputseg[outseg].length +=
|
306
|
+
options.align -
|
307
|
+
(outputseg[outseg].length % options.align);
|
308
|
+
|
309
|
+
mod->seginfo[seg].reloc = outputseg[outseg].length;
|
310
|
+
outputseg[outseg].length += mod->f.seg[seg].length;
|
311
|
+
|
312
|
+
if (options.verbose > 1)
|
313
|
+
printf("=> %04x:%08"PRIx32" (+%04"PRIx32")\n", outseg,
|
314
|
+
mod->seginfo[seg].reloc, mod->f.seg[seg].length);
|
315
|
+
}
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
/*
|
320
|
+
* extract symbols from the header, and dump them into the
|
321
|
+
* symbol table
|
322
|
+
*/
|
323
|
+
header = nasm_malloc(mod->f.header_len);
|
324
|
+
if (!header) {
|
325
|
+
fprintf(stderr, "ldrdf: not enough memory\n");
|
326
|
+
exit(1);
|
327
|
+
}
|
328
|
+
if (rdfloadseg(&mod->f, RDOFF_HEADER, header)) {
|
329
|
+
rdfperror("ldrdf", filename);
|
330
|
+
exit(1);
|
331
|
+
}
|
332
|
+
|
333
|
+
while ((hr = rdfgetheaderrec(&mod->f))) {
|
334
|
+
switch (hr->type) {
|
335
|
+
case RDFREC_IMPORT: /* imported symbol */
|
336
|
+
case RDFREC_FARIMPORT:
|
337
|
+
/* Define with seg = -1 */
|
338
|
+
symtab_add(hr->i.label, -1, 0);
|
339
|
+
break;
|
340
|
+
|
341
|
+
case RDFREC_GLOBAL:{ /* exported symbol */
|
342
|
+
int destseg;
|
343
|
+
int32_t destreloc;
|
344
|
+
|
345
|
+
if (hr->e.segment == 2) {
|
346
|
+
bss_was_referenced = 1;
|
347
|
+
destreloc = bss_length;
|
348
|
+
if (destreloc % options.align != 0)
|
349
|
+
destreloc +=
|
350
|
+
options.align - (destreloc % options.align);
|
351
|
+
destseg = 2;
|
352
|
+
} else {
|
353
|
+
if ((destseg =
|
354
|
+
mod->seginfo[(int)hr->e.segment].dest_seg) == -1)
|
355
|
+
continue;
|
356
|
+
destreloc = mod->seginfo[(int)hr->e.segment].reloc;
|
357
|
+
}
|
358
|
+
symtab_add(hr->e.label, destseg, destreloc + hr->e.offset);
|
359
|
+
break;
|
360
|
+
}
|
361
|
+
|
362
|
+
case RDFREC_BSS: /* BSS reservation */
|
363
|
+
/*
|
364
|
+
* first, amalgamate all BSS reservations in this module
|
365
|
+
* into one, because we allow this in the output format.
|
366
|
+
*/
|
367
|
+
bssamount += hr->b.amount;
|
368
|
+
break;
|
369
|
+
|
370
|
+
case RDFREC_COMMON:{ /* Common variable */
|
371
|
+
symtabEnt *ste = symtabFind(symtab, hr->c.label);
|
372
|
+
|
373
|
+
/* Is the symbol already in the table? */
|
374
|
+
if (ste)
|
375
|
+
break;
|
376
|
+
|
377
|
+
/* Align the variable */
|
378
|
+
if (bss_length % hr->c.align != 0)
|
379
|
+
bss_length += hr->c.align - (bss_length % hr->c.align);
|
380
|
+
if (options.verbose > 1) {
|
381
|
+
printf("%s %04x common '%s' => 0002:%08"PRIx32" (+%04"PRIx32")\n",
|
382
|
+
filename, hr->c.segment, hr->c.label,
|
383
|
+
bss_length, hr->c.size);
|
384
|
+
}
|
385
|
+
|
386
|
+
symtab_add(hr->c.label, 2, bss_length);
|
387
|
+
mod->bss_reloc = bss_length;
|
388
|
+
bss_length += hr->c.size;
|
389
|
+
break;
|
390
|
+
}
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
if (bssamount != 0 || bss_was_referenced) {
|
395
|
+
/*
|
396
|
+
* handle the BSS segment - first pad the existing bss length
|
397
|
+
* to the correct alignment, then store the length in bss_reloc
|
398
|
+
* for this module. Then add this module's BSS length onto
|
399
|
+
* bss_length.
|
400
|
+
*/
|
401
|
+
if (bss_length % options.align != 0)
|
402
|
+
bss_length += options.align - (bss_length % options.align);
|
403
|
+
|
404
|
+
mod->bss_reloc = bss_length;
|
405
|
+
if (options.verbose > 1) {
|
406
|
+
printf("%s 0002 [ BSS] => 0002:%08"PRIx32" (+%04"PRIx32")\n",
|
407
|
+
filename, bss_length, bssamount);
|
408
|
+
}
|
409
|
+
bss_length += bssamount;
|
410
|
+
}
|
411
|
+
#ifdef STINGY_MEMORY
|
412
|
+
/*
|
413
|
+
* we free the header buffer here, to save memory later.
|
414
|
+
* this isn't efficient, but probably halves the memory usage
|
415
|
+
* of this program...
|
416
|
+
*/
|
417
|
+
mod->f.header_loc = NULL;
|
418
|
+
nasm_free(header);
|
419
|
+
|
420
|
+
#endif
|
421
|
+
|
422
|
+
}
|
423
|
+
|
424
|
+
/*
|
425
|
+
* Return 1 if a given module is in the list, 0 otherwise.
|
426
|
+
*/
|
427
|
+
static int lookformodule(const char *name)
|
428
|
+
{
|
429
|
+
struct modulenode *curr = modules;
|
430
|
+
|
431
|
+
while (curr) {
|
432
|
+
if (!strcmp(name, curr->name))
|
433
|
+
return 1;
|
434
|
+
curr = curr->next;
|
435
|
+
}
|
436
|
+
return 0;
|
437
|
+
}
|
438
|
+
|
439
|
+
/*
|
440
|
+
* allocnewseg()
|
441
|
+
* findsegment()
|
442
|
+
*
|
443
|
+
* These functions manipulate the array of output segments, and are used
|
444
|
+
* by processmodule(). allocnewseg() allocates a segment in the array,
|
445
|
+
* initialising it to be empty. findsegment() first scans the array for
|
446
|
+
* a segment of the type requested, and if one isn't found allocates a
|
447
|
+
* new one.
|
448
|
+
*/
|
449
|
+
int allocnewseg(uint16_t type, uint16_t reserved)
|
450
|
+
{
|
451
|
+
outputseg[nsegs].type = type;
|
452
|
+
outputseg[nsegs].number = nsegs;
|
453
|
+
outputseg[nsegs].reserved = reserved;
|
454
|
+
outputseg[nsegs].length = 0;
|
455
|
+
outputseg[nsegs].offset = 0;
|
456
|
+
outputseg[nsegs].data = NULL;
|
457
|
+
|
458
|
+
return nsegs++;
|
459
|
+
}
|
460
|
+
|
461
|
+
int findsegment(uint16_t type, uint16_t reserved)
|
462
|
+
{
|
463
|
+
int i;
|
464
|
+
|
465
|
+
for (i = 0; i < nsegs; i++)
|
466
|
+
if (outputseg[i].type == type)
|
467
|
+
return i;
|
468
|
+
|
469
|
+
return allocnewseg(type, reserved);
|
470
|
+
}
|
471
|
+
|
472
|
+
/*
|
473
|
+
* symtab_add()
|
474
|
+
*
|
475
|
+
* inserts a symbol into the global symbol table, which associates symbol
|
476
|
+
* names either with addresses, or a marker that the symbol hasn't been
|
477
|
+
* resolved yet, or possibly that the symbol has been defined as
|
478
|
+
* contained in a dynamic [load time/run time] linked library.
|
479
|
+
*
|
480
|
+
* segment = -1 => not yet defined
|
481
|
+
* segment = -2 => defined as dll symbol
|
482
|
+
*
|
483
|
+
* If the symbol is already defined, and the new segment >= 0, then
|
484
|
+
* if the original segment was < 0 the symbol is redefined, otherwise
|
485
|
+
* a duplicate symbol warning is issued. If new segment == -1, this
|
486
|
+
* routine won't change a previously existing symbol. It will change
|
487
|
+
* to segment = -2 only if the segment was previously < 0.
|
488
|
+
*/
|
489
|
+
void symtab_add(const char *symbol, int segment, int32_t offset)
|
490
|
+
{
|
491
|
+
symtabEnt *ste;
|
492
|
+
|
493
|
+
ste = symtabFind(symtab, symbol);
|
494
|
+
if (ste) {
|
495
|
+
if (ste->segment >= 0) {
|
496
|
+
/*
|
497
|
+
* symbol previously defined
|
498
|
+
*/
|
499
|
+
if (segment < 0)
|
500
|
+
return;
|
501
|
+
fprintf(error_file, "warning: `%s' redefined\n", symbol);
|
502
|
+
return;
|
503
|
+
}
|
504
|
+
|
505
|
+
/*
|
506
|
+
* somebody wanted the symbol, and put an undefined symbol
|
507
|
+
* marker into the table
|
508
|
+
*/
|
509
|
+
if (segment == -1)
|
510
|
+
return;
|
511
|
+
/*
|
512
|
+
* we have more information now - update the symbol's entry
|
513
|
+
*/
|
514
|
+
ste->segment = segment;
|
515
|
+
ste->offset = offset;
|
516
|
+
ste->flags = 0;
|
517
|
+
return;
|
518
|
+
}
|
519
|
+
/*
|
520
|
+
* this is the first declaration of this symbol
|
521
|
+
*/
|
522
|
+
ste = nasm_malloc(sizeof(symtabEnt));
|
523
|
+
if (!ste) {
|
524
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
525
|
+
exit(1);
|
526
|
+
}
|
527
|
+
ste->name = nasm_strdup(symbol);
|
528
|
+
ste->segment = segment;
|
529
|
+
ste->offset = offset;
|
530
|
+
ste->flags = 0;
|
531
|
+
symtabInsert(symtab, ste);
|
532
|
+
}
|
533
|
+
|
534
|
+
/*
|
535
|
+
* symtab_get()
|
536
|
+
*
|
537
|
+
* Retrieves the values associated with a symbol. Undefined symbols
|
538
|
+
* are assumed to have -1:0 associated. Returns 1 if the symbol was
|
539
|
+
* successfully located.
|
540
|
+
*/
|
541
|
+
int symtab_get(const char *symbol, int *segment, int32_t *offset)
|
542
|
+
{
|
543
|
+
symtabEnt *ste = symtabFind(symtab, symbol);
|
544
|
+
if (!ste) {
|
545
|
+
*segment = -1;
|
546
|
+
*offset = 0;
|
547
|
+
return 0;
|
548
|
+
} else {
|
549
|
+
*segment = ste->segment;
|
550
|
+
*offset = ste->offset;
|
551
|
+
return 1;
|
552
|
+
}
|
553
|
+
}
|
554
|
+
|
555
|
+
/*
|
556
|
+
* add_library()
|
557
|
+
*
|
558
|
+
* checks that a library can be opened and is in the correct format,
|
559
|
+
* then adds it to the linked list of libraries.
|
560
|
+
*/
|
561
|
+
static void add_library(const char *name)
|
562
|
+
{
|
563
|
+
if (rdl_verify(name)) {
|
564
|
+
rdl_perror("ldrdf", name);
|
565
|
+
errorcount++;
|
566
|
+
return;
|
567
|
+
}
|
568
|
+
if (!libraries) {
|
569
|
+
lastlib = libraries = nasm_malloc(sizeof(*libraries));
|
570
|
+
if (!libraries) {
|
571
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
572
|
+
exit(1);
|
573
|
+
}
|
574
|
+
} else {
|
575
|
+
lastlib->next = nasm_malloc(sizeof(*libraries));
|
576
|
+
if (!lastlib->next) {
|
577
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
578
|
+
exit(1);
|
579
|
+
}
|
580
|
+
lastlib = lastlib->next;
|
581
|
+
}
|
582
|
+
lastlib->next = NULL;
|
583
|
+
if (rdl_open(lastlib, name)) {
|
584
|
+
rdl_perror("ldrdf", name);
|
585
|
+
errorcount++;
|
586
|
+
return;
|
587
|
+
}
|
588
|
+
}
|
589
|
+
|
590
|
+
/*
|
591
|
+
* search_libraries()
|
592
|
+
*
|
593
|
+
* scans through the list of libraries, attempting to match symbols
|
594
|
+
* defined in library modules against symbols that are referenced but
|
595
|
+
* not defined (segment = -1 in the symbol table)
|
596
|
+
*
|
597
|
+
* returns 1 if any extra library modules are included, indicating that
|
598
|
+
* another pass through the library list should be made (possibly).
|
599
|
+
*/
|
600
|
+
static int search_libraries(void)
|
601
|
+
{
|
602
|
+
struct librarynode *cur;
|
603
|
+
rdffile f;
|
604
|
+
int i;
|
605
|
+
void *header;
|
606
|
+
int segment;
|
607
|
+
int32_t offset;
|
608
|
+
int doneanything = 0, pass = 1, keepfile;
|
609
|
+
rdfheaderrec *hr;
|
610
|
+
|
611
|
+
cur = libraries;
|
612
|
+
|
613
|
+
while (cur) {
|
614
|
+
if (options.verbose > 2)
|
615
|
+
printf("scanning library `%s', pass %d...\n", cur->name, pass);
|
616
|
+
|
617
|
+
for (i = 0; rdl_openmodule(cur, i, &f) == 0; i++) {
|
618
|
+
if (pass == 2 && lookformodule(f.name))
|
619
|
+
continue;
|
620
|
+
|
621
|
+
if (options.verbose > 3)
|
622
|
+
printf(" looking in module `%s'\n", f.name);
|
623
|
+
|
624
|
+
header = nasm_malloc(f.header_len);
|
625
|
+
if (!header) {
|
626
|
+
fprintf(stderr, "ldrdf: not enough memory\n");
|
627
|
+
exit(1);
|
628
|
+
}
|
629
|
+
if (rdfloadseg(&f, RDOFF_HEADER, header)) {
|
630
|
+
rdfperror("ldrdf", f.name);
|
631
|
+
errorcount++;
|
632
|
+
return 0;
|
633
|
+
}
|
634
|
+
|
635
|
+
keepfile = 0;
|
636
|
+
|
637
|
+
while ((hr = rdfgetheaderrec(&f))) {
|
638
|
+
/* We're only interested in exports, so skip others */
|
639
|
+
if (hr->type != RDFREC_GLOBAL)
|
640
|
+
continue;
|
641
|
+
|
642
|
+
/*
|
643
|
+
* If the symbol is marked as SYM_GLOBAL, somebody will be
|
644
|
+
* definitely interested in it..
|
645
|
+
*/
|
646
|
+
if ((hr->e.flags & SYM_GLOBAL) == 0) {
|
647
|
+
/*
|
648
|
+
* otherwise the symbol is just public. Find it in
|
649
|
+
* the symbol table. If the symbol isn't defined, we
|
650
|
+
* aren't interested, so go on to the next.
|
651
|
+
* If it is defined as anything but -1, we're also not
|
652
|
+
* interested. But if it is defined as -1, insert this
|
653
|
+
* module into the list of modules to use, and go
|
654
|
+
* immediately on to the next module...
|
655
|
+
*/
|
656
|
+
if (!symtab_get(hr->e.label, &segment, &offset)
|
657
|
+
|| segment != -1)
|
658
|
+
continue;
|
659
|
+
}
|
660
|
+
|
661
|
+
doneanything = 1;
|
662
|
+
keepfile = 1;
|
663
|
+
|
664
|
+
/*
|
665
|
+
* as there are undefined symbols, we can assume that
|
666
|
+
* there are modules on the module list by the time
|
667
|
+
* we get here.
|
668
|
+
*/
|
669
|
+
lastmodule->next = nasm_malloc(sizeof(*lastmodule->next));
|
670
|
+
if (!lastmodule->next) {
|
671
|
+
fprintf(stderr, "ldrdf: not enough memory\n");
|
672
|
+
exit(1);
|
673
|
+
}
|
674
|
+
lastmodule = lastmodule->next;
|
675
|
+
memcpy(&lastmodule->f, &f, sizeof(f));
|
676
|
+
lastmodule->name = nasm_strdup(f.name);
|
677
|
+
lastmodule->next = NULL;
|
678
|
+
processmodule(f.name, lastmodule);
|
679
|
+
break;
|
680
|
+
}
|
681
|
+
if (!keepfile) {
|
682
|
+
nasm_free(f.name);
|
683
|
+
f.name = NULL;
|
684
|
+
f.fp = NULL;
|
685
|
+
}
|
686
|
+
}
|
687
|
+
if (rdl_error != 0 && rdl_error != RDL_ENOTFOUND)
|
688
|
+
rdl_perror("ldrdf", cur->name);
|
689
|
+
|
690
|
+
cur = cur->next;
|
691
|
+
if (cur == NULL && pass == 1) {
|
692
|
+
cur = libraries;
|
693
|
+
pass++;
|
694
|
+
}
|
695
|
+
}
|
696
|
+
|
697
|
+
return doneanything;
|
698
|
+
}
|
699
|
+
|
700
|
+
/*
|
701
|
+
* write_output()
|
702
|
+
*
|
703
|
+
* this takes the linked list of modules, and walks through it, merging
|
704
|
+
* all the modules into a single output module, and then writes this to a
|
705
|
+
* file.
|
706
|
+
*/
|
707
|
+
static void write_output(const char *filename)
|
708
|
+
{
|
709
|
+
FILE *f;
|
710
|
+
rdf_headerbuf *rdfheader;
|
711
|
+
struct modulenode *cur;
|
712
|
+
int i, n, availableseg, seg, localseg, isrelative;
|
713
|
+
void *header;
|
714
|
+
rdfheaderrec *hr, newrec;
|
715
|
+
symtabEnt *se;
|
716
|
+
segtab segs;
|
717
|
+
int32_t offset;
|
718
|
+
uint8_t *data;
|
719
|
+
|
720
|
+
if ((f = fopen(filename, "wb")) == NULL) {
|
721
|
+
fprintf(stderr, "ldrdf: couldn't open %s for output\n", filename);
|
722
|
+
exit(1);
|
723
|
+
}
|
724
|
+
if ((rdfheader = rdfnewheader()) == NULL) {
|
725
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
726
|
+
exit(1);
|
727
|
+
}
|
728
|
+
|
729
|
+
/*
|
730
|
+
* If '-g' option was given, first record in output file will be a
|
731
|
+
* `generic' record, filled with a given file content.
|
732
|
+
* This can be useful, for example, when constructing multiboot
|
733
|
+
* compliant kernels.
|
734
|
+
*/
|
735
|
+
if (generic_rec_file) {
|
736
|
+
FILE *ff;
|
737
|
+
|
738
|
+
if (options.verbose)
|
739
|
+
printf("\nadding generic record from binary file %s\n",
|
740
|
+
generic_rec_file);
|
741
|
+
|
742
|
+
hr = (rdfheaderrec *) nasm_malloc(sizeof(struct GenericRec));
|
743
|
+
if ((ff = fopen(generic_rec_file, "r")) == NULL) {
|
744
|
+
fprintf(stderr, "ldrdf: couldn't open %s for input\n",
|
745
|
+
generic_rec_file);
|
746
|
+
exit(1);
|
747
|
+
}
|
748
|
+
n = fread(hr->g.data, 1, sizeof(hr->g.data), ff);
|
749
|
+
fseek(ff, 0, SEEK_END);
|
750
|
+
if (ftell(ff) > (long)sizeof(hr->g.data)) {
|
751
|
+
fprintf(error_file,
|
752
|
+
"warning: maximum generic record size is %u, "
|
753
|
+
"rest of file ignored\n",
|
754
|
+
(unsigned int)sizeof(hr->g.data));
|
755
|
+
}
|
756
|
+
fclose(ff);
|
757
|
+
|
758
|
+
hr->g.type = RDFREC_GENERIC;
|
759
|
+
hr->g.reclen = n;
|
760
|
+
rdfaddheader(rdfheader, hr);
|
761
|
+
nasm_free(hr);
|
762
|
+
}
|
763
|
+
|
764
|
+
/*
|
765
|
+
* Add module name record if `-mn' option was given
|
766
|
+
*/
|
767
|
+
if (modname_specified) {
|
768
|
+
n = strlen(modname_specified);
|
769
|
+
|
770
|
+
if ((n < 1) || (n >= MODLIB_NAME_MAX)) {
|
771
|
+
fprintf(stderr, "ldrdf: invalid length of module name `%s'\n",
|
772
|
+
modname_specified);
|
773
|
+
exit(1);
|
774
|
+
}
|
775
|
+
|
776
|
+
if (options.verbose)
|
777
|
+
printf("\nadding module name record %s\n", modname_specified);
|
778
|
+
|
779
|
+
hr = (rdfheaderrec *) nasm_malloc(sizeof(struct ModRec));
|
780
|
+
hr->m.type = RDFREC_MODNAME;
|
781
|
+
hr->m.reclen = n + 1;
|
782
|
+
strcpy(hr->m.modname, modname_specified);
|
783
|
+
rdfaddheader(rdfheader, hr);
|
784
|
+
nasm_free(hr);
|
785
|
+
}
|
786
|
+
|
787
|
+
|
788
|
+
if (options.verbose)
|
789
|
+
printf("\nbuilding output module (%d segments)\n", nsegs);
|
790
|
+
|
791
|
+
/*
|
792
|
+
* Allocate the memory for the segments. We may be better off
|
793
|
+
* building the output module one segment at a time when running
|
794
|
+
* under 16 bit DOS, but that would be a slower way of doing this.
|
795
|
+
* And you could always use DJGPP...
|
796
|
+
*/
|
797
|
+
for (i = 0; i < nsegs; i++) {
|
798
|
+
outputseg[i].data = NULL;
|
799
|
+
if (!outputseg[i].length)
|
800
|
+
continue;
|
801
|
+
outputseg[i].data = nasm_malloc(outputseg[i].length);
|
802
|
+
if (!outputseg[i].data) {
|
803
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
804
|
+
exit(1);
|
805
|
+
}
|
806
|
+
}
|
807
|
+
|
808
|
+
/*
|
809
|
+
* initialise availableseg, used to allocate segment numbers for
|
810
|
+
* imported and exported labels...
|
811
|
+
*/
|
812
|
+
availableseg = nsegs;
|
813
|
+
|
814
|
+
/*
|
815
|
+
* Step through the modules, performing required actions on each one
|
816
|
+
*/
|
817
|
+
for (cur = modules; cur; cur = cur->next) {
|
818
|
+
/*
|
819
|
+
* Read the actual segment contents into the correct places in
|
820
|
+
* the newly allocated segments
|
821
|
+
*/
|
822
|
+
|
823
|
+
for (i = 0; i < cur->f.nsegs; i++) {
|
824
|
+
int dest = cur->seginfo[i].dest_seg;
|
825
|
+
|
826
|
+
if (dest == -1)
|
827
|
+
continue;
|
828
|
+
if (rdfloadseg(&cur->f, i,
|
829
|
+
outputseg[dest].data + cur->seginfo[i].reloc)) {
|
830
|
+
rdfperror("ldrdf", cur->name);
|
831
|
+
exit(1);
|
832
|
+
}
|
833
|
+
}
|
834
|
+
|
835
|
+
/*
|
836
|
+
* Perform fixups, and add new header records where required
|
837
|
+
*/
|
838
|
+
|
839
|
+
header = nasm_malloc(cur->f.header_len);
|
840
|
+
if (!header) {
|
841
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
842
|
+
exit(1);
|
843
|
+
}
|
844
|
+
|
845
|
+
if (cur->f.header_loc)
|
846
|
+
rdfheaderrewind(&cur->f);
|
847
|
+
else if (rdfloadseg(&cur->f, RDOFF_HEADER, header)) {
|
848
|
+
rdfperror("ldrdf", cur->name);
|
849
|
+
exit(1);
|
850
|
+
}
|
851
|
+
|
852
|
+
/*
|
853
|
+
* we need to create a local segment number -> location
|
854
|
+
* table for the segments in this module.
|
855
|
+
*/
|
856
|
+
init_seglocations(&segs);
|
857
|
+
for (i = 0; i < cur->f.nsegs; i++) {
|
858
|
+
add_seglocation(&segs, cur->f.seg[i].number,
|
859
|
+
cur->seginfo[i].dest_seg,
|
860
|
+
cur->seginfo[i].reloc);
|
861
|
+
}
|
862
|
+
/*
|
863
|
+
* and the BSS segment (doh!)
|
864
|
+
*/
|
865
|
+
add_seglocation(&segs, 2, 2, cur->bss_reloc);
|
866
|
+
|
867
|
+
while ((hr = rdfgetheaderrec(&cur->f))) {
|
868
|
+
switch (hr->type) {
|
869
|
+
case RDFREC_RELOC: /* relocation record - need to do a fixup */
|
870
|
+
/*
|
871
|
+
* First correct the offset stored in the segment from
|
872
|
+
* the start of the segment (which may well have changed).
|
873
|
+
*
|
874
|
+
* To do this we add to the number stored the relocation
|
875
|
+
* factor associated with the segment that contains the
|
876
|
+
* target segment.
|
877
|
+
*
|
878
|
+
* The relocation could be a relative relocation, in which
|
879
|
+
* case we have to first subtract the amount we've relocated
|
880
|
+
* the containing segment by.
|
881
|
+
*/
|
882
|
+
if (!get_seglocation(&segs, hr->r.refseg, &seg, &offset)) {
|
883
|
+
fprintf(stderr,
|
884
|
+
"%s: reloc to undefined segment %04x\n",
|
885
|
+
cur->name, (int)hr->r.refseg);
|
886
|
+
errorcount++;
|
887
|
+
break;
|
888
|
+
}
|
889
|
+
|
890
|
+
isrelative =
|
891
|
+
(hr->r.segment & RDOFF_RELATIVEMASK) ==
|
892
|
+
RDOFF_RELATIVEMASK;
|
893
|
+
hr->r.segment &= (RDOFF_RELATIVEMASK - 1);
|
894
|
+
|
895
|
+
if (hr->r.segment == 2 ||
|
896
|
+
(localseg =
|
897
|
+
rdffindsegment(&cur->f, hr->r.segment)) == -1) {
|
898
|
+
fprintf(stderr, "%s: reloc from %s segment (%d)\n",
|
899
|
+
cur->name,
|
900
|
+
hr->r.segment == 2 ? "BSS" : "unknown",
|
901
|
+
hr->r.segment);
|
902
|
+
errorcount++;
|
903
|
+
break;
|
904
|
+
}
|
905
|
+
|
906
|
+
if (hr->r.length != 1 && hr->r.length != 2 &&
|
907
|
+
hr->r.length != 4) {
|
908
|
+
fprintf(stderr, "%s: nonstandard length reloc "
|
909
|
+
"(%d bytes)\n", cur->name, hr->r.length);
|
910
|
+
errorcount++;
|
911
|
+
break;
|
912
|
+
}
|
913
|
+
|
914
|
+
/*
|
915
|
+
* okay, now the relocation is in the segment pointed to by
|
916
|
+
* cur->seginfo[localseg], and we know everything else is
|
917
|
+
* okay to go ahead and do the relocation
|
918
|
+
*/
|
919
|
+
data = outputseg[cur->seginfo[localseg].dest_seg].data;
|
920
|
+
data += cur->seginfo[localseg].reloc + hr->r.offset;
|
921
|
+
|
922
|
+
/*
|
923
|
+
* data now points to the reference that needs
|
924
|
+
* relocation. Calculate the relocation factor.
|
925
|
+
* Factor is:
|
926
|
+
* offset of referred object in segment [in offset]
|
927
|
+
* (- relocation of localseg, if ref is relative)
|
928
|
+
* For simplicity, the result is stored in 'offset'.
|
929
|
+
* Then add 'offset' onto the value at data.
|
930
|
+
*/
|
931
|
+
|
932
|
+
if (isrelative)
|
933
|
+
offset -= cur->seginfo[localseg].reloc;
|
934
|
+
switch (hr->r.length) {
|
935
|
+
case 1:
|
936
|
+
offset += *data;
|
937
|
+
if (offset < -127 || offset > 128)
|
938
|
+
fprintf(error_file,
|
939
|
+
"warning: relocation out of range "
|
940
|
+
"at %s(%02x:%08"PRIx32")\n", cur->name,
|
941
|
+
(int)hr->r.segment, hr->r.offset);
|
942
|
+
*data = (char)offset;
|
943
|
+
break;
|
944
|
+
case 2:
|
945
|
+
offset += *(int16_t *)data;
|
946
|
+
if (offset < -32767 || offset > 32768)
|
947
|
+
fprintf(error_file,
|
948
|
+
"warning: relocation out of range "
|
949
|
+
"at %s(%02x:%08"PRIx32")\n", cur->name,
|
950
|
+
(int)hr->r.segment, hr->r.offset);
|
951
|
+
*(int16_t *)data = (int16_t)offset;
|
952
|
+
break;
|
953
|
+
case 4:
|
954
|
+
*(int32_t *)data += offset;
|
955
|
+
/* we can't easily detect overflow on this one */
|
956
|
+
break;
|
957
|
+
}
|
958
|
+
|
959
|
+
/*
|
960
|
+
* If the relocation was relative between two symbols in
|
961
|
+
* the same segment, then we're done.
|
962
|
+
*
|
963
|
+
* Otherwise, we need to output a new relocation record
|
964
|
+
* with the references updated segment and offset...
|
965
|
+
*/
|
966
|
+
if (!isrelative || cur->seginfo[localseg].dest_seg != seg) {
|
967
|
+
hr->r.segment = cur->seginfo[localseg].dest_seg;
|
968
|
+
hr->r.offset += cur->seginfo[localseg].reloc;
|
969
|
+
hr->r.refseg = seg;
|
970
|
+
if (isrelative)
|
971
|
+
hr->r.segment += RDOFF_RELATIVEMASK;
|
972
|
+
rdfaddheader(rdfheader, hr);
|
973
|
+
}
|
974
|
+
break;
|
975
|
+
|
976
|
+
case RDFREC_IMPORT: /* import symbol */
|
977
|
+
case RDFREC_FARIMPORT:
|
978
|
+
/*
|
979
|
+
* scan the global symbol table for the symbol
|
980
|
+
* and associate its location with the segment number
|
981
|
+
* for this module
|
982
|
+
*/
|
983
|
+
se = symtabFind(symtab, hr->i.label);
|
984
|
+
if (!se || se->segment == -1) {
|
985
|
+
if (!options.dynalink && !(hr->i.flags & SYM_IMPORT)) {
|
986
|
+
fprintf(error_file,
|
987
|
+
"error: unresolved reference to `%s'"
|
988
|
+
" in module `%s'\n", hr->i.label,
|
989
|
+
cur->name);
|
990
|
+
errorcount++;
|
991
|
+
}
|
992
|
+
/*
|
993
|
+
* we need to allocate a segment number for this
|
994
|
+
* symbol, and store it in the symbol table for
|
995
|
+
* future reference
|
996
|
+
*/
|
997
|
+
if (!se) {
|
998
|
+
se = nasm_malloc(sizeof(*se));
|
999
|
+
if (!se) {
|
1000
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
1001
|
+
exit(1);
|
1002
|
+
}
|
1003
|
+
se->name = nasm_strdup(hr->i.label);
|
1004
|
+
se->flags = 0;
|
1005
|
+
se->segment = availableseg++;
|
1006
|
+
se->offset = 0;
|
1007
|
+
symtabInsert(symtab, se);
|
1008
|
+
} else {
|
1009
|
+
se->segment = availableseg++;
|
1010
|
+
se->offset = 0;
|
1011
|
+
}
|
1012
|
+
/*
|
1013
|
+
* output a header record that imports it to the
|
1014
|
+
* recently allocated segment number...
|
1015
|
+
*/
|
1016
|
+
newrec = *hr;
|
1017
|
+
newrec.i.segment = se->segment;
|
1018
|
+
rdfaddheader(rdfheader, &newrec);
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
add_seglocation(&segs, hr->i.segment, se->segment,
|
1022
|
+
se->offset);
|
1023
|
+
break;
|
1024
|
+
|
1025
|
+
case RDFREC_GLOBAL: /* export symbol */
|
1026
|
+
/*
|
1027
|
+
* need to insert an export for this symbol into the new
|
1028
|
+
* header, unless we're stripping symbols. Even if we're
|
1029
|
+
* stripping, put the symbol if it's marked as SYM_GLOBAL.
|
1030
|
+
*/
|
1031
|
+
if (options.strip && !(hr->e.flags & SYM_GLOBAL))
|
1032
|
+
break;
|
1033
|
+
|
1034
|
+
if (hr->e.segment == 2) {
|
1035
|
+
seg = 2;
|
1036
|
+
offset = cur->bss_reloc;
|
1037
|
+
} else {
|
1038
|
+
localseg = rdffindsegment(&cur->f, hr->e.segment);
|
1039
|
+
if (localseg == -1) {
|
1040
|
+
fprintf(stderr, "%s: exported symbol `%s' from "
|
1041
|
+
"unrecognised segment\n", cur->name,
|
1042
|
+
hr->e.label);
|
1043
|
+
errorcount++;
|
1044
|
+
break;
|
1045
|
+
}
|
1046
|
+
offset = cur->seginfo[localseg].reloc;
|
1047
|
+
seg = cur->seginfo[localseg].dest_seg;
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
hr->e.segment = seg;
|
1051
|
+
hr->e.offset += offset;
|
1052
|
+
rdfaddheader(rdfheader, hr);
|
1053
|
+
break;
|
1054
|
+
|
1055
|
+
case RDFREC_MODNAME: /* module name */
|
1056
|
+
/*
|
1057
|
+
* Insert module name record if export symbols
|
1058
|
+
* are not stripped.
|
1059
|
+
* If module name begins with '$' - insert it anyway.
|
1060
|
+
*/
|
1061
|
+
if (options.strip && hr->m.modname[0] != '$')
|
1062
|
+
break;
|
1063
|
+
rdfaddheader(rdfheader, hr);
|
1064
|
+
break;
|
1065
|
+
|
1066
|
+
case RDFREC_DLL: /* DLL name */
|
1067
|
+
/*
|
1068
|
+
* Insert DLL name if it begins with '$'
|
1069
|
+
*/
|
1070
|
+
if (hr->d.libname[0] != '$')
|
1071
|
+
break;
|
1072
|
+
rdfaddheader(rdfheader, hr);
|
1073
|
+
break;
|
1074
|
+
|
1075
|
+
case RDFREC_SEGRELOC: /* segment fixup */
|
1076
|
+
/*
|
1077
|
+
* modify the segment numbers if necessary, and
|
1078
|
+
* pass straight through to the output module header
|
1079
|
+
*
|
1080
|
+
* *** FIXME ***
|
1081
|
+
*/
|
1082
|
+
if (hr->r.segment == 2) {
|
1083
|
+
fprintf(stderr, "%s: segment fixup in BSS section\n",
|
1084
|
+
cur->name);
|
1085
|
+
errorcount++;
|
1086
|
+
break;
|
1087
|
+
}
|
1088
|
+
localseg = rdffindsegment(&cur->f, hr->r.segment);
|
1089
|
+
if (localseg == -1) {
|
1090
|
+
fprintf(stderr, "%s: segment fixup in unrecognised"
|
1091
|
+
" segment (%d)\n", cur->name, hr->r.segment);
|
1092
|
+
errorcount++;
|
1093
|
+
break;
|
1094
|
+
}
|
1095
|
+
hr->r.segment = cur->seginfo[localseg].dest_seg;
|
1096
|
+
hr->r.offset += cur->seginfo[localseg].reloc;
|
1097
|
+
|
1098
|
+
if (!get_seglocation(&segs, hr->r.refseg, &seg, &offset)) {
|
1099
|
+
fprintf(stderr, "%s: segment fixup to undefined "
|
1100
|
+
"segment %04x\n", cur->name,
|
1101
|
+
(int)hr->r.refseg);
|
1102
|
+
errorcount++;
|
1103
|
+
break;
|
1104
|
+
}
|
1105
|
+
hr->r.refseg = seg;
|
1106
|
+
rdfaddheader(rdfheader, hr);
|
1107
|
+
break;
|
1108
|
+
|
1109
|
+
case RDFREC_COMMON: /* Common variable */
|
1110
|
+
/* Is this symbol already in the table? */
|
1111
|
+
se = symtabFind(symtab, hr->c.label);
|
1112
|
+
if (!se) {
|
1113
|
+
printf("%s is not in symtab yet\n", hr->c.label);
|
1114
|
+
break;
|
1115
|
+
}
|
1116
|
+
/* Add segment location */
|
1117
|
+
add_seglocation(&segs, hr->c.segment, se->segment,
|
1118
|
+
se->offset);
|
1119
|
+
break;
|
1120
|
+
}
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
nasm_free(header);
|
1124
|
+
done_seglocations(&segs);
|
1125
|
+
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
/*
|
1129
|
+
* combined BSS reservation for the entire results
|
1130
|
+
*/
|
1131
|
+
newrec.type = RDFREC_BSS;
|
1132
|
+
newrec.b.reclen = 4;
|
1133
|
+
newrec.b.amount = bss_length;
|
1134
|
+
rdfaddheader(rdfheader, &newrec);
|
1135
|
+
|
1136
|
+
/*
|
1137
|
+
* Write the header
|
1138
|
+
*/
|
1139
|
+
for (i = 0; i < nsegs; i++) {
|
1140
|
+
if (i == 2)
|
1141
|
+
continue;
|
1142
|
+
rdfaddsegment(rdfheader, outputseg[i].length);
|
1143
|
+
}
|
1144
|
+
|
1145
|
+
rdfwriteheader(f, rdfheader);
|
1146
|
+
rdfdoneheader(rdfheader);
|
1147
|
+
|
1148
|
+
/*
|
1149
|
+
* Step through the segments, one at a time, writing out into
|
1150
|
+
* the output file
|
1151
|
+
*/
|
1152
|
+
for (i = 0; i < nsegs; i++) {
|
1153
|
+
if (i == 2)
|
1154
|
+
continue;
|
1155
|
+
|
1156
|
+
fwriteint16_t(outputseg[i].type, f);
|
1157
|
+
fwriteint16_t(outputseg[i].number, f);
|
1158
|
+
fwriteint16_t(outputseg[i].reserved, f);
|
1159
|
+
fwriteint32_t(outputseg[i].length, f);
|
1160
|
+
nasm_write(outputseg[i].data, outputseg[i].length, f);
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
fwritezero(10, f);
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
/* =========================================================================
|
1167
|
+
* Main program
|
1168
|
+
*/
|
1169
|
+
|
1170
|
+
static void usage(void)
|
1171
|
+
{
|
1172
|
+
printf("usage:\n"
|
1173
|
+
" ldrdf [options] object modules ... [-llibrary ...]\n"
|
1174
|
+
" ldrdf -r\n"
|
1175
|
+
"options:\n"
|
1176
|
+
" -v[=n] increase verbosity by 1, or set it to n\n"
|
1177
|
+
" -a nn set segment alignment value (default 16)\n"
|
1178
|
+
" -s strip public symbols\n"
|
1179
|
+
" -dy Unix-style dynamic linking\n"
|
1180
|
+
" -o name write output in file 'name'\n"
|
1181
|
+
" -j path specify objects search path\n"
|
1182
|
+
" -L path specify libraries search path\n"
|
1183
|
+
" -g file embed 'file' as a first header record with type 'generic'\n"
|
1184
|
+
" -mn name add module name record at the beginning of output file\n");
|
1185
|
+
exit(0);
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
int main(int argc, char **argv)
|
1189
|
+
{
|
1190
|
+
char *outname = "aout.rdf";
|
1191
|
+
int moduleloaded = 0;
|
1192
|
+
char *respstrings[128] = { 0, };
|
1193
|
+
|
1194
|
+
rdoff_init();
|
1195
|
+
|
1196
|
+
options.verbose = 0;
|
1197
|
+
options.align = 16;
|
1198
|
+
options.dynalink = 0;
|
1199
|
+
options.strip = 0;
|
1200
|
+
|
1201
|
+
error_file = stderr;
|
1202
|
+
|
1203
|
+
argc--, argv++;
|
1204
|
+
if (argc == 0)
|
1205
|
+
usage();
|
1206
|
+
while (argc && *argv && **argv == '-' && argv[0][1] != 'l') {
|
1207
|
+
switch (argv[0][1]) {
|
1208
|
+
case 'r':
|
1209
|
+
printf("ldrdf (linker for RDF files) version " LDRDF_VERSION
|
1210
|
+
"\n");
|
1211
|
+
printf("RDOFF2 revision %s\n", RDOFF2_REVISION);
|
1212
|
+
exit(0);
|
1213
|
+
case 'v':
|
1214
|
+
if (argv[0][2] == '=') {
|
1215
|
+
options.verbose = argv[0][3] - '0';
|
1216
|
+
if (options.verbose < 0 || options.verbose > 9) {
|
1217
|
+
fprintf(stderr,
|
1218
|
+
"ldrdf: verbosity level must be a number"
|
1219
|
+
" between 0 and 9\n");
|
1220
|
+
exit(1);
|
1221
|
+
}
|
1222
|
+
} else
|
1223
|
+
options.verbose++;
|
1224
|
+
break;
|
1225
|
+
case 'a':
|
1226
|
+
options.align = atoi(argv[1]);
|
1227
|
+
if (options.align <= 0) {
|
1228
|
+
fprintf(stderr,
|
1229
|
+
"ldrdf: -a expects a positive number argument\n");
|
1230
|
+
exit(1);
|
1231
|
+
}
|
1232
|
+
argv++, argc--;
|
1233
|
+
break;
|
1234
|
+
case 's':
|
1235
|
+
options.strip = 1;
|
1236
|
+
break;
|
1237
|
+
case 'd':
|
1238
|
+
if (argv[0][2] == 'y')
|
1239
|
+
options.dynalink = 1;
|
1240
|
+
break;
|
1241
|
+
case 'm':
|
1242
|
+
if (argv[0][2] == 'n') {
|
1243
|
+
modname_specified = argv[1];
|
1244
|
+
argv++, argc--;
|
1245
|
+
if (!argc) {
|
1246
|
+
fprintf(stderr, "ldrdf: -mn expects a module name\n");
|
1247
|
+
exit(1);
|
1248
|
+
}
|
1249
|
+
}
|
1250
|
+
break;
|
1251
|
+
case 'o':
|
1252
|
+
outname = argv[1];
|
1253
|
+
argv++, argc--;
|
1254
|
+
break;
|
1255
|
+
case 'j':
|
1256
|
+
if (!objpath) {
|
1257
|
+
options.objpath = 1;
|
1258
|
+
objpath = argv[1];
|
1259
|
+
argv++, argc--;
|
1260
|
+
break;
|
1261
|
+
} else {
|
1262
|
+
fprintf(stderr,
|
1263
|
+
"ldrdf: more than one objects search path specified\n");
|
1264
|
+
exit(1);
|
1265
|
+
}
|
1266
|
+
case 'L':
|
1267
|
+
if (!libpath) {
|
1268
|
+
options.libpath = 1;
|
1269
|
+
libpath = argv[1];
|
1270
|
+
argv++, argc--;
|
1271
|
+
break;
|
1272
|
+
} else {
|
1273
|
+
fprintf(stderr,
|
1274
|
+
"ldrdf: more than one libraries search path specified\n");
|
1275
|
+
exit(1);
|
1276
|
+
}
|
1277
|
+
case '@':{
|
1278
|
+
int i = 0;
|
1279
|
+
char buf[256];
|
1280
|
+
FILE *f;
|
1281
|
+
|
1282
|
+
options.respfile = 1;
|
1283
|
+
if (argv[1] != NULL)
|
1284
|
+
f = fopen(argv[1], "r");
|
1285
|
+
else {
|
1286
|
+
fprintf(stderr,
|
1287
|
+
"ldrdf: no response file name specified\n");
|
1288
|
+
exit(1);
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
if (f == NULL) {
|
1292
|
+
fprintf(stderr,
|
1293
|
+
"ldrdf: unable to open response file\n");
|
1294
|
+
exit(1);
|
1295
|
+
}
|
1296
|
+
|
1297
|
+
argv++, argc--;
|
1298
|
+
while (fgets(buf, sizeof(buf), f) != NULL) {
|
1299
|
+
char *p;
|
1300
|
+
if (buf[0] == '\n')
|
1301
|
+
continue;
|
1302
|
+
if ((p = strchr(buf, '\n')) != NULL)
|
1303
|
+
*p = '\0';
|
1304
|
+
if (i >= 128) {
|
1305
|
+
fclose(f);
|
1306
|
+
fprintf(stderr, "ldrdf: too many input files\n");
|
1307
|
+
exit(1);
|
1308
|
+
}
|
1309
|
+
*(respstrings + i) = nasm_strdup(buf);
|
1310
|
+
argc++, i++;
|
1311
|
+
}
|
1312
|
+
fclose(f);
|
1313
|
+
break;
|
1314
|
+
}
|
1315
|
+
case '2':
|
1316
|
+
options.stderr_redir = 1;
|
1317
|
+
error_file = stdout;
|
1318
|
+
break;
|
1319
|
+
case 'g':
|
1320
|
+
generic_rec_file = argv[1];
|
1321
|
+
argv++, argc--;
|
1322
|
+
if (!argc) {
|
1323
|
+
fprintf(stderr, "ldrdf: -g expects a file name\n");
|
1324
|
+
exit(1);
|
1325
|
+
}
|
1326
|
+
break;
|
1327
|
+
default:
|
1328
|
+
usage();
|
1329
|
+
}
|
1330
|
+
argv++, argc--;
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
if (options.verbose > 4) {
|
1334
|
+
printf("ldrdf invoked with options:\n");
|
1335
|
+
printf(" section alignment: %d bytes\n", options.align);
|
1336
|
+
printf(" output name: `%s'\n", outname);
|
1337
|
+
if (options.strip)
|
1338
|
+
printf(" strip symbols\n");
|
1339
|
+
if (options.dynalink)
|
1340
|
+
printf(" Unix-style dynamic linking\n");
|
1341
|
+
if (options.objpath)
|
1342
|
+
printf(" objects search path: %s\n", objpath);
|
1343
|
+
if (options.libpath)
|
1344
|
+
printf(" libraries search path: %s\n", libpath);
|
1345
|
+
printf("\n");
|
1346
|
+
}
|
1347
|
+
|
1348
|
+
symtab = symtabNew();
|
1349
|
+
initsegments();
|
1350
|
+
|
1351
|
+
if (!symtab) {
|
1352
|
+
fprintf(stderr, "ldrdf: out of memory\n");
|
1353
|
+
exit(1);
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
while (argc) {
|
1357
|
+
if (!*argv)
|
1358
|
+
argv = respstrings;
|
1359
|
+
if (!*argv)
|
1360
|
+
break;
|
1361
|
+
if (!strncmp(*argv, "-l", 2)) {
|
1362
|
+
if (libpath && (argv[0][2] != '/'))
|
1363
|
+
add_library(nasm_strcat(libpath, *argv + 2));
|
1364
|
+
else
|
1365
|
+
add_library(*argv + 2);
|
1366
|
+
} else {
|
1367
|
+
if (objpath && (argv[0][0] != '/'))
|
1368
|
+
loadmodule(nasm_strcat(objpath, *argv));
|
1369
|
+
else
|
1370
|
+
loadmodule(*argv);
|
1371
|
+
moduleloaded = 1;
|
1372
|
+
}
|
1373
|
+
argv++, argc--;
|
1374
|
+
}
|
1375
|
+
|
1376
|
+
if (!moduleloaded) {
|
1377
|
+
printf("ldrdf: nothing to do. ldrdf -h for usage\n");
|
1378
|
+
return 0;
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
search_libraries();
|
1382
|
+
|
1383
|
+
if (options.verbose > 2) {
|
1384
|
+
printf("symbol table:\n");
|
1385
|
+
symtabDump(symtab, stdout);
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
write_output(outname);
|
1389
|
+
|
1390
|
+
if (errorcount > 0) {
|
1391
|
+
remove(outname);
|
1392
|
+
exit(1);
|
1393
|
+
}
|
1394
|
+
return 0;
|
1395
|
+
}
|