/config.log
/config.status
/configure
+/directives.c
+/directives.h
/doc/*.dip
/doc/*.hpj
/doc/*.pdf
/tokhash.c
/version.h
/version.mac
+/version.mak
+/version.nsh
/version.sed
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
raa.$(O) saa.$(O) rbtree.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
+ directives.$(O) \
assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \
+ output/nullout.$(O) \
output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \
output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
pptok.ph: pptok.dat pptok.pl perllib/phash.ph
$(PERL) $(srcdir)/pptok.pl ph $(srcdir)/pptok.dat pptok.ph
+# Directives hash
+directives.h: directives.dat directives.pl perllib/phash.ph
+ $(PERL) $(srcdir)/directives.pl h $(srcdir)/directives.dat directives.h
+directives.c: directives.dat directives.pl perllib/phash.ph
+ $(PERL) $(srcdir)/directives.pl c $(srcdir)/directives.dat directives.c
+
# This target generates all files that require perl.
# This allows easier generation of distribution (see dist target).
PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
regs.c regs.h regflags.c regdis.c regdis.h regvals.c \
tokhash.c tokens.h pptok.h pptok.c pptok.ph \
+ directives.c directives.h \
version.h version.mac version.mak version.nsh
perlreq: $(PERLREQ)
# @object-ending: ".$(O)"
# @path-separator: "/"
#-- Everything below is generated by mkdep.pl - do not edit --#
-assemble.$(O): assemble.c assemble.h compiler.h config.h insns.h insnsi.h \
- nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
+assemble.$(O): assemble.c assemble.h compiler.h config.h directives.h \
+ insns.h insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h \
+ tokens.h
crc64.$(O): crc64.c compiler.h config.h nasmlib.h
-disasm.$(O): disasm.c compiler.h config.h disasm.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
-eval.$(O): eval.c compiler.h config.h eval.h float.h insnsi.h labels.h \
- nasm.h nasmlib.h pptok.h preproc.h regs.h
-exprlib.$(O): exprlib.c compiler.h config.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-float.$(O): float.c compiler.h config.h float.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-hashtbl.$(O): hashtbl.c compiler.h config.h hashtbl.h insnsi.h nasm.h \
+directives.$(O): directives.c compiler.h config.h directives.h hashtbl.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h
+disasm.$(O): disasm.c compiler.h config.h directives.h disasm.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regdis.h regs.h sync.h tables.h \
+ tokens.h
+eval.$(O): eval.c compiler.h config.h directives.h eval.h float.h insnsi.h \
+ labels.h nasm.h nasmlib.h pptok.h preproc.h regs.h
+exprlib.$(O): exprlib.c compiler.h config.h directives.h insnsi.h nasm.h \
nasmlib.h pptok.h preproc.h regs.h
-insnsa.$(O): insnsa.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h tokens.h
-insnsb.$(O): insnsb.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h tokens.h
-insnsd.$(O): insnsd.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h tokens.h
-insnsn.$(O): insnsn.c compiler.h config.h insnsi.h tables.h
-labels.$(O): labels.c compiler.h config.h hashtbl.h insnsi.h nasm.h \
+float.$(O): float.c compiler.h config.h directives.h float.h insnsi.h nasm.h \
nasmlib.h pptok.h preproc.h regs.h
+hashtbl.$(O): hashtbl.c compiler.h config.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+insnsa.$(O): insnsa.c compiler.h config.h directives.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsb.$(O): insnsb.c compiler.h config.h directives.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsd.$(O): insnsd.c compiler.h config.h directives.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsn.$(O): insnsn.c compiler.h config.h insnsi.h tables.h
+labels.$(O): labels.c compiler.h config.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
lib/snprintf.$(O): lib/snprintf.c compiler.h config.h nasmlib.h
lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h config.h nasmlib.h
-listing.$(O): listing.c compiler.h config.h insnsi.h listing.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h
-macros.$(O): macros.c compiler.h config.h hashtbl.h insnsi.h nasm.h \
- nasmlib.h output/outform.h pptok.h preproc.h regs.h tables.h
-nasm.$(O): nasm.c assemble.h compiler.h config.h eval.h float.h insns.h \
- insnsi.h labels.h listing.h nasm.h nasmlib.h output/outform.h parser.h \
- pptok.h preproc.h raa.h regs.h saa.h stdscan.h tokens.h
-nasmlib.$(O): nasmlib.c compiler.h config.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h tokens.h
-ndisasm.$(O): ndisasm.c compiler.h config.h disasm.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
-output/nulldbg.$(O): output/nulldbg.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h
-output/outaout.$(O): output/outaout.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h \
- saa.h stdscan.h
-output/outas86.$(O): output/outas86.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h \
- saa.h
-output/outbin.$(O): output/outbin.c compiler.h config.h eval.h insnsi.h \
- labels.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+listing.$(O): listing.c compiler.h config.h directives.h insnsi.h listing.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+macros.$(O): macros.c compiler.h config.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h pptok.h preproc.h regs.h tables.h
+nasm.$(O): nasm.c assemble.h compiler.h config.h directives.h eval.h float.h \
+ insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h output/outform.h \
+ parser.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h tokens.h
+nasmlib.$(O): nasmlib.c compiler.h config.h directives.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+ndisasm.$(O): ndisasm.c compiler.h config.h directives.h disasm.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
+output/nulldbg.$(O): output/nulldbg.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h
+output/nullout.$(O): output/nullout.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outlib.h pptok.h preproc.h regs.h
+output/outaout.$(O): output/outaout.c compiler.h config.h directives.h \
+ eval.h insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h stdscan.h
+output/outas86.$(O): output/outas86.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h
+output/outbin.$(O): output/outbin.c compiler.h config.h directives.h eval.h \
+ insnsi.h labels.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
preproc.h regs.h saa.h stdscan.h
-output/outcoff.$(O): output/outcoff.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h \
- saa.h
-output/outdbg.$(O): output/outdbg.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h pptok.h preproc.h regs.h
-output/outelf.$(O): output/outelf.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/dwarf.h output/elfcommon.h output/outelf.h \
+output/outcoff.$(O): output/outcoff.c compiler.h config.h directives.h \
+ eval.h insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h
+output/outdbg.$(O): output/outdbg.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outelf.$(O): output/outelf.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/dwarf.h output/elfcommon.h output/outelf.h \
output/outform.h pptok.h preproc.h regs.h
-output/outelf32.$(O): output/outelf32.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/dwarf.h output/elf32.h output/elfcommon.h output/outelf.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h rbtree.h regs.h \
- saa.h stdscan.h
-output/outelf64.$(O): output/outelf64.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/dwarf.h output/elf64.h output/elfcommon.h output/outelf.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h rbtree.h regs.h \
- saa.h stdscan.h
-output/outform.$(O): output/outform.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h pptok.h preproc.h regs.h
-output/outieee.$(O): output/outieee.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h
-output/outlib.$(O): output/outlib.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outlib.h pptok.h preproc.h regs.h
-output/outmacho32.$(O): output/outmacho32.c compiler.h config.h insnsi.h \
- nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
- regs.h saa.h
-output/outmacho64.$(O): output/outmacho64.c compiler.h config.h insnsi.h \
- nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
- regs.h saa.h
-output/outobj.$(O): output/outobj.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h \
- stdscan.h
-output/outrdf.$(O): output/outrdf.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h pptok.h preproc.h regs.h
-output/outrdf2.$(O): output/outrdf2.c compiler.h config.h insnsi.h nasm.h \
- nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h rdoff/rdoff.h \
- regs.h saa.h
-owtest.$(O): owtest.c
-parser.$(O): parser.c compiler.h config.h float.h insns.h insnsi.h nasm.h \
- nasmlib.h parser.h pptok.h preproc.h regs.h stdscan.h tables.h tokens.h
+output/outelf32.$(O): output/outelf32.c compiler.h config.h directives.h \
+ eval.h insnsi.h nasm.h nasmlib.h output/dwarf.h output/elf32.h \
+ output/elfcommon.h output/outelf.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
+output/outelf64.$(O): output/outelf64.c compiler.h config.h directives.h \
+ eval.h insnsi.h nasm.h nasmlib.h output/dwarf.h output/elf64.h \
+ output/elfcommon.h output/outelf.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
+output/outexe.$(O): output/outexe.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outform.$(O): output/outform.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outieee.$(O): output/outieee.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h regs.h
+output/outlib.$(O): output/outlib.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outlib.h pptok.h preproc.h regs.h
+output/outmacho32.$(O): output/outmacho32.c compiler.h config.h directives.h \
+ eval.h insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h
+output/outmacho64.$(O): output/outmacho64.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h
+output/outobj.$(O): output/outobj.c compiler.h config.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h regs.h stdscan.h
+output/outrdf.$(O): output/outrdf.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outrdf2.$(O): output/outrdf2.c compiler.h config.h directives.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h rdoff/rdoff.h regs.h saa.h
+parser.$(O): parser.c compiler.h config.h directives.h float.h insns.h \
+ insnsi.h nasm.h nasmlib.h parser.h pptok.h preproc.h regs.h stdscan.h \
+ tables.h tokens.h
pptok.$(O): pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h \
preproc.h
-preproc.$(O): preproc.c compiler.h config.h hashtbl.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
+preproc.$(O): preproc.c compiler.h config.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tables.h \
+ tokens.h
quote.$(O): quote.c compiler.h config.h nasmlib.h quote.h
raa.$(O): raa.c compiler.h config.h nasmlib.h raa.h
rbtree.$(O): rbtree.c compiler.h config.h rbtree.h
regdis.$(O): regdis.c regdis.h regs.h
-regflags.$(O): regflags.c compiler.h config.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h tables.h
+regflags.$(O): regflags.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tables.h
regs.$(O): regs.c compiler.h config.h insnsi.h tables.h
regvals.$(O): regvals.c compiler.h config.h insnsi.h tables.h
saa.$(O): saa.c compiler.h config.h nasmlib.h saa.h
-stdscan.$(O): stdscan.c compiler.h config.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tokens.h
-strfunc.$(O): strfunc.c compiler.h config.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
+stdscan.$(O): stdscan.c compiler.h config.h directives.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tokens.h
+strfunc.$(O): strfunc.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
sync.$(O): sync.c compiler.h config.h nasmlib.h sync.h
-tokhash.$(O): tokhash.c compiler.h config.h hashtbl.h insns.h insnsi.h \
- nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
-ver.$(O): ver.c compiler.h config.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h version.h
+tokhash.$(O): tokhash.c compiler.h config.h directives.h hashtbl.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+ver.$(O): ver.c compiler.h config.h directives.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h version.h
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
raa.$(O) saa.$(O) rbtree.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
+ directives.$(O) \
assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \
+ output/nullout.$(O) \
output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \
output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
- output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
- preproc.$(O) quote.$(O) pptok.$(O) macros.$(O) \
- listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) strfunc.$(O) \
- tokhash.$(O) regvals.$(O) regflags.$(O)
+ output/outdbg.$(O) output/outieee.$(O) output/outmacho32.$(O) \
+ output/outmacho64.$(O) preproc.$(O) quote.$(O) pptok.$(O) \
+ macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) \
+ strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
# @path-separator: "/"
# @exclude: "config.h"
#-- Everything below is generated by mkdep.pl - do not edit --#
-assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
+assemble.$(O): assemble.c assemble.h compiler.h directives.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
crc64.$(O): crc64.c compiler.h nasmlib.h
-disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
-eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h
-exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
-float.$(O): float.c compiler.h float.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
-hashtbl.$(O): hashtbl.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
+directives.$(O): directives.c compiler.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+disasm.$(O): disasm.c compiler.h directives.h disasm.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
+eval.$(O): eval.c compiler.h directives.h eval.h float.h insnsi.h labels.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+exprlib.$(O): exprlib.c compiler.h directives.h insnsi.h nasm.h nasmlib.h \
pptok.h preproc.h regs.h
-insnsa.$(O): insnsa.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tokens.h
-insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tokens.h
-insnsd.$(O): insnsd.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tokens.h
+float.$(O): float.c compiler.h directives.h float.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
+hashtbl.$(O): hashtbl.c compiler.h directives.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
+insnsa.$(O): insnsa.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsb.$(O): insnsb.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsd.$(O): insnsd.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
-labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
+labels.$(O): labels.c compiler.h directives.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
-listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-macros.$(O): macros.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
- output/outform.h pptok.h preproc.h regs.h tables.h
-nasm.$(O): nasm.c assemble.h compiler.h eval.h float.h insns.h insnsi.h \
- labels.h listing.h nasm.h nasmlib.h output/outform.h parser.h pptok.h \
- preproc.h raa.h regs.h saa.h stdscan.h tokens.h
-nasmlib.$(O): nasmlib.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tokens.h
-ndisasm.$(O): ndisasm.c compiler.h disasm.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
-output/nulldbg.$(O): output/nulldbg.c compiler.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-output/outaout.$(O): output/outaout.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h \
- stdscan.h
-output/outas86.$(O): output/outas86.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output/outbin.$(O): output/outbin.c compiler.h eval.h insnsi.h labels.h \
- nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h \
- saa.h stdscan.h
-output/outcoff.$(O): output/outcoff.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output/outdbg.$(O): output/outdbg.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h pptok.h preproc.h regs.h
-output/outelf.$(O): output/outelf.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/dwarf.h output/elfcommon.h output/outelf.h output/outform.h pptok.h \
- preproc.h regs.h
-output/outelf32.$(O): output/outelf32.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/dwarf.h output/elf32.h output/elfcommon.h output/outelf.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h rbtree.h regs.h \
- saa.h stdscan.h
-output/outelf64.$(O): output/outelf64.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/dwarf.h output/elf64.h output/elfcommon.h output/outelf.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h rbtree.h regs.h \
- saa.h stdscan.h
-output/outform.$(O): output/outform.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h pptok.h preproc.h regs.h
-output/outieee.$(O): output/outieee.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h regs.h
-output/outlib.$(O): output/outlib.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outlib.h pptok.h preproc.h regs.h
-output/outmacho.$(O): output/outmacho.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output/outobj.$(O): output/outobj.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h regs.h stdscan.h
-output/outrdf.$(O): output/outrdf.c compiler.h insnsi.h nasm.h nasmlib.h \
+listing.$(O): listing.c compiler.h directives.h insnsi.h listing.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
+macros.$(O): macros.c compiler.h directives.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h output/outform.h pptok.h preproc.h regs.h tables.h
+nasm.$(O): nasm.c assemble.h compiler.h directives.h eval.h float.h insns.h \
+ insnsi.h labels.h listing.h nasm.h nasmlib.h output/outform.h parser.h \
+ pptok.h preproc.h raa.h regs.h saa.h stdscan.h tokens.h
+nasmlib.$(O): nasmlib.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+ndisasm.$(O): ndisasm.c compiler.h directives.h disasm.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
+output/nulldbg.$(O): output/nulldbg.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+output/nullout.$(O): output/nullout.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outlib.h pptok.h preproc.h regs.h
+output/outaout.$(O): output/outaout.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h stdscan.h
+output/outas86.$(O): output/outas86.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
+ regs.h saa.h
+output/outbin.$(O): output/outbin.c compiler.h directives.h eval.h insnsi.h \
+ labels.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h regs.h saa.h stdscan.h
+output/outcoff.$(O): output/outcoff.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h
+output/outdbg.$(O): output/outdbg.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outelf.$(O): output/outelf.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/dwarf.h output/elfcommon.h output/outelf.h \
output/outform.h pptok.h preproc.h regs.h
-output/outrdf2.$(O): output/outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h rdoff/rdoff.h regs.h \
- saa.h
-owtest.$(O): owtest.c
-parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h \
- parser.h pptok.h preproc.h regs.h stdscan.h tables.h tokens.h
+output/outelf32.$(O): output/outelf32.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/dwarf.h output/elf32.h output/elfcommon.h \
+ output/outelf.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
+ rbtree.h regs.h saa.h stdscan.h
+output/outelf64.$(O): output/outelf64.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/dwarf.h output/elf64.h output/elfcommon.h \
+ output/outelf.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
+ rbtree.h regs.h saa.h stdscan.h
+output/outexe.$(O): output/outexe.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outform.$(O): output/outform.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outieee.$(O): output/outieee.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h
+output/outlib.$(O): output/outlib.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/outlib.h pptok.h preproc.h regs.h
+output/outmacho32.$(O): output/outmacho32.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h
+output/outmacho64.$(O): output/outmacho64.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
+ regs.h saa.h
+output/outobj.$(O): output/outobj.c compiler.h directives.h eval.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h \
+ stdscan.h
+output/outrdf.$(O): output/outrdf.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outrdf2.$(O): output/outrdf2.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h \
+ rdoff/rdoff.h regs.h saa.h
+parser.$(O): parser.c compiler.h directives.h float.h insns.h insnsi.h \
+ nasm.h nasmlib.h parser.h pptok.h preproc.h regs.h stdscan.h tables.h \
+ tokens.h
pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
-preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
+preproc.$(O): preproc.c compiler.h directives.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
quote.$(O): quote.c compiler.h nasmlib.h quote.h
raa.$(O): raa.c compiler.h nasmlib.h raa.h
rbtree.$(O): rbtree.c compiler.h rbtree.h
regdis.$(O): regdis.c regdis.h regs.h
-regflags.$(O): regflags.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tables.h
+regflags.$(O): regflags.c compiler.h directives.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h tables.h
regs.$(O): regs.c compiler.h insnsi.h tables.h
regvals.$(O): regvals.c compiler.h insnsi.h tables.h
saa.$(O): saa.c compiler.h nasmlib.h saa.h
-stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h quote.h regs.h stdscan.h tokens.h
-strfunc.$(O): strfunc.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
+stdscan.$(O): stdscan.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tokens.h
+strfunc.$(O): strfunc.c compiler.h directives.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h
sync.$(O): sync.c compiler.h nasmlib.h sync.h
-tokhash.$(O): tokhash.c compiler.h hashtbl.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h tokens.h
-ver.$(O): ver.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h preproc.h \
- regs.h version.h
+tokhash.$(O): tokhash.c compiler.h directives.h hashtbl.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+ver.$(O): ver.c compiler.h directives.h insnsi.h nasm.h nasmlib.h pptok.h \
+ preproc.h regs.h version.h
NASM = nasm.o nasmlib.o ver.o \
raa.o saa.o rbtree.o \
float.o insnsa.o insnsb.o \
+ directives.o \
assemble.o labels.o hashtbl.o crc64.o parser.o \
outform.o outlib.o nulldbg.o \
+ nullout.o \
outbin.o outaout.o outcoff.o \
outelf.o outelf32.o outelf64.o \
outobj.o outas86.o outrdf2.o \
- outdbg.o outieee.o outmacho.o \
- preproc.o quote.o pptok.o macros.o \
- listing.o eval.o exprlib.o stdscan.o strfunc.o \
- tokhash.o regvals.o regflags.o
+ outdbg.o outieee.o outmacho32.o \
+ outmacho64.o preproc.o quote.o pptok.o \
+ macros.o listing.o eval.o exprlib.o stdscan.o \
+ strfunc.o tokhash.o regvals.o regflags.o
NDISASM = ndisasm.o disasm.o sync.o nasmlib.o ver.o \
insnsd.o insnsb.o insnsn.o regs.o regdis.o
# @path-separator: ""
# @continuation: "\"
#-- Everything below is generated by mkdep.pl - do not edit --#
-assemble.o: assemble.c assemble.h compiler.h config.h insns.h insnsi.h \
- nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
+assemble.o: assemble.c assemble.h compiler.h config.h directives.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
crc64.o: crc64.c compiler.h config.h nasmlib.h
-disasm.o: disasm.c compiler.h config.h disasm.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
-eval.o: eval.c compiler.h config.h eval.h float.h insnsi.h labels.h nasm.h \
+directives.o: directives.c compiler.h config.h directives.h hashtbl.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h
+disasm.o: disasm.c compiler.h config.h directives.h disasm.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regdis.h regs.h sync.h tables.h \
+ tokens.h
+eval.o: eval.c compiler.h config.h directives.h eval.h float.h insnsi.h \
+ labels.h nasm.h nasmlib.h pptok.h preproc.h regs.h
+exprlib.o: exprlib.c compiler.h config.h directives.h insnsi.h nasm.h \
nasmlib.h pptok.h preproc.h regs.h
-exprlib.o: exprlib.c compiler.h config.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
-float.o: float.c compiler.h config.h float.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-hashtbl.o: hashtbl.c compiler.h config.h hashtbl.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-insnsa.o: insnsa.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h tokens.h
-insnsb.o: insnsb.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h tokens.h
-insnsd.o: insnsd.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h tokens.h
+float.o: float.c compiler.h config.h directives.h float.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
+hashtbl.o: hashtbl.c compiler.h config.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+insnsa.o: insnsa.c compiler.h config.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsb.o: insnsb.c compiler.h config.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsd.o: insnsd.c compiler.h config.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
insnsn.o: insnsn.c compiler.h config.h insnsi.h tables.h
-labels.o: labels.c compiler.h config.h hashtbl.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
+labels.o: labels.c compiler.h config.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
snprintf.o: snprintf.c compiler.h config.h nasmlib.h
vsnprintf.o: vsnprintf.c compiler.h config.h nasmlib.h
-listing.o: listing.c compiler.h config.h insnsi.h listing.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-macros.o: macros.c compiler.h config.h hashtbl.h insnsi.h nasm.h nasmlib.h \
- outform.h pptok.h preproc.h regs.h tables.h
-nasm.o: nasm.c assemble.h compiler.h config.h eval.h float.h insns.h \
- insnsi.h labels.h listing.h nasm.h nasmlib.h outform.h parser.h pptok.h \
- preproc.h raa.h regs.h saa.h stdscan.h tokens.h
-nasmlib.o: nasmlib.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h tokens.h
-ndisasm.o: ndisasm.c compiler.h config.h disasm.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
-nulldbg.o: nulldbg.c compiler.h config.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
-outaout.o: outaout.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- outlib.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h
-outas86.o: outas86.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- outlib.h pptok.h preproc.h raa.h regs.h saa.h
-outbin.o: outbin.c compiler.h config.h eval.h insnsi.h labels.h nasm.h \
- nasmlib.h outform.h outlib.h pptok.h preproc.h regs.h saa.h stdscan.h
-outcoff.o: outcoff.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- outlib.h pptok.h preproc.h raa.h regs.h saa.h
-outdbg.o: outdbg.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- pptok.h preproc.h regs.h
-outelf.o: outelf.c compiler.h config.h insnsi.h nasm.h nasmlib.h dwarf.h \
- elfcommon.h outelf.h outform.h pptok.h preproc.h regs.h
-outelf32.o: outelf32.c compiler.h config.h insnsi.h nasm.h nasmlib.h dwarf.h \
- elf32.h elfcommon.h outelf.h outform.h outlib.h pptok.h preproc.h raa.h \
- rbtree.h regs.h saa.h stdscan.h
-outelf64.o: outelf64.c compiler.h config.h insnsi.h nasm.h nasmlib.h dwarf.h \
- elf64.h elfcommon.h outelf.h outform.h outlib.h pptok.h preproc.h raa.h \
- rbtree.h regs.h saa.h stdscan.h
-outform.o: outform.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- pptok.h preproc.h regs.h
-outieee.o: outieee.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- outlib.h pptok.h preproc.h regs.h
-outlib.o: outlib.c compiler.h config.h insnsi.h nasm.h nasmlib.h outlib.h \
- pptok.h preproc.h regs.h
-outmacho.o: outmacho.c compiler.h config.h insnsi.h nasm.h nasmlib.h \
- outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h
-outobj.o: outobj.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- outlib.h pptok.h preproc.h regs.h stdscan.h
-outrdf.o: outrdf.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- pptok.h preproc.h regs.h
-outrdf2.o: outrdf2.c compiler.h config.h insnsi.h nasm.h nasmlib.h outform.h \
- outlib.h pptok.h preproc.h rdoff.h regs.h saa.h
-owtest.o: owtest.c
-parser.o: parser.c compiler.h config.h float.h insns.h insnsi.h nasm.h \
- nasmlib.h parser.h pptok.h preproc.h regs.h stdscan.h tables.h tokens.h
+listing.o: listing.c compiler.h config.h directives.h insnsi.h listing.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+macros.o: macros.c compiler.h config.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h outform.h pptok.h preproc.h regs.h tables.h
+nasm.o: nasm.c assemble.h compiler.h config.h directives.h eval.h float.h \
+ insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h outform.h parser.h \
+ pptok.h preproc.h raa.h regs.h saa.h stdscan.h tokens.h
+nasmlib.o: nasmlib.c compiler.h config.h directives.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+ndisasm.o: ndisasm.c compiler.h config.h directives.h disasm.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
+nulldbg.o: nulldbg.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
+nullout.o: nullout.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outlib.h pptok.h preproc.h regs.h
+outaout.o: outaout.c compiler.h config.h directives.h eval.h insnsi.h nasm.h \
+ nasmlib.h outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h
+outas86.o: outas86.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h
+outbin.o: outbin.c compiler.h config.h directives.h eval.h insnsi.h labels.h \
+ nasm.h nasmlib.h outform.h outlib.h pptok.h preproc.h regs.h saa.h \
+ stdscan.h
+outcoff.o: outcoff.c compiler.h config.h directives.h eval.h insnsi.h nasm.h \
+ nasmlib.h outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h
+outdbg.o: outdbg.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outform.h pptok.h preproc.h regs.h
+outelf.o: outelf.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h dwarf.h elfcommon.h outelf.h outform.h pptok.h preproc.h regs.h
+outelf32.o: outelf32.c compiler.h config.h directives.h eval.h insnsi.h \
+ nasm.h nasmlib.h dwarf.h elf32.h elfcommon.h outelf.h outform.h outlib.h \
+ pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
+outelf64.o: outelf64.c compiler.h config.h directives.h eval.h insnsi.h \
+ nasm.h nasmlib.h dwarf.h elf64.h elfcommon.h outelf.h outform.h outlib.h \
+ pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
+outexe.o: outexe.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outform.h pptok.h preproc.h regs.h
+outform.o: outform.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outform.h pptok.h preproc.h regs.h
+outieee.o: outieee.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outform.h outlib.h pptok.h preproc.h regs.h
+outlib.o: outlib.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outlib.h pptok.h preproc.h regs.h
+outmacho32.o: outmacho32.c compiler.h config.h directives.h eval.h insnsi.h \
+ nasm.h nasmlib.h outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h
+outmacho64.o: outmacho64.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h
+outobj.o: outobj.c compiler.h config.h directives.h eval.h insnsi.h nasm.h \
+ nasmlib.h outform.h outlib.h pptok.h preproc.h regs.h stdscan.h
+outrdf.o: outrdf.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outform.h pptok.h preproc.h regs.h
+outrdf2.o: outrdf2.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h outform.h outlib.h pptok.h preproc.h rdoff.h regs.h saa.h
+parser.o: parser.c compiler.h config.h directives.h float.h insns.h insnsi.h \
+ nasm.h nasmlib.h parser.h pptok.h preproc.h regs.h stdscan.h tables.h \
+ tokens.h
pptok.o: pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h preproc.h
-preproc.o: preproc.c compiler.h config.h hashtbl.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
+preproc.o: preproc.c compiler.h config.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tables.h \
+ tokens.h
quote.o: quote.c compiler.h config.h nasmlib.h quote.h
raa.o: raa.c compiler.h config.h nasmlib.h raa.h
rbtree.o: rbtree.c compiler.h config.h rbtree.h
regdis.o: regdis.c regdis.h regs.h
-regflags.o: regflags.c compiler.h config.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tables.h
+regflags.o: regflags.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tables.h
regs.o: regs.c compiler.h config.h insnsi.h tables.h
regvals.o: regvals.c compiler.h config.h insnsi.h tables.h
saa.o: saa.c compiler.h config.h nasmlib.h saa.h
-stdscan.o: stdscan.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h quote.h regs.h stdscan.h tokens.h
-strfunc.o: strfunc.c compiler.h config.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
+stdscan.o: stdscan.c compiler.h config.h directives.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tokens.h
+strfunc.o: strfunc.c compiler.h config.h directives.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
sync.o: sync.c compiler.h config.h nasmlib.h sync.h
-tokhash.o: tokhash.c compiler.h config.h hashtbl.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h tokens.h
-ver.o: ver.c compiler.h config.h insnsi.h nasm.h nasmlib.h pptok.h preproc.h \
- regs.h version.h
+tokhash.o: tokhash.c compiler.h config.h directives.h hashtbl.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+ver.o: ver.c compiler.h config.h directives.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h version.h
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) &
raa.$(O) saa.$(O) rbtree.$(O) &
float.$(O) insnsa.$(O) insnsb.$(O) &
+ directives.$(O) &
assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) &
output\outform.$(O) output\outlib.$(O) output\nulldbg.$(O) &
+ output\nullout.$(O) &
output\outbin.$(O) output\outaout.$(O) output\outcoff.$(O) &
output\outelf.$(O) output\outelf32.$(O) output\outelf64.$(O) &
output\outobj.$(O) output\outas86.$(O) output\outrdf2.$(O) &
- output\outdbg.$(O) output\outieee.$(O) output\outmacho.$(O) &
- preproc.$(O) quote.$(O) pptok.$(O) macros.$(O) &
- listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) strfunc.$(O) &
- tokhash.$(O) regvals.$(O) regflags.$(O)
+ output\outdbg.$(O) output\outieee.$(O) output\outmacho32.$(O) &
+ output\outmacho64.$(O) preproc.$(O) quote.$(O) pptok.$(O) &
+ macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) &
+ strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) &
insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
# @exclude: "config.h"
# @continuation: "&"
#-- Everything below is generated by mkdep.pl - do not edit --#
-assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h &
- nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
+assemble.$(O): assemble.c assemble.h compiler.h directives.h insns.h &
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
crc64.$(O): crc64.c compiler.h nasmlib.h
-disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h nasm.h nasmlib.h &
- pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
-eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h &
- nasmlib.h pptok.h preproc.h regs.h
-exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h
-float.$(O): float.c compiler.h float.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h
-hashtbl.$(O): hashtbl.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h &
+directives.$(O): directives.c compiler.h directives.h hashtbl.h insnsi.h &
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+disasm.$(O): disasm.c compiler.h directives.h disasm.h insns.h insnsi.h &
+ nasm.h nasmlib.h pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
+eval.$(O): eval.c compiler.h directives.h eval.h float.h insnsi.h labels.h &
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+exprlib.$(O): exprlib.c compiler.h directives.h insnsi.h nasm.h nasmlib.h &
pptok.h preproc.h regs.h
-insnsa.$(O): insnsa.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h tokens.h
-insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h tokens.h
-insnsd.$(O): insnsd.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h tokens.h
+float.$(O): float.c compiler.h directives.h float.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h regs.h
+hashtbl.$(O): hashtbl.c compiler.h directives.h hashtbl.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h regs.h
+insnsa.$(O): insnsa.c compiler.h directives.h insns.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsb.$(O): insnsb.c compiler.h directives.h insns.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsd.$(O): insnsd.c compiler.h directives.h insns.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
-labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h
+labels.$(O): labels.c compiler.h directives.h hashtbl.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h regs.h
lib\snprintf.$(O): lib\snprintf.c compiler.h nasmlib.h
lib\vsnprintf.$(O): lib\vsnprintf.c compiler.h nasmlib.h
-listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h &
- pptok.h preproc.h regs.h
-macros.$(O): macros.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h &
- output\outform.h pptok.h preproc.h regs.h tables.h
-nasm.$(O): nasm.c assemble.h compiler.h eval.h float.h insns.h insnsi.h &
- labels.h listing.h nasm.h nasmlib.h output\outform.h parser.h pptok.h &
- preproc.h raa.h regs.h saa.h stdscan.h tokens.h
-nasmlib.$(O): nasmlib.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h tokens.h
-ndisasm.$(O): ndisasm.c compiler.h disasm.h insns.h insnsi.h nasm.h &
- nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
-output\nulldbg.$(O): output\nulldbg.c compiler.h insnsi.h nasm.h nasmlib.h &
- pptok.h preproc.h regs.h
-output\outaout.$(O): output\outaout.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h output\outlib.h pptok.h preproc.h raa.h regs.h saa.h &
- stdscan.h
-output\outas86.$(O): output\outas86.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h output\outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output\outbin.$(O): output\outbin.c compiler.h eval.h insnsi.h labels.h &
- nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h preproc.h regs.h &
- saa.h stdscan.h
-output\outcoff.$(O): output\outcoff.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h output\outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output\outdbg.$(O): output\outdbg.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h pptok.h preproc.h regs.h
-output\outelf.$(O): output\outelf.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\dwarf.h output\elfcommon.h output\outelf.h output\outform.h pptok.h &
- preproc.h regs.h
-output\outelf32.$(O): output\outelf32.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\dwarf.h output\elf32.h output\elfcommon.h output\outelf.h &
- output\outform.h output\outlib.h pptok.h preproc.h raa.h rbtree.h regs.h &
- saa.h stdscan.h
-output\outelf64.$(O): output\outelf64.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\dwarf.h output\elf64.h output\elfcommon.h output\outelf.h &
- output\outform.h output\outlib.h pptok.h preproc.h raa.h rbtree.h regs.h &
- saa.h stdscan.h
-output\outform.$(O): output\outform.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h pptok.h preproc.h regs.h
-output\outieee.$(O): output\outieee.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h output\outlib.h pptok.h preproc.h regs.h
-output\outlib.$(O): output\outlib.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outlib.h pptok.h preproc.h regs.h
-output\outmacho.$(O): output\outmacho.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h output\outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output\outobj.$(O): output\outobj.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h output\outlib.h pptok.h preproc.h regs.h stdscan.h
-output\outrdf.$(O): output\outrdf.c compiler.h insnsi.h nasm.h nasmlib.h &
+listing.$(O): listing.c compiler.h directives.h insnsi.h listing.h nasm.h &
+ nasmlib.h pptok.h preproc.h regs.h
+macros.$(O): macros.c compiler.h directives.h hashtbl.h insnsi.h nasm.h &
+ nasmlib.h output\outform.h pptok.h preproc.h regs.h tables.h
+nasm.$(O): nasm.c assemble.h compiler.h directives.h eval.h float.h insns.h &
+ insnsi.h labels.h listing.h nasm.h nasmlib.h output\outform.h parser.h &
+ pptok.h preproc.h raa.h regs.h saa.h stdscan.h tokens.h
+nasmlib.$(O): nasmlib.c compiler.h directives.h insns.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+ndisasm.$(O): ndisasm.c compiler.h directives.h disasm.h insns.h insnsi.h &
+ nasm.h nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
+output\nulldbg.$(O): output\nulldbg.c compiler.h directives.h insnsi.h &
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+output\nullout.$(O): output\nullout.c compiler.h directives.h insnsi.h &
+ nasm.h nasmlib.h output\outlib.h pptok.h preproc.h regs.h
+output\outaout.$(O): output\outaout.c compiler.h directives.h eval.h &
+ insnsi.h nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h &
+ preproc.h raa.h regs.h saa.h stdscan.h
+output\outas86.$(O): output\outas86.c compiler.h directives.h insnsi.h &
+ nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h preproc.h raa.h &
+ regs.h saa.h
+output\outbin.$(O): output\outbin.c compiler.h directives.h eval.h insnsi.h &
+ labels.h nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h &
+ preproc.h regs.h saa.h stdscan.h
+output\outcoff.$(O): output\outcoff.c compiler.h directives.h eval.h &
+ insnsi.h nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h &
+ preproc.h raa.h regs.h saa.h
+output\outdbg.$(O): output\outdbg.c compiler.h directives.h insnsi.h nasm.h &
+ nasmlib.h output\outform.h pptok.h preproc.h regs.h
+output\outelf.$(O): output\outelf.c compiler.h directives.h insnsi.h nasm.h &
+ nasmlib.h output\dwarf.h output\elfcommon.h output\outelf.h &
output\outform.h pptok.h preproc.h regs.h
-output\outrdf2.$(O): output\outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h &
- output\outform.h output\outlib.h pptok.h preproc.h rdoff\rdoff.h regs.h &
- saa.h
-owtest.$(O): owtest.c
-parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h &
- parser.h pptok.h preproc.h regs.h stdscan.h tables.h tokens.h
+output\outelf32.$(O): output\outelf32.c compiler.h directives.h eval.h &
+ insnsi.h nasm.h nasmlib.h output\dwarf.h output\elf32.h output\elfcommon.h &
+ output\outelf.h output\outform.h output\outlib.h pptok.h preproc.h raa.h &
+ rbtree.h regs.h saa.h stdscan.h
+output\outelf64.$(O): output\outelf64.c compiler.h directives.h eval.h &
+ insnsi.h nasm.h nasmlib.h output\dwarf.h output\elf64.h output\elfcommon.h &
+ output\outelf.h output\outform.h output\outlib.h pptok.h preproc.h raa.h &
+ rbtree.h regs.h saa.h stdscan.h
+output\outexe.$(O): output\outexe.c compiler.h directives.h insnsi.h nasm.h &
+ nasmlib.h output\outform.h pptok.h preproc.h regs.h
+output\outform.$(O): output\outform.c compiler.h directives.h insnsi.h &
+ nasm.h nasmlib.h output\outform.h pptok.h preproc.h regs.h
+output\outieee.$(O): output\outieee.c compiler.h directives.h insnsi.h &
+ nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h preproc.h regs.h
+output\outlib.$(O): output\outlib.c compiler.h directives.h insnsi.h nasm.h &
+ nasmlib.h output\outlib.h pptok.h preproc.h regs.h
+output\outmacho32.$(O): output\outmacho32.c compiler.h directives.h eval.h &
+ insnsi.h nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h &
+ preproc.h raa.h regs.h saa.h
+output\outmacho64.$(O): output\outmacho64.c compiler.h directives.h insnsi.h &
+ nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h preproc.h raa.h &
+ regs.h saa.h
+output\outobj.$(O): output\outobj.c compiler.h directives.h eval.h insnsi.h &
+ nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h preproc.h regs.h &
+ stdscan.h
+output\outrdf.$(O): output\outrdf.c compiler.h directives.h insnsi.h nasm.h &
+ nasmlib.h output\outform.h pptok.h preproc.h regs.h
+output\outrdf2.$(O): output\outrdf2.c compiler.h directives.h insnsi.h &
+ nasm.h nasmlib.h output\outform.h output\outlib.h pptok.h preproc.h &
+ rdoff\rdoff.h regs.h saa.h
+parser.$(O): parser.c compiler.h directives.h float.h insns.h insnsi.h &
+ nasm.h nasmlib.h parser.h pptok.h preproc.h regs.h stdscan.h tables.h &
+ tokens.h
pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
-preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h &
- pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
+preproc.$(O): preproc.c compiler.h directives.h hashtbl.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
quote.$(O): quote.c compiler.h nasmlib.h quote.h
raa.$(O): raa.c compiler.h nasmlib.h raa.h
rbtree.$(O): rbtree.c compiler.h rbtree.h
regdis.$(O): regdis.c regdis.h regs.h
-regflags.$(O): regflags.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h tables.h
+regflags.$(O): regflags.c compiler.h directives.h insnsi.h nasm.h nasmlib.h &
+ pptok.h preproc.h regs.h tables.h
regs.$(O): regs.c compiler.h insnsi.h tables.h
regvals.$(O): regvals.c compiler.h insnsi.h tables.h
saa.$(O): saa.c compiler.h nasmlib.h saa.h
-stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h quote.h regs.h stdscan.h tokens.h
-strfunc.$(O): strfunc.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h &
- preproc.h regs.h
+stdscan.$(O): stdscan.c compiler.h directives.h insns.h insnsi.h nasm.h &
+ nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tokens.h
+strfunc.$(O): strfunc.c compiler.h directives.h insnsi.h nasm.h nasmlib.h &
+ pptok.h preproc.h regs.h
sync.$(O): sync.c compiler.h nasmlib.h sync.h
-tokhash.$(O): tokhash.c compiler.h hashtbl.h insns.h insnsi.h nasm.h &
- nasmlib.h pptok.h preproc.h regs.h tokens.h
-ver.$(O): ver.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h preproc.h &
- regs.h version.h
+tokhash.$(O): tokhash.c compiler.h directives.h hashtbl.h insns.h insnsi.h &
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+ver.$(O): ver.c compiler.h directives.h insnsi.h nasm.h nasmlib.h pptok.h &
+ preproc.h regs.h version.h
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
raa.$(O) saa.$(O) rbtree.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
+ directives.$(O) \
assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \
+ output/nullout.$(O) \
output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \
output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
- output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
- preproc.$(O) quote.$(O) pptok.$(O) macros.$(O) \
- listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) strfunc.$(O) \
- tokhash.$(O) regvals.$(O) regflags.$(O)
+ output/outdbg.$(O) output/outieee.$(O) output/outmacho32.$(O) \
+ output/outmacho64.$(O) preproc.$(O) quote.$(O) pptok.$(O) \
+ macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) \
+ strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
# @exclude: "config.h"
# @continuation: "\"
#-- Everything below is generated by mkdep.pl - do not edit --#
-assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
+assemble.$(O): assemble.c assemble.h compiler.h directives.h insns.h \
+ insnsi.h nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
crc64.$(O): crc64.c compiler.h nasmlib.h
-disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
-eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h
-exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
-float.$(O): float.c compiler.h float.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
-hashtbl.$(O): hashtbl.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
+directives.$(O): directives.c compiler.h directives.h hashtbl.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+disasm.$(O): disasm.c compiler.h directives.h disasm.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
+eval.$(O): eval.c compiler.h directives.h eval.h float.h insnsi.h labels.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+exprlib.$(O): exprlib.c compiler.h directives.h insnsi.h nasm.h nasmlib.h \
pptok.h preproc.h regs.h
-insnsa.$(O): insnsa.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tokens.h
-insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tokens.h
-insnsd.$(O): insnsd.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tokens.h
+float.$(O): float.c compiler.h directives.h float.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
+hashtbl.$(O): hashtbl.c compiler.h directives.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
+insnsa.$(O): insnsa.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsb.$(O): insnsb.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+insnsd.$(O): insnsd.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
-labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
+labels.$(O): labels.c compiler.h directives.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
-listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-macros.$(O): macros.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
- output/outform.h pptok.h preproc.h regs.h tables.h
-nasm.$(O): nasm.c assemble.h compiler.h eval.h float.h insns.h insnsi.h \
- labels.h listing.h nasm.h nasmlib.h output/outform.h parser.h pptok.h \
- preproc.h raa.h regs.h saa.h stdscan.h tokens.h
-nasmlib.$(O): nasmlib.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tokens.h
-ndisasm.$(O): ndisasm.c compiler.h disasm.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
-output/nulldbg.$(O): output/nulldbg.c compiler.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h regs.h
-output/outaout.$(O): output/outaout.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h \
- stdscan.h
-output/outas86.$(O): output/outas86.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output/outbin.$(O): output/outbin.c compiler.h eval.h insnsi.h labels.h \
- nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h \
- saa.h stdscan.h
-output/outcoff.$(O): output/outcoff.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output/outdbg.$(O): output/outdbg.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h pptok.h preproc.h regs.h
-output/outelf.$(O): output/outelf.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/dwarf.h output/elfcommon.h output/outelf.h output/outform.h pptok.h \
- preproc.h regs.h
-output/outelf32.$(O): output/outelf32.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/dwarf.h output/elf32.h output/elfcommon.h output/outelf.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h rbtree.h regs.h \
- saa.h stdscan.h
-output/outelf64.$(O): output/outelf64.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/dwarf.h output/elf64.h output/elfcommon.h output/outelf.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h rbtree.h regs.h \
- saa.h stdscan.h
-output/outform.$(O): output/outform.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h pptok.h preproc.h regs.h
-output/outieee.$(O): output/outieee.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h regs.h
-output/outlib.$(O): output/outlib.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outlib.h pptok.h preproc.h regs.h
-output/outmacho.$(O): output/outmacho.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h
-output/outobj.$(O): output/outobj.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h regs.h stdscan.h
-output/outrdf.$(O): output/outrdf.c compiler.h insnsi.h nasm.h nasmlib.h \
+listing.$(O): listing.c compiler.h directives.h insnsi.h listing.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h
+macros.$(O): macros.c compiler.h directives.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h output/outform.h pptok.h preproc.h regs.h tables.h
+nasm.$(O): nasm.c assemble.h compiler.h directives.h eval.h float.h insns.h \
+ insnsi.h labels.h listing.h nasm.h nasmlib.h output/outform.h parser.h \
+ pptok.h preproc.h raa.h regs.h saa.h stdscan.h tokens.h
+nasmlib.$(O): nasmlib.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h tokens.h
+ndisasm.$(O): ndisasm.c compiler.h directives.h disasm.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
+output/nulldbg.$(O): output/nulldbg.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h
+output/nullout.$(O): output/nullout.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outlib.h pptok.h preproc.h regs.h
+output/outaout.$(O): output/outaout.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h stdscan.h
+output/outas86.$(O): output/outas86.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
+ regs.h saa.h
+output/outbin.$(O): output/outbin.c compiler.h directives.h eval.h insnsi.h \
+ labels.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h regs.h saa.h stdscan.h
+output/outcoff.$(O): output/outcoff.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h
+output/outdbg.$(O): output/outdbg.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outelf.$(O): output/outelf.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/dwarf.h output/elfcommon.h output/outelf.h \
output/outform.h pptok.h preproc.h regs.h
-output/outrdf2.$(O): output/outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h \
- output/outform.h output/outlib.h pptok.h preproc.h rdoff/rdoff.h regs.h \
- saa.h
-owtest.$(O): owtest.c
-parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h \
- parser.h pptok.h preproc.h regs.h stdscan.h tables.h tokens.h
+output/outelf32.$(O): output/outelf32.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/dwarf.h output/elf32.h output/elfcommon.h \
+ output/outelf.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
+ rbtree.h regs.h saa.h stdscan.h
+output/outelf64.$(O): output/outelf64.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/dwarf.h output/elf64.h output/elfcommon.h \
+ output/outelf.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
+ rbtree.h regs.h saa.h stdscan.h
+output/outexe.$(O): output/outexe.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outform.$(O): output/outform.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outieee.$(O): output/outieee.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h
+output/outlib.$(O): output/outlib.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/outlib.h pptok.h preproc.h regs.h
+output/outmacho32.$(O): output/outmacho32.c compiler.h directives.h eval.h \
+ insnsi.h nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h \
+ preproc.h raa.h regs.h saa.h
+output/outmacho64.$(O): output/outmacho64.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h \
+ regs.h saa.h
+output/outobj.$(O): output/outobj.c compiler.h directives.h eval.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h \
+ stdscan.h
+output/outrdf.$(O): output/outrdf.c compiler.h directives.h insnsi.h nasm.h \
+ nasmlib.h output/outform.h pptok.h preproc.h regs.h
+output/outrdf2.$(O): output/outrdf2.c compiler.h directives.h insnsi.h \
+ nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h \
+ rdoff/rdoff.h regs.h saa.h
+parser.$(O): parser.c compiler.h directives.h float.h insns.h insnsi.h \
+ nasm.h nasmlib.h parser.h pptok.h preproc.h regs.h stdscan.h tables.h \
+ tokens.h
pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
-preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
- pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
+preproc.$(O): preproc.c compiler.h directives.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
quote.$(O): quote.c compiler.h nasmlib.h quote.h
raa.$(O): raa.c compiler.h nasmlib.h raa.h
rbtree.$(O): rbtree.c compiler.h rbtree.h
regdis.$(O): regdis.c regdis.h regs.h
-regflags.$(O): regflags.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h tables.h
+regflags.$(O): regflags.c compiler.h directives.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h tables.h
regs.$(O): regs.c compiler.h insnsi.h tables.h
regvals.$(O): regvals.c compiler.h insnsi.h tables.h
saa.$(O): saa.c compiler.h nasmlib.h saa.h
-stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h quote.h regs.h stdscan.h tokens.h
-strfunc.$(O): strfunc.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
- preproc.h regs.h
+stdscan.$(O): stdscan.c compiler.h directives.h insns.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h quote.h regs.h stdscan.h tokens.h
+strfunc.$(O): strfunc.c compiler.h directives.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h
sync.$(O): sync.c compiler.h nasmlib.h sync.h
-tokhash.$(O): tokhash.c compiler.h hashtbl.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regs.h tokens.h
-ver.$(O): ver.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h preproc.h \
- regs.h version.h
+tokhash.$(O): tokhash.c compiler.h directives.h hashtbl.h insns.h insnsi.h \
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tokens.h
+ver.$(O): ver.c compiler.h directives.h insnsi.h nasm.h nasmlib.h pptok.h \
+ preproc.h regs.h version.h
--- /dev/null
+;; --------------------------------------------------------------------------
+;;
+;; Copyright 1996-2009 The NASM Authors - All Rights Reserved
+;; See the file AUTHORS included with the NASM distribution for
+;; the specific copyright holders.
+;;
+;; Redistribution and use in source and binary forms, with or without
+;; modification, are permitted provided that the following
+;; conditions are met:
+;;
+;; * Redistributions of source code must retain the above copyright
+;; notice, this list of conditions and the following disclaimer.
+;; * Redistributions in binary form must reproduce the above
+;; copyright notice, this list of conditions and the following
+;; disclaimer in the documentation and/or other materials provided
+;; with the distribution.
+;;
+;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+;; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+;; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+;; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;;
+;; --------------------------------------------------------------------------
+;;
+;; List of global NASM directives (including backend-specific ones)
+;;
+
+; --- Global directives
+absolute
+bits
+common
+cpu
+debug
+default
+extern
+float
+global
+list
+section
+segment
+warning
+
+; --- Format-specific directives
+export ; outcoff, outobj
+group ; outobj
+import ; outobj
+library ; outrdf2
+map ; outbin
+module ; outrdf2
+org ; outbin
+osabi ; outelf
+safeseh ; outcoff
+uppercase ; outieee, outobj
--- /dev/null
+#!/usr/bin/perl
+## --------------------------------------------------------------------------
+##
+## Copyright 1996-2009 The NASM Authors - All Rights Reserved
+## See the file AUTHORS included with the NASM distribution for
+## the specific copyright holders.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following
+## conditions are met:
+##
+## * Redistributions of source code must retain the above copyright
+## notice, this list of conditions and the following disclaimer.
+## * Redistributions in binary form must reproduce the above
+## copyright notice, this list of conditions and the following
+## disclaimer in the documentation and/or other materials provided
+## with the distribution.
+##
+## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+##
+## --------------------------------------------------------------------------
+
+#
+# Generate a perfect hash for directive parsing
+#
+# Usage: directives.pl directives.dat directives.c directives.h
+#
+
+require 'phash.ph';
+
+my($output, $directives_dat, $outfile) = @ARGV;
+
+@directives = ();
+
+open(DD, "< ${directives_dat}\0")
+ or die "$0: cannot open: ${directives_dat}: $!\n";
+while (defined($line = <DD>)) {
+ chomp $line;
+ if ($line =~ /^\s*([[:alnum:]]+)\s*(|[\;\#].*)$/) {
+ push(@directives, $1);
+ }
+}
+close(DD);
+
+if ($output eq 'h') {
+ open(H, "> ${outfile}\0")
+ or die "$0: cannot create: ${outfile}: $!\n";
+
+ print H "/*\n";
+ print H " * This file is generated from directives.dat\n";
+ print H " * by directives.pl; do not edit.\n";
+ print H " */\n";
+ print H "\n";
+
+ print H "#ifndef NASM_DIRECTIVES_H\n";
+ print H "#define NASM_DIRECTIVES_H\n";
+ print H "\n";
+
+ print H "enum directives {\n";
+ print H " D_NONE";
+ foreach $d (@directives) {
+ print H ",\n D_\U$d";
+ }
+ print H "\n};\n\n";
+ printf H "extern const char * const directives[%d];\n",
+ scalar(@directives)+1;
+ print H "enum directives find_directive(const char *token);\n\n";
+ print H "#endif /* NASM_DIRECTIVES_H */\n";
+} elsif ($output eq 'c') {
+ %directive = ();
+ $n = 0;
+ foreach $d (@directives) {
+ if (exists($directive{$d})) {
+ die "$0: $directives_dat: duplicate directive: $d\n";
+ }
+ $directive{$d} = $n++; # This is zero-based, unlike the enum!
+ }
+
+ @hashinfo = gen_perfect_hash(\%directive);
+ if (!defined(@hashinfo)) {
+ die "$0: no hash found\n";
+ }
+
+ # Paranoia...
+ verify_hash_table(\%directive, \@hashinfo);
+
+ ($n, $sv, $g) = @hashinfo;
+ $sv2 = $sv+2;
+
+ die if ($n & ($n-1));
+
+ open(C, "> ${outfile}\0")
+ or die "$0: cannot create: ${directives_c}: $!\n";
+
+ print C "/*\n";
+ print C " * This file is generated from directives.dat\n";
+ print C " * by directives.pl; do not edit.\n";
+ print C " */\n";
+ print C "\n";
+
+ print C "#include \"compiler.h\"\n";
+ print C "#include <string.h>\n";
+ print C "#include \"nasm.h\"\n";
+ print C "#include \"hashtbl.h\"\n";
+ print C "#include \"directives.h\"\n";
+ print C "\n";
+
+ printf C "const char * const directives[%d] = {\n",
+ scalar(@directives)+1;
+ print C " NULL";
+ foreach $d (@directives) {
+ print C ",\n \"$d\"";
+ }
+ print C "\n};\n\n";
+
+ print C "enum directives find_directive(const char *token)\n";
+ print C "{\n";
+
+ # Put a large value in unused slots. This makes it extremely unlikely
+ # that any combination that involves unused slot will pass the range test.
+ # This speeds up rejection of unrecognized tokens, i.e. identifiers.
+ print C "#define UNUSED 16383\n";
+
+ print C " static const int16_t hash1[$n] = {\n";
+ for ($i = 0; $i < $n; $i++) {
+ my $h = ${$g}[$i*2+0];
+ print C " ", defined($h) ? $h : 'UNUSED', ",\n";
+ }
+ print C " };\n";
+
+ print C " static const int16_t hash2[$n] = {\n";
+ for ($i = 0; $i < $n; $i++) {
+ my $h = ${$g}[$i*2+1];
+ print C " ", defined($h) ? $h : 'UNUSED', ",\n";
+ }
+ print C " };\n";
+
+ print C " uint32_t k1, k2;\n";
+ print C " uint64_t crc;\n";
+ # For correct overflow behavior, "ix" should be unsigned of the same
+ # width as the hash arrays.
+ print C " uint16_t ix;\n";
+ print C "\n";
+ printf C " crc = crc64i(UINT64_C(0x%08x%08x), token);\n",
+ $$sv[0], $$sv[1];
+ print C " k1 = (uint32_t)crc;\n";
+ print C " k2 = (uint32_t)(crc >> 32);\n";
+ print C "\n";
+ printf C " ix = hash1[k1 & 0x%x] + hash2[k2 & 0x%x];\n", $n-1, $n-1;
+ printf C " if (ix >= %d)\n", scalar(@directives);
+ print C " return D_NONE;\n";
+ print C "\n";
+ print C " ix++;\n"; # Account for D_NONE
+ print C " if (nasm_stricmp(token, directives[ix]))\n";
+ print C " return D_NONE;\n";
+ print C "\n";
+ print C " return ix;\n";
+ print C "}\n";
+}
\c %defstr PATH %!PATH ; The operating system PATH variable
+\S{deftok} Defining Tokens: \I\c{%ideftok}\i\c{%deftok}
+
+\c{%deftok}, and its case-insensitive counterpart \c{%ideftok}, define
+or redefine a single-line macro without parameters but converts the
+second parameter, after string conversion, to a sequence of tokens.
+
+For example:
+
+\c %deftok test 'TEST'
+
+is equivalent to
+
+\c %define test TEST
+
+
\H{strlen} \i{String Manipulation in Macros}
It's often useful to be able to handle strings in macros. NASM
\c silly {13,10}, crlf ; crlf: db 13,10
+\S{mlrmacro} \i{Recursive Multi-Line Macros}: \I\c{%irmacro}\i\c{%rmacro}
+
+A multi-line macro cannot be referenced within itself, in order to
+prevent accidental infinite recursion.
+
+Recursive multi-line macros allow for self-referencing, with the
+caveat that the user is aware of the existence, use and purpose of
+recursive multi-line macros. There is also a generous, but sane, upper
+limit to the number of recursions, in order to prevent run-away memory
+consumption in case of accidental infinite recursion.
+
+As with non-recursive multi-line macros, recursive multi-line macros are
+\i{case-sensitive}, unless you define them using the alternative
+directive \c{%irmacro}.
+
+
\S{mlmacover} Overloading Multi-Line Macros\I{overloading, multi-line macros}
As with single-line macros, multi-line macros can be overloaded by
}
void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
- bool is_norm, bool isextrn, struct ofmt *ofmt,
- efunc error)
+ bool is_norm, bool isextrn)
{
union label *lptr;
int exi;
(void)special; /* Don't warn that this parameter is unused */
(void)is_norm; /* Don't warn that this parameter is unused */
(void)isextrn; /* Don't warn that this parameter is unused */
- (void)ofmt; /* Don't warn that this parameter is unused */
#ifdef DEBUG
#if DEBUG<3
if (!strncmp(label, "debugdump", 9))
#endif
- error(ERR_DEBUG, "redefine_label (%s, %ld, %08lx, %s, %d, %d)",
+ nasm_error(ERR_DEBUG, "redefine_label (%s, %ld, %08lx, %s, %d, %d)",
label, segment, offset, special, is_norm, isextrn);
#endif
lptr = find_label(label, 1);
if (!lptr)
- error(ERR_PANIC, "can't find label `%s' on pass two", label);
+ nasm_error(ERR_PANIC, "can't find label `%s' on pass two", label);
if (!islocal(label)) {
if (!islocalchar(*label) && lptr->defn.is_norm)
}
void define_label(char *label, int32_t segment, int64_t offset, char *special,
- bool is_norm, bool isextrn, struct ofmt *ofmt, efunc error)
+ bool is_norm, bool isextrn)
{
union label *lptr;
int exi;
#if DEBUG<3
if (!strncmp(label, "debugdump", 9))
#endif
- error(ERR_DEBUG, "define_label (%s, %ld, %08lx, %s, %d, %d)",
+ nasm_error(ERR_DEBUG, "define_label (%s, %ld, %08lx, %s, %d, %d)",
label, segment, offset, special, is_norm, isextrn);
#endif
lptr = find_label(label, 1);
if (lptr->defn.is_global & DEFINED_BIT) {
- error(ERR_NONFATAL, "symbol `%s' redefined", label);
+ nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label);
return;
}
lptr->defn.is_global |= DEFINED_BIT;
/* not local, but not special either */
prevlabel = lptr->defn.label;
} else if (islocal(label) && !*prevlabel) {
- error(ERR_NONFATAL, "attempt to define a local label before any"
+ nasm_error(ERR_NONFATAL, "attempt to define a local label before any"
" non-local labels");
}
} /* if (pass0 == 1) */
}
-void define_common(char *label, int32_t segment, int32_t size, char *special,
- struct ofmt *ofmt, efunc error)
+void define_common(char *label, int32_t segment, int32_t size, char *special)
{
union label *lptr;
lptr = find_label(label, 1);
if ((lptr->defn.is_global & DEFINED_BIT) &&
(passn == 1 || !(lptr->defn.is_global & COMMON_BIT))) {
- error(ERR_NONFATAL, "symbol `%s' redefined", label);
+ nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label);
return;
}
lptr->defn.is_global |= DEFINED_BIT|COMMON_BIT;
if (!islocalchar(label[0])) {
prevlabel = lptr->defn.label;
} else {
- error(ERR_NONFATAL, "attempt to define a local label as a "
+ nasm_error(ERR_NONFATAL, "attempt to define a local label as a "
"common variable");
return;
}
special);
}
-void declare_as_global(char *label, char *special, efunc error)
+void declare_as_global(char *label, char *special)
{
union label *lptr;
if (islocal(label)) {
- error(ERR_NONFATAL, "attempt to declare local symbol `%s' as"
+ nasm_error(ERR_NONFATAL, "attempt to declare local symbol `%s' as"
" global", label);
return;
}
break;
case LOCAL_SYMBOL:
if (!(lptr->defn.is_global & EXTERN_BIT)) {
- error(ERR_WARNING, "symbol `%s': GLOBAL directive "
+ nasm_error(ERR_WARNING, "symbol `%s': GLOBAL directive "
"after symbol definition is an experimental feature", label);
lptr->defn.is_global = GLOBAL_SYMBOL;
}
bool lookup_label(char *label, int32_t *segment, int64_t *offset);
bool is_extern(char *label);
void define_label(char *label, int32_t segment, int64_t offset, char *special,
- bool is_norm, bool isextrn, struct ofmt *ofmt,
- efunc error);
+ bool is_norm, bool isextrn);
void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
- bool is_norm, bool isextrn, struct ofmt *ofmt,
- efunc error);
-void define_common(char *label, int32_t segment, int32_t size, char *special,
- struct ofmt *ofmt, efunc error);
-void declare_as_global(char *label, char *special, efunc error);
+ bool is_norm, bool isextrn);
+void define_common(char *label, int32_t segment, int32_t size, char *special);
+void declare_as_global(char *label, char *special);
int init_labels(void);
void cleanup_labels(void);
char *local_scope(char *label);
--- /dev/null
+#include <inttypes.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ /* Polynomial in bit-reversed notation */
+ uint64_t poly;
+ uint64_t crctab[256], v;
+ int i, j;
+
+ poly = strtoumax(argv[1], NULL, 0);
+
+ printf("/* C */\n");
+ printf("static const uint64_t crc64_tab[256] = {\n");
+ for (i = 0; i < 256; i++) {
+ v = i;
+ for (j = 0; j < 8; j++)
+ v = (v >> 1) ^ ((v & 1) ? poly : 0);
+ crctab[i] = v;
+ }
+
+ for (i = 0; i < 256; i += 2) {
+ printf(" /* %02x */ UINT64_C(0x%016"PRIx64"), "
+ "UINT64_C(0x%016"PRIx64")%s\n",
+ i, crctab[i], crctab[i+1], (i == 254) ? "" : ",");
+ }
+ printf("};\n\n");
+
+ printf("# perl\n");
+ printf("@crc64_tab = (\n");
+ for (i = 0; i < 256; i += 2) {
+ printf(" [0x%08"PRIx32", 0x%08"PRIx32"], "
+ "[0x%08"PRIx32", 0x%08"PRIx32"]%-1s # %02x\n",
+ (uint32_t)(crctab[i] >> 32),
+ (uint32_t)(crctab[i]),
+ (uint32_t)(crctab[i+1] >> 32),
+ (uint32_t)(crctab[i+1]),
+ (i == 254) ? "" : ",",
+ i);
+ }
+ printf(");\n");
+
+ return 0;
+}
--- /dev/null
+/*
+ * Produce a "generalized CRC" table. Assumes a platform with
+ * /dev/urandom -- otherwise reimplement get_random_byte().
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static uint8_t get_random_byte(void)
+{
+ static int fd = -1;
+ uint8_t buf;
+ int rv;
+
+ if (fd < 0)
+ fd = open("/dev/urandom", O_RDONLY);
+
+ do {
+ errno = 0;
+ rv = read(fd, &buf, 1);
+ if (rv < 1 && errno != EAGAIN)
+ abort();
+ } while (rv < 1);
+
+ return buf;
+}
+
+static void random_permute(uint8_t *buf)
+{
+ int i, j, k;
+ int m;
+
+ for (i = 0; i < 256; i++)
+ buf[i] = i;
+
+ m = 255;
+ for (i = 255; i > 0; i--) {
+ if (i <= (m >> 1))
+ m >>= 1;
+ do {
+ j = get_random_byte() & m;
+ } while (j > i);
+ k = buf[i];
+ buf[i] = buf[j];
+ buf[j] = k;
+ }
+}
+
+static void xcrc_table(uint64_t *buf)
+{
+ uint8_t perm[256];
+ int i, j;
+
+ memset(buf, 0, 8*256); /* Make static checkers happy */
+
+ for (i = 0; i < 8; i++) {
+ random_permute(perm);
+ for (j = 0; j < 256; j++)
+ buf[j] = (buf[j] << 8) | perm[j];
+ }
+}
+
+int main(void)
+{
+ int i;
+ uint64_t buf[256];
+
+ xcrc_table(buf);
+
+ for (i = 0; i < 256; i++) {
+ printf("%016"PRIx64"\n", buf[i]);
+ }
+
+ return 0;
+}
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1996-2009 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
*
* ----------------------------------------------------------------------- */
-/*
+/*
* The Netwide Assembler main program module
*/
static uint32_t get_cpu(char *cpu_str);
static void parse_cmdline(int, char **);
static void assemble_file(char *, StrList **);
-static void register_output_formats(void);
-static void report_error_gnu(int severity, const char *fmt, ...);
-static void report_error_vc(int severity, const char *fmt, ...);
-static void report_error_common(int severity, const char *fmt,
- va_list args);
+static void nasm_verror_gnu(int severity, const char *fmt, va_list args);
+static void nasm_verror_vc(int severity, const char *fmt, va_list args);
+static void nasm_verror_common(int severity, const char *fmt, va_list args);
static bool is_suppressed_warning(int severity);
static void usage(void);
-static efunc report_error;
static int using_debug_info, opt_verbose_info;
bool tasm_compatible_mode = false;
int maxbits = 0;
int globalrel = 0;
-time_t official_compile_time;
+static time_t official_compile_time;
static char inname[FILENAME_MAX];
static char outname[FILENAME_MAX];
static char errname[FILENAME_MAX];
static int globallineno; /* for forward-reference tracking */
/* static int pass = 0; */
-static struct ofmt *ofmt = NULL;
+struct ofmt *ofmt = &OF_DEFAULT;
+const struct dfmt *dfmt;
static FILE *error_file; /* Where to write error messages */
-static FILE *ofile = NULL;
+FILE *ofile = NULL;
int optimizing = -1; /* number of optimization passes to take */
static int sb, cmd_sb = 16; /* by default */
static uint32_t cmd_cpu = IF_PLEVEL; /* highest level by default */
* not preprocess their source file.
*/
-static void no_pp_reset(char *, int, efunc, evalfunc, ListGen *, StrList **);
+static void no_pp_reset(char *, int, ListGen *, StrList **);
static char *no_pp_getline(void);
static void no_pp_cleanup(int);
static Preproc no_pp = {
if (depend_file && strcmp(depend_file, "-")) {
deps = fopen(depend_file, "w");
if (!deps) {
- report_error(ERR_NONFATAL|ERR_NOFILE|ERR_USAGE,
+ nasm_error(ERR_NONFATAL|ERR_NOFILE|ERR_USAGE,
"unable to write dependency file `%s'", depend_file);
return;
}
} else {
deps = stdout;
}
-
+
linepos = fprintf(deps, "%s:", depend_target);
for (l = list; l; l = l->next) {
len = strlen(l->str);
linepos += len+1;
}
fprintf(deps, "\n\n");
-
+
for (l = list; l; l = nl) {
if (depend_emit_phony)
fprintf(deps, "%s:\n\n", l->str);
-
+
nl = l->next;
nasm_free(l);
}
pass0 = 0;
want_usage = terminate_after_phase = false;
- report_error = report_error_gnu;
+ nasm_set_verror(nasm_verror_gnu);
error_file = stderr;
tolower_init();
- nasm_set_malloc_error(report_error);
+ nasm_init_malloc_error();
offsets = raa_init();
forwrefs = saa_init((int32_t)sizeof(struct forwrefinfo));
seg_init();
- register_output_formats();
-
/* Define some macros dependent on the runtime, but not
on the command line. */
define_macros_early();
if (ofmt->stdmac)
pp_extra_stdmac(ofmt->stdmac);
- parser_global_info(ofmt, &location);
+ parser_global_info(&location);
eval_global_info(ofmt, lookup_label, &location);
/* define some macros dependent of command-line */
if (depend_missing_ok)
pp_include_path(NULL); /* "assume generated" */
- preproc->reset(inname, 0, report_error, evaluate, &nasmlist,
- depend_ptr);
+ preproc->reset(inname, 0, &nasmlist, depend_ptr);
if (outname[0] == '\0')
- ofmt->filename(inname, outname, report_error);
+ ofmt->filename(inname, outname);
ofile = NULL;
while ((line = preproc->getline()))
nasm_free(line);
if (*outname) {
ofile = fopen(outname, "w");
if (!ofile)
- report_error(ERR_FATAL | ERR_NOFILE,
+ nasm_error(ERR_FATAL | ERR_NOFILE,
"unable to open output file `%s'",
outname);
} else
location.known = false;
/* pass = 1; */
- preproc->reset(inname, 3, report_error, evaluate, &nasmlist,
- depend_ptr);
+ preproc->reset(inname, 3, &nasmlist, depend_ptr);
while ((line = preproc->getline())) {
/*
fclose(ofile);
if (ofile && terminate_after_phase)
remove(outname);
+ ofile = NULL;
}
break;
* the name of the input file and then put that inside the
* file.
*/
- ofmt->filename(inname, outname, report_error);
+ ofmt->filename(inname, outname);
ofile = fopen(outname, (ofmt->flags & OFMT_TEXT) ? "w" : "wb");
if (!ofile) {
- report_error(ERR_FATAL | ERR_NOFILE,
+ nasm_error(ERR_FATAL | ERR_NOFILE,
"unable to open output file `%s'", outname);
}
*/
init_labels();
- ofmt->init(ofile, report_error, define_label, evaluate);
- ofmt->current_dfmt->init(ofmt, NULL, ofile, report_error);
+ ofmt->init();
+ dfmt = ofmt->current_dfmt;
+ dfmt->init();
assemble_file(inname, depend_ptr);
if (!terminate_after_phase) {
ofmt->cleanup(using_debug_info);
cleanup_labels();
- } else {
- /*
- * Despite earlier comments, we need this fclose.
- * The object output drivers only fclose on cleanup,
- * and we just skipped that.
- */
- fclose (ofile);
+ fflush(ofile);
+ if (ferror(ofile)) {
+ nasm_error(ERR_NONFATAL|ERR_NOFILE,
+ "write error on output file `%s'", outname);
+ }
+ }
- remove(outname);
- }
+ if (ofile) {
+ fclose(ofile);
+ if (terminate_after_phase)
+ remove(outname);
+ ofile = NULL;
+ }
}
break;
}
*advance = true;
return q;
}
- report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"option `-%c' requires an argument", p[1]);
return NULL;
}
size_t len = strlen(src);
if (len >= (size_t)FILENAME_MAX) {
- report_error(ERR_FATAL | ERR_NOFILE, "file name too long");
+ nasm_error(ERR_FATAL | ERR_NOFILE, "file name too long");
return;
}
strncpy(dst, src, FILENAME_MAX);
case 'f': /* output format */
ofmt = ofmt_find(param);
if (!ofmt) {
- report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
"unrecognised output format `%s' - "
"use -hf for a list", param);
}
break;
default:
- report_error(ERR_FATAL,
+ nasm_error(ERR_FATAL,
"unknown optimization option -O%c\n",
*param);
break;
case 'F': /* specify debug format */
ofmt->current_dfmt = dfmt_find(ofmt, param);
if (!ofmt->current_dfmt) {
- report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
"unrecognized debug format `%s' for"
" output format `%s'",
param, ofmt->shortname);
case 'X': /* specify error reporting format */
if (nasm_stricmp("vc", param) == 0)
- report_error = report_error_vc;
+ nasm_set_verror(nasm_verror_vc);
else if (nasm_stricmp("gnu", param) == 0)
- report_error = report_error_gnu;
+ nasm_set_verror(nasm_verror_gnu);
else
- report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
"unrecognized error reporting format `%s'",
param);
break;
case 'w':
if (param[0] != '+' && param[0] != '-') {
- report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"invalid option to `-w'");
break;
}
for (i = 1; i <= ERR_WARN_MAX; i++)
warning_on_global[i] = !do_warn;
else
- report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"invalid warning `%s'", param);
break;
advance = true;
break;
default:
- report_error(ERR_NONFATAL|ERR_NOFILE|ERR_USAGE,
+ nasm_error(ERR_NONFATAL|ERR_NOFILE|ERR_USAGE,
"unknown dependency option `-M%c'", p[2]);
break;
}
if (advance && (!q || !q[0])) {
- report_error(ERR_NONFATAL|ERR_NOFILE|ERR_USAGE,
+ nasm_error(ERR_NONFATAL|ERR_NOFILE|ERR_USAGE,
"option `-M%c' requires a parameter", p[2]);
break;
}
case OPT_POSTFIX:
{
if (!q) {
- report_error(ERR_NONFATAL | ERR_NOFILE |
+ nasm_error(ERR_NONFATAL | ERR_NOFILE |
ERR_USAGE,
"option `--%s' requires an argument",
p + 2);
}
default:
{
- report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"unrecognised option `--%s'", p + 2);
break;
}
default:
if (!ofmt->setinfo(GI_SWITCH, &p))
- report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"unrecognised option `-%c'", p[1]);
break;
}
} else {
if (*inname) {
- report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"more than one input file specified");
} else {
copy_filename(inname, p);
process_respfile(rfile);
fclose(rfile);
} else
- report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"unable to open response file `%s'", p);
}
} else
/* Look for basic command line typos. This definitely doesn't
catch all errors, but it might help cases of fumbled fingers. */
if (!*inname)
- report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"no input file specified");
else if (!strcmp(inname, errname) ||
!strcmp(inname, outname) ||
!strcmp(inname, listname) ||
(depend_file && !strcmp(inname, depend_file)))
- report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
"file `%s' is both input and output file",
inname);
error_file = fopen(errname, "w");
if (!error_file) {
error_file = stderr; /* Revert to default! */
- report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
+ nasm_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE,
"cannot open file `%s' for error messages",
errname);
}
}
}
-/* List of directives */
-enum directives {
- D_NONE, D_ABSOLUTE, D_BITS, D_COMMON, D_CPU, D_DEBUG, D_DEFAULT,
- D_EXTERN, D_FLOAT, D_GLOBAL, D_LIST, D_SECTION, D_SEGMENT, D_WARNING
-};
-static const char *directives[] = {
- "", "absolute", "bits", "common", "cpu", "debug", "default",
- "extern", "float", "global", "list", "section", "segment", "warning"
-};
static enum directives getkw(char **directive, char **value);
static void assemble_file(char *fname, StrList **depend_ptr)
int pass_max;
if (cmd_sb == 32 && cmd_cpu < IF_386)
- report_error(ERR_FATAL, "command line: "
+ nasm_error(ERR_FATAL, "command line: "
"32-bit segment size requires a higher cpu");
pass_max = prev_offset_changed = (INT_MAX >> 1) + 2; /* Almost unlimited */
cpu = cmd_cpu;
if (pass0 == 2) {
if (*listname)
- nasmlist.init(listname, report_error);
+ nasmlist.init(listname, nasm_error);
}
in_abs_seg = false;
global_offset_changed = 0; /* set by redefine_label */
raa_free(offsets);
offsets = raa_init();
}
- preproc->reset(fname, pass1, report_error, evaluate, &nasmlist,
+ preproc->reset(fname, pass1, &nasmlist,
pass1 == 2 ? depend_ptr : NULL);
memcpy(warning_on, warning_on_global, (ERR_WARN_MAX+1) * sizeof(bool));
case D_SECTION:
seg = ofmt->section(value, pass2, &sb);
if (seg == NO_SEG) {
- report_error(pass1 == 1 ? ERR_NONFATAL : ERR_PANIC,
+ nasm_error(pass1 == 1 ? ERR_NONFATAL : ERR_PANIC,
"segment name `%s' not recognized",
value);
} else {
q++;
}
if (!validid) {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"identifier expected after EXTERN");
break;
}
if (!is_extern(value)) { /* allow re-EXTERN to be ignored */
int temp = pass0;
pass0 = 1; /* fake pass 1 in labels.c */
- declare_as_global(value, special,
- report_error);
+ declare_as_global(value, special);
define_label(value, seg_alloc(), 0L, NULL,
- false, true, ofmt, report_error);
+ false, true);
pass0 = temp;
}
} /* else pass0 == 1 */
q++;
}
if (!validid) {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"identifier expected after GLOBAL");
break;
}
special = q;
} else
special = NULL;
- declare_as_global(value, special, report_error);
+ declare_as_global(value, special);
} /* pass == 1 */
break;
case D_COMMON: /* [COMMON symbol size:special] */
p++;
}
if (!validid) {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"identifier expected after COMMON");
break;
}
}
size = readnum(p, &rn_error);
if (rn_error) {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"invalid size specified"
" in COMMON declaration");
break;
}
} else {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"no size specified in"
" COMMON declaration");
break;
}
if (pass0 < 2) {
- define_common(value, seg_alloc(), size,
- special, ofmt, report_error);
+ define_common(value, seg_alloc(), size, special);
} else if (pass0 == 2) {
if (special)
ofmt->symdef(value, 0L, 0L, 3, special);
stdscan_bufptr = value;
tokval.t_type = TOKEN_INVALID;
e = evaluate(stdscan, NULL, &tokval, NULL, pass2,
- report_error, NULL);
+ nasm_error, NULL);
if (e) {
if (!is_reloc(e))
- report_error(pass0 ==
+ nasm_error(pass0 ==
1 ? ERR_NONFATAL : ERR_PANIC,
"cannot use non-relocatable expression as "
"ABSOLUTE address");
} else if (passn == 1)
abs_offset = 0x100; /* don't go near zero in case of / */
else
- report_error(ERR_PANIC, "invalid ABSOLUTE address "
+ nasm_error(ERR_PANIC, "invalid ABSOLUTE address "
"in pass two");
in_abs_seg = true;
location.segment = NO_SEG;
}
*q++ = 0;
if (!validid) {
- report_error(passn == 1 ? ERR_NONFATAL : ERR_PANIC,
+ nasm_error(passn == 1 ? ERR_NONFATAL : ERR_PANIC,
"identifier expected after DEBUG");
break;
}
while (*p && nasm_isspace(*p))
p++;
if (pass0 == 2)
- ofmt->current_dfmt->debug_directive(debugid, p);
+ dfmt->debug_directive(debugid, p);
break;
case D_WARNING: /* [WARNING {+|-|*}warn-name] */
while (*value && nasm_isspace(*value))
}
}
else
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"invalid warning id in WARNING directive");
break;
case D_CPU: /* [CPU] */
break;
case D_FLOAT:
if (float_option(value)) {
- report_error(pass1 == 1 ? ERR_NONFATAL : ERR_PANIC,
+ nasm_error(pass1 == 1 ? ERR_NONFATAL : ERR_PANIC,
"unknown 'float' directive: %s",
value);
}
break;
default:
- if (!ofmt->directive(directive, value, pass2))
- report_error(pass1 == 1 ? ERR_NONFATAL : ERR_PANIC,
+ if (!d || !ofmt->directive(d, value, pass2))
+ nasm_error(pass1 == 1 ? ERR_NONFATAL : ERR_PANIC,
"unrecognised directive [%s]",
directive);
+ break;
}
if (err) {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"invalid parameter to [%s] directive",
directive);
}
} else { /* it isn't a directive */
-
- parse_line(pass1, line, &output_ins,
- report_error, evaluate, def_label);
+ parse_line(pass1, line, &output_ins, def_label);
if (optimizing > 0) {
if (forwref != NULL && globallineno == forwref->lineno) {
&& forwref->lineno == globallineno);
} else
output_ins.forw_ref = false;
-
+
if (output_ins.forw_ref) {
if (passn == 1) {
for (i = 0; i < output_ins.operands; i++) {
* in the normal place.
*/
if (!output_ins.label)
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"EQU not preceded by label");
else if (output_ins.label[0] != '.' ||
def_label(output_ins.label,
output_ins.oprs[0].segment,
output_ins.oprs[0].offset, NULL,
- false, isext, ofmt,
- report_error);
+ false, isext);
} else if (output_ins.operands == 2
&& (output_ins.oprs[0].type & IMMEDIATE)
&& (output_ins.oprs[0].type & COLON)
def_label(output_ins.label,
output_ins.oprs[0].offset | SEG_ABS,
output_ins.oprs[1].offset,
- NULL, false, false, ofmt,
- report_error);
+ NULL, false, false);
} else
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"bad syntax for EQU");
}
} else {
define_label(output_ins.label,
output_ins.oprs[0].segment,
output_ins.oprs[0].offset,
- NULL, false, false, ofmt,
- report_error);
+ NULL, false, false);
} else if (output_ins.operands == 2
&& (output_ins.oprs[0].
type & IMMEDIATE)
output_ins.oprs[0].
offset | SEG_ABS,
output_ins.oprs[1].offset,
- NULL, false, false, ofmt,
- report_error);
+ NULL, false, false);
} else
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"bad syntax for EQU");
}
}
if (pass1 == 1) {
int64_t l = insn_size(location.segment, offs, sb, cpu,
- &output_ins, report_error);
+ &output_ins, nasm_error);
/* if (using_debug_info) && output_ins.opcode != -1) */
if (using_debug_info)
}
- ofmt->current_dfmt->debug_typevalue(typeinfo);
-
+ dfmt->debug_typevalue(typeinfo);
}
if (l != -1) {
offs += l;
} else {
offs += assemble(location.segment, offs, sb, cpu,
- &output_ins, ofmt, report_error,
+ &output_ins, ofmt, nasm_error,
&nasmlist);
SET_CURR_OFFS(offs);
} /* end while (line = preproc->getline... */
if (pass0 == 2 && global_offset_changed && !terminate_after_phase)
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"phase error detected at end of assembly.");
if (pass1 == 1)
/* We get here if the labels don't converge
* Example: FOO equ FOO + 1
*/
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"Can't find valid values for all labels "
"after %d passes, giving up.", passn);
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"Possible causes: recursive EQUs, macro abuse.");
break;
}
*buf++ = '\0';
}
- return bsii(*directive, directives, elements(directives));
+ return find_directive(*directive);
}
/**
* @param severity the severity of the warning or error
* @param fmt the printf style format string
*/
-static void report_error_gnu(int severity, const char *fmt, ...)
+static void nasm_verror_gnu(int severity, const char *fmt, va_list ap)
{
- va_list ap;
char *currentfile = NULL;
int32_t lineno = 0;
fputs("nasm: ", error_file);
}
- va_start(ap, fmt);
- report_error_common(severity, fmt, ap);
- va_end(ap);
+ nasm_verror_common(severity, fmt, ap);
}
/**
* @param severity the severity of the warning or error
* @param fmt the printf style format string
*/
-static void report_error_vc(int severity, const char *fmt, ...)
+static void nasm_verror_vc(int severity, const char *fmt, va_list ap)
{
- va_list ap;
char *currentfile = NULL;
int32_t lineno = 0;
fputs("nasm: ", error_file);
}
- va_start(ap, fmt);
- report_error_common(severity, fmt, ap);
- va_end(ap);
+ nasm_verror_common(severity, fmt, ap);
}
/**
* @param severity the severity of the warning or error
* @param fmt the printf style format string
*/
-static void report_error_common(int severity, const char *fmt,
- va_list args)
+static void nasm_verror_common(int severity, const char *fmt, va_list args)
{
char msg[1024];
const char *pfx;
-
+
switch (severity & (ERR_MASK|ERR_NO_SEVERITY)) {
case ERR_WARNING:
pfx = "warning: ";
if (ofile) {
fclose(ofile);
remove(outname);
+ ofile = NULL;
}
if (want_usage)
usage();
fputs("type `nasm -h' for help\n", error_file);
}
-static void register_output_formats(void)
-{
- ofmt = ofmt_register(report_error);
-}
-
#define BUF_DELTA 512
static FILE *no_pp_fp;
-static efunc no_pp_err;
static ListGen *no_pp_list;
static int32_t no_pp_lineinc;
-static void no_pp_reset(char *file, int pass, efunc error, evalfunc eval,
- ListGen * listgen, StrList **deplist)
+static void no_pp_reset(char *file, int pass, ListGen * listgen,
+ StrList **deplist)
{
src_set_fname(nasm_strdup(file));
src_set_linnum(0);
no_pp_lineinc = 1;
- no_pp_err = error;
no_pp_fp = fopen(file, "r");
if (!no_pp_fp)
- no_pp_err(ERR_FATAL | ERR_NOFILE,
- "unable to open input file `%s'", file);
+ nasm_error(ERR_FATAL | ERR_NOFILE,
+ "unable to open input file `%s'", file);
no_pp_list = listgen;
(void)pass; /* placate compilers */
- (void)eval; /* placate compilers */
if (deplist) {
StrList *sl = nasm_malloc(strlen(file)+1+sizeof sl->next);
!nasm_stricmp(value, "itanic") || !nasm_stricmp(value, "merced"))
return IF_IA64;
- report_error(pass0 < 2 ? ERR_NONFATAL : ERR_FATAL,
+ nasm_error(pass0 < 2 ? ERR_NONFATAL : ERR_FATAL,
"unknown 'cpu' type");
return IF_PLEVEL; /* the maximum level */
return i; /* set for a 16-bit segment */
else if (i == 32) {
if (cpu < IF_386) {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"cannot specify 32-bit segment on processor below a 386");
i = 16;
}
} else if (i == 64) {
if (cpu < IF_X86_64) {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"cannot specify 64-bit segment on processor below an x86-64");
i = 16;
}
if (i != maxbits) {
- report_error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"%s output format does not support 64-bit code",
ofmt->shortname);
i = 16;
}
} else {
- report_error(pass0 < 2 ? ERR_NONFATAL : ERR_FATAL,
+ nasm_error(pass0 < 2 ? ERR_NONFATAL : ERR_FATAL,
"`%s' is not a valid segment size; must be 16, 32 or 64",
value);
i = 16;
#include "nasmlib.h"
#include "preproc.h"
#include "insnsi.h" /* For enum opcode */
+#include "directives.h" /* For enum directive */
#define NO_SEG -1L /* null segment value */
#define SEG_ABS 0x40000000L /* mask for far-absolute segments */
* should affect the local-label system), or something odder like
* an EQU or a segment-base symbol, which shouldn't.
*/
-typedef void (*ldfunc) (char *label, int32_t segment, int64_t offset,
- char *special, bool is_norm, bool isextrn,
- struct ofmt * ofmt, efunc error);
+typedef void (*ldfunc)(char *label, int32_t segment, int64_t offset,
+ char *special, bool is_norm, bool isextrn);
+void define_label(char *label, int32_t segment, int64_t offset,
+ char *special, bool is_norm, bool isextrn);
/*
* List-file generators should look like this:
* of the pass, an error reporting function, an evaluator
* function, and a listing generator to talk to.
*/
- void (*reset) (char *, int, efunc, evalfunc, ListGen *, StrList **);
+ void (*reset) (char *, int, ListGen *, StrList **);
/*
* Called to fetch a line of preprocessed source. The line
* an output format, be sure to set this to whatever default you want
*
*/
- struct dfmt *current_dfmt;
+ const struct dfmt *current_dfmt;
/*
* This, if non-NULL, is a NULL-terminated list of `char *'s
macros_t *stdmac;
/*
- * This procedure is called at the start of an output session.
- * It tells the output format what file it will be writing to,
- * what routine to report errors through, and how to interface
- * to the label manager and expression evaluator if necessary.
- * It also gives it a chance to do other initialisation.
+ * This procedure is called at the start of an output session to set
+ * up internal parameters.
*/
- void (*init) (FILE * fp, efunc error, ldfunc ldef, evalfunc eval);
+ void (*init)(void);
/*
* This procedure is called to pass generic information to the
* should also return non-zero if it correctly processes the
* directive.
*/
- int (*directive) (char *directive, char *value, int pass);
+ int (*directive)(enum directives directive, char *value, int pass);
/*
* This procedure is called before anything else - even before
* The parameter `outname' points to an area of storage
* guaranteed to be at least FILENAME_MAX in size.
*/
- void (*filename) (char *inname, char *outname, efunc error);
+ void (*filename) (char *inname, char *outname);
/*
* This procedure is called after assembly finishes, to allow
void (*cleanup) (int debuginfo);
};
+extern struct ofmt *ofmt;
+extern FILE *ofile;
/*
* ------------------------------------------------------------
const char *shortname;
/*
- * init - called initially to set up local pointer to object format,
- * void pointer to implementation defined data, file pointer (which
- * probably won't be used, but who knows?), and error function.
+ * init - called initially to set up local pointer to object format.
*/
- void (*init) (struct ofmt * of, void *id, FILE * fp, efunc error);
+ void (*init)(void);
/*
* linenum - called any time there is output with a change of
* line number or file.
*/
- void (*linenum) (const char *filename, int32_t linenumber, int32_t segto);
+ void (*linenum)(const char *filename, int32_t linenumber, int32_t segto);
/*
* debug_deflabel - called whenever a label is defined. Parameters
* would be called before the output format version.
*/
- void (*debug_deflabel) (char *name, int32_t segment, int64_t offset,
- int is_global, char *special);
+ void (*debug_deflabel)(char *name, int32_t segment, int64_t offset,
+ int is_global, char *special);
/*
* debug_directive - called whenever a DEBUG directive other than 'LINE'
* is encountered. 'directive' contains the first parameter to the
* function with 'directive' equal to "VAR" and 'params' equal to
* "_somevar:int".
*/
- void (*debug_directive) (const char *directive, const char *params);
+ void (*debug_directive)(const char *directive, const char *params);
/*
* typevalue - called whenever the assembler wishes to register a type
* for the last defined label. This routine MUST detect if a type was
* already registered and not re-register it.
*/
- void (*debug_typevalue) (int32_t type);
+ void (*debug_typevalue)(int32_t type);
/*
* debug_output - called whenever output is required
* 'type' is the type of info required, and this is format-specific
*/
- void (*debug_output) (int type, void *param);
+ void (*debug_output)(int type, void *param);
/*
* cleanup - called after processing of file is complete
*/
- void (*cleanup) (void);
-
+ void (*cleanup)(void);
};
+
+extern const struct dfmt *dfmt;
+
/*
* The type definition macros
* for debugging
#include "insns.h"
int globalbits = 0; /* defined in nasm.h, works better here for ASM+DISASM */
-efunc nasm_malloc_error; /* Exported for the benefit of vsnprintf.c */
+static vefunc nasm_verror; /* Global error handling function */
#ifdef LOGALLOC
static FILE *logfp;
nasm_tolower_tab[i] = tolower(i);
}
-void nasm_set_malloc_error(efunc error)
+void nasm_set_verror(vefunc ve)
+{
+ nasm_verror = ve;
+}
+
+void nasm_error(int severity, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ nasm_verror(severity, fmt, ap);
+ va_end(ap);
+}
+
+void nasm_init_malloc_error(void)
{
- nasm_malloc_error = error;
#ifdef LOGALLOC
logfp = fopen("malloc.log", "w");
setvbuf(logfp, NULL, _IOLBF, BUFSIZ);
{
void *p = malloc(size);
if (!p)
- nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
+ nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory");
#ifdef LOGALLOC
else
fprintf(logfp, "%s %d malloc(%ld) returns %p\n",
{
void *p = calloc(size, 1);
if (!p)
- nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
+ nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory");
#ifdef LOGALLOC
else
fprintf(logfp, "%s %d calloc(%ld, 1) returns %p\n",
{
void *p = q ? realloc(q, size) : malloc(size);
if (!p)
- nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
+ nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory");
#ifdef LOGALLOC
else if (q)
fprintf(logfp, "%s %d realloc(%p,%ld) returns %p\n",
p = malloc(size);
if (!p)
- nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
+ nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory");
#ifdef LOGALLOC
else
fprintf(logfp, "%s %d strdup(%ld) returns %p\n",
p = malloc(size);
if (!p)
- nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
+ nasm_error(ERR_FATAL | ERR_NOFILE, "out of memory");
#ifdef LOGALLOC
else
fprintf(logfp, "%s %d strndup(%ld) returns %p\n",
no_return nasm_assert_failed(const char *file, int line, const char *msg)
{
- nasm_malloc_error(ERR_FATAL, "assertion %s failed at %s:%d",
- msg, file, line);
+ nasm_error(ERR_FATAL, "assertion %s failed at %s:%d", msg, file, line);
exit(1);
}
}
if (warn)
- nasm_malloc_error(ERR_WARNING | ERR_PASS1 | ERR_WARN_NOV,
- "numeric constant %s does not fit in 64 bits",
- str);
+ nasm_error(ERR_WARNING | ERR_PASS1 | ERR_WARN_NOV,
+ "numeric constant %s does not fit in 64 bits",
+ str);
return result * sign;
}
return count;
}
-void standard_extension(char *inname, char *outname, char *extension,
- efunc error)
+void standard_extension(char *inname, char *outname, char *extension)
{
char *p, *q;
p++; /* go back to end if none found */
if (!strcmp(p, extension)) { /* is the extension already there? */
if (*extension)
- error(ERR_WARNING | ERR_NOFILE,
- "file name already ends in `%s': "
- "output will be in `nasm.out'", extension);
+ nasm_error(ERR_WARNING | ERR_NOFILE,
+ "file name already ends in `%s': "
+ "output will be in `nasm.out'", extension);
else
- error(ERR_WARNING | ERR_NOFILE,
- "file name already has no extension: "
- "output will be in `nasm.out'");
+ nasm_error(ERR_WARNING | ERR_NOFILE,
+ "file name already has no extension: "
+ "output will be in `nasm.out'");
strcpy(outname, "nasm.out");
} else
strcpy(p, extension);
* An error reporting function should look like this.
*/
typedef void (*efunc) (int severity, const char *fmt, ...);
-extern efunc nasm_malloc_error;
+typedef void (*vefunc) (int severity, const char *fmt, va_list ap);
+void nasm_error(int severity, const char *fmt, ...);
+void nasm_set_verror(vefunc);
/*
* These are the error severity codes which get passed as the first
* passed a NULL pointer; nasm_free will do nothing if it is passed
* a NULL pointer.
*/
-void nasm_set_malloc_error(efunc);
+void nasm_init_malloc_error(void);
#ifndef LOGALLOC
void *nasm_malloc(size_t);
void *nasm_zalloc(size_t);
* many output formats will be able to make use of this: a standard
* function to add an extension to the name of the input file
*/
-#ifdef NASM_NASM_H
-void standard_extension(char *inname, char *outname, char *extension,
- efunc error);
-#endif
+void standard_extension(char *inname, char *outname, char *extension);
/*
* Utility macros...
static void output_ins(uint32_t, uint8_t *, int, char *);
static void skip(uint32_t dist, FILE * fp);
-static void ndisasm_error(int severity, const char *fmt, ...)
+static void ndisasm_verror(int severity, const char *fmt, va_list va)
{
- va_list va;
-
- va_start(va, fmt);
vfprintf(stderr, fmt, va);
if (severity & ERR_FATAL)
FILE *fp;
tolower_init();
- nasm_set_malloc_error(ndisasm_error);
+ nasm_set_verror(ndisasm_verror);
+ nasm_init_malloc_error();
offset = 0;
init_sync();
#include "nasm.h"
#include "nasmlib.h"
-void null_debug_init(struct ofmt *of, void *id, FILE * fp, efunc error)
+void null_debug_init(void)
{
- (void)of;
- (void)id;
- (void)fp;
- (void)error;
}
+
void null_debug_linenum(const char *filename, int32_t linenumber, int32_t segto)
{
(void)filename;
(void)linenumber;
(void)segto;
}
+
void null_debug_deflabel(char *name, int32_t segment, int64_t offset,
int is_global, char *special)
{
(void)is_global;
(void)special;
}
+
void null_debug_routine(const char *directive, const char *params)
{
(void)directive;
(void)params;
}
+
void null_debug_typevalue(int32_t type)
{
(void)type;
}
+
void null_debug_output(int type, void *param)
{
(void)type;
(void)param;
}
+
void null_debug_cleanup(void)
{
}
--- /dev/null
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 1996-2009 The NASM Authors - All Rights Reserved
+ * See the file AUTHORS included with the NASM distribution for
+ * the specific copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include "nasm.h"
+#include "nasmlib.h"
+#include "output/outlib.h"
+
+int null_setinfo(enum geninfo type, char **string)
+{
+ (void)type;
+ (void)string;
+ return 0;
+}
+
+int null_directive(enum directives directive, char *value, int pass)
+{
+ (void)directive;
+ (void)value;
+ (void)pass;
+ return 0;
+}
#include "saa.h"
#include "raa.h"
#include "stdscan.h"
+#include "eval.h"
#include "output/outform.h"
#include "output/outlib.h"
static struct Symbol *fwds;
-static FILE *aoutfp;
-static efunc error;
-static evalfunc evaluate;
-
static int bsd;
static int is_pic;
static int32_t aout_got_sect, aout_plt_sect;
static int32_t aout_sym_sect;
-static void aoutg_init(FILE * fp, efunc errfunc, ldfunc ldef,
- evalfunc eval)
+static void aoutg_init(void)
{
- aoutfp = fp;
- error = errfunc;
- evaluate = eval;
- (void)ldef; /* placate optimisers */
stext.data = saa_init(1L);
stext.head = NULL;
stext.tail = &stext.head;
#ifdef OF_AOUT
-static void aout_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void aout_init(void)
{
bsd = false;
- aoutg_init(fp, errfunc, ldef, eval);
+ aoutg_init();
aout_gotpc_sect = aout_gotoff_sect = aout_got_sect =
aout_plt_sect = aout_sym_sect = NO_SEG;
extern struct ofmt of_aoutb;
-static void aoutb_init(FILE * fp, efunc errfunc, ldfunc ldef,
- evalfunc eval)
+static void aoutb_init(void)
{
bsd = true;
- aoutg_init(fp, errfunc, ldef, eval);
+ aoutg_init();
is_pic = 0x00; /* may become 0x40 */
aout_gotpc_sect = seg_alloc();
- ldef("..gotpc", aout_gotpc_sect + 1, 0L, NULL, false, false, &of_aoutb,
- error);
+ define_label("..gotpc", aout_gotpc_sect + 1, 0L, NULL, false, false);
aout_gotoff_sect = seg_alloc();
- ldef("..gotoff", aout_gotoff_sect + 1, 0L, NULL, false, false,
- &of_aoutb, error);
+ define_label("..gotoff", aout_gotoff_sect + 1, 0L, NULL, false, false);
aout_got_sect = seg_alloc();
- ldef("..got", aout_got_sect + 1, 0L, NULL, false, false, &of_aoutb,
- error);
+ define_label("..got", aout_got_sect + 1, 0L, NULL, false, false);
aout_plt_sect = seg_alloc();
- ldef("..plt", aout_plt_sect + 1, 0L, NULL, false, false, &of_aoutb,
- error);
+ define_label("..plt", aout_plt_sect + 1, 0L, NULL, false, false);
aout_sym_sect = seg_alloc();
- ldef("..sym", aout_sym_sect + 1, 0L, NULL, false, false, &of_aoutb,
- error);
+ define_label("..sym", aout_sym_sect + 1, 0L, NULL, false, false);
}
#endif
aout_fixup_relocs(&stext);
aout_fixup_relocs(&sdata);
aout_write();
- fclose(aoutfp);
saa_free(stext.data);
while (stext.head) {
r = stext.head;
if (strcmp(name, "..gotpc") && strcmp(name, "..gotoff") &&
strcmp(name, "..got") && strcmp(name, "..plt") &&
strcmp(name, "..sym"))
- error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
return;
}
stdscan_reset();
stdscan_bufptr = p;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, NULL, 1, error, NULL);
+ e = evaluate(stdscan, NULL, &tokval, NULL, 1, nasm_error, NULL);
if (e) {
if (!is_simple(e))
- error(ERR_NONFATAL, "cannot use relocatable"
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
" expression as symbol size");
else
(*s)->size = reloc_value(e);
!nasm_strnicmp(special, "object", n))
sym->type |= SYM_DATA;
else
- error(ERR_NONFATAL, "unrecognised symbol type `%.*s'",
+ nasm_error(ERR_NONFATAL, "unrecognised symbol type `%.*s'",
n, special);
if (special[n]) {
struct tokenval tokval;
char *saveme = stdscan_bufptr; /* bugfix? fbk 8/10/00 */
if (!bsd) {
- error(ERR_NONFATAL, "Linux a.out does not support"
+ nasm_error(ERR_NONFATAL, "Linux a.out does not support"
" symbol size information");
} else {
while (special[n] && nasm_isspace(special[n]))
stdscan_reset();
stdscan_bufptr = special + n;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, &fwd, 0, error,
+ e = evaluate(stdscan, NULL, &tokval, &fwd, 0, nasm_error,
NULL);
if (fwd) {
sym->nextfwd = fwds;
sym->name = nasm_strdup(name);
} else if (e) {
if (!is_simple(e))
- error(ERR_NONFATAL, "cannot use relocatable"
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
" expression as symbol size");
else
sym->size = reloc_value(e);
nsyms++; /* and another for the size */
if (special && !special_used)
- error(ERR_NONFATAL, "no special symbol features supported here");
+ nasm_error(ERR_NONFATAL, "no special symbol features supported here");
}
static void aout_add_reloc(struct Section *sect, int32_t segment,
shead = sbss.gsyms;
if (!shead) {
if (exact && offset != 0)
- error(ERR_NONFATAL, "unable to find a suitable global symbol"
+ nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol"
" for this reference");
else
aout_add_reloc(sect, segment, type, bytes);
sym = sm;
}
if (!sym && exact) {
- error(ERR_NONFATAL, "unable to find a suitable global symbol"
+ nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol"
" for this reference");
return 0;
}
else if (segment == sbss.index)
asym = sbss.asym;
if (!asym)
- error(ERR_NONFATAL, "`..gotoff' relocations require a non-global"
+ nasm_error(ERR_NONFATAL, "`..gotoff' relocations require a non-global"
" symbol in the section");
r = *sect->tail = nasm_malloc(sizeof(struct Reloc));
*/
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
" space");
return;
}
else if (segto == sbss.index)
s = NULL;
else {
- error(ERR_WARNING, "attempt to assemble code in"
+ nasm_error(ERR_WARNING, "attempt to assemble code in"
" segment %d: defaulting to `.text'", segto);
s = &stext;
}
if (!s && type != OUT_RESERVE) {
- error(ERR_WARNING, "attempt to initialize memory in the"
+ nasm_error(ERR_WARNING, "attempt to initialize memory in the"
" BSS section: ignored");
sbss.len += realsize(type, size);
return;
if (type == OUT_RESERVE) {
if (s) {
- error(ERR_WARNING, "uninitialized space declared in"
+ nasm_error(ERR_WARNING, "uninitialized space declared in"
" %s section: zeroing",
(segto == stext.index ? "code" : "data"));
aout_sect_write(s, NULL, size);
sbss.len += size;
} else if (type == OUT_RAWDATA) {
if (segment != NO_SEG)
- error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
+ nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
aout_sect_write(s, data, size);
} else if (type == OUT_ADDRESS) {
addr = *(int64_t *)data;
if (segment != NO_SEG) {
if (segment % 2) {
- error(ERR_NONFATAL, "a.out format does not support"
+ nasm_error(ERR_NONFATAL, "a.out format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
aout_add_reloc(s, segment, RELTYPE_ABSOLUTE,
size);
} else if (!bsd) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"Linux a.out format does not support"
" any use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
false);
} else if (wrt == aout_plt_sect + 1) {
is_pic = 0x40;
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"a.out format cannot produce non-PC-"
"relative PLT references");
} else {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"a.out format does not support this"
" use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
aout_sect_write(s, mydata, size);
} else if (type == OUT_REL2ADR) {
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL2ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR");
if (segment != NO_SEG && segment % 2) {
- error(ERR_NONFATAL, "a.out format does not support"
+ nasm_error(ERR_NONFATAL, "a.out format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
aout_add_reloc(s, segment, RELTYPE_RELATIVE, 2);
} else if (!bsd) {
- error(ERR_NONFATAL, "Linux a.out format does not support"
+ nasm_error(ERR_NONFATAL, "Linux a.out format does not support"
" any use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
} else if (wrt == aout_plt_sect + 1) {
} else if (wrt == aout_gotpc_sect + 1 ||
wrt == aout_gotoff_sect + 1 ||
wrt == aout_got_sect + 1) {
- error(ERR_NONFATAL, "a.out format cannot produce PC-"
+ nasm_error(ERR_NONFATAL, "a.out format cannot produce PC-"
"relative GOT references");
} else {
- error(ERR_NONFATAL, "a.out format does not support this"
+ nasm_error(ERR_NONFATAL, "a.out format does not support this"
" use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
}
aout_sect_write(s, mydata, 2L);
} else if (type == OUT_REL4ADR) {
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL4ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR");
if (segment != NO_SEG && segment % 2) {
- error(ERR_NONFATAL, "a.out format does not support"
+ nasm_error(ERR_NONFATAL, "a.out format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
aout_add_reloc(s, segment, RELTYPE_RELATIVE, 4);
} else if (!bsd) {
- error(ERR_NONFATAL, "Linux a.out format does not support"
+ nasm_error(ERR_NONFATAL, "Linux a.out format does not support"
" any use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
} else if (wrt == aout_plt_sect + 1) {
} else if (wrt == aout_gotpc_sect + 1 ||
wrt == aout_gotoff_sect + 1 ||
wrt == aout_got_sect + 1) {
- error(ERR_NONFATAL, "a.out format cannot produce PC-"
+ nasm_error(ERR_NONFATAL, "a.out format cannot produce PC-"
"relative GOT references");
} else {
- error(ERR_NONFATAL, "a.out format does not support this"
+ nasm_error(ERR_NONFATAL, "a.out format does not support this"
" use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
}
* Emit the a.out header.
*/
/* OMAGIC, M_386 or MID_I386, no flags */
- fwriteint32_t(bsd ? 0x07018600 | is_pic : 0x640107L, aoutfp);
- fwriteint32_t(stext.len, aoutfp);
- fwriteint32_t(sdata.len, aoutfp);
- fwriteint32_t(sbss.len, aoutfp);
- fwriteint32_t(nsyms * 12, aoutfp); /* length of symbol table */
- fwriteint32_t(0L, aoutfp); /* object files have no entry point */
- fwriteint32_t(stext.nrelocs * 8, aoutfp); /* size of text relocs */
- fwriteint32_t(sdata.nrelocs * 8, aoutfp); /* size of data relocs */
+ fwriteint32_t(bsd ? 0x07018600 | is_pic : 0x640107L, ofile);
+ fwriteint32_t(stext.len, ofile);
+ fwriteint32_t(sdata.len, ofile);
+ fwriteint32_t(sbss.len, ofile);
+ fwriteint32_t(nsyms * 12, ofile); /* length of symbol table */
+ fwriteint32_t(0L, ofile); /* object files have no entry point */
+ fwriteint32_t(stext.nrelocs * 8, ofile); /* size of text relocs */
+ fwriteint32_t(sdata.nrelocs * 8, ofile); /* size of data relocs */
/*
* Write out the code section and the data section.
*/
- saa_fpwrite(stext.data, aoutfp);
- saa_fpwrite(sdata.data, aoutfp);
+ saa_fpwrite(stext.data, ofile);
+ saa_fpwrite(sdata.data, ofile);
/*
* Write out the relocations.
/*
* And the string table.
*/
- fwriteint32_t(strslen + 4, aoutfp); /* length includes length count */
- saa_fpwrite(strs, aoutfp);
+ fwriteint32_t(strslen + 4, ofile); /* length includes length count */
+ saa_fpwrite(strs, ofile);
}
static void aout_write_relocs(struct Reloc *r)
while (r) {
uint32_t word2;
- fwriteint32_t(r->address, aoutfp);
+ fwriteint32_t(r->address, ofile);
if (r->symbol >= 0)
word2 = r->symbol;
word2 |= r->reltype << 24;
word2 |= (r->bytes == 1 ? 0 :
r->bytes == 2 ? 0x2000000L : 0x4000000L);
- fwriteint32_t(word2, aoutfp);
+ fwriteint32_t(word2, ofile);
r = r->next;
}
saa_rewind(syms);
for (i = 0; i < nsyms; i++) {
struct Symbol *sym = saa_rstruct(syms);
- fwriteint32_t(sym->strpos, aoutfp);
- fwriteint32_t((int32_t)sym->type & ~SYM_WITH_SIZE, aoutfp);
+ fwriteint32_t(sym->strpos, ofile);
+ fwriteint32_t((int32_t)sym->type & ~SYM_WITH_SIZE, ofile);
/*
* Fix up the symbol value now we know the final section
* sizes.
sym->value += stext.len;
if ((sym->type & SECT_MASK) == SECT_BSS)
sym->value += stext.len + sdata.len;
- fwriteint32_t(sym->value, aoutfp);
+ fwriteint32_t(sym->value, ofile);
/*
* Output a size record if necessary.
*/
if (sym->type & SYM_WITH_SIZE) {
- fwriteint32_t(sym->strpos, aoutfp);
- fwriteint32_t(0x0DL, aoutfp); /* special value: means size */
- fwriteint32_t(sym->size, aoutfp);
+ fwriteint32_t(sym->strpos, ofile);
+ fwriteint32_t(0x0DL, ofile); /* special value: means size */
+ fwriteint32_t(sym->size, ofile);
i++; /* use up another of `nsyms' */
}
}
return segment;
}
-static int aout_directive(char *directive, char *value, int pass)
+static void aout_filename(char *inname, char *outname)
{
- (void)directive;
- (void)value;
- (void)pass;
- return 0;
-}
-
-static void aout_filename(char *inname, char *outname, efunc error)
-{
- standard_extension(inname, outname, ".o", error);
+ standard_extension(inname, outname, ".o");
}
extern macros_t aout_stdmac[];
-static int aout_set_info(enum geninfo type, char **val)
-{
- (void)type;
- (void)val;
- return 0;
-}
#endif /* OF_AOUT || OF_AOUTB */
#ifdef OF_AOUT
&null_debug_form,
aout_stdmac,
aout_init,
- aout_set_info,
+ null_setinfo,
aout_out,
aout_deflabel,
aout_section_names,
aout_segbase,
- aout_directive,
+ null_directive,
aout_filename,
aout_cleanup
};
&null_debug_form,
aout_stdmac,
aoutb_init,
- aout_set_info,
+ null_setinfo,
aout_out,
aout_deflabel,
aout_section_names,
aout_segbase,
- aout_directive,
+ null_directive,
aout_filename,
aout_cleanup
};
static int as86_reloc_size;
-static FILE *as86fp;
-static efunc error;
-
static void as86_write(void);
static void as86_write_section(struct Section *, int);
static int as86_add_string(char *name);
static void as86_sect_write(struct Section *, const uint8_t *,
uint32_t);
-static void as86_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void as86_init(void)
{
- as86fp = fp;
- error = errfunc;
- (void)ldef; /* placate optimisers */
- (void)eval;
stext.data = saa_init(1L);
stext.datalen = 0L;
stext.head = stext.last = NULL;
(void)debuginfo;
as86_write();
- fclose(as86fp);
saa_free(stext.data);
while (stext.head) {
p = stext.head;
struct Symbol *sym;
if (special)
- error(ERR_NONFATAL, "as86 format does not support any"
+ nasm_error(ERR_NONFATAL, "as86 format does not support any"
" special symbol types");
if (name[0] == '.' && name[1] == '.' && name[2] != '@') {
if (strcmp(name, "..start")) {
- error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
return;
} else {
is_start = true;
if (wrt != NO_SEG) {
wrt = NO_SEG; /* continue to do _something_ */
- error(ERR_NONFATAL, "WRT not supported by as86 output format");
+ nasm_error(ERR_NONFATAL, "WRT not supported by as86 output format");
}
/*
*/
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
" space");
return;
}
else if (segto == bssindex)
s = NULL;
else {
- error(ERR_WARNING, "attempt to assemble code in"
+ nasm_error(ERR_WARNING, "attempt to assemble code in"
" segment %d: defaulting to `.text'", segto);
s = &stext;
}
if (!s && type != OUT_RESERVE) {
- error(ERR_WARNING, "attempt to initialize memory in the"
+ nasm_error(ERR_WARNING, "attempt to initialize memory in the"
" BSS section: ignored");
bsslen += realsize(type, size);
return;
if (type == OUT_RESERVE) {
if (s) {
- error(ERR_WARNING, "uninitialized space declared in"
+ nasm_error(ERR_WARNING, "uninitialized space declared in"
" %s section: zeroing",
(segto == stext.index ? "code" : "data"));
as86_sect_write(s, NULL, size);
bsslen += size;
} else if (type == OUT_RAWDATA) {
if (segment != NO_SEG)
- error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
+ nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
as86_sect_write(s, data, size);
as86_add_piece(s, 0, 0L, 0L, size, 0);
} else if (type == OUT_ADDRESS) {
if (segment != NO_SEG) {
if (segment % 2) {
- error(ERR_NONFATAL, "as86 format does not support"
+ nasm_error(ERR_NONFATAL, "as86 format does not support"
" segment base references");
} else {
offset = *(int64_t *)data;
}
} else if (type == OUT_REL2ADR) {
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL2ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR");
if (segment != NO_SEG) {
if (segment % 2) {
- error(ERR_NONFATAL, "as86 format does not support"
+ nasm_error(ERR_NONFATAL, "as86 format does not support"
" segment base references");
} else {
offset = *(int64_t *)data;
}
} else if (type == OUT_REL4ADR) {
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL4ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR");
if (segment != NO_SEG) {
if (segment % 2) {
- error(ERR_NONFATAL, "as86 format does not support"
+ nasm_error(ERR_NONFATAL, "as86 format does not support"
" segment base references");
} else {
offset = *(int64_t *)data;
/*
* Emit the as86 header.
*/
- fwriteint32_t(0x000186A3L, as86fp);
- fputc(0x2A, as86fp);
- fwriteint32_t(27 + symlen + seglen + strslen, as86fp); /* header length */
- fwriteint32_t(stext.len + sdata.len + bsslen, as86fp);
- fwriteint16_t(strslen, as86fp);
- fwriteint16_t(0, as86fp); /* class = revision = 0 */
- fwriteint32_t(0x55555555L, as86fp); /* segment max sizes: always this */
- fwriteint32_t(segsize, as86fp); /* segment size descriptors */
+ fwriteint32_t(0x000186A3L, ofile);
+ fputc(0x2A, ofile);
+ fwriteint32_t(27 + symlen + seglen + strslen, ofile); /* header length */
+ fwriteint32_t(stext.len + sdata.len + bsslen, ofile);
+ fwriteint16_t(strslen, ofile);
+ fwriteint16_t(0, ofile); /* class = revision = 0 */
+ fwriteint32_t(0x55555555L, ofile); /* segment max sizes: always this */
+ fwriteint32_t(segsize, ofile); /* segment size descriptors */
if (segsize & 0x01000000L)
- fwriteint32_t(stext.len, as86fp);
+ fwriteint32_t(stext.len, ofile);
else
- fwriteint16_t(stext.len, as86fp);
+ fwriteint16_t(stext.len, ofile);
if (segsize & 0x40000000L)
- fwriteint32_t(sdata.len + bsslen, as86fp);
+ fwriteint32_t(sdata.len + bsslen, ofile);
else
- fwriteint16_t(sdata.len + bsslen, as86fp);
- fwriteint16_t(nsyms, as86fp);
+ fwriteint16_t(sdata.len + bsslen, ofile);
+ fwriteint16_t(nsyms, ofile);
/*
* Write the symbol table.
saa_rewind(syms);
for (i = 0; i < nsyms; i++) {
struct Symbol *sym = saa_rstruct(syms);
- fwriteint16_t(sym->strpos, as86fp);
- fwriteint16_t(sym->flags, as86fp);
+ fwriteint16_t(sym->strpos, ofile);
+ fwriteint16_t(sym->flags, ofile);
switch (sym->flags & (3 << 14)) {
case 0 << 14:
break;
case 1 << 14:
- fputc(sym->value, as86fp);
+ fputc(sym->value, ofile);
break;
case 2 << 14:
- fwriteint16_t(sym->value, as86fp);
+ fwriteint16_t(sym->value, ofile);
break;
case 3 << 14:
- fwriteint32_t(sym->value, as86fp);
+ fwriteint32_t(sym->value, ofile);
break;
}
}
/*
* Write out the string table.
*/
- saa_fpwrite(strs, as86fp);
+ saa_fpwrite(strs, ofile);
/*
* Write the program text.
* Append the BSS section to the .data section
*/
if (bsslen > 65535L) {
- fputc(0x13, as86fp);
- fwriteint32_t(bsslen, as86fp);
+ fputc(0x13, ofile);
+ fwriteint32_t(bsslen, ofile);
} else if (bsslen > 255) {
- fputc(0x12, as86fp);
- fwriteint16_t(bsslen, as86fp);
+ fputc(0x12, ofile);
+ fwriteint16_t(bsslen, ofile);
} else if (bsslen) {
- fputc(0x11, as86fp);
- fputc(bsslen, as86fp);
+ fputc(0x11, ofile);
+ fputc(bsslen, ofile);
}
- fputc(0, as86fp); /* termination */
+ fputc(0, ofile); /* termination */
}
static void as86_set_rsize(int size)
if (as86_reloc_size != size) {
switch (as86_reloc_size = size) {
case 1:
- fputc(0x01, as86fp);
+ fputc(0x01, ofile);
break;
case 2:
- fputc(0x02, as86fp);
+ fputc(0x02, ofile);
break;
case 4:
- fputc(0x03, as86fp);
+ fputc(0x03, ofile);
break;
default:
- error(ERR_PANIC, "bizarre relocation size %d", size);
+ nasm_error(ERR_PANIC, "bizarre relocation size %d", size);
+ break;
}
}
}
uint32_t s;
int32_t length;
- fputc(0x20 + index, as86fp); /* select the right section */
+ fputc(0x20 + index, ofile); /* select the right section */
saa_rewind(sect->data);
do {
char buf[64];
int32_t tmplen = (length > 64 ? 64 : length);
- fputc(0x40 | (tmplen & 0x3F), as86fp);
+ fputc(0x40 | (tmplen & 0x3F), ofile);
saa_rnbytes(sect->data, buf, tmplen);
- fwrite(buf, 1, tmplen, as86fp);
+ fwrite(buf, 1, tmplen, ofile);
length -= tmplen;
} while (length > 0);
break;
if (p->number == SECT_BSS)
p->number = SECT_DATA, p->offset += sdata.len;
as86_set_rsize(p->bytes);
- fputc(0x80 | (p->relative ? 0x20 : 0) | p->number, as86fp);
+ fputc(0x80 | (p->relative ? 0x20 : 0) | p->number, ofile);
if (as86_reloc_size == 2)
- fwriteint16_t(p->offset, as86fp);
+ fwriteint16_t(p->offset, ofile);
else
- fwriteint32_t(p->offset, as86fp);
+ fwriteint32_t(p->offset, ofile);
break;
case 2:
/*
s = 0;
fputc(0xC0 |
(p->relative ? 0x20 : 0) |
- (p->number > 255 ? 0x04 : 0) | s, as86fp);
+ (p->number > 255 ? 0x04 : 0) | s, ofile);
if (p->number > 255)
- fwriteint16_t(p->number, as86fp);
+ fwriteint16_t(p->number, ofile);
else
- fputc(p->number, as86fp);
+ fputc(p->number, ofile);
switch ((int)s) {
case 0:
break;
case 1:
- fputc(p->offset, as86fp);
+ fputc(p->offset, ofile);
break;
case 2:
- fwriteint16_t(p->offset, as86fp);
+ fwriteint16_t(p->offset, ofile);
break;
case 3:
- fwriteint32_t(p->offset, as86fp);
+ fwriteint32_t(p->offset, ofile);
break;
}
break;
return segment;
}
-static int as86_directive(char *directive, char *value, int pass)
-{
- (void)directive;
- (void)value;
- (void)pass;
- return 0;
-}
-
-static void as86_filename(char *inname, char *outname, efunc error)
+static void as86_filename(char *inname, char *outname)
{
char *p;
} else
strcpy(as86_module, inname);
- standard_extension(inname, outname, ".o", error);
+ standard_extension(inname, outname, ".o");
}
extern macros_t as86_stdmac[];
-static int as86_set_info(enum geninfo type, char **val)
-{
- (void)type;
- (void)val;
- return 0;
-}
-void as86_linenumber(char *name, int32_t segment, int32_t offset, int is_main,
- int lineno)
-{
- (void)name;
- (void)segment;
- (void)offset;
- (void)is_main;
- (void)lineno;
-}
struct ofmt of_as86 = {
"Linux as86 (bin86 version 0.3) object files",
"as86",
&null_debug_form,
as86_stdmac,
as86_init,
- as86_set_info,
+ null_setinfo,
as86_out,
as86_deflabel,
as86_section_names,
as86_segbase,
- as86_directive,
+ null_directive,
as86_filename,
as86_cleanup
};
#ifdef OF_BIN
-static FILE *fp, *rf = NULL;
-static efunc error;
-static struct ofmt *my_ofmt;
+static FILE *rf = NULL;
static void (*do_output)(void);
/* Section flags keep track of which attributes the user has defined. */
if (s->flags & (START_DEFINED | ALIGN_DEFINED | FOLLOWS_DEFINED)) { /* Check for a mixture of real and virtual section attributes. */
if (s->flags & (VSTART_DEFINED | VALIGN_DEFINED |
VFOLLOWS_DEFINED))
- error(ERR_FATAL|ERR_NOFILE,
+ nasm_error(ERR_FATAL|ERR_NOFILE,
"cannot mix real and virtual attributes"
" in nobits section (%s)", s->name);
/* Real and virtual attributes mean the same thing for nobits sections. */
s && strcmp(s->name, g->follows);
sp = &s->next, s = s->next) ;
if (!s)
- error(ERR_FATAL|ERR_NOFILE, "section %s follows an invalid or"
+ nasm_error(ERR_FATAL|ERR_NOFILE, "section %s follows an invalid or"
" unknown section (%s)", g->name, g->follows);
if (s->next && (s->next->flags & FOLLOWS_DEFINED) &&
!strcmp(s->name, s->next->follows))
- error(ERR_FATAL|ERR_NOFILE, "sections %s and %s can't both follow"
+ nasm_error(ERR_FATAL|ERR_NOFILE, "sections %s and %s can't both follow"
" section %s", g->name, s->next->name, s->name);
/* Find the end of the current follows group (gs). */
for (gsp = &g->next, gs = g->next;
if (sections->flags & START_DEFINED) {
/* Make sure this section doesn't begin before the origin. */
if (sections->start < origin)
- error(ERR_FATAL|ERR_NOFILE, "section %s begins"
+ nasm_error(ERR_FATAL|ERR_NOFILE, "section %s begins"
" before program origin", sections->name);
} else if (sections->flags & ALIGN_DEFINED) {
sections->start = ((origin + sections->align - 1) &
/* Check for section overlap. */
if (s) {
if (s->start < origin)
- error(ERR_FATAL|ERR_NOFILE, "section %s beings before program origin",
+ nasm_error(ERR_FATAL|ERR_NOFILE, "section %s beings before program origin",
s->name);
if (g->start > s->start)
- error(ERR_FATAL|ERR_NOFILE, "sections %s ~ %s and %s overlap!",
+ nasm_error(ERR_FATAL|ERR_NOFILE, "sections %s ~ %s and %s overlap!",
gs->name, g->name, s->name);
if (pend > s->start)
- error(ERR_FATAL|ERR_NOFILE, "sections %s and %s overlap!",
+ nasm_error(ERR_FATAL|ERR_NOFILE, "sections %s and %s overlap!",
g->name, s->name);
}
/* Remember this section as the latest >0 length section. */
for (s = sections; s && strcmp(g->vfollows, s->name);
s = s->next) ;
if (!s)
- error(ERR_FATAL|ERR_NOFILE,
+ nasm_error(ERR_FATAL|ERR_NOFILE,
"section %s vfollows unknown section (%s)",
g->name, g->vfollows);
} else if (g->ifollows != NULL)
for (h = 0, s = sections; s; s = s->next) {
if (!(s->flags & VSTART_DEFINED)) { /* Non-fatal errors after assembly has completed are generally a
* no-no, but we'll throw a fatal one eventually so it's ok. */
- error(ERR_NONFATAL, "cannot compute vstart for section %s",
+ nasm_error(ERR_NONFATAL, "cannot compute vstart for section %s",
s->name);
h++;
}
}
if (h)
- error(ERR_FATAL|ERR_NOFILE, "circular vfollows path detected");
+ nasm_error(ERR_FATAL|ERR_NOFILE, "circular vfollows path detected");
#ifdef DEBUG
fprintf(stdout,
/* Step 6: Write the section data to the output file. */
do_output();
- fclose(fp); /* Done with the output file */
/* Step 7: Generate the map file. */
if (wrt != NO_SEG) {
wrt = NO_SEG; /* continue to do _something_ */
- error(ERR_NONFATAL, "WRT not supported by binary output format");
+ nasm_error(ERR_NONFATAL, "WRT not supported by binary output format");
}
/* Handle absolute-assembly (structure definitions). */
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in"
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in"
" [ABSOLUTE] space");
return;
}
/* Find the segment we are targeting. */
s = find_section_by_index(segto);
if (!s)
- error(ERR_PANIC, "code directed to nonexistent segment?");
+ nasm_error(ERR_PANIC, "code directed to nonexistent segment?");
/* "Smart" section-type adaptation code. */
if (!(s->flags & TYPE_DEFINED)) {
}
if ((s->flags & TYPE_NOBITS) && (type != OUT_RESERVE))
- error(ERR_WARNING, "attempt to initialize memory in a"
+ nasm_error(ERR_WARNING, "attempt to initialize memory in a"
" nobits section: ignored");
if (type == OUT_ADDRESS) {
if (segment != NO_SEG && !find_section_by_index(segment)) {
if (segment % 2)
- error(ERR_NONFATAL, "binary output format does not support"
+ nasm_error(ERR_NONFATAL, "binary output format does not support"
" segment base references");
else
- error(ERR_NONFATAL, "binary output format does not support"
+ nasm_error(ERR_NONFATAL, "binary output format does not support"
" external references");
segment = NO_SEG;
}
s->length += size;
} else if (type == OUT_RESERVE) {
if (s->flags & TYPE_PROGBITS) {
- error(ERR_WARNING, "uninitialized space declared in"
+ nasm_error(ERR_WARNING, "uninitialized space declared in"
" %s section: zeroing", s->name);
saa_wbytes(s->contents, NULL, size);
}
size = realsize(type, size);
if (segment != NO_SEG && !find_section_by_index(segment)) {
if (segment % 2)
- error(ERR_NONFATAL, "binary output format does not support"
+ nasm_error(ERR_NONFATAL, "binary output format does not support"
" segment base references");
else
- error(ERR_NONFATAL, "binary output format does not support"
+ nasm_error(ERR_NONFATAL, "binary output format does not support"
" external references");
segment = NO_SEG;
}
(void)offset; /* Don't warn that this parameter is unused */
if (special)
- error(ERR_NONFATAL, "binary format does not support any"
+ nasm_error(ERR_NONFATAL, "binary format does not support any"
" special symbol types");
else if (name[0] == '.' && name[1] == '.' && name[2] != '@')
- error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
else if (is_global == 2)
- error(ERR_NONFATAL, "binary output format does not support common"
+ nasm_error(ERR_NONFATAL, "binary output format does not support common"
" variables");
else {
struct Section *s;
break;
}
if (!**line) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"invalid syntax in `section' directive");
return -1;
}
++(*line);
}
if (!**line) {
- error(ERR_NONFATAL, "expecting `)'");
+ nasm_error(ERR_NONFATAL, "expecting `)'");
return -1;
}
}
/* Check for no value given. */
if (!*exp) {
- error(ERR_WARNING, "No value given to attribute in"
+ nasm_error(ERR_WARNING, "No value given to attribute in"
" `section' directive");
return -1;
}
stdscan_reset();
stdscan_bufptr = exp;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, NULL, 1, error, NULL);
+ e = evaluate(stdscan, NULL, &tokval, NULL, 1, nasm_error, NULL);
if (e) {
if (!is_really_simple(e)) {
- error(ERR_NONFATAL, "section attribute value must be"
+ nasm_error(ERR_NONFATAL, "section attribute value must be"
" a critical expression");
return -1;
}
} else {
- error(ERR_NONFATAL, "Invalid attribute value"
+ nasm_error(ERR_NONFATAL, "Invalid attribute value"
" specified in `section' directive.");
return -1;
}
*astring = '\0';
astring++;
}
- error(ERR_WARNING, "ignoring unknown section attribute:"
+ nasm_error(ERR_WARNING, "ignoring unknown section attribute:"
" \"%s\"", p);
}
continue;
case ATTRIB_NOBITS:
if ((sec->flags & TYPE_DEFINED)
&& (sec->flags & TYPE_PROGBITS))
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"attempt to change section type"
" from progbits to nobits");
else
/* Handle progbits attribute. */
case ATTRIB_PROGBITS:
if ((sec->flags & TYPE_DEFINED) && (sec->flags & TYPE_NOBITS))
- error(ERR_NONFATAL, "attempt to change section type"
+ nasm_error(ERR_NONFATAL, "attempt to change section type"
" from nobits to progbits");
else
sec->flags |= TYPE_DEFINED | TYPE_PROGBITS;
/* Handle align attribute. */
case ATTRIB_ALIGN:
if (!format_mode && (!strcmp(sec->name, ".text")))
- error(ERR_NONFATAL, "cannot specify an alignment"
+ nasm_error(ERR_NONFATAL, "cannot specify an alignment"
" to the .text section");
else {
if (!value || ((value - 1) & value))
- error(ERR_NONFATAL, "argument to `align' is not a"
+ nasm_error(ERR_NONFATAL, "argument to `align' is not a"
" power of two");
else { /* Alignment is already satisfied if the previous
* align value is greater. */
/* Don't allow a conflicting align value. */
if ((sec->flags & START_DEFINED)
&& (sec->start & (value - 1)))
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"`align' value conflicts "
"with section start address");
else {
/* Handle valign attribute. */
case ATTRIB_VALIGN:
if (!value || ((value - 1) & value))
- error(ERR_NONFATAL, "argument to `valign' is not a"
+ nasm_error(ERR_NONFATAL, "argument to `valign' is not a"
" power of two");
else { /* Alignment is already satisfied if the previous
* align value is greater. */
/* Don't allow a conflicting valign value. */
if ((sec->flags & VSTART_DEFINED)
&& (sec->vstart & (value - 1)))
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"`valign' value conflicts "
"with `vstart' address");
else {
/* Handle start attribute. */
case ATTRIB_START:
if (sec->flags & FOLLOWS_DEFINED)
- error(ERR_NONFATAL, "cannot combine `start' and `follows'"
+ nasm_error(ERR_NONFATAL, "cannot combine `start' and `follows'"
" section attributes");
else if ((sec->flags & START_DEFINED) && (value != sec->start))
- error(ERR_NONFATAL, "section start address redefined");
+ nasm_error(ERR_NONFATAL, "section start address redefined");
else {
sec->start = value;
sec->flags |= START_DEFINED;
if (sec->flags & ALIGN_DEFINED) {
if (sec->start & (sec->align - 1))
- error(ERR_NONFATAL, "`start' address conflicts"
+ nasm_error(ERR_NONFATAL, "`start' address conflicts"
" with section alignment");
sec->flags ^= ALIGN_DEFINED;
}
/* Handle vstart attribute. */
case ATTRIB_VSTART:
if (sec->flags & VFOLLOWS_DEFINED)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"cannot combine `vstart' and `vfollows'"
" section attributes");
else if ((sec->flags & VSTART_DEFINED)
&& (value != sec->vstart))
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"section virtual start address"
" (vstart) redefined");
else {
sec->flags |= VSTART_DEFINED;
if (sec->flags & VALIGN_DEFINED) {
if (sec->vstart & (sec->valign - 1))
- error(ERR_NONFATAL, "`vstart' address conflicts"
+ nasm_error(ERR_NONFATAL, "`vstart' address conflicts"
" with `valign' value");
sec->flags ^= VALIGN_DEFINED;
}
p = astring;
astring += strcspn(astring, " \t");
if (astring == p)
- error(ERR_NONFATAL, "expecting section name for `follows'"
+ nasm_error(ERR_NONFATAL, "expecting section name for `follows'"
" attribute");
else {
*(astring++) = '\0';
if (sec->flags & START_DEFINED)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"cannot combine `start' and `follows'"
" section attributes");
sec->follows = nasm_strdup(p);
/* Handle vfollows attribute. */
case ATTRIB_VFOLLOWS:
if (sec->flags & VSTART_DEFINED)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"cannot combine `vstart' and `vfollows'"
" section attributes");
else {
p = astring;
astring += strcspn(astring, " \t");
if (astring == p)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"expecting section name for `vfollows'"
" attribute");
else {
/* section.<name>.start */
strcpy(label_name + base_len, ".start");
- define_label(label_name, sec->start_index, 0L,
- NULL, 0, 0, my_ofmt, error);
+ define_label(label_name, sec->start_index, 0L, NULL, 0, 0);
/* section.<name>.vstart */
strcpy(label_name + base_len, ".vstart");
- define_label(label_name, sec->vstart_index, 0L,
- NULL, 0, 0, my_ofmt, error);
+ define_label(label_name, sec->vstart_index, 0L, NULL, 0, 0);
nasm_free(label_name);
}
sec->flags |= TYPE_DEFINED | TYPE_NOBITS;
sec->ifollows = NULL;
} else if (!format_mode) {
- error(ERR_NONFATAL, "section name must be "
+ nasm_error(ERR_NONFATAL, "section name must be "
".text, .data, or .bss");
return current_section;
}
return current_section;
}
-static int bin_directive(char *directive, char *args, int pass)
+static int bin_directive(enum directives directive, char *args, int pass)
{
- /* Handle ORG directive */
- if (!nasm_stricmp(directive, "org")) {
+ switch (directive) {
+ case D_ORG:
+ {
struct tokenval tokval;
uint64_t value;
expr *e;
stdscan_reset();
stdscan_bufptr = args;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, NULL, 1, error, NULL);
+ e = evaluate(stdscan, NULL, &tokval, NULL, 1, nasm_error, NULL);
if (e) {
if (!is_really_simple(e))
- error(ERR_NONFATAL, "org value must be a critical"
+ nasm_error(ERR_NONFATAL, "org value must be a critical"
" expression");
else {
value = reloc_value(e);
/* Check for ORG redefinition. */
if (origin_defined && (value != origin))
- error(ERR_NONFATAL, "program origin redefined");
+ nasm_error(ERR_NONFATAL, "program origin redefined");
else {
origin = value;
origin_defined = 1;
}
}
} else
- error(ERR_NONFATAL, "No or invalid offset specified"
+ nasm_error(ERR_NONFATAL, "No or invalid offset specified"
" in ORG directive.");
return 1;
}
-
+ case D_MAP:
+ {
/* The 'map' directive allows the user to generate section
* and symbol information to stdout, stderr, or to a file. */
- else if (format_mode && !nasm_stricmp(directive, "map")) {
- char *p;
-
+ char *p;
+
if (pass != 1)
return 1;
args += strspn(args, " \t");
else { /* Must be a filename. */
rf = fopen(p, "wt");
if (!rf) {
- error(ERR_WARNING, "unable to open map file `%s'",
+ nasm_error(ERR_WARNING, "unable to open map file `%s'",
p);
map_control = 0;
return 1;
}
}
} else
- error(ERR_WARNING, "map file already specified");
+ nasm_error(ERR_WARNING, "map file already specified");
}
if (map_control == 0)
map_control |= MAP_ORIGIN | MAP_SUMMARY;
rf = stdout;
return 1;
}
- return 0;
+ default:
+ return 0;
+ }
}
-static void bin_filename(char *inname, char *outname, efunc error)
+static void bin_filename(char *inname, char *outname)
{
- standard_extension(inname, outname, "", error);
+ standard_extension(inname, outname, "");
infile = inname;
outfile = outname;
}
-static void ith_filename(char *inname, char *outname, efunc error)
+static void ith_filename(char *inname, char *outname)
{
- standard_extension(inname, outname, ".ith", error);
+ standard_extension(inname, outname, ".ith");
infile = inname;
outfile = outname;
}
-static void srec_filename(char *inname, char *outname, efunc error)
+static void srec_filename(char *inname, char *outname)
{
- standard_extension(inname, outname, ".srec", error);
+ standard_extension(inname, outname, ".srec");
infile = inname;
outfile = outname;
}
return 0;
}
-static void binfmt_init(FILE *afp, efunc errfunc, ldfunc ldef, evalfunc eval);
struct ofmt of_bin, of_ith, of_srec;
+static void binfmt_init(void);
static void do_output_bin(void);
static void do_output_ith(void);
static void do_output_srec(void);
-static void bin_init(FILE *afp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void bin_init(void)
{
- my_ofmt = &of_bin;
do_output = do_output_bin;
- binfmt_init(afp, errfunc, ldef, eval);
+ binfmt_init();
}
-static void ith_init(FILE *afp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void ith_init(void)
{
- my_ofmt = &of_ith;
do_output = do_output_ith;
- binfmt_init(afp, errfunc, ldef, eval);
+ binfmt_init();
}
-static void srec_init(FILE *afp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void srec_init(void)
{
- my_ofmt = &of_srec;
do_output = do_output_srec;
- binfmt_init(afp, errfunc, ldef, eval);
+ binfmt_init();
}
-static void binfmt_init(FILE *afp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void binfmt_init(void)
{
- fp = afp;
- error = errfunc;
-
- (void)eval; /* Don't warn that this parameter is unused. */
- (void)ldef; /* Placate optimizers. */
-
maxbits = 64; /* Support 64-bit Segments */
relocs = NULL;
reloctail = &relocs;
/* Pad the space between sections. */
nasm_assert(addr <= s->start);
- fwritezero(s->start - addr, fp);
+ fwritezero(s->start - addr, ofile);
/* Write the section to the output file. */
- saa_fpwrite(s->contents, fp);
+ saa_fpwrite(s->contents, ofile);
/* Keep track of the current file position */
addr = s->start + s->length;
p += sprintf(p, "%02X", dptr[i]);
p += sprintf(p, "%02X\n", csum);
- if (fwrite(buf, 1, p-buf, fp) != (size_t)(p-buf))
+ if (fwrite(buf, 1, p-buf, ofile) != (size_t)(p-buf))
return -1;
return 0;
p += sprintf(p, "%02X", dptr[i]);
p += sprintf(p, "%02X\n", csum);
- if (fwrite(buf, 1, p-buf, fp) != (size_t)(p-buf))
+ if (fwrite(buf, 1, p-buf, ofile) != (size_t)(p-buf))
return -1;
return 0;
#include "nasmlib.h"
#include "saa.h"
#include "raa.h"
+#include "eval.h"
#include "output/outform.h"
#include "output/outlib.h"
int32_t namlen; /* full name length */
};
-static FILE *coffp;
-static efunc error;
static char coff_infile[FILENAME_MAX];
struct Section {
static struct SAA *strs;
static uint32_t strslen;
-static void coff_gen_init(FILE *, efunc);
+static void coff_gen_init(void);
static void coff_sect_write(struct Section *, const uint8_t *,
uint32_t);
static void coff_write(void);
static void coff_write_relocs(struct Section *);
static void coff_write_symbols(void);
-static void coff_win32_init(FILE * fp, efunc errfunc,
- ldfunc ldef, evalfunc eval)
+static void coff_win32_init(void)
{
- win32 = true; win64 = false;
- (void)ldef; /* placate optimizers */
- (void)eval;
- coff_gen_init(fp, errfunc);
+ win32 = true;
+ win64 = false;
+ coff_gen_init();
}
-static void coff_win64_init(FILE * fp, efunc errfunc,
- ldfunc ldef, evalfunc eval)
+static void coff_win64_init(void)
{
- extern struct ofmt of_win64;
-
maxbits = 64;
- win32 = false; win64 = true;
- (void)ldef; /* placate optimizers */
- (void)eval;
- coff_gen_init(fp, errfunc);
+ win32 = false;
+ win64 = true;
+ coff_gen_init();
imagebase_sect = seg_alloc()+1;
- ldef(WRT_IMAGEBASE,imagebase_sect,0,NULL,false,false,&of_win64,errfunc);
+ define_label(WRT_IMAGEBASE, imagebase_sect, 0, NULL, false, false);
}
-static void coff_std_init(FILE * fp, efunc errfunc, ldfunc ldef,
- evalfunc eval)
+static void coff_std_init(void)
{
win32 = win64 = false;
- (void)ldef; /* placate optimizers */
- (void)eval;
- coff_gen_init(fp, errfunc);
+ coff_gen_init();
}
-static void coff_gen_init(FILE * fp, efunc errfunc)
+static void coff_gen_init(void)
{
- coffp = fp;
- error = errfunc;
sects = NULL;
nsects = sectlen = 0;
syms = saa_init(sizeof(struct Symbol));
(void)debuginfo;
coff_write();
- fclose(coffp);
for (i = 0; i < nsects; i++) {
if (sects[i]->data)
saa_free(sects[i]->data);
if (*p)
*p++ = '\0';
if (strlen(name) > 8) {
- error(ERR_WARNING, "COFF section names limited to 8 characters:"
+ nasm_error(ERR_WARNING, "COFF section names limited to 8 characters:"
" truncating");
name[8] = '\0';
}
flags = RDATA_FLAGS;
else {
flags = DATA_FLAGS; /* gotta do something */
- error(ERR_NONFATAL, "standard COFF does not support"
+ nasm_error(ERR_NONFATAL, "standard COFF does not support"
" read-only data sections");
}
} else if (!nasm_stricmp(q, "bss")) {
flags = INFO_FLAGS;
else {
flags = DATA_FLAGS; /* gotta do something */
- error(ERR_NONFATAL, "standard COFF does not support"
+ nasm_error(ERR_NONFATAL, "standard COFF does not support"
" informational sections");
}
} else if (!nasm_strnicmp(q, "align=", 6)) {
if (!(win32 | win64))
- error(ERR_NONFATAL, "standard COFF does not support"
+ nasm_error(ERR_NONFATAL, "standard COFF does not support"
" section alignment specification");
else {
if (q[6 + strspn(q + 6, "0123456789")])
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"argument to `align' is not numeric");
else {
unsigned int align = atoi(q + 6);
if (!align || ((align - 1) & align))
- error(ERR_NONFATAL, "argument to `align' is not a"
+ nasm_error(ERR_NONFATAL, "argument to `align' is not a"
" power of two");
else if (align > 64)
- error(ERR_NONFATAL, "Win32 cannot align sections"
+ nasm_error(ERR_NONFATAL, "Win32 cannot align sections"
" to better than 64-byte boundaries");
else {
align_and = ~0x00F00000L;
sects[i]->flags |= align_or;
} else if (pass == 1) {
if (flags)
- error(ERR_WARNING, "section attributes ignored on"
+ nasm_error(ERR_WARNING, "section attributes ignored on"
" redeclaration of section `%s'", name);
}
struct Symbol *sym;
if (special)
- error(ERR_NONFATAL, "COFF format does not support any"
+ nasm_error(ERR_NONFATAL, "COFF format does not support any"
" special symbol types");
if (name[0] == '.' && name[1] == '.' && name[2] != '@') {
if (strcmp(name,WRT_IMAGEBASE))
- error(ERR_NONFATAL, "unrecognized special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognized special symbol `%s'", name);
return;
}
if (wrt != NO_SEG && !win64) {
wrt = NO_SEG; /* continue to do _something_ */
- error(ERR_NONFATAL, "WRT not supported by COFF output formats");
+ nasm_error(ERR_NONFATAL, "WRT not supported by COFF output formats");
}
/*
*/
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
" space");
return;
}
if (!s) {
int tempint; /* ignored */
if (segto != coff_section_names(".text", 2, &tempint))
- error(ERR_PANIC, "strange segment conditions in COFF driver");
+ nasm_error(ERR_PANIC, "strange segment conditions in COFF driver");
else
s = sects[nsects - 1];
}
wrt = imagebase_sect;
if (!s->data && type != OUT_RESERVE) {
- error(ERR_WARNING, "attempt to initialize memory in"
+ nasm_error(ERR_WARNING, "attempt to initialize memory in"
" BSS section `%s': ignored", s->name);
s->len += realsize(type, size);
return;
if (type == OUT_RESERVE) {
if (s->data) {
- error(ERR_WARNING, "uninitialised space declared in"
+ nasm_error(ERR_WARNING, "uninitialised space declared in"
" non-BSS section `%s': zeroing", s->name);
coff_sect_write(s, NULL, size);
} else
s->len += size;
} else if (type == OUT_RAWDATA) {
if (segment != NO_SEG)
- error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
+ nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
coff_sect_write(s, data, size);
} else if (type == OUT_ADDRESS) {
if (!(win64)) {
if (size != 4 && (segment != NO_SEG || wrt != NO_SEG))
- error(ERR_NONFATAL, "COFF format does not support non-32-bit"
+ nasm_error(ERR_NONFATAL, "COFF format does not support non-32-bit"
" relocations");
else {
int32_t fix = 0;
if (segment != NO_SEG || wrt != NO_SEG) {
if (wrt != NO_SEG) {
- error(ERR_NONFATAL, "COFF format does not support"
+ nasm_error(ERR_NONFATAL, "COFF format does not support"
" WRT types");
} else if (segment % 2) {
- error(ERR_NONFATAL, "COFF format does not support"
+ nasm_error(ERR_NONFATAL, "COFF format does not support"
" segment base references");
} else
fix = coff_add_reloc(s, segment, IMAGE_REL_I386_DIR32);
p = mydata;
if (size == 8) {
if (wrt == imagebase_sect) {
- error(ERR_NONFATAL, "operand size mismatch: 'wrt "
+ nasm_error(ERR_NONFATAL, "operand size mismatch: 'wrt "
WRT_IMAGEBASE "' is a 32-bit operand");
}
fix = coff_add_reloc(s, segment, IMAGE_REL_AMD64_ADDR64);
}
}
} else if (type == OUT_REL2ADR) {
- error(ERR_NONFATAL, "COFF format does not support 16-bit"
+ nasm_error(ERR_NONFATAL, "COFF format does not support 16-bit"
" relocations");
} else if (type == OUT_REL4ADR) {
if (segment == segto && !(win64)) /* Acceptable for RIP-relative */
- error(ERR_PANIC, "intra-segment OUT_REL4ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR");
else if (segment == NO_SEG && win32)
- error(ERR_NONFATAL, "Win32 COFF does not correctly support"
+ nasm_error(ERR_NONFATAL, "Win32 COFF does not correctly support"
" relative references to absolute addresses");
else {
int32_t fix = 0;
if (segment != NO_SEG && segment % 2) {
- error(ERR_NONFATAL, "COFF format does not support"
+ nasm_error(ERR_NONFATAL, "COFF format does not support"
" segment base references");
} else
fix = coff_add_reloc(s, segment,
Exports = NULL;
}
-static int coff_directives(char *directive, char *value, int pass)
+static int coff_directives(enum directives directive, char *value, int pass)
{
- if (!strcmp(directive, "export")) {
+ switch (directive) {
+ case D_EXPORT:
+ {
char *q, *name;
if (pass == 2)
}
if (!*name) {
- error(ERR_NONFATAL, "`export' directive requires export name");
+ nasm_error(ERR_NONFATAL, "`export' directive requires export name");
return 1;
}
if (*q) {
- error(ERR_NONFATAL, "unrecognized export qualifier `%s'", q);
+ nasm_error(ERR_NONFATAL, "unrecognized export qualifier `%s'", q);
return 1;
}
AddExport(name);
return 1;
- } else if (win32 && !strcmp(directive,"safeseh")) {
+ }
+ case D_SAFESEH:
+ {
static int sxseg=-1;
int i;
+
+ if (!win32) /* Only applicable for -f win32 */
+ return 0;
+
if (sxseg==-1)
{ for (i = 0; i < nsects; i++)
if (!strcmp(".sxdata",sects[i]->name))
}
}
if (n == nsyms) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"`safeseh' directive requires valid symbol");
}
}
return 1;
}
- return 0;
+ default:
+ return 0;
+ }
}
static void coff_write(void)
* Output the COFF header.
*/
if (win64)
- fwriteint16_t(0x8664, coffp); /* MACHINE_x86-64 */
+ fwriteint16_t(0x8664, ofile); /* MACHINE_x86-64 */
else
- fwriteint16_t(0x014C, coffp); /* MACHINE_i386 */
- fwriteint16_t(nsects, coffp); /* number of sections */
- fwriteint32_t(time(NULL), coffp); /* time stamp */
- fwriteint32_t(sympos, coffp);
- fwriteint32_t(nsyms + initsym, coffp);
- fwriteint16_t(0, coffp); /* no optional header */
+ fwriteint16_t(0x014C, ofile); /* MACHINE_i386 */
+ fwriteint16_t(nsects, ofile); /* number of sections */
+ fwriteint32_t(time(NULL), ofile); /* time stamp */
+ fwriteint32_t(sympos, ofile);
+ fwriteint32_t(nsyms + initsym, ofile);
+ fwriteint16_t(0, ofile); /* no optional header */
/* Flags: 32-bit, no line numbers. Win32 doesn't even bother with them. */
- fwriteint16_t((win32 | win64) ? 0 : 0x104, coffp);
+ fwriteint16_t((win32 | win64) ? 0 : 0x104, ofile);
/*
* Output the section headers.
*/
for (i = 0; i < nsects; i++)
if (sects[i]->data) {
- saa_fpwrite(sects[i]->data, coffp);
+ saa_fpwrite(sects[i]->data, ofile);
coff_write_relocs(sects[i]);
}
* Output the symbol and string tables.
*/
coff_write_symbols();
- fwriteint32_t(strslen + 4, coffp); /* length includes length count */
- saa_fpwrite(strs, coffp);
+ fwriteint32_t(strslen + 4, ofile); /* length includes length count */
+ saa_fpwrite(strs, ofile);
}
static void coff_section_header(char *name, int32_t vsize,
memset(padname, 0, 8);
strncpy(padname, name, 8);
- fwrite(padname, 8, 1, coffp);
- fwriteint32_t(0, coffp); /* Virtual size field - set to 0 or vsize */
- fwriteint32_t(0L, coffp); /* RVA/offset - we ignore */
- fwriteint32_t(datalen, coffp);
- fwriteint32_t(datapos, coffp);
- fwriteint32_t(relpos, coffp);
- fwriteint32_t(0L, coffp); /* no line numbers - we don't do 'em */
- fwriteint16_t(nrelocs, coffp);
- fwriteint16_t(0, coffp); /* again, no line numbers */
- fwriteint32_t(flags, coffp);
+ fwrite(padname, 8, 1, ofile);
+ fwriteint32_t(0, ofile); /* Virtual size field - set to 0 or vsize */
+ fwriteint32_t(0L, ofile); /* RVA/offset - we ignore */
+ fwriteint32_t(datalen, ofile);
+ fwriteint32_t(datapos, ofile);
+ fwriteint32_t(relpos, ofile);
+ fwriteint32_t(0L, ofile); /* no line numbers - we don't do 'em */
+ fwriteint16_t(nrelocs, ofile);
+ fwriteint16_t(0, ofile); /* again, no line numbers */
+ fwriteint32_t(flags, ofile);
}
static void coff_write_relocs(struct Section *s)
struct Reloc *r;
for (r = s->head; r; r = r->next) {
- fwriteint32_t(r->address, coffp);
+ fwriteint32_t(r->address, ofile);
fwriteint32_t(r->symbol + (r->symbase == REAL_SYMBOLS ? initsym :
r->symbase == ABS_SYMBOL ? initsym - 1 :
r->symbase == SECT_SYMBOLS ? 2 : 0),
- coffp);
- fwriteint16_t(r->type, coffp);
+ ofile);
+ fwriteint16_t(r->type, ofile);
}
}
if (name) {
memset(padname, 0, 8);
strncpy(padname, name, 8);
- fwrite(padname, 8, 1, coffp);
+ fwrite(padname, 8, 1, ofile);
} else {
- fwriteint32_t(0, coffp);
- fwriteint32_t(strpos, coffp);
+ fwriteint32_t(0, ofile);
+ fwriteint32_t(strpos, ofile);
}
- fwriteint32_t(value, coffp);
- fwriteint16_t(section, coffp);
- fwriteint16_t(type, coffp);
- fputc(storageclass, coffp);
- fputc(aux, coffp);
+ fwriteint32_t(value, ofile);
+ fwriteint16_t(section, ofile);
+ fwriteint16_t(type, ofile);
+ fputc(storageclass, ofile);
+ fputc(aux, ofile);
}
static void coff_write_symbols(void)
coff_symbol(".file", 0L, 0L, -2, 0, 0x67, 1);
memset(filename, 0, 18);
strncpy(filename, coff_infile, 18);
- fwrite(filename, 18, 1, coffp);
+ fwrite(filename, 18, 1, ofile);
/*
* The section records, with their auxiliaries.
for (i = 0; i < (uint32_t) nsects; i++) {
coff_symbol(sects[i]->name, 0L, 0L, i + 1, 0, 3, 1);
- fwriteint32_t(sects[i]->len, coffp);
- fwriteint16_t(sects[i]->nrelocs, coffp);
- fwrite(filename, 12, 1, coffp);
+ fwriteint32_t(sects[i]->len, ofile);
+ fwriteint16_t(sects[i]->nrelocs, ofile);
+ fwrite(filename, 12, 1, ofile);
}
/*
return segment;
}
-static void coff_std_filename(char *inname, char *outname, efunc error)
+static void coff_std_filename(char *inname, char *outname)
{
strcpy(coff_infile, inname);
- standard_extension(inname, outname, ".o", error);
+ standard_extension(inname, outname, ".o");
}
-static void coff_win32_filename(char *inname, char *outname, efunc error)
+static void coff_win32_filename(char *inname, char *outname)
{
strcpy(coff_infile, inname);
- standard_extension(inname, outname, ".obj", error);
+ standard_extension(inname, outname, ".obj");
}
extern macros_t coff_stdmac[];
char *name;
} *dbgsect;
-FILE *dbgf;
-efunc dbgef;
-
struct ofmt of_dbg;
-static void dbg_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void dbg_init(void)
{
- (void)eval;
-
- dbgf = fp;
- dbgef = errfunc;
dbgsect = NULL;
- (void)ldef;
- fprintf(fp, "NASM Output format debug dump\n");
+ fprintf(ofile, "NASM Output format debug dump\n");
}
static void dbg_cleanup(int debuginfo)
nasm_free(tmp->name);
nasm_free(tmp);
}
- fclose(dbgf);
}
static int32_t dbg_section_names(char *name, int pass, int *bits)
*bits = 16;
if (!name)
- fprintf(dbgf, "section_name on init: returning %d\n",
+ fprintf(ofile, "section_name on init: returning %d\n",
seg = seg_alloc());
else {
int n = strcspn(name, " \t");
s->number = seg = seg_alloc();
s->next = dbgsect;
dbgsect = s;
- fprintf(dbgf, "section_name %s (pass %d): returning %d\n",
+ fprintf(ofile, "section_name %s (pass %d): returning %d\n",
name, pass, seg);
}
}
static void dbg_deflabel(char *name, int32_t segment, int64_t offset,
int is_global, char *special)
{
- fprintf(dbgf, "deflabel %s := %08"PRIx32":%016"PRIx64" %s (%d)%s%s\n",
+ fprintf(ofile, "deflabel %s := %08"PRIx32":%016"PRIx64" %s (%d)%s%s\n",
name, segment, offset,
is_global == 2 ? "common" : is_global ? "global" : "local",
is_global, special ? ": " : "", special);
int32_t ldata;
int id;
- fprintf(dbgf, "out to %"PRIx32", len = %"PRIu64": ", segto, size);
+ fprintf(ofile, "out to %"PRIx32", len = %"PRIu64": ", segto, size);
switch (type) {
case OUT_RESERVE:
- fprintf(dbgf, "reserved.\n");
+ fprintf(ofile, "reserved.\n");
break;
case OUT_RAWDATA:
- fprintf(dbgf, "raw data = ");
+ fprintf(ofile, "raw data = ");
while (size--) {
id = *(uint8_t *)data;
data = (char *)data + 1;
- fprintf(dbgf, "%02x ", id);
+ fprintf(ofile, "%02x ", id);
}
- fprintf(dbgf, "\n");
+ fprintf(ofile, "\n");
break;
case OUT_ADDRESS:
ldata = *(int64_t *)data;
- fprintf(dbgf, "addr %08"PRIx32" (seg %08"PRIx32", wrt %08"PRIx32")\n", ldata,
+ fprintf(ofile, "addr %08"PRIx32" (seg %08"PRIx32", wrt %08"PRIx32")\n", ldata,
segment, wrt);
break;
case OUT_REL2ADR:
- fprintf(dbgf, "rel2adr %04"PRIx16" (seg %08"PRIx32")\n",
+ fprintf(ofile, "rel2adr %04"PRIx16" (seg %08"PRIx32")\n",
(uint16_t)*(int64_t *)data, segment);
break;
case OUT_REL4ADR:
- fprintf(dbgf, "rel4adr %08"PRIx32" (seg %08"PRIx32")\n",
+ fprintf(ofile, "rel4adr %08"PRIx32" (seg %08"PRIx32")\n",
(uint32_t)*(int64_t *)data,
segment);
break;
case OUT_REL8ADR:
- fprintf(dbgf, "rel8adr %016"PRIx64" (seg %08"PRIx32")\n",
+ fprintf(ofile, "rel8adr %016"PRIx64" (seg %08"PRIx32")\n",
(uint64_t)*(int64_t *)data, segment);
break;
default:
- fprintf(dbgf, "unknown\n");
+ fprintf(ofile, "unknown\n");
break;
}
}
return segment;
}
-static int dbg_directive(char *directive, char *value, int pass)
+static int dbg_directive(enum directives directive, char *value, int pass)
{
- fprintf(dbgf, "directive [%s] value [%s] (pass %d)\n",
- directive, value, pass);
+ fprintf(ofile, "directive [%s] value [%s] (pass %d)\n",
+ directives[directive], value, pass);
return 1;
}
-static void dbg_filename(char *inname, char *outname, efunc error)
+static void dbg_filename(char *inname, char *outname)
{
- standard_extension(inname, outname, ".dbg", error);
+ standard_extension(inname, outname, ".dbg");
}
static int dbg_set_info(enum geninfo type, char **val)
char *types[] = {
"unknown", "label", "byte", "word", "dword", "float", "qword", "tbyte"
};
-void dbgdbg_init(struct ofmt *of, void *id, FILE * fp, efunc error)
+void dbgdbg_init(void)
{
- (void)of;
- (void)id;
- (void)fp;
- (void)error;
- fprintf(fp, " With debug info\n");
+ fprintf(ofile, " With debug info\n");
}
static void dbgdbg_cleanup(void)
{
static void dbgdbg_linnum(const char *lnfname, int32_t lineno, int32_t segto)
{
- fprintf(dbgf, "dbglinenum %s(%"PRId32") := %08"PRIx32"\n",
+ fprintf(ofile, "dbglinenum %s(%"PRId32") := %08"PRIx32"\n",
lnfname, lineno, segto);
}
static void dbgdbg_deflabel(char *name, int32_t segment,
int64_t offset, int is_global, char *special)
{
- fprintf(dbgf, "dbglabel %s := %08"PRIx32":%016"PRIx64" %s (%d)%s%s\n",
+ fprintf(ofile, "dbglabel %s := %08"PRIx32":%016"PRIx64" %s (%d)%s%s\n",
name,
segment, offset,
is_global == 2 ? "common" : is_global ? "global" : "local",
}
static void dbgdbg_define(const char *type, const char *params)
{
- fprintf(dbgf, "dbgdirective [%s] value [%s]\n", type, params);
+ fprintf(ofile, "dbgdirective [%s] value [%s]\n", type, params);
}
static void dbgdbg_output(int output_type, void *param)
{
}
static void dbgdbg_typevalue(int32_t type)
{
- fprintf(dbgf, "new type: %s(%"PRIX32")\n",
+ fprintf(ofile, "new type: %s(%"PRIX32")\n",
types[TYM_TYPE(type) >> 3], TYM_ELEMENTS(type));
}
static struct dfmt debug_debug_form = {
#include "saa.h"
#include "raa.h"
#include "stdscan.h"
+#include "eval.h"
#include "output/outform.h"
#include "output/outlib.h"
#include "rbtree.h"
static struct SAA *strs;
static uint32_t strslen;
-static FILE *elffp;
-static efunc error;
-static evalfunc evaluate;
-
static struct Symbol *fwds;
static char elf_module[FILENAME_MAX];
static void stabs32_cleanup(void);
/* dwarf debugging routines */
-static void dwarf32_init(struct ofmt *, void *, FILE *, efunc);
+static void dwarf32_init(void);
static void dwarf32_linenum(const char *filename, int32_t linenumber, int32_t);
static void dwarf32_output(int, void *);
static void dwarf32_generate(void);
static int32_t elf_got_sect, elf_plt_sect;
static int32_t elf_sym_sect, elf_tlsie_sect;
-static void elf_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void elf_init(void)
{
- elffp = fp;
- error = errfunc;
- evaluate = eval;
- (void)ldef; /* placate optimisers */
sects = NULL;
nsects = sectlen = 0;
syms = saa_init((int32_t)sizeof(struct Symbol));
fwds = NULL;
elf_gotpc_sect = seg_alloc();
- ldef("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false, &of_elf32,
- error);
+ define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false);
elf_gotoff_sect = seg_alloc();
- ldef("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false, &of_elf32,
- error);
+ define_label("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false);
elf_got_sect = seg_alloc();
- ldef("..got", elf_got_sect + 1, 0L, NULL, false, false, &of_elf32,
- error);
+ define_label("..got", elf_got_sect + 1, 0L, NULL, false, false);
elf_plt_sect = seg_alloc();
- ldef("..plt", elf_plt_sect + 1, 0L, NULL, false, false, &of_elf32,
- error);
+ define_label("..plt", elf_plt_sect + 1, 0L, NULL, false, false);
elf_sym_sect = seg_alloc();
- ldef("..sym", elf_sym_sect + 1, 0L, NULL, false, false, &of_elf32,
- error);
+ define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false);
elf_tlsie_sect = seg_alloc();
- ldef("..tlsie", elf_tlsie_sect + 1, 0L, NULL, false, false, &of_elf32,
- error);
+ define_label("..tlsie", elf_tlsie_sect + 1, 0L, NULL, false, false);
def_seg = seg_alloc();
}
-static void elf_init_hack(FILE * fp, efunc errfunc, ldfunc ldef,
- evalfunc eval)
+static void elf_init_hack(void)
{
of_elf32.current_dfmt = of_elf.current_dfmt; /* Sync debugging format */
- elf_init(fp, errfunc, ldef, eval);
+ elf_init();
}
static void elf_cleanup(int debuginfo)
(void)debuginfo;
elf_write();
- fclose(elffp);
for (i = 0; i < nsects; i++) {
if (sects[i]->type != SHT_NOBITS)
saa_free(sects[i]->data);
if (align == 0)
align = 1;
if ((align - 1) & align) { /* means it's not a power of two */
- error(ERR_NONFATAL, "section alignment %d is not"
+ nasm_error(ERR_NONFATAL, "section alignment %d is not"
" a power of two", align);
align = 1;
}
} else if (!nasm_stricmp(q, "nobits")) {
type = SHT_NOBITS;
} else if (pass == 1) {
- error(ERR_WARNING, "Unknown section attribute '%s' ignored on"
+ nasm_error(ERR_WARNING, "Unknown section attribute '%s' ignored on"
" declaration of section `%s'", q, name);
}
}
if (!strcmp(name, ".shstrtab") ||
!strcmp(name, ".symtab") ||
!strcmp(name, ".strtab")) {
- error(ERR_NONFATAL, "attempt to redefine reserved section"
+ nasm_error(ERR_NONFATAL, "attempt to redefine reserved section"
"name `%s'", name);
return NO_SEG;
}
if ((type && sects[i]->type != type)
|| (align && sects[i]->align != align)
|| (flags_and && ((sects[i]->flags & flags_and) != flags_or)))
- error(ERR_WARNING, "section attributes ignored on"
+ nasm_error(ERR_WARNING, "section attributes ignored on"
" redeclaration of section `%s'", name);
}
if (strcmp(name, "..gotpc") && strcmp(name, "..gotoff") &&
strcmp(name, "..got") && strcmp(name, "..plt") &&
strcmp(name, "..sym") && strcmp(name, "..tlsie"))
- error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
return;
}
stdscan_reset();
stdscan_bufptr = p;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, NULL, 1, error, NULL);
+ e = evaluate(stdscan, NULL, &tokval, NULL, 1, nasm_error, NULL);
if (e) {
if (!is_simple(e))
- error(ERR_NONFATAL, "cannot use relocatable"
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
" expression as symbol size");
else
(*s)->size = reloc_value(e);
if (nsects == 0 && segment == def_seg) {
int tempint;
if (segment != elf_section_names(".text", 2, &tempint))
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"strange segment conditions in ELF driver");
sym->section = nsects;
} else {
bool err;
sym->symv.key = readnum(special, &err);
if (err)
- error(ERR_NONFATAL, "alignment constraint `%s' is not a"
+ nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
" valid number", special);
else if ((sym->symv.key | (sym->symv.key - 1))
!= 2 * sym->symv.key - 1)
- error(ERR_NONFATAL, "alignment constraint `%s' is not a"
+ nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
" power of two", special);
}
special_used = true;
else if (!nasm_strnicmp(special, "notype", n))
sym->type |= STT_NOTYPE;
else
- error(ERR_NONFATAL, "unrecognised symbol type `%.*s'",
+ nasm_error(ERR_NONFATAL, "unrecognised symbol type `%.*s'",
n, special);
special += n;
stdscan_reset();
stdscan_bufptr = special + n;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, &fwd, 0, error,
+ e = evaluate(stdscan, NULL, &tokval, &fwd, 0, nasm_error,
NULL);
if (fwd) {
sym->nextfwd = fwds;
sym->name = nasm_strdup(name);
} else if (e) {
if (!is_simple(e))
- error(ERR_NONFATAL, "cannot use relocatable"
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
" expression as symbol size");
else
sym->size = reloc_value(e);
nlocals++;
if (special && !special_used)
- error(ERR_NONFATAL, "no special symbol features supported here");
+ nasm_error(ERR_NONFATAL, "no special symbol features supported here");
}
static void elf_add_reloc(struct Section *sect, int32_t segment, int type)
}
if (!s) {
if (exact && offset != 0)
- error(ERR_NONFATAL, "unable to find a suitable global symbol"
+ nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol"
" for this reference");
else
elf_add_reloc(sect, segment, type);
srb = rb_search(s->gsyms, offset);
if (!srb || (exact && srb->key != offset)) {
- error(ERR_NONFATAL, "unable to find a suitable global symbol"
+ nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol"
" for this reference");
return 0;
}
*/
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
" space");
return;
}
if (!s) {
int tempint; /* ignored */
if (segto != elf_section_names(".text", 2, &tempint))
- error(ERR_PANIC, "strange segment conditions in ELF driver");
+ nasm_error(ERR_PANIC, "strange segment conditions in ELF driver");
else {
s = sects[nsects - 1];
i = nsects - 1;
/* end of debugging stuff */
if (s->type == SHT_NOBITS && type != OUT_RESERVE) {
- error(ERR_WARNING, "attempt to initialize memory in"
+ nasm_error(ERR_WARNING, "attempt to initialize memory in"
" BSS section `%s': ignored", s->name);
s->len += realsize(type, size);
return;
if (type == OUT_RESERVE) {
if (s->type == SHT_PROGBITS) {
- error(ERR_WARNING, "uninitialized space declared in"
+ nasm_error(ERR_WARNING, "uninitialized space declared in"
" non-BSS section `%s': zeroing", s->name);
elf_sect_write(s, NULL, size);
} else
s->len += size;
} else if (type == OUT_RAWDATA) {
if (segment != NO_SEG)
- error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
+ nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
elf_sect_write(s, data, size);
} else if (type == OUT_ADDRESS) {
bool gnu16 = false;
addr = *(int64_t *)data;
if (segment != NO_SEG) {
if (segment % 2) {
- error(ERR_NONFATAL, "ELF format does not support"
+ nasm_error(ERR_NONFATAL, "ELF format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
R_386_32, false);
}
} else if (wrt == elf_plt_sect + 1) {
- error(ERR_NONFATAL, "ELF format cannot produce non-PC-"
+ nasm_error(ERR_NONFATAL, "ELF format cannot produce non-PC-"
"relative PLT references");
} else {
- error(ERR_NONFATAL, "ELF format does not support this"
+ nasm_error(ERR_NONFATAL, "ELF format does not support this"
" use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
}
}
p = mydata;
if (gnu16) {
- error(ERR_WARNING | ERR_WARN_GNUELF,
+ nasm_error(ERR_WARNING | ERR_WARN_GNUELF,
"16-bit relocations in ELF is a GNU extension");
WRITESHORT(p, addr);
} else {
if (size != 4 && segment != NO_SEG) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"Unsupported non-32-bit ELF relocation");
}
WRITELONG(p, addr);
elf_sect_write(s, mydata, size);
} else if (type == OUT_REL2ADR) {
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL2ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR");
if (segment != NO_SEG && segment % 2) {
- error(ERR_NONFATAL, "ELF format does not support"
+ nasm_error(ERR_NONFATAL, "ELF format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
- error(ERR_WARNING | ERR_WARN_GNUELF,
+ nasm_error(ERR_WARNING | ERR_WARN_GNUELF,
"16-bit relocations in ELF is a GNU extension");
elf_add_reloc(s, segment, R_386_PC16);
} else {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"Unsupported non-32-bit ELF relocation");
}
}
elf_sect_write(s, mydata, 2L);
} else if (type == OUT_REL4ADR) {
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL4ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR");
if (segment != NO_SEG && segment % 2) {
- error(ERR_NONFATAL, "ELF format does not support"
+ nasm_error(ERR_NONFATAL, "ELF format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
} else if (wrt == elf_gotpc_sect + 1 ||
wrt == elf_gotoff_sect + 1 ||
wrt == elf_got_sect + 1) {
- error(ERR_NONFATAL, "ELF format cannot produce PC-"
+ nasm_error(ERR_NONFATAL, "ELF format cannot produce PC-"
"relative GOT references");
} else {
- error(ERR_NONFATAL, "ELF format does not support this"
+ nasm_error(ERR_NONFATAL, "ELF format does not support this"
" use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
}
/*
* Output the ELF header.
*/
- fwrite("\177ELF\1\1\1", 7, 1, elffp);
- fputc(elf_osabi, elffp);
- fputc(elf_abiver, elffp);
- fwritezero(7, elffp);
- fwriteint16_t(1, elffp); /* ET_REL relocatable file */
- fwriteint16_t(3, elffp); /* EM_386 processor ID */
- fwriteint32_t(1L, elffp); /* EV_CURRENT file format version */
- fwriteint32_t(0L, elffp); /* no entry point */
- fwriteint32_t(0L, elffp); /* no program header table */
- fwriteint32_t(0x40L, elffp); /* section headers straight after
+ fwrite("\177ELF\1\1\1", 7, 1, ofile);
+ fputc(elf_osabi, ofile);
+ fputc(elf_abiver, ofile);
+ fwritezero(7, ofile);
+ fwriteint16_t(1, ofile); /* ET_REL relocatable file */
+ fwriteint16_t(3, ofile); /* EM_386 processor ID */
+ fwriteint32_t(1L, ofile); /* EV_CURRENT file format version */
+ fwriteint32_t(0L, ofile); /* no entry point */
+ fwriteint32_t(0L, ofile); /* no program header table */
+ fwriteint32_t(0x40L, ofile); /* section headers straight after
* ELF header plus alignment */
- fwriteint32_t(0L, elffp); /* 386 defines no special flags */
- fwriteint16_t(0x34, elffp); /* size of ELF header */
- fwriteint16_t(0, elffp); /* no program header table, again */
- fwriteint16_t(0, elffp); /* still no program header table */
- fwriteint16_t(0x28, elffp); /* size of section header */
- fwriteint16_t(nsections, elffp); /* number of sections */
- fwriteint16_t(sec_shstrtab, elffp); /* string table section index for
+ fwriteint32_t(0L, ofile); /* 386 defines no special flags */
+ fwriteint16_t(0x34, ofile); /* size of ELF header */
+ fwriteint16_t(0, ofile); /* no program header table, again */
+ fwriteint16_t(0, ofile); /* still no program header table */
+ fwriteint16_t(0x28, ofile); /* size of section header */
+ fwriteint16_t(nsections, ofile); /* number of sections */
+ fwriteint16_t(sec_shstrtab, ofile); /* string table section index for
* section header table */
- fwriteint32_t(0L, elffp); /* align to 0x40 bytes */
- fwriteint32_t(0L, elffp);
- fwriteint32_t(0L, elffp);
+ fwriteint32_t(0L, ofile); /* align to 0x40 bytes */
+ fwriteint32_t(0L, ofile);
+ fwriteint32_t(0L, ofile);
/*
* Build the symbol table and relocation tables.
loclen, 0, 0, 1, 0);
p += strlen(p) + 1;
}
- fwritezero(align, elffp);
+ fwritezero(align, ofile);
/*
* Now output the sections.
elf_sects[elf_nsect].is_saa = is_saa;
elf_nsect++;
- fwriteint32_t((int32_t)name, elffp);
- fwriteint32_t((int32_t)type, elffp);
- fwriteint32_t((int32_t)flags, elffp);
- fwriteint32_t(0L, elffp); /* no address, ever, in object files */
- fwriteint32_t(type == 0 ? 0L : elf_foffs, elffp);
- fwriteint32_t(datalen, elffp);
+ fwriteint32_t((int32_t)name, ofile);
+ fwriteint32_t((int32_t)type, ofile);
+ fwriteint32_t((int32_t)flags, ofile);
+ fwriteint32_t(0L, ofile); /* no address, ever, in object files */
+ fwriteint32_t(type == 0 ? 0L : elf_foffs, ofile);
+ fwriteint32_t(datalen, ofile);
if (data)
elf_foffs += (datalen + SEG_ALIGN_1) & ~SEG_ALIGN_1;
- fwriteint32_t((int32_t)link, elffp);
- fwriteint32_t((int32_t)info, elffp);
- fwriteint32_t((int32_t)align, elffp);
- fwriteint32_t((int32_t)eltsize, elffp);
+ fwriteint32_t((int32_t)link, ofile);
+ fwriteint32_t((int32_t)info, ofile);
+ fwriteint32_t((int32_t)align, ofile);
+ fwriteint32_t((int32_t)eltsize, ofile);
}
static void elf_write_sections(void)
int32_t reallen = (len + SEG_ALIGN_1) & ~SEG_ALIGN_1;
int32_t align = reallen - len;
if (elf_sects[i].is_saa)
- saa_fpwrite(elf_sects[i].data, elffp);
+ saa_fpwrite(elf_sects[i].data, ofile);
else
- fwrite(elf_sects[i].data, len, 1, elffp);
- fwritezero(align, elffp);
+ fwrite(elf_sects[i].data, len, 1, ofile);
+ fwritezero(align, ofile);
}
}
return segment;
}
-static int elf_directive(char *directive, char *value, int pass)
+static int elf_directive(enum directives directive, char *value, int pass)
{
bool err;
int64_t n;
char *p;
- if (!strcmp(directive, "osabi")) {
+ switch (directive) {
+ case D_OSABI:
if (pass == 2)
return 1; /* ignore in pass 2 */
n = readnum(value, &err);
if (err) {
- error(ERR_NONFATAL, "`osabi' directive requires a parameter");
+ nasm_error(ERR_NONFATAL, "`osabi' directive requires a parameter");
return 1;
}
if (n < 0 || n > 255) {
- error(ERR_NONFATAL, "valid osabi numbers are 0 to 255");
+ nasm_error(ERR_NONFATAL, "valid osabi numbers are 0 to 255");
return 1;
}
elf_osabi = n;
n = readnum(p+1, &err);
if (err || n < 0 || n > 255) {
- error(ERR_NONFATAL, "invalid ABI version number (valid: 0 to 255)");
+ nasm_error(ERR_NONFATAL, "invalid ABI version number (valid: 0 to 255)");
return 1;
}
elf_abiver = n;
return 1;
+
+ default:
+ return 0;
}
-
- return 0;
}
-static void elf_filename(char *inname, char *outname, efunc error)
+static void elf_filename(char *inname, char *outname)
{
strcpy(elf_module, inname);
- standard_extension(inname, outname, ".o", error);
+ standard_extension(inname, outname, ".o");
}
extern macros_t elf_stdmac[];
/* dwarf routines */
-static void dwarf32_init(struct ofmt *of, void *id, FILE * fp, efunc error)
+static void dwarf32_init(void)
{
- (void)of;
- (void)id;
- (void)fp;
- (void)error;
-
ndebugs = 3; /* 3 debug symbols */
}
#include "saa.h"
#include "raa.h"
#include "stdscan.h"
+#include "eval.h"
#include "output/outform.h"
#include "output/outlib.h"
#include "rbtree.h"
static struct SAA *strs;
static uint32_t strslen;
-static FILE *elffp;
-static efunc error;
-static evalfunc evaluate;
-
static struct Symbol *fwds;
static char elf_module[FILENAME_MAX];
static void stabs64_cleanup(void);
/* dwarf debugging routines */
-static void dwarf64_init(struct ofmt *, void *, FILE *, efunc);
+static void dwarf64_init(void);
static void dwarf64_linenum(const char *filename, int32_t linenumber, int32_t);
static void dwarf64_output(int, void *);
static void dwarf64_generate(void);
static int32_t elf_sym_sect;
static int32_t elf_gottpoff_sect;
-static void elf_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void elf_init(void)
{
maxbits = 64;
- elffp = fp;
- error = errfunc;
- evaluate = eval;
- (void)ldef; /* placate optimisers */
sects = NULL;
nsects = sectlen = 0;
syms = saa_init((int32_t)sizeof(struct Symbol));
fwds = NULL;
elf_gotpc_sect = seg_alloc();
- ldef("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false, &of_elf64,
- error);
+ define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false);
elf_gotoff_sect = seg_alloc();
- ldef("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false, &of_elf64,
- error);
+ define_label("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false);
elf_got_sect = seg_alloc();
- ldef("..got", elf_got_sect + 1, 0L, NULL, false, false, &of_elf64,
- error);
+ define_label("..got", elf_got_sect + 1, 0L, NULL, false, false);
elf_plt_sect = seg_alloc();
- ldef("..plt", elf_plt_sect + 1, 0L, NULL, false, false, &of_elf64,
- error);
+ define_label("..plt", elf_plt_sect + 1, 0L, NULL, false, false);
elf_sym_sect = seg_alloc();
- ldef("..sym", elf_sym_sect + 1, 0L, NULL, false, false, &of_elf64,
- error);
+ define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false);
elf_gottpoff_sect = seg_alloc();
- ldef("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false, &of_elf64,
- error);
+ define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false);
def_seg = seg_alloc();
(void)debuginfo;
elf_write();
- fclose(elffp);
for (i = 0; i < nsects; i++) {
if (sects[i]->type != SHT_NOBITS)
saa_free(sects[i]->data);
if (align == 0)
align = 1;
if ((align - 1) & align) { /* means it's not a power of two */
- error(ERR_NONFATAL, "section alignment %d is not"
+ nasm_error(ERR_NONFATAL, "section alignment %d is not"
" a power of two", align);
align = 1;
}
} else if (!nasm_stricmp(q, "nobits")) {
type = SHT_NOBITS;
} else if (pass == 1) {
- error(ERR_WARNING, "Unknown section attribute '%s' ignored on"
+ nasm_error(ERR_WARNING, "Unknown section attribute '%s' ignored on"
" declaration of section `%s'", q, name);
}
}
if (!strcmp(name, ".shstrtab") ||
!strcmp(name, ".symtab") ||
!strcmp(name, ".strtab")) {
- error(ERR_NONFATAL, "attempt to redefine reserved section"
+ nasm_error(ERR_NONFATAL, "attempt to redefine reserved section"
"name `%s'", name);
return NO_SEG;
}
if ((type && sects[i]->type != type)
|| (align && sects[i]->align != align)
|| (flags_and && ((sects[i]->flags & flags_and) != flags_or)))
- error(ERR_WARNING, "incompatible section attributes ignored on"
+ nasm_error(ERR_WARNING, "incompatible section attributes ignored on"
" redeclaration of section `%s'", name);
}
if (strcmp(name, "..gotpc") && strcmp(name, "..gotoff") &&
strcmp(name, "..got") && strcmp(name, "..plt") &&
strcmp(name, "..sym") && strcmp(name, "..gottpoff"))
- error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
return;
}
stdscan_reset();
stdscan_bufptr = p;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, NULL, 1, error, NULL);
+ e = evaluate(stdscan, NULL, &tokval, NULL, 1, nasm_error, NULL);
if (e) {
if (!is_simple(e))
- error(ERR_NONFATAL, "cannot use relocatable"
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
" expression as symbol size");
else
(*s)->size = reloc_value(e);
if (nsects == 0 && segment == def_seg) {
int tempint;
if (segment != elf_section_names(".text", 2, &tempint))
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"strange segment conditions in ELF driver");
sym->section = nsects;
} else {
bool err;
sym->symv.key = readnum(special, &err);
if (err)
- error(ERR_NONFATAL, "alignment constraint `%s' is not a"
+ nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
" valid number", special);
else if ((sym->symv.key | (sym->symv.key - 1))
!= 2 * sym->symv.key - 1)
- error(ERR_NONFATAL, "alignment constraint `%s' is not a"
+ nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
" power of two", special);
}
special_used = true;
else if (!nasm_strnicmp(special, "notype", n))
sym->type |= STT_NOTYPE;
else
- error(ERR_NONFATAL, "unrecognised symbol type `%.*s'",
+ nasm_error(ERR_NONFATAL, "unrecognised symbol type `%.*s'",
n, special);
special += n;
stdscan_reset();
stdscan_bufptr = special + n;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, &fwd, 0, error,
+ e = evaluate(stdscan, NULL, &tokval, &fwd, 0, nasm_error,
NULL);
if (fwd) {
sym->nextfwd = fwds;
sym->name = nasm_strdup(name);
} else if (e) {
if (!is_simple(e))
- error(ERR_NONFATAL, "cannot use relocatable"
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
" expression as symbol size");
else
sym->size = reloc_value(e);
nlocals++;
if (special && !special_used)
- error(ERR_NONFATAL, "no special symbol features supported here");
+ nasm_error(ERR_NONFATAL, "no special symbol features supported here");
}
static void elf_add_reloc(struct Section *sect, int32_t segment,
if (!s) {
if (exact && offset)
- error(ERR_NONFATAL, "invalid access to an external symbol");
+ nasm_error(ERR_NONFATAL, "invalid access to an external symbol");
else
elf_add_reloc(sect, segment, offset - pcrel, type);
return;
srb = rb_search(s->gsyms, offset);
if (!srb || (exact && srb->key != offset)) {
- error(ERR_NONFATAL, "unable to find a suitable global symbol"
+ nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol"
" for this reference");
return;
}
*/
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
" space");
return;
}
if (!s) {
int tempint; /* ignored */
if (segto != elf_section_names(".text", 2, &tempint))
- error(ERR_PANIC, "strange segment conditions in ELF driver");
+ nasm_error(ERR_PANIC, "strange segment conditions in ELF driver");
else {
s = sects[nsects - 1];
i = nsects - 1;
/* end of debugging stuff */
if (s->type == SHT_NOBITS && type != OUT_RESERVE) {
- error(ERR_WARNING, "attempt to initialize memory in"
+ nasm_error(ERR_WARNING, "attempt to initialize memory in"
" BSS section `%s': ignored", s->name);
s->len += realsize(type, size);
return;
if (type == OUT_RESERVE) {
if (s->type == SHT_PROGBITS) {
- error(ERR_WARNING, "uninitialized space declared in"
+ nasm_error(ERR_WARNING, "uninitialized space declared in"
" non-BSS section `%s': zeroing", s->name);
elf_sect_write(s, NULL, size);
} else
s->len += size;
} else if (type == OUT_RAWDATA) {
if (segment != NO_SEG)
- error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
+ nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
elf_sect_write(s, data, size);
} else if (type == OUT_ADDRESS) {
addr = *(int64_t *)data;
if (segment == NO_SEG) {
/* Do nothing */
} else if (segment % 2) {
- error(ERR_NONFATAL, "ELF format does not support"
+ nasm_error(ERR_NONFATAL, "ELF format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
elf_add_reloc(s, segment, addr, R_X86_64_64);
break;
default:
- error(ERR_PANIC, "internal error elf64-hpa-871");
+ nasm_error(ERR_PANIC, "internal error elf64-hpa-871");
break;
}
addr = 0;
addr = 0;
} else if (wrt == elf_gotoff_sect + 1) {
if (size != 8) {
- error(ERR_NONFATAL, "ELF64 requires ..gotoff "
+ nasm_error(ERR_NONFATAL, "ELF64 requires ..gotoff "
"references to be qword");
} else {
elf_add_reloc(s, segment, addr, R_X86_64_GOTOFF64);
addr = 0;
break;
default:
- error(ERR_NONFATAL, "invalid ..got reference");
+ nasm_error(ERR_NONFATAL, "invalid ..got reference");
break;
}
} else if (wrt == elf_sym_sect + 1) {
addr = 0;
break;
default:
- error(ERR_PANIC, "internal error elf64-hpa-903");
+ nasm_error(ERR_PANIC, "internal error elf64-hpa-903");
break;
}
} else if (wrt == elf_plt_sect + 1) {
- error(ERR_NONFATAL, "ELF format cannot produce non-PC-"
+ nasm_error(ERR_NONFATAL, "ELF format cannot produce non-PC-"
"relative PLT references");
} else {
- error(ERR_NONFATAL, "ELF format does not support this"
+ nasm_error(ERR_NONFATAL, "ELF format does not support this"
" use of WRT");
}
}
} else if (type == OUT_REL2ADR) {
addr = *(int64_t *)data - size;
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL2ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR");
if (segment == NO_SEG) {
/* Do nothing */
} else if (segment % 2) {
- error(ERR_NONFATAL, "ELF format does not support"
+ nasm_error(ERR_NONFATAL, "ELF format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
elf_add_reloc(s, segment, addr, R_X86_64_PC16);
addr = 0;
} else {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"Unsupported non-32-bit ELF relocation [2]");
}
}
} else if (type == OUT_REL4ADR) {
addr = *(int64_t *)data - size;
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL4ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR");
if (segment == NO_SEG) {
/* Do nothing */
} else if (segment % 2) {
- error(ERR_NONFATAL, "ELF64 format does not support"
+ nasm_error(ERR_NONFATAL, "ELF64 format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
addr = 0;
} else if (wrt == elf_gotoff_sect + 1 ||
wrt == elf_got_sect + 1) {
- error(ERR_NONFATAL, "ELF64 requires ..gotoff references to be "
+ nasm_error(ERR_NONFATAL, "ELF64 requires ..gotoff references to be "
"qword absolute");
} else if (wrt == elf_gottpoff_sect + 1) {
elf_add_gsym_reloc(s, segment, addr+size, size,
R_X86_64_GOTTPOFF, true);
addr = 0;
} else {
- error(ERR_NONFATAL, "ELF64 format does not support this"
+ nasm_error(ERR_NONFATAL, "ELF64 format does not support this"
" use of WRT");
}
}
} else if (type == OUT_REL8ADR) {
addr = *(int64_t *)data - size;
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL8ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL8ADR");
if (segment == NO_SEG) {
/* Do nothing */
} else if (segment % 2) {
- error(ERR_NONFATAL, "ELF64 format does not support"
+ nasm_error(ERR_NONFATAL, "ELF64 format does not support"
" segment base references");
} else {
if (wrt == NO_SEG) {
addr = 0;
} else if (wrt == elf_gotoff_sect + 1 ||
wrt == elf_got_sect + 1) {
- error(ERR_NONFATAL, "ELF64 requires ..gotoff references to be "
+ nasm_error(ERR_NONFATAL, "ELF64 requires ..gotoff references to be "
"absolute");
} else if (wrt == elf_gottpoff_sect + 1) {
- error(ERR_NONFATAL, "ELF64 requires ..gottpoff references to be "
+ nasm_error(ERR_NONFATAL, "ELF64 requires ..gottpoff references to be "
"dword");
} else {
- error(ERR_NONFATAL, "ELF64 format does not support this"
+ nasm_error(ERR_NONFATAL, "ELF64 format does not support this"
" use of WRT");
}
}
/*
* Output the ELF header.
*/
- fwrite("\177ELF\2\1\1", 7, 1, elffp);
- fputc(elf_osabi, elffp);
- fputc(elf_abiver, elffp);
- fwritezero(7, elffp);
- fwriteint16_t(ET_REL, elffp); /* relocatable file */
- fwriteint16_t(EM_X86_64, elffp); /* processor ID */
- fwriteint32_t(1L, elffp); /* EV_CURRENT file format version */
- fwriteint64_t(0L, elffp); /* no entry point */
- fwriteint64_t(0L, elffp); /* no program header table */
- fwriteint64_t(0x40L, elffp); /* section headers straight after
+ fwrite("\177ELF\2\1\1", 7, 1, ofile);
+ fputc(elf_osabi, ofile);
+ fputc(elf_abiver, ofile);
+ fwritezero(7, ofile);
+ fwriteint16_t(ET_REL, ofile); /* relocatable file */
+ fwriteint16_t(EM_X86_64, ofile); /* processor ID */
+ fwriteint32_t(1L, ofile); /* EV_CURRENT file format version */
+ fwriteint64_t(0L, ofile); /* no entry point */
+ fwriteint64_t(0L, ofile); /* no program header table */
+ fwriteint64_t(0x40L, ofile); /* section headers straight after
* ELF header plus alignment */
- fwriteint32_t(0L, elffp); /* 386 defines no special flags */
- fwriteint16_t(0x40, elffp); /* size of ELF header */
- fwriteint16_t(0, elffp); /* no program header table, again */
- fwriteint16_t(0, elffp); /* still no program header table */
- fwriteint16_t(sizeof(Elf64_Shdr), elffp); /* size of section header */
- fwriteint16_t(nsections, elffp); /* number of sections */
- fwriteint16_t(sec_shstrtab, elffp); /* string table section index for
+ fwriteint32_t(0L, ofile); /* 386 defines no special flags */
+ fwriteint16_t(0x40, ofile); /* size of ELF header */
+ fwriteint16_t(0, ofile); /* no program header table, again */
+ fwriteint16_t(0, ofile); /* still no program header table */
+ fwriteint16_t(sizeof(Elf64_Shdr), ofile); /* size of section header */
+ fwriteint16_t(nsections, ofile); /* number of sections */
+ fwriteint16_t(sec_shstrtab, ofile); /* string table section index for
* section header table */
/*
loclen, 0, 0, 1, 0);
p += strlen(p) + 1;
}
- fwritezero(align, elffp);
+ fwritezero(align, ofile);
/*
* Now output the sections.
elf_sects[elf_nsect].is_saa = is_saa;
elf_nsect++;
- fwriteint32_t((int32_t)name, elffp);
- fwriteint32_t((int32_t)type, elffp);
- fwriteint64_t((int64_t)flags, elffp);
- fwriteint64_t(0L, elffp); /* no address, ever, in object files */
- fwriteint64_t(type == 0 ? 0L : elf_foffs, elffp);
- fwriteint64_t(datalen, elffp);
+ fwriteint32_t((int32_t)name, ofile);
+ fwriteint32_t((int32_t)type, ofile);
+ fwriteint64_t((int64_t)flags, ofile);
+ fwriteint64_t(0L, ofile); /* no address, ever, in object files */
+ fwriteint64_t(type == 0 ? 0L : elf_foffs, ofile);
+ fwriteint64_t(datalen, ofile);
if (data)
elf_foffs += (datalen + SEG_ALIGN_1) & ~SEG_ALIGN_1;
- fwriteint32_t((int32_t)link, elffp);
- fwriteint32_t((int32_t)info, elffp);
- fwriteint64_t((int64_t)align, elffp);
- fwriteint64_t((int64_t)eltsize, elffp);
+ fwriteint32_t((int32_t)link, ofile);
+ fwriteint32_t((int32_t)info, ofile);
+ fwriteint64_t((int64_t)align, ofile);
+ fwriteint64_t((int64_t)eltsize, ofile);
}
static void elf_write_sections(void)
int32_t reallen = (len + SEG_ALIGN_1) & ~SEG_ALIGN_1;
int32_t align = reallen - len;
if (elf_sects[i].is_saa)
- saa_fpwrite(elf_sects[i].data, elffp);
+ saa_fpwrite(elf_sects[i].data, ofile);
else
- fwrite(elf_sects[i].data, len, 1, elffp);
- fwritezero(align, elffp);
+ fwrite(elf_sects[i].data, len, 1, ofile);
+ fwritezero(align, ofile);
}
}
return segment;
}
-static int elf_directive(char *directive, char *value, int pass)
+static int elf_directive(enum directives directive, char *value, int pass)
{
bool err;
int64_t n;
char *p;
- if (!strcmp(directive, "osabi")) {
+ switch (directive) {
+ case D_OSABI:
if (pass == 2)
return 1; /* ignore in pass 2 */
n = readnum(value, &err);
if (err) {
- error(ERR_NONFATAL, "`osabi' directive requires a parameter");
+ nasm_error(ERR_NONFATAL, "`osabi' directive requires a parameter");
return 1;
}
if (n < 0 || n > 255) {
- error(ERR_NONFATAL, "valid osabi numbers are 0 to 255");
+ nasm_error(ERR_NONFATAL, "valid osabi numbers are 0 to 255");
return 1;
}
elf_osabi = n;
n = readnum(p+1, &err);
if (err || n < 0 || n > 255) {
- error(ERR_NONFATAL, "invalid ABI version number (valid: 0 to 255)");
+ nasm_error(ERR_NONFATAL, "invalid ABI version number (valid: 0 to 255)");
return 1;
}
elf_abiver = n;
return 1;
+
+ default:
+ return 0;
}
-
- return 0;
}
-static void elf_filename(char *inname, char *outname, efunc error)
+static void elf_filename(char *inname, char *outname)
{
strcpy(elf_module, inname);
- standard_extension(inname, outname, ".o", error);
+ standard_extension(inname, outname, ".o");
}
extern macros_t elf_stdmac[];
nasm_free(stabstrbuf);
}
/* dwarf routines */
-static void dwarf64_init(struct ofmt *of, void *id, FILE * fp, efunc error)
+static void dwarf64_init(void)
{
- (void)of;
- (void)id;
- (void)fp;
- (void)error;
-
ndebugs = 3; /* 3 debug symbols */
}
#define BUILD_DRIVERS_ARRAY
#include "output/outform.h"
-static int ndrivers = 0;
-
struct ofmt *ofmt_find(char *name)
{ /* find driver */
- int i;
-
- for (i = 0; i < ndrivers; i++)
- if (!strcmp(name, drivers[i]->shortname))
- return drivers[i];
+ struct ofmt **ofp, *of;
+ for (ofp = drivers; (of = *ofp); ofp++) {
+ if (!nasm_stricmp(name, of->shortname))
+ return of;
+ }
return NULL;
}
+
struct dfmt *dfmt_find(struct ofmt *ofmt, char *name)
{ /* find driver */
- struct dfmt **dfmt = ofmt->debug_formats;
- while (*dfmt) {
- if (!strcmp(name, (*dfmt)->shortname))
- return (*dfmt);
- dfmt++;
+ struct dfmt **dfp, *df;
+
+ for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) {
+ if (!nasm_stricmp(name, df->shortname))
+ return df;
}
return NULL;
}
void ofmt_list(struct ofmt *deffmt, FILE * fp)
{
- int i;
- for (i = 0; i < ndrivers; i++)
- fprintf(fp, " %c %-10s%s\n",
- drivers[i] == deffmt ? '*' : ' ',
- drivers[i]->shortname, drivers[i]->fullname);
-}
-void dfmt_list(struct ofmt *ofmt, FILE * fp)
-{
- struct dfmt **drivers = ofmt->debug_formats;
- while (*drivers) {
+ struct ofmt **ofp, *of;
+
+ for (ofp = drivers; (of = *ofp); ofp++) {
fprintf(fp, " %c %-10s%s\n",
- drivers[0] == ofmt->current_dfmt ? '*' : ' ',
- drivers[0]->shortname, drivers[0]->fullname);
- drivers++;
+ of == deffmt ? '*' : ' ',
+ of->shortname, of->fullname);
}
}
-struct ofmt *ofmt_register(efunc error)
+
+void dfmt_list(struct ofmt *ofmt, FILE *fp)
{
- for (ndrivers = 0; drivers[ndrivers] != NULL; ndrivers++) ;
+ struct dfmt **dfp, *df;
- if (ndrivers == 0) {
- error(ERR_PANIC | ERR_NOFILE,
- "No output drivers given at compile time");
+ for (dfp = ofmt->debug_formats; (df = *dfp); dfp++) {
+ fprintf(fp, " %c %-10s%s\n",
+ df == ofmt->current_dfmt ? '*' : ' ',
+ df->shortname, df->fullname);
}
-
- return (&OF_DEFAULT);
}
#define OF_DEFAULT of_bin
#endif
-#ifdef BUILD_DRIVERS_ARRAY /* only if included from outform.c */
-
-/* pull in the externs for the different formats, then make the *drivers
- * array based on the above defines */
-
extern struct ofmt of_bin;
extern struct ofmt of_ith;
extern struct ofmt of_srec;
extern struct ofmt of_macho64;
extern struct ofmt of_dbg;
-struct ofmt *drivers[] = {
+#ifdef BUILD_DRIVERS_ARRAY /* only if included from outform.c */
+
+/* pull in the externs for the different formats, then make the *drivers
+ * array based on the above defines */
+
+static struct ofmt *drivers[] = {
#ifdef OF_BIN
&of_bin,
&of_ith,
static char ieee_infile[FILENAME_MAX];
static int ieee_uppercase;
-static efunc error;
-static ldfunc deflabel;
-static FILE *ofp;
static bool any_segs;
static int arrindex;
/*
* pup init
*/
-static void ieee_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void ieee_init(void)
{
- (void)eval;
- ofp = fp;
- error = errfunc;
- deflabel = ldef;
any_segs = false;
fpubhead = NULL;
fpubtail = &fpubhead;
{
ieee_write_file(debuginfo);
of_ieee.current_dfmt->cleanup();
- fclose(ofp);
while (seghead) {
struct ieeeSection *segtmp = seghead;
seghead = seghead->next;
int i;
if (special) {
- error(ERR_NONFATAL, "unrecognised symbol type `%s'", special);
+ nasm_error(ERR_NONFATAL, "unrecognised symbol type `%s'", special);
}
/*
* First check for the double-period, signifying something
*/
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
" space");
return;
}
if (!any_segs) {
int tempint; /* ignored */
if (segto != ieee_segment("__NASMDEFSEG", 2, &tempint))
- error(ERR_PANIC, "strange segment conditions in IEEE driver");
+ nasm_error(ERR_PANIC, "strange segment conditions in IEEE driver");
}
/*
if (seg->index == segto)
break;
if (!seg)
- error(ERR_PANIC, "code directed to nonexistent segment?");
+ nasm_error(ERR_PANIC, "code directed to nonexistent segment?");
if (type == OUT_RAWDATA) {
ucdata = data;
} else if (type == OUT_ADDRESS || type == OUT_REL2ADR ||
type == OUT_REL4ADR) {
if (segment == NO_SEG && type != OUT_ADDRESS)
- error(ERR_NONFATAL, "relative call to absolute address not"
+ nasm_error(ERR_NONFATAL, "relative call to absolute address not"
" supported by IEEE format");
ldata = *(int64_t *)data;
if (type == OUT_REL2ADR)
s.addend = 0;
s.id2 = eb->index[i];
} else
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"Source of WRT must be an offset");
}
} else
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"unrecognised WRT value in ieee_write_fixup");
} else
- error(ERR_NONFATAL, "target of WRT must be a section ");
+ nasm_error(ERR_NONFATAL, "target of WRT must be a section ");
}
s.size = size;
ieee_install_fixup(segto, &s);
*/
if (eb) {
if (realtype == OUT_REL2ADR || realtype == OUT_REL4ADR) {
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"Segment of a rel not supported in ieee_write_fixup");
} else {
/* If we want the segment */
} else
/* If we get here the seg value doesn't make sense */
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"unrecognised segment value in ieee_write_fixup");
}
} else
/* If we get here the seg value doesn't make sense */
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"unrecognised segment value in ieee_write_fixup");
}
}
if (size != 2 && s.ftype == FT_SEG)
- error(ERR_NONFATAL, "IEEE format can only handle 2-byte"
+ nasm_error(ERR_NONFATAL, "IEEE format can only handle 2-byte"
" segment base references");
s.size = size;
ieee_install_fixup(segto, &s);
ieee_idx++;
if (!strcmp(seg->name, name)) {
if (attrs > 0 && pass == 1)
- error(ERR_WARNING, "segment attributes specified on"
+ nasm_error(ERR_WARNING, "segment attributes specified on"
" redeclaration of segment: ignoring");
if (seg->use32)
*bits = 32;
seg->align = 1;
if (rn_error) {
seg->align = 1;
- error(ERR_NONFATAL, "segment alignment should be"
+ nasm_error(ERR_NONFATAL, "segment alignment should be"
" numeric");
}
switch ((int)seg->align) {
case 128:
break;
default:
- error(ERR_NONFATAL, "invalid alignment value %d",
+ nasm_error(ERR_NONFATAL, "invalid alignment value %d",
seg->align);
seg->align = 1;
break;
} else if (!nasm_strnicmp(p, "absolute=", 9)) {
seg->align = SEG_ABS + readnum(p + 9, &rn_error);
if (rn_error)
- error(ERR_NONFATAL, "argument to `absolute' segment"
+ nasm_error(ERR_NONFATAL, "argument to `absolute' segment"
" attribute should be numeric");
}
}
ieee_seg_needs_update = seg;
if (seg->align >= SEG_ABS)
- deflabel(name, NO_SEG, seg->align - SEG_ABS,
- NULL, false, false, &of_ieee, error);
+ define_label(name, NO_SEG, seg->align - SEG_ABS,
+ NULL, false, false);
else
- deflabel(name, seg->index + 1, 0L,
- NULL, false, false, &of_ieee, error);
+ define_label(name, seg->index + 1, 0L, NULL, false, false);
ieee_seg_needs_update = NULL;
if (seg->use32)
/*
* directives supported
*/
-static int ieee_directive(char *directive, char *value, int pass)
+static int ieee_directive(enum directives directive, char *value, int pass)
{
(void)value;
(void)pass;
- if (!strcmp(directive, "uppercase")) {
+
+ switch (directive) {
+ case D_UPPERCASE:
ieee_uppercase = true;
return 1;
+
+ default:
+ return 0;
}
- return 0;
}
/*
/*
* filename
*/
-static void ieee_filename(char *inname, char *outname, efunc error)
+static void ieee_filename(char *inname, char *outname)
{
strcpy(ieee_infile, inname);
- standard_extension(inname, outname, ".o", error);
+ standard_extension(inname, outname, ".o");
}
static void ieee_write_file(int debuginfo)
if (seg->index == ieee_entry_seg)
break;
if (!seg)
- error(ERR_PANIC, "Start address records are incorrect");
+ nasm_error(ERR_PANIC, "Start address records are incorrect");
else
ieee_putascii("ASG,R%X,%lX,+.\n", seg->ieee_index,
ieee_entry_ofs);
if ((uint8_t)buffer[i] > 31)
checksum += buffer[i];
va_end(ap);
- fprintf(ofp, buffer);
+ fprintf(ofile, buffer);
}
/*
} else
strcpy(dest, source);
}
-void dbgls_init(struct ofmt *of, void *id, FILE * fp, efunc error)
+void dbgls_init(void)
{
int tempint;
- (void)of;
- (void)id;
- (void)fp;
- (void)error;
fnhead = NULL;
fntail = &fnhead;
if (!any_segs) {
int tempint; /* ignored */
if (segto != ieee_segment("__NASMDEFSEG", 2, &tempint))
- error(ERR_PANIC, "strange segment conditions in OBJ driver");
+ nasm_error(ERR_PANIC, "strange segment conditions in OBJ driver");
}
/*
if (seg->index == segto)
break;
if (!seg)
- error(ERR_PANIC, "lineno directed to nonexistent segment?");
+ nasm_error(ERR_PANIC, "lineno directed to nonexistent segment?");
for (fn = fnhead; fn; fn = fn->next) {
if (!nasm_stricmp(lnfname, fn->name))
uint64_t realsize(enum out_type type, uint64_t size);
+/* Do-nothing versions of some output routines */
+int null_setinfo(enum geninfo type, char **string);
+int null_directive(enum directives directive, char *value, int pass);
+
/* Do-nothing versions of all the debug routines */
struct ofmt;
-void null_debug_init(struct ofmt *of, void *id, FILE * fp, efunc error);
+void null_debug_init(void);
void null_debug_linenum(const char *filename, int32_t linenumber,
int32_t segto);
void null_debug_deflabel(char *name, int32_t segment, int64_t offset,
#include "nasmlib.h"
#include "saa.h"
#include "raa.h"
+#include "eval.h"
#include "output/outform.h"
#include "output/outlib.h"
static struct SAA *strs;
static uint32_t strslen;
-static FILE *machofp;
static efunc error;
-static evalfunc evaluate;
extern struct ofmt of_macho;
return NO_SECT;
}
-static void macho_init(FILE * fp, efunc errfunc, ldfunc ldef,
- evalfunc eval)
+static void macho_init(void)
{
char zero = 0;
- machofp = fp;
- error = errfunc;
- evaluate = eval;
-
- (void)ldef; /* placate optimisers */
-
sects = NULL;
sectstail = §s;
strslen = 1;
}
-static int macho_setinfo(enum geninfo type, char **val)
-{
- (void)type;
- (void)val;
- return 0;
-}
-
static void sect_write(struct section *sect,
const uint8_t *data, uint32_t len)
{
return section;
}
-static int macho_directive(char *directive, char *value, int pass)
+static void macho_filename(char *inname, char *outname)
{
- (void)directive;
- (void)value;
- (void)pass;
- return 0;
-}
-
-static void macho_filename(char *inname, char *outname, efunc error)
-{
- standard_extension(inname, outname, ".o", error);
+ standard_extension(inname, outname, ".o");
}
extern macros_t macho_stdmac[];
static void macho_write_header (void)
{
- fwriteint32_t(MH_MAGIC, machofp); /* magic */
- fwriteint32_t(CPU_TYPE_I386, machofp); /* CPU type */
- fwriteint32_t(CPU_SUBTYPE_I386_ALL, machofp); /* CPU subtype */
- fwriteint32_t(MH_OBJECT, machofp); /* Mach-O file type */
- fwriteint32_t(head_ncmds, machofp); /* number of load commands */
- fwriteint32_t(head_sizeofcmds, machofp); /* size of load commands */
- fwriteint32_t(0, machofp); /* no flags */
+ fwriteint32_t(MH_MAGIC, ofile); /* magic */
+ fwriteint32_t(CPU_TYPE_I386, ofile); /* CPU type */
+ fwriteint32_t(CPU_SUBTYPE_I386_ALL, ofile); /* CPU subtype */
+ fwriteint32_t(MH_OBJECT, ofile); /* Mach-O file type */
+ fwriteint32_t(head_ncmds, ofile); /* number of load commands */
+ fwriteint32_t(head_sizeofcmds, ofile); /* size of load commands */
+ fwriteint32_t(0, ofile); /* no flags */
}
/* Write out the segment load command at offset. */
uint32_t s_reloff = 0;
struct section *s;
- fwriteint32_t(LC_SEGMENT, machofp); /* cmd == LC_SEGMENT */
+ fwriteint32_t(LC_SEGMENT, ofile); /* cmd == LC_SEGMENT */
/* size of load command including section load commands */
fwriteint32_t(MACHO_SEGCMD_SIZE + seg_nsects *
- MACHO_SECTCMD_SIZE, machofp);
+ MACHO_SECTCMD_SIZE, ofile);
/* in an MH_OBJECT file all sections are in one unnamed (name
** all zeros) segment */
- fwritezero(16, machofp);
- fwriteint32_t(0, machofp); /* in-memory offset */
- fwriteint32_t(seg_vmsize, machofp); /* in-memory size */
- fwriteint32_t(offset, machofp); /* in-file offset to data */
- fwriteint32_t(seg_filesize, machofp); /* in-file size */
- fwriteint32_t(VM_PROT_DEFAULT, machofp); /* maximum vm protection */
- fwriteint32_t(VM_PROT_DEFAULT, machofp); /* initial vm protection */
- fwriteint32_t(seg_nsects, machofp); /* number of sections */
- fwriteint32_t(0, machofp); /* no flags */
+ fwritezero(16, ofile);
+ fwriteint32_t(0, ofile); /* in-memory offset */
+ fwriteint32_t(seg_vmsize, ofile); /* in-memory size */
+ fwriteint32_t(offset, ofile); /* in-file offset to data */
+ fwriteint32_t(seg_filesize, ofile); /* in-file size */
+ fwriteint32_t(VM_PROT_DEFAULT, ofile); /* maximum vm protection */
+ fwriteint32_t(VM_PROT_DEFAULT, ofile); /* initial vm protection */
+ fwriteint32_t(seg_nsects, ofile); /* number of sections */
+ fwriteint32_t(0, ofile); /* no flags */
/* emit section headers */
for (s = sects; s != NULL; s = s->next) {
- fwrite(s->sectname, sizeof(s->sectname), 1, machofp);
- fwrite(s->segname, sizeof(s->segname), 1, machofp);
- fwriteint32_t(s->addr, machofp);
- fwriteint32_t(s->size, machofp);
+ fwrite(s->sectname, sizeof(s->sectname), 1, ofile);
+ fwrite(s->segname, sizeof(s->segname), 1, ofile);
+ fwriteint32_t(s->addr, ofile);
+ fwriteint32_t(s->size, ofile);
/* dummy data for zerofill sections or proper values */
if ((s->flags & SECTION_TYPE) != S_ZEROFILL) {
- fwriteint32_t(offset, machofp);
+ fwriteint32_t(offset, ofile);
/* Write out section alignment, as a power of two.
e.g. 32-bit word alignment would be 2 (2^^2 = 4). */
if (s->align == -1)
s->align = DEFAULT_SECTION_ALIGNMENT;
- fwriteint32_t(s->align, machofp);
+ fwriteint32_t(s->align, ofile);
/* To be compatible with cctools as we emit
a zero reloff if we have no relocations. */
- fwriteint32_t(s->nreloc ? rel_base + s_reloff : 0, machofp);
- fwriteint32_t(s->nreloc, machofp);
+ fwriteint32_t(s->nreloc ? rel_base + s_reloff : 0, ofile);
+ fwriteint32_t(s->nreloc, ofile);
offset += s->size;
s_reloff += s->nreloc * MACHO_RELINFO_SIZE;
} else {
- fwriteint32_t(0, machofp);
- fwriteint32_t(0, machofp);
- fwriteint32_t(0, machofp);
- fwriteint32_t(0, machofp);
+ fwriteint32_t(0, ofile);
+ fwriteint32_t(0, ofile);
+ fwriteint32_t(0, ofile);
+ fwriteint32_t(0, ofile);
}
- fwriteint32_t(s->flags, machofp); /* flags */
- fwriteint32_t(0, machofp); /* reserved */
- fwriteint32_t(0, machofp); /* reserved */
+ fwriteint32_t(s->flags, ofile); /* flags */
+ fwriteint32_t(0, ofile); /* reserved */
+ fwriteint32_t(0, ofile); /* reserved */
}
rel_padcnt = rel_base - offset;
while (r) {
uint32_t word2;
- fwriteint32_t(r->addr, machofp); /* reloc offset */
+ fwriteint32_t(r->addr, ofile); /* reloc offset */
word2 = r->snum;
word2 |= r->pcrel << 24;
word2 |= r->length << 25;
word2 |= r->ext << 27;
word2 |= r->type << 28;
- fwriteint32_t(word2, machofp); /* reloc data */
+ fwriteint32_t(word2, ofile); /* reloc data */
r = r->next;
}
}
/* dump the section data to file */
- saa_fpwrite(s->data, machofp);
+ saa_fpwrite(s->data, ofile);
}
/* pad last section up to reloc entries on int32_t boundary */
- fwritezero(rel_padcnt, machofp);
+ fwritezero(rel_padcnt, ofile);
/* emit relocation entries */
for (s = sects; s != NULL; s = s->next)
for (sym = syms; sym != NULL; sym = sym->next) {
if ((sym->type & N_EXT) == 0) {
- fwriteint32_t(sym->strx, machofp); /* string table entry number */
- fwrite(&sym->type, 1, 1, machofp); /* symbol type */
- fwrite(&sym->sect, 1, 1, machofp); /* section */
- fwriteint16_t(sym->desc, machofp); /* description */
+ fwriteint32_t(sym->strx, ofile); /* string table entry number */
+ fwrite(&sym->type, 1, 1, ofile); /* symbol type */
+ fwrite(&sym->sect, 1, 1, ofile); /* section */
+ fwriteint16_t(sym->desc, ofile); /* description */
/* Fix up the symbol value now that we know the final section
sizes. */
sym->value += s->size;
}
- fwriteint32_t(sym->value, machofp); /* value (i.e. offset) */
+ fwriteint32_t(sym->value, ofile); /* value (i.e. offset) */
}
}
for (i = 0; i < nextdefsym; i++) {
sym = extdefsyms[i];
- fwriteint32_t(sym->strx, machofp);
- fwrite(&sym->type, 1, 1, machofp); /* symbol type */
- fwrite(&sym->sect, 1, 1, machofp); /* section */
- fwriteint16_t(sym->desc, machofp); /* description */
+ fwriteint32_t(sym->strx, ofile);
+ fwrite(&sym->type, 1, 1, ofile); /* symbol type */
+ fwrite(&sym->sect, 1, 1, ofile); /* section */
+ fwriteint16_t(sym->desc, ofile); /* description */
/* Fix up the symbol value now that we know the final section
sizes. */
sym->value += s->size;
}
- fwriteint32_t(sym->value, machofp); /* value (i.e. offset) */
+ fwriteint32_t(sym->value, ofile); /* value (i.e. offset) */
}
for (i = 0; i < nundefsym; i++) {
sym = undefsyms[i];
- fwriteint32_t(sym->strx, machofp);
- fwrite(&sym->type, 1, 1, machofp); /* symbol type */
- fwrite(&sym->sect, 1, 1, machofp); /* section */
- fwriteint16_t(sym->desc, machofp); /* description */
+ fwriteint32_t(sym->strx, ofile);
+ fwrite(&sym->type, 1, 1, ofile); /* symbol type */
+ fwrite(&sym->sect, 1, 1, ofile); /* section */
+ fwriteint16_t(sym->desc, ofile); /* description */
/* Fix up the symbol value now that we know the final section
sizes. */
sym->value += s->size;
}
- fwriteint32_t(sym->value, machofp); /* value (i.e. offset) */
+ fwriteint32_t(sym->value, ofile); /* value (i.e. offset) */
}
}
if (nsyms > 0) {
/* write out symbol command */
- fwriteint32_t(LC_SYMTAB, machofp); /* cmd == LC_SYMTAB */
- fwriteint32_t(MACHO_SYMCMD_SIZE, machofp); /* size of load command */
- fwriteint32_t(offset, machofp); /* symbol table offset */
- fwriteint32_t(nsyms, machofp); /* number of symbol
+ fwriteint32_t(LC_SYMTAB, ofile); /* cmd == LC_SYMTAB */
+ fwriteint32_t(MACHO_SYMCMD_SIZE, ofile); /* size of load command */
+ fwriteint32_t(offset, ofile); /* symbol table offset */
+ fwriteint32_t(nsyms, ofile); /* number of symbol
** table entries */
offset += nsyms * MACHO_NLIST_SIZE;
- fwriteint32_t(offset, machofp); /* string table offset */
- fwriteint32_t(strslen, machofp); /* string table size */
+ fwriteint32_t(offset, ofile); /* string table offset */
+ fwriteint32_t(strslen, ofile); /* string table size */
}
/* emit section data */
/* we don't need to pad here since MACHO_NLIST_SIZE == 12 */
/* emit string table */
- saa_fpwrite(strs, machofp);
+ saa_fpwrite(strs, ofile);
}
/* We do quite a bit here, starting with finalizing all of the data
for the object file, writing, and then freeing all of the data from
macho_calculate_sizes();
macho_write();
- /* done - yay! */
- fclose(machofp);
-
/* free up everything */
while (sects->next) {
s = sects;
&null_debug_form,
macho_stdmac,
macho_init,
- macho_setinfo,
+ null_setinfo,
macho_output,
macho_symdef,
macho_section,
macho_segbase,
- macho_directive,
+ null_directive,
macho_filename,
macho_cleanup
};
&null_debug_form,
macho_stdmac,
macho_init,
- macho_setinfo,
+ null_setinfo,
macho_output,
macho_symdef,
macho_section,
macho_segbase,
- macho_directive,
+ null_directive,
macho_filename,
macho_cleanup
};
static struct SAA *strs;
static uint32_t strslen;
-static FILE *machofp;
-static efunc error;
-static evalfunc evaluate;
-
extern struct ofmt of_macho64;
/* Global file information. This should be cleaned up into either
return i;
if (i == MAX_SECT)
- error(ERR_WARNING,
+ nasm_error(ERR_WARNING,
"too many sections (>255) - clipped by fileindex");
return NO_SECT;
*/
static int32_t macho_gotpcrel_sect;
-static void macho_init(FILE * fp, efunc errfunc, ldfunc ldef,
- evalfunc eval)
+static void macho_init(void)
{
char zero = 0;
- maxbits = 64;
- machofp = fp;
- error = errfunc;
- evaluate = eval;
-
- (void)ldef; /* placate optimizers */
+ maxbits = 64;
sects = NULL;
sectstail = §s;
/* string table starts with a zero byte - don't ask why */
saa_wbytes(strs, &zero, sizeof(char));
strslen = 1;
-
- /* add special symbol for ..gotpcrel */
- macho_gotpcrel_sect = seg_alloc();
- macho_gotpcrel_sect ++;
- ldef("..gotpcrel", macho_gotpcrel_sect, 0L, NULL, false, false, &of_macho64, error);
-}
-static int macho_setinfo(enum geninfo type, char **val)
-{
- (void)type;
- (void)val;
- return 0;
+ /* add special symbol for ..gotpcrel */
+ macho_gotpcrel_sect = seg_alloc();
+ macho_gotpcrel_sect++;
+ define_label("..gotpcrel", macho_gotpcrel_sect, 0L, NULL, false, false);
}
static void sect_write(struct section *sect,
int pcrel, int bytes, int64_t reloff)
{
struct reloc *r;
- struct symbol *sym;
+ struct symbol *sym;
int32_t fi;
- int32_t adjustment = 0;
+ int32_t adjustment = 0;
/* NeXT as puts relocs in reversed order (address-wise) into the
** files, so we do the same, doesn't seem to make much of a
if (secto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in "
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in "
"[ABSOLUTE] space");
return;
s = get_section_by_index(secto);
if (s == NULL) {
- error(ERR_WARNING, "attempt to assemble code in"
+ nasm_error(ERR_WARNING, "attempt to assemble code in"
" section %d: defaulting to `.text'", secto);
s = get_section_by_name("__TEXT", "__text");
/* should never happen */
if (s == NULL)
- error(ERR_PANIC, "text section not found");
+ nasm_error(ERR_PANIC, "text section not found");
}
sbss = get_section_by_name("__DATA", "__bss");
if (s == sbss && type != OUT_RESERVE) {
- error(ERR_WARNING, "attempt to initialize memory in the"
+ nasm_error(ERR_WARNING, "attempt to initialize memory in the"
" BSS section: ignored");
s->size += realsize(type, size);
return;
switch (type) {
case OUT_RESERVE:
if (s != sbss) {
- error(ERR_WARNING, "uninitialized space declared in"
+ nasm_error(ERR_WARNING, "uninitialized space declared in"
" %s section: zeroing",
get_section_name_by_index(secto));
case OUT_RAWDATA:
if (section != NO_SEG)
- error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
+ nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
sect_write(s, data, size);
break;
addr = *(int64_t *)data;
if (section != NO_SEG) {
if (section % 2) {
- error(ERR_NONFATAL, "Mach-O format does not support"
+ nasm_error(ERR_NONFATAL, "Mach-O format does not support"
" section base references");
} else {
if (wrt == NO_SEG) {
if (size < 8) {
- error(ERR_NONFATAL, "Mach-O 64-bit format does not support"
+ nasm_error(ERR_NONFATAL, "Mach-O 64-bit format does not support"
" 32-bit absolute addresses");
/*
Seemingly, Mach-O's X86_64_RELOC_SUBTRACTOR would require
addr -= add_reloc(s, section, 0, size, addr); // X86_64_RELOC_UNSIGNED
}
} else {
- error(ERR_NONFATAL, "Mach-O format does not support"
+ nasm_error(ERR_NONFATAL, "Mach-O format does not support"
" this use of WRT");
}
}
WRITESHORT(p, *(int64_t *)data);
if (section == secto)
- error(ERR_PANIC, "intra-section OUT_REL2ADR");
+ nasm_error(ERR_PANIC, "intra-section OUT_REL2ADR");
if (section == NO_SEG) {
/* Do nothing */
} else if (section % 2) {
- error(ERR_NONFATAL, "Mach-O format does not support"
+ nasm_error(ERR_NONFATAL, "Mach-O format does not support"
" section base references");
} else {
- error(ERR_NONFATAL, "Unsupported non-32-bit"
+ nasm_error(ERR_NONFATAL, "Unsupported non-32-bit"
" Macho-O relocation [2]");
}
WRITELONG(p, *(int64_t *)data);
if (section == secto)
- error(ERR_PANIC, "intra-section OUT_REL4ADR");
+ nasm_error(ERR_PANIC, "intra-section OUT_REL4ADR");
if (section != NO_SEG && section % 2) {
- error(ERR_NONFATAL, "Mach-O format does not support"
+ nasm_error(ERR_NONFATAL, "Mach-O format does not support"
" section base references");
} else {
if (wrt == NO_SEG) {
*mydata -= add_reloc(s, section, 3, 4, (int64_t)*mydata); // X86_64_GOT
}
} else {
- error(ERR_NONFATAL, "Mach-O format does not support"
+ nasm_error(ERR_NONFATAL, "Mach-O format does not support"
" this use of WRT");
wrt = NO_SEG; /* we can at least _try_ to continue */
}
break;
default:
- error(ERR_PANIC, "unknown output type?");
+ nasm_error(ERR_PANIC, "unknown output type?");
break;
}
}
newAlignment = exact_log2(value);
if (0 != *end) {
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"unknown or missing alignment value \"%s\" "
"specified for section \"%s\"",
currentAttribute + 6,
name);
return NO_SEG;
} else if (0 > newAlignment) {
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"alignment of %d (for section \"%s\") is not "
"a power of two",
value,
if ((-1 != originalIndex)
&& (s->align != newAlignment)
&& (s->align != -1)) {
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"section \"%s\" has already been specified "
"with alignment %d, conflicts with new "
"alignment of %d",
} else if (!nasm_stricmp("data", currentAttribute)) {
/* Do nothing; 'data' is implicit */
} else {
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"unknown section attribute %s for section %s",
currentAttribute,
name);
}
}
- error(ERR_PANIC, "invalid section name %s", name);
+ nasm_error(ERR_PANIC, "invalid section name %s", name);
return NO_SEG;
}
struct symbol *sym;
if (special) {
- error(ERR_NONFATAL, "The Mach-O output format does "
+ nasm_error(ERR_NONFATAL, "The Mach-O output format does "
"not support any special symbol types");
return;
}
if (is_global == 3) {
- error(ERR_NONFATAL, "The Mach-O format does not "
+ nasm_error(ERR_NONFATAL, "The Mach-O format does not "
"(yet) support forward reference fixups.");
return;
}
* _isn't_ a valid one, we should barf immediately.
*/
if (strcmp(name, "..gotpcrel"))
- error(ERR_NONFATAL, "unrecognized special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognized special symbol `%s'", name);
return;
}
/* give an error on unfound section if it's not an
** external or common symbol (assemble_file() does a
** seg_alloc() on every call for them) */
- error(ERR_PANIC, "in-file index for section %d not found",
+ nasm_error(ERR_PANIC, "in-file index for section %d not found",
section);
}
}
return section;
}
-static int macho_directive(char *directive, char *value, int pass)
-{
- (void)directive;
- (void)value;
- (void)pass;
- return 0;
-}
-
-static void macho_filename(char *inname, char *outname, efunc error)
+static void macho_filename(char *inname, char *outname)
{
- standard_extension(inname, outname, ".o", error);
+ standard_extension(inname, outname, ".o");
}
extern macros_t macho_stdmac[];
static void macho_write_header (void)
{
- fwriteint32_t(MH_MAGIC_64, machofp); /* magic */
- fwriteint32_t(CPU_TYPE_X86_64, machofp); /* CPU type */
- fwriteint32_t(CPU_SUBTYPE_I386_ALL, machofp); /* CPU subtype */
- fwriteint32_t(MH_OBJECT, machofp); /* Mach-O file type */
- fwriteint32_t(head_ncmds64, machofp); /* number of load commands */
- fwriteint32_t(head_sizeofcmds64, machofp); /* size of load commands */
- fwriteint32_t(0, machofp); /* no flags */
- fwriteint32_t(0, machofp); /* reserved for future use */
+ fwriteint32_t(MH_MAGIC_64, ofile); /* magic */
+ fwriteint32_t(CPU_TYPE_X86_64, ofile); /* CPU type */
+ fwriteint32_t(CPU_SUBTYPE_I386_ALL, ofile); /* CPU subtype */
+ fwriteint32_t(MH_OBJECT, ofile); /* Mach-O file type */
+ fwriteint32_t(head_ncmds64, ofile); /* number of load commands */
+ fwriteint32_t(head_sizeofcmds64, ofile); /* size of load commands */
+ fwriteint32_t(0, ofile); /* no flags */
+ fwriteint32_t(0, ofile); /* reserved for future use */
}
/* Write out the segment load command at offset. */
uint32_t s_reloff = 0;
struct section *s;
- fwriteint32_t(LC_SEGMENT_64, machofp); /* cmd == LC_SEGMENT_64 */
+ fwriteint32_t(LC_SEGMENT_64, ofile); /* cmd == LC_SEGMENT_64 */
/* size of load command including section load commands */
fwriteint32_t(MACHO_SEGCMD64_SIZE + seg_nsects64 *
- MACHO_SECTCMD64_SIZE, machofp);
+ MACHO_SECTCMD64_SIZE, ofile);
/* in an MH_OBJECT file all sections are in one unnamed (name
** all zeros) segment */
- fwritezero(16, machofp);
- fwriteint64_t(0, machofp); /* in-memory offset */
- fwriteint64_t(seg_vmsize64, machofp); /* in-memory size */
- fwriteint64_t(offset, machofp); /* in-file offset to data */
- fwriteint64_t(seg_filesize64, machofp); /* in-file size */
- fwriteint32_t(VM_PROT_DEFAULT, machofp); /* maximum vm protection */
- fwriteint32_t(VM_PROT_DEFAULT, machofp); /* initial vm protection */
- fwriteint32_t(seg_nsects64, machofp); /* number of sections */
- fwriteint32_t(0, machofp); /* no flags */
+ fwritezero(16, ofile);
+ fwriteint64_t(0, ofile); /* in-memory offset */
+ fwriteint64_t(seg_vmsize64, ofile); /* in-memory size */
+ fwriteint64_t(offset, ofile); /* in-file offset to data */
+ fwriteint64_t(seg_filesize64, ofile); /* in-file size */
+ fwriteint32_t(VM_PROT_DEFAULT, ofile); /* maximum vm protection */
+ fwriteint32_t(VM_PROT_DEFAULT, ofile); /* initial vm protection */
+ fwriteint32_t(seg_nsects64, ofile); /* number of sections */
+ fwriteint32_t(0, ofile); /* no flags */
/* emit section headers */
for (s = sects; s != NULL; s = s->next) {
- fwrite(s->sectname, sizeof(s->sectname), 1, machofp);
- fwrite(s->segname, sizeof(s->segname), 1, machofp);
- fwriteint64_t(s->addr, machofp);
- fwriteint64_t(s->size, machofp);
+ fwrite(s->sectname, sizeof(s->sectname), 1, ofile);
+ fwrite(s->segname, sizeof(s->segname), 1, ofile);
+ fwriteint64_t(s->addr, ofile);
+ fwriteint64_t(s->size, ofile);
/* dummy data for zerofill sections or proper values */
if ((s->flags & SECTION_TYPE) != S_ZEROFILL) {
- fwriteint32_t(offset, machofp);
+ fwriteint32_t(offset, ofile);
/* Write out section alignment, as a power of two.
e.g. 32-bit word alignment would be 2 (2^2 = 4). */
if (s->align == -1)
s->align = DEFAULT_SECTION_ALIGNMENT;
- fwriteint32_t(s->align, machofp);
+ fwriteint32_t(s->align, ofile);
/* To be compatible with cctools as we emit
a zero reloff if we have no relocations. */
- fwriteint32_t(s->nreloc ? rel_base + s_reloff : 0, machofp);
- fwriteint32_t(s->nreloc, machofp);
+ fwriteint32_t(s->nreloc ? rel_base + s_reloff : 0, ofile);
+ fwriteint32_t(s->nreloc, ofile);
offset += s->size;
s_reloff += s->nreloc * MACHO_RELINFO64_SIZE;
} else {
- fwriteint32_t(0, machofp);
- fwriteint32_t(0, machofp);
- fwriteint32_t(0, machofp);
- fwriteint32_t(0, machofp);
+ fwriteint32_t(0, ofile);
+ fwriteint32_t(0, ofile);
+ fwriteint32_t(0, ofile);
+ fwriteint32_t(0, ofile);
}
if (s->nreloc) {
s->flags |= S_ATTR_EXT_RELOC;
}
- fwriteint32_t(s->flags, machofp); /* flags */
- fwriteint32_t(0, machofp); /* reserved */
- fwriteint32_t(0, machofp); /* reserved */
+ fwriteint32_t(s->flags, ofile); /* flags */
+ fwriteint32_t(0, ofile); /* reserved */
+ fwriteint32_t(0, ofile); /* reserved */
- fwriteint32_t(0, machofp); /* align */
+ fwriteint32_t(0, ofile); /* align */
}
rel_padcnt64 = rel_base - offset;
while (r) {
uint32_t word2;
- fwriteint32_t(r->addr, machofp); /* reloc offset */
+ fwriteint32_t(r->addr, ofile); /* reloc offset */
word2 = r->snum;
word2 |= r->pcrel << 24;
word2 |= r->length << 25;
word2 |= r->ext << 27;
word2 |= r->type << 28;
- fwriteint32_t(word2, machofp); /* reloc data */
+ fwriteint32_t(word2, ofile); /* reloc data */
r = r->next;
}
}
}
/* dump the section data to file */
- saa_fpwrite(s->data, machofp);
+ saa_fpwrite(s->data, ofile);
}
/* pad last section up to reloc entries on int64_t boundary */
- fwritezero(rel_padcnt64, machofp);
+ fwritezero(rel_padcnt64, ofile);
/* emit relocation entries */
for (s = sects; s != NULL; s = s->next)
for (sym = syms; sym != NULL; sym = sym->next) {
if ((sym->type & N_EXT) == 0) {
- fwriteint32_t(sym->strx, machofp); /* string table entry number */
- fwrite(&sym->type, 1, 1, machofp); /* symbol type */
- fwrite(&sym->sect, 1, 1, machofp); /* section */
- fwriteint16_t(sym->desc, machofp); /* description */
+ fwriteint32_t(sym->strx, ofile); /* string table entry number */
+ fwrite(&sym->type, 1, 1, ofile); /* symbol type */
+ fwrite(&sym->sect, 1, 1, ofile); /* section */
+ fwriteint16_t(sym->desc, ofile); /* description */
/* Fix up the symbol value now that we know the final section
sizes. */
sym->value += s->size;
}
- fwriteint64_t(sym->value, machofp); /* value (i.e. offset) */
+ fwriteint64_t(sym->value, ofile); /* value (i.e. offset) */
}
}
for (i = 0; i < nextdefsym; i++) {
sym = extdefsyms[i];
- fwriteint32_t(sym->strx, machofp);
- fwrite(&sym->type, 1, 1, machofp); /* symbol type */
- fwrite(&sym->sect, 1, 1, machofp); /* section */
- fwriteint16_t(sym->desc, machofp); /* description */
+ fwriteint32_t(sym->strx, ofile);
+ fwrite(&sym->type, 1, 1, ofile); /* symbol type */
+ fwrite(&sym->sect, 1, 1, ofile); /* section */
+ fwriteint16_t(sym->desc, ofile); /* description */
/* Fix up the symbol value now that we know the final section
sizes. */
sym->value += s->size;
}
- fwriteint64_t(sym->value, machofp); /* value (i.e. offset) */
+ fwriteint64_t(sym->value, ofile); /* value (i.e. offset) */
}
for (i = 0; i < nundefsym; i++) {
sym = undefsyms[i];
- fwriteint32_t(sym->strx, machofp);
- fwrite(&sym->type, 1, 1, machofp); /* symbol type */
- fwrite(&sym->sect, 1, 1, machofp); /* section */
- fwriteint16_t(sym->desc, machofp); /* description */
+ fwriteint32_t(sym->strx, ofile);
+ fwrite(&sym->type, 1, 1, ofile); /* symbol type */
+ fwrite(&sym->sect, 1, 1, ofile); /* section */
+ fwriteint16_t(sym->desc, ofile); /* description */
// Fix up the symbol value now that we know the final section sizes.
if (((sym->type & N_TYPE) == N_SECT) && (sym->sect != NO_SECT)) {
sym->value += s->size;
}
- fwriteint64_t(sym->value, machofp); // value (i.e. offset)
+ fwriteint64_t(sym->value, ofile); // value (i.e. offset)
}
}
if (seg_nsects64 > 0)
offset = macho_write_segment (offset);
else
- error(ERR_WARNING, "no sections?");
+ nasm_error(ERR_WARNING, "no sections?");
if (nsyms > 0) {
/* write out symbol command */
- fwriteint32_t(LC_SYMTAB, machofp); /* cmd == LC_SYMTAB */
- fwriteint32_t(MACHO_SYMCMD_SIZE, machofp); /* size of load command */
- fwriteint32_t(offset, machofp); /* symbol table offset */
- fwriteint32_t(nsyms, machofp); /* number of symbol
+ fwriteint32_t(LC_SYMTAB, ofile); /* cmd == LC_SYMTAB */
+ fwriteint32_t(MACHO_SYMCMD_SIZE, ofile); /* size of load command */
+ fwriteint32_t(offset, ofile); /* symbol table offset */
+ fwriteint32_t(nsyms, ofile); /* number of symbol
** table entries */
offset += nsyms * MACHO_NLIST64_SIZE;
- fwriteint32_t(offset, machofp); /* string table offset */
- fwriteint32_t(strslen, machofp); /* string table size */
+ fwriteint32_t(offset, ofile); /* string table offset */
+ fwriteint32_t(strslen, ofile); /* string table size */
}
/* emit section data */
/* we don't need to pad here since MACHO_NLIST64_SIZE == 16 */
/* emit string table */
- saa_fpwrite(strs, machofp);
+ saa_fpwrite(strs, ofile);
}
/* We do quite a bit here, starting with finalizing all of the data
for the object file, writing, and then freeing all of the data from
macho_calculate_sizes();
macho_write();
- /* done - yay! */
- fclose(machofp);
-
/* free up everything */
while (sects->next) {
s = sects;
&null_debug_form,
macho_stdmac,
macho_init,
- macho_setinfo,
+ null_setinfo,
macho_output,
macho_symdef,
macho_section,
macho_segbase,
- macho_directive,
+ null_directive,
macho_filename,
macho_cleanup
};
#include "nasm.h"
#include "nasmlib.h"
#include "stdscan.h"
+#include "eval.h"
#include "output/outform.h"
#include "output/outlib.h"
static char obj_infile[FILENAME_MAX];
-static efunc error;
-static evalfunc evaluate;
-static ldfunc deflabel;
-static FILE *ofp;
static int32_t first_seg;
static bool any_segs;
static int passtwo;
static int32_t obj_segment(char *, int, int *);
static void obj_write_file(int debuginfo);
-static int obj_directive(char *, char *, int);
+static int obj_directive(enum directives, char *, int);
-static void obj_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void obj_init(void)
{
- ofp = fp;
- error = errfunc;
- evaluate = eval;
- deflabel = ldef;
first_seg = seg_alloc();
any_segs = false;
fpubhead = NULL;
{
obj_write_file(debuginfo);
of_obj.current_dfmt->cleanup();
- fclose(ofp);
while (seghead) {
struct Segment *segtmp = seghead;
seghead = seghead->next;
obj_entry_ofs = offset;
return;
}
- error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
}
/*
pub->segment = (segment == NO_SEG ? 0 : segment & ~SEG_ABS);
}
if (special)
- error(ERR_NONFATAL, "OBJ supports no special symbol features"
+ nasm_error(ERR_NONFATAL, "OBJ supports no special symbol features"
" for this symbol type");
return;
}
if (!any_segs && segment == first_seg) {
int tempint; /* ignored */
if (segment != obj_segment("__NASMDEFSEG", 2, &tempint))
- error(ERR_PANIC, "strange segment conditions in OBJ driver");
+ nasm_error(ERR_PANIC, "strange segment conditions in OBJ driver");
}
for (seg = seghead; seg && is_global; seg = seg->next)
loc->offset = offset;
if (special)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"OBJ supports no special symbol features"
" for this symbol type");
return;
obj_ext_set_defwrt(ext, p);
special += len;
if (*special && *special != ':')
- error(ERR_NONFATAL, "`:' expected in special symbol"
+ nasm_error(ERR_NONFATAL, "`:' expected in special symbol"
" text for `%s'", ext->name);
else if (*special == ':')
special++;
if (ext->commonsize)
ext->commonelem = 1;
else
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"`%s': `far' keyword may only be applied"
" to common variables\n", ext->name);
special += 3;
if (ext->commonsize)
ext->commonelem = 0;
else
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"`%s': `far' keyword may only be applied"
" to common variables\n", ext->name);
special += 4;
stdscan_reset();
stdscan_bufptr = special;
tokval.t_type = TOKEN_INVALID;
- e = evaluate(stdscan, NULL, &tokval, NULL, 1, error, NULL);
+ e = evaluate(stdscan, NULL, &tokval, NULL, 1, nasm_error, NULL);
if (e) {
if (!is_simple(e))
- error(ERR_NONFATAL, "cannot use relocatable"
+ nasm_error(ERR_NONFATAL, "cannot use relocatable"
" expression as common-variable element size");
else
ext->commonelem = reloc_value(e);
}
special = stdscan_bufptr;
} else {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"`%s': element-size specifications only"
" apply to common variables", ext->name);
while (*special && *special != ':')
ext->index = ++externals;
if (special && !used_special)
- error(ERR_NONFATAL, "OBJ supports no special symbol features"
+ nasm_error(ERR_NONFATAL, "OBJ supports no special symbol features"
" for this symbol type");
}
*/
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
+ nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]"
" space");
return;
}
if (!any_segs) {
int tempint; /* ignored */
if (segto != obj_segment("__NASMDEFSEG", 2, &tempint))
- error(ERR_PANIC, "strange segment conditions in OBJ driver");
+ nasm_error(ERR_PANIC, "strange segment conditions in OBJ driver");
}
/*
if (seg->index == segto)
break;
if (!seg)
- error(ERR_PANIC, "code directed to nonexistent segment?");
+ nasm_error(ERR_PANIC, "code directed to nonexistent segment?");
orp = seg->orp;
orp->parm[0] = seg->currentpos;
int rsize;
if (segment == NO_SEG && type != OUT_ADDRESS)
- error(ERR_NONFATAL, "relative call to absolute address not"
+ nasm_error(ERR_NONFATAL, "relative call to absolute address not"
" supported by OBJ format");
if (segment >= SEG_ABS)
- error(ERR_NONFATAL, "far-absolute relocations not supported"
+ nasm_error(ERR_NONFATAL, "far-absolute relocations not supported"
" by OBJ format");
ldata = *(int64_t *)data;
if (type == OUT_REL2ADR) {
*/
rsize = 2;
if (ldata & 0xFFFF)
- error(ERR_NONFATAL, "OBJ format cannot handle complex"
+ nasm_error(ERR_NONFATAL, "OBJ format cannot handle complex"
" dword-size segment base references");
}
if (segment != NO_SEG)
ObjRecord *forp;
if (bytes == 1) {
- error(ERR_NONFATAL, "`obj' output driver does not support"
+ nasm_error(ERR_NONFATAL, "`obj' output driver does not support"
" one-byte relocations");
return;
}
locat = FIX_16_SELECTOR;
seg--;
if (bytes != 2)
- error(ERR_PANIC, "OBJ: 4-byte segment base fixup got"
+ nasm_error(ERR_PANIC, "OBJ: 4-byte segment base fixup got"
" through sanity check");
} else {
base = false;
if (eb)
method = 6, e = eb->exts[i], tidx = e->index;
else
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"unrecognised segment value in obj_write_fixup");
}
}
else if (e->defwrt_type == DEFWRT_GROUP)
method |= 0x10, fidx = e->defwrt_ptr.grp->obj_index;
else {
- error(ERR_NONFATAL, "default WRT specification for"
+ nasm_error(ERR_NONFATAL, "default WRT specification for"
" external `%s' unresolved", e->name);
method |= 0x50, fidx = -1; /* got to do _something_ */
}
if (eb)
method |= 0x20, fidx = eb->exts[i]->index;
else
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"unrecognised WRT value in obj_write_fixup");
}
}
obj_idx++;
if (!strcmp(seg->name, name)) {
if (attrs > 0 && pass == 1)
- error(ERR_WARNING, "segment attributes specified on"
+ nasm_error(ERR_WARNING, "segment attributes specified on"
" redeclaration of segment: ignoring");
if (seg->use32)
*bits = 32;
if (!strcmp(grp->name, "FLAT"))
break;
if (!grp) {
- obj_directive("group", "FLAT", 1);
+ obj_directive(D_GROUP, "FLAT", 1);
for (grp = grphead; grp; grp = grp->next)
if (!strcmp(grp->name, "FLAT"))
break;
if (!grp)
- error(ERR_PANIC, "failure to define FLAT?!");
+ nasm_error(ERR_PANIC, "failure to define FLAT?!");
}
seg->grp = grp;
} else if (!nasm_strnicmp(p, "class=", 6))
seg->align = readnum(p + 6, &rn_error);
if (rn_error) {
seg->align = 1;
- error(ERR_NONFATAL, "segment alignment should be"
+ nasm_error(ERR_NONFATAL, "segment alignment should be"
" numeric");
}
switch ((int)seg->align) {
case 4096: /* PharLap extension */
break;
case 8:
- error(ERR_WARNING,
+ nasm_error(ERR_WARNING,
"OBJ format does not support alignment"
" of 8: rounding up to 16");
seg->align = 16;
case 32:
case 64:
case 128:
- error(ERR_WARNING,
+ nasm_error(ERR_WARNING,
"OBJ format does not support alignment"
" of %d: rounding up to 256", seg->align);
seg->align = 256;
case 512:
case 1024:
case 2048:
- error(ERR_WARNING,
+ nasm_error(ERR_WARNING,
"OBJ format does not support alignment"
" of %d: rounding up to 4096", seg->align);
seg->align = 4096;
break;
default:
- error(ERR_NONFATAL, "invalid alignment value %d",
+ nasm_error(ERR_NONFATAL, "invalid alignment value %d",
seg->align);
seg->align = 1;
break;
} else if (!nasm_strnicmp(p, "absolute=", 9)) {
seg->align = SEG_ABS + readnum(p + 9, &rn_error);
if (rn_error)
- error(ERR_NONFATAL, "argument to `absolute' segment"
+ nasm_error(ERR_NONFATAL, "argument to `absolute' segment"
" attribute should be numeric");
}
}
obj_seg_needs_update = seg;
if (seg->align >= SEG_ABS)
- deflabel(name, NO_SEG, seg->align - SEG_ABS,
- NULL, false, false, &of_obj, error);
+ define_label(name, NO_SEG, seg->align - SEG_ABS,
+ NULL, false, false);
else
- deflabel(name, seg->index + 1, 0L,
- NULL, false, false, &of_obj, error);
+ define_label(name, seg->index + 1, 0L,
+ NULL, false, false);
obj_seg_needs_update = NULL;
/*
grp->segs[i] = grp->segs[grp->nindices];
grp->segs[grp->nindices++].index = seg->obj_index;
if (seg->grp)
- error(ERR_WARNING,
- "segment `%s' is already part of"
- " a group: first one takes precedence",
- seg->name);
+ nasm_error(ERR_WARNING,
+ "segment `%s' is already part of"
+ " a group: first one takes precedence",
+ seg->name);
else
seg->grp = grp;
}
}
}
-static int obj_directive(char *directive, char *value, int pass)
+static int obj_directive(enum directives directive, char *value, int pass)
{
- if (!strcmp(directive, "group")) {
+ switch (directive) {
+ case D_GROUP:
+ {
char *p, *q, *v;
if (pass == 1) {
struct Group *grp;
* practice, so the sanity check has been removed.
*
* if (!*q) {
- * error(ERR_NONFATAL,"GROUP directive contains no segments");
+ * nasm_error(ERR_NONFATAL,"GROUP directive contains no segments");
* return 1;
* }
*/
for (grp = grphead; grp; grp = grp->next) {
obj_idx++;
if (!strcmp(grp->name, v)) {
- error(ERR_NONFATAL, "group `%s' defined twice", v);
+ nasm_error(ERR_NONFATAL, "group `%s' defined twice", v);
return 1;
}
}
grp->name = NULL;
obj_grp_needs_update = grp;
- deflabel(v, grp->index + 1, 0L,
- NULL, false, false, &of_obj, error);
+ define_label(v, grp->index + 1, 0L, NULL, false, false);
obj_grp_needs_update = NULL;
while (*q) {
grp->segs[grp->nentries++] = grp->segs[grp->nindices];
grp->segs[grp->nindices++].index = seg->obj_index;
if (seg->grp)
- error(ERR_WARNING,
+ nasm_error(ERR_WARNING,
"segment `%s' is already part of"
" a group: first one takes precedence",
seg->name);
}
return 1;
}
- if (!strcmp(directive, "uppercase")) {
+ case D_UPPERCASE:
obj_uppercase = true;
return 1;
- }
- if (!strcmp(directive, "import")) {
+
+ case D_IMPORT:
+ {
char *q, *extname, *libname, *impname;
if (pass == 2)
impname = q;
if (!*extname || !*libname)
- error(ERR_NONFATAL, "`import' directive requires symbol name"
+ nasm_error(ERR_NONFATAL, "`import' directive requires symbol name"
" and library name");
else {
struct ImpDef *imp;
return 1;
}
- if (!strcmp(directive, "export")) {
+ case D_EXPORT:
+ {
char *q, *extname, *intname, *v;
struct ExpDef *export;
int flags = 0;
}
if (!*intname) {
- error(ERR_NONFATAL, "`export' directive requires export name");
+ nasm_error(ERR_NONFATAL, "`export' directive requires export name");
return 1;
}
if (!*extname) {
bool err = false;
flags |= EXPDEF_MASK_PARMCNT & readnum(v + 5, &err);
if (err) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"value `%s' for `parm' is non-numeric", v + 5);
return 1;
}
bool err = false;
ordinal = readnum(v, &err);
if (err) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"unrecognised export qualifier `%s'", v);
return 1;
}
return 1;
}
- return 0;
+ default:
+ return 0;
+ }
}
static int32_t obj_segbase(int32_t segment)
return segment; /* no special treatment */
}
-static void obj_filename(char *inname, char *outname, efunc lerror)
+static void obj_filename(char *inname, char *outname)
{
strcpy(obj_infile, inname);
- standard_extension(inname, outname, ".obj", lerror);
+ standard_extension(inname, outname, ".obj");
}
static void obj_write_file(int debuginfo)
/* acbp |= 0x00 */ ;
else if (seg->align >= 4096) {
if (seg->align > 4096)
- error(ERR_NONFATAL, "segment `%s' requires more alignment"
+ nasm_error(ERR_NONFATAL, "segment `%s' requires more alignment"
" than OBJ format supports", seg->name);
acbp |= 0xC0; /* PharLap extension */
} else if (seg->align >= 256) {
if (grp->nindices != grp->nentries) {
for (i = grp->nindices; i < grp->nentries; i++) {
- error(ERR_NONFATAL, "group `%s' contains undefined segment"
+ nasm_error(ERR_NONFATAL, "group `%s' contains undefined segment"
" `%s'", grp->name, grp->segs[i].name);
nasm_free(grp->segs[i].name);
grp->segs[i].name = NULL;
}
}
if (!seg)
- error(ERR_NONFATAL, "entry point is not in this module");
+ nasm_error(ERR_NONFATAL, "entry point is not in this module");
}
/*
cksum = orp->type;
if (orp->x_size == 32)
cksum |= 1;
- fputc(cksum, ofp);
+ fputc(cksum, ofile);
len = orp->committed + 1;
cksum += (len & 0xFF) + ((len >> 8) & 0xFF);
- fwriteint16_t(len, ofp);
- fwrite(orp->buf, 1, len - 1, ofp);
+ fwriteint16_t(len, ofile);
+ fwrite(orp->buf, 1, len - 1, ofile);
for (ptr = orp->buf; --len; ptr++)
cksum += *ptr;
- fputc((-cksum) & 0xFF, ofp);
+ fputc((-cksum) & 0xFF, ofile);
}
extern macros_t obj_stdmac[];
-void dbgbi_init(struct ofmt *of, void *id, FILE * fp, efunc error)
+void dbgbi_init(void)
{
- (void)of;
- (void)id;
- (void)fp;
- (void)error;
-
fnhead = NULL;
fntail = &fnhead;
arrindex = ARRAYBOT;
if (!any_segs) {
int tempint; /* ignored */
if (segto != obj_segment("__NASMDEFSEG", 2, &tempint))
- error(ERR_PANIC, "strange segment conditions in OBJ driver");
+ nasm_error(ERR_PANIC, "strange segment conditions in OBJ driver");
}
/*
if (seg->index == segto)
break;
if (!seg)
- error(ERR_PANIC, "lineno directed to nonexistent segment?");
+ nasm_error(ERR_PANIC, "lineno directed to nonexistent segment?");
/* for (fn = fnhead; fn; fn = fnhead->next) */
for (fn = fnhead; fn; fn = fn->next) /* fbk - Austin Lunnen - John Fine */
freemembuf(header);
freemembuf(seg[0]);
freemembuf(seg[1]);
- fclose(ofile);
}
static int32_t rdf_segbase(int32_t segment)
static struct SAA *seg[RDF_MAXSEGS]; /* seg 0 = code, seg 1 = data */
static struct SAA *header; /* relocation/import/export records */
-static FILE *ofile;
-
-static efunc error;
-
static struct seginfo {
char *segname;
int segnumber;
static int32_t bsslength;
static int32_t headerlength;
-static void rdf2_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
+static void rdf2_init(void)
{
int segtext, segdata, segbss;
- (void)ldef;
- (void)eval;
-
maxbits = 64;
/* set up the initial segments */
nsegments = 3;
- ofile = fp;
- error = errfunc;
-
seg[0] = saa_init(1L);
seg[1] = saa_init(1L);
seg[2] = NULL; /* special case! */
segdata = seg_alloc();
segbss = seg_alloc();
if (segtext != 0 || segdata != 2 || segbss != 4)
- error(ERR_PANIC,
+ nasm_error(ERR_PANIC,
"rdf segment numbers not allocated as expected (%d,%d,%d)",
segtext, segdata, segbss);
bsslength = 0;
reserved = readnum(q, &err);
if (err) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"value following comma must be numeric");
reserved = 0;
}
if (code == -1) { /* didn't find anything */
code = readnum(p, &err);
if (err) {
- error(ERR_NONFATAL, "unrecognised RDF segment type (%s)",
+ nasm_error(ERR_NONFATAL, "unrecognised RDF segment type (%s)",
p);
code = 3;
}
for (i = 0; i < nsegments; i++) {
if (!strcmp(name, segments[i].segname)) {
if (code != -1 || reserved != 0)
- error(ERR_NONFATAL, "segment attributes specified on"
+ nasm_error(ERR_NONFATAL, "segment attributes specified on"
" redeclaration of segment");
return segments[i].segnumber * 2;
}
/* declaring a new segment! */
if (code == -1) {
- error(ERR_NONFATAL, "new segment declared without type code");
+ nasm_error(ERR_NONFATAL, "new segment declared without type code");
code = 3;
}
if (nsegments == RDF_MAXSEGS) {
- error(ERR_FATAL, "reached compiled-in maximum segment limit (%d)",
+ nasm_error(ERR_FATAL, "reached compiled-in maximum segment limit (%d)",
RDF_MAXSEGS);
return NO_SEG;
}
segments[nsegments].segname = nasm_strdup(name);
i = seg_alloc();
if (i % 2 != 0)
- error(ERR_PANIC, "seg_alloc() returned odd number");
+ nasm_error(ERR_PANIC, "seg_alloc() returned odd number");
segments[nsegments].segnumber = i >> 1;
segments[nsegments].segtype = code;
segments[nsegments].segreserved = reserved;
/* Check if the label length is OK */
if ((len = strlen(name)) >= EXIM_LABEL_MAX) {
- error(ERR_NONFATAL, "label size exceeds %d bytes", EXIM_LABEL_MAX);
+ nasm_error(ERR_NONFATAL, "label size exceeds %d bytes", EXIM_LABEL_MAX);
return;
}
if (!len) {
- error(ERR_NONFATAL, "zero-length label");
+ nasm_error(ERR_NONFATAL, "zero-length label");
return;
}
bool err;
ci.align = readnum(special, &err);
if (err)
- error(ERR_NONFATAL, "alignment constraint `%s' is not a"
+ nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
" valid number", special);
else if ((ci.align | (ci.align - 1)) != 2 * ci.align - 1)
- error(ERR_NONFATAL, "alignment constraint `%s' is not a"
+ nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
" power of two", special);
}
write_common_rec(&ci);
!nasm_stricmp(special, "object")) {
symflags |= SYM_DATA;
} else
- error(ERR_NONFATAL, "unrecognised symbol type `%s'",
+ nasm_error(ERR_NONFATAL, "unrecognised symbol type `%s'",
special);
}
}
if (name[0] == '.' && name[1] == '.' && name[2] != '@') {
- error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
+ nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name);
return;
}
if (i >= nsegments) { /* EXTERN declaration */
ri.type = farsym ? RDFREC_FARIMPORT : RDFREC_IMPORT;
if (symflags & SYM_GLOBAL)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"symbol type conflict - EXTERN cannot be EXPORT");
ri.flags = symflags;
ri.segment = segment;
} else if (is_global) {
r.type = RDFREC_GLOBAL; /* GLOBAL declaration */
if (symflags & SYM_IMPORT)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"symbol type conflict - GLOBAL cannot be IMPORT");
r.flags = symflags;
r.segment = segment;
break;
}
if (i == nsegments)
- error(ERR_PANIC, "can't find segment %d", segment);
+ nasm_error(ERR_PANIC, "can't find segment %d", segment);
if (bytes < 0) {
b = buf;
break;
}
if (i == nsegments)
- error(ERR_PANIC, "can't find segment %d", segment);
+ nasm_error(ERR_PANIC, "can't find segment %d", segment);
return segments[i].seglength;
}
if (segto == NO_SEG) {
if (type != OUT_RESERVE)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"attempt to assemble code in ABSOLUTE space");
return;
}
break;
}
if (seg >= nsegments) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"specified segment not supported by rdf output format");
return;
}
if (wrt != NO_SEG) {
wrt = NO_SEG; /* continue to do _something_ */
- error(ERR_NONFATAL, "WRT not supported by rdf output format");
+ nasm_error(ERR_NONFATAL, "WRT not supported by rdf output format");
}
if (segto == 2 && type != OUT_RESERVE) {
- error(ERR_NONFATAL, "BSS segments may not be initialized");
+ nasm_error(ERR_NONFATAL, "BSS segments may not be initialized");
/* just reserve the space for now... */
membufwrite(segto, databuf, 1);
} else if (type == OUT_RAWDATA) {
if (segment != NO_SEG)
- error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
+ nasm_error(ERR_PANIC, "OUT_RAWDATA with other than NO_SEG");
membufwrite(segto, data, size);
} else if (type == OUT_ADDRESS) {
membufwrite(segto, databuf, size);
} else if (type == OUT_REL2ADR) {
if (segment == segto)
- error(ERR_PANIC, "intra-segment OUT_REL2ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR");
rr.reclen = 8;
rr.offset = getsegmentlength(segto); /* current offset */
membufwrite(segto, &rr.offset, -2);
} else if (type == OUT_REL4ADR) {
if ((segment == segto) && (globalbits != 64))
- error(ERR_PANIC, "intra-segment OUT_REL4ADR");
+ nasm_error(ERR_PANIC, "intra-segment OUT_REL4ADR");
if (segment != NO_SEG && segment % 2) {
- error(ERR_PANIC, "erm... 4 byte segment base ref?");
+ nasm_error(ERR_PANIC, "erm... 4 byte segment base ref?");
}
rr.type = RDFREC_RELOC; /* type signature */
fwriteint32_t(0, ofile);
fwriteint32_t(0, ofile);
fwriteint16_t(0, ofile);
-
- fclose(ofile);
}
static int32_t rdf2_segbase(int32_t segment)
/*
* Handle RDOFF2 specific directives
*/
-static int rdf2_directive(char *directive, char *value, int pass)
+static int rdf2_directive(enum directives directive, char *value, int pass)
{
- int n;
-
- /* Check if the name length is OK */
- if ((n = strlen(value)) >= MODLIB_NAME_MAX) {
- error(ERR_NONFATAL, "name size exceeds %d bytes", MODLIB_NAME_MAX);
- return 0;
- }
-
- if (!strcmp(directive, "library")) {
+ size_t n;
+
+ switch (directive) {
+ case D_LIBRARY:
+ n = strlen(value);
+ if (n >= MODLIB_NAME_MAX) {
+ nasm_error(ERR_NONFATAL, "name size exceeds %d bytes", MODLIB_NAME_MAX);
+ return 1;
+ }
if (pass == 1) {
struct DLLRec r;
r.type = RDFREC_DLL;
write_dll_rec(&r);
}
return 1;
- }
-
- if (!strcmp(directive, "module")) {
+
+ case D_MODULE:
+ if ((n = strlen(value)) >= MODLIB_NAME_MAX) {
+ nasm_error(ERR_NONFATAL, "name size exceeds %d bytes", MODLIB_NAME_MAX);
+ return 1;
+ }
if (pass == 1) {
struct ModRec r;
r.type = RDFREC_MODNAME;
write_modname_rec(&r);
}
return 1;
- }
- return 0;
+ default:
+ return 0;
+ }
}
-static void rdf2_filename(char *inname, char *outname, efunc error)
+static void rdf2_filename(char *inname, char *outname)
{
- standard_extension(inname, outname, ".rdf", error);
+ standard_extension(inname, outname, ".rdf");
}
extern macros_t rdf2_stdmac[];
#include "insns.h"
#include "nasmlib.h"
#include "stdscan.h"
+#include "eval.h"
#include "parser.h"
#include "float.h"
#include "tables.h"
static int i;
static struct tokenval tokval;
-static efunc error;
-static struct ofmt *outfmt; /* Structure of addresses of output routines */
static struct location *location; /* Pointer to current line's segment,offset */
-void parser_global_info(struct ofmt *output, struct location * locp)
+void parser_global_info(struct location * locp)
{
- outfmt = output;
location = locp;
}
case P_ASP:
return PPS_ASIZE;
default:
- error(ERR_PANIC, "Invalid value %d passed to prefix_slot()", prefix);
+ nasm_error(ERR_PANIC, "Invalid value %d passed to prefix_slot()", prefix);
return -1;
}
}
result->oprs[operand].type |= BITS128;
break;
default:
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"invalid operand size specification");
break;
}
case P_A64:
if (result->prefixes[PPS_ASIZE] &&
result->prefixes[PPS_ASIZE] != tokval.t_integer)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"conflicting address size specifications");
else
result->prefixes[PPS_ASIZE] = tokval.t_integer;
result->oprs[operand].eaflags |= EAF_WORDOFFS;
break;
default:
- error(ERR_NONFATAL, "invalid size specification in"
+ nasm_error(ERR_NONFATAL, "invalid size specification in"
" effective address");
break;
}
}
}
-insn *parse_line(int pass, char *buffer, insn * result,
- efunc errfunc, evalfunc evaluate, ldfunc ldef)
+insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef)
{
int operand;
int critical;
restart_parse:
first = true;
result->forw_ref = false;
- error = errfunc;
stdscan_reset();
stdscan_bufptr = buffer;
}
if (i != TOKEN_ID && i != TOKEN_INSN && i != TOKEN_PREFIX &&
(i != TOKEN_REG || (REG_SREG & ~nasm_reg_flags[tokval.t_integer]))) {
- error(ERR_NONFATAL, "label or instruction expected"
+ nasm_error(ERR_NONFATAL, "label or instruction expected"
" at start of line");
result->opcode = -1;
return result;
if (i == ':') { /* skip over the optional colon */
i = stdscan(NULL, &tokval);
} else if (i == 0) {
- error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
+ nasm_error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
"label alone on a line without a colon might be in error");
}
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
* am still not certain.
*/
ldef(result->label, in_abs_seg ? abs_seg : location->segment,
- location->offset, NULL, true, false, outfmt, errfunc);
+ location->offset, NULL, true, false);
}
}
i = stdscan(NULL, &tokval);
value =
- evaluate(stdscan, NULL, &tokval, NULL, pass0, error, NULL);
+ evaluate(stdscan, NULL, &tokval, NULL, pass0, nasm_error, NULL);
i = tokval.t_type;
if (!value) { /* but, error in evaluator */
result->opcode = -1; /* unrecoverable parse error: */
return result; /* ignore this instruction */
}
if (!is_simple(value)) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"non-constant argument supplied to TIMES");
result->times = 1L;
} else {
result->times = value->value;
if (value->value < 0 && pass0 == 2) {
- error(ERR_NONFATAL, "TIMES value %d is negative",
+ nasm_error(ERR_NONFATAL, "TIMES value %d is negative",
value->value);
result->times = 0;
}
int slot = prefix_slot(tokval.t_integer);
if (result->prefixes[slot]) {
if (result->prefixes[slot] == tokval.t_integer)
- error(ERR_WARNING,
+ nasm_error(ERR_WARNING,
"instruction has redundant prefixes");
else
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"instruction has conflicting prefixes");
}
result->prefixes[slot] = tokval.t_integer;
result->oprs[0].segment = result->oprs[0].wrt = NO_SEG;
return result;
} else {
- error(ERR_NONFATAL, "parser: instruction expected");
+ nasm_error(ERR_NONFATAL, "parser: instruction expected");
result->opcode = -1;
return result;
}
i = stdscan(NULL, &tokval);
}
if (i != TOKEN_STR) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"%s must be followed by a string constant",
funcname);
eop->type = EOT_NOTHING;
string_transform(tokval.t_charptr, tokval.t_inttwo,
&eop->stringval, func);
if (eop->stringlen == (size_t)-1) {
- error(ERR_NONFATAL, "invalid string for transform");
+ nasm_error(ERR_NONFATAL, "invalid string for transform");
eop->type = EOT_NOTHING;
}
}
if (parens && i && i != ')') {
i = stdscan(NULL, &tokval);
if (i != ')') {
- error(ERR_NONFATAL, "unterminated %s function",
+ nasm_error(ERR_NONFATAL, "unterminated %s function",
funcname);
}
}
eop->stringlen = 16;
break;
case I_DY:
- error(ERR_NONFATAL, "floating-point constant"
+ nasm_error(ERR_NONFATAL, "floating-point constant"
" encountered in DY instruction");
eop->stringlen = 0;
break;
default:
- error(ERR_NONFATAL, "floating-point constant"
+ nasm_error(ERR_NONFATAL, "floating-point constant"
" encountered in unknown instruction");
/*
* fix suggested by Pedro Gimeno... original line
if (!eop->stringlen ||
!float_const(tokval.t_charptr, sign,
(uint8_t *)eop->stringval,
- eop->stringlen, error))
+ eop->stringlen, nasm_error))
eop->type = EOT_NOTHING;
i = stdscan(NULL, &tokval); /* eat the comma */
} else {
is_expression:
value = evaluate(stdscan, NULL, &tokval, NULL,
- critical, error, NULL);
+ critical, nasm_error, NULL);
i = tokval.t_type;
if (!value) { /* error in evaluator */
result->opcode = -1; /* unrecoverable parse error: */
eop->segment = reloc_seg(value);
eop->wrt = reloc_wrt(value);
} else {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"operand %d: expression is not simple"
" or relocatable", oper_num);
}
if (i == 0) /* also could be EOL */
break;
if (i != ',') {
- error(ERR_NONFATAL, "comma expected after operand %d",
+ nasm_error(ERR_NONFATAL, "comma expected after operand %d",
oper_num);
result->opcode = -1; /* unrecoverable parse error: */
return result; /* ignore this instruction */
* operands.
*/
if (!result->eops || result->eops->type != EOT_DB_STRING)
- error(ERR_NONFATAL, "`incbin' expects a file name");
+ nasm_error(ERR_NONFATAL, "`incbin' expects a file name");
else if (result->eops->next &&
result->eops->next->type != EOT_DB_NUMBER)
- error(ERR_NONFATAL, "`incbin': second parameter is",
+ nasm_error(ERR_NONFATAL, "`incbin': second parameter is",
" non-numeric");
else if (result->eops->next && result->eops->next->next &&
result->eops->next->next->type != EOT_DB_NUMBER)
- error(ERR_NONFATAL, "`incbin': third parameter is",
+ nasm_error(ERR_NONFATAL, "`incbin': third parameter is",
" non-numeric");
else if (result->eops->next && result->eops->next->next &&
result->eops->next->next->next)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"`incbin': more than three parameters");
else
return result;
result->opcode = -1;
return result;
} else /* DB ... */ if (oper_num == 0)
- error(ERR_WARNING | ERR_PASS1,
+ nasm_error(ERR_WARNING | ERR_PASS1,
"no operand for data declaration");
else
result->operands = oper_num;
result->oprs[operand].type |= SHORT;
break;
default:
- error(ERR_NONFATAL, "invalid operand size specification");
+ nasm_error(ERR_NONFATAL, "invalid operand size specification");
}
i = stdscan(NULL, &tokval);
}
if ((result->oprs[operand].type & FAR) && !mref &&
result->opcode != I_JMP && result->opcode != I_CALL) {
- error(ERR_NONFATAL, "invalid use of FAR operand specifier");
+ nasm_error(ERR_NONFATAL, "invalid use of FAR operand specifier");
}
value = evaluate(stdscan, NULL, &tokval,
&result->oprs[operand].opflags,
- critical, error, &hints);
+ critical, nasm_error, &hints);
i = tokval.t_type;
if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
result->forw_ref = true;
}
- if (!value) { /* error in evaluator */
+ if (!value) { /* nasm_error in evaluator */
result->opcode = -1; /* unrecoverable parse error: */
return result; /* ignore this instruction */
}
*/
if (value[1].type != 0 || value->value != 1 ||
REG_SREG & ~nasm_reg_flags[value->type])
- error(ERR_NONFATAL, "invalid segment override");
+ nasm_error(ERR_NONFATAL, "invalid segment override");
else if (result->prefixes[PPS_SEG])
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"instruction has conflicting segment overrides");
else {
result->prefixes[PPS_SEG] = value->type;
}
value = evaluate(stdscan, NULL, &tokval,
&result->oprs[operand].opflags,
- critical, error, &hints);
+ critical, nasm_error, &hints);
i = tokval.t_type;
if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
result->forw_ref = true;
recover = false;
if (mref && bracket) { /* find ] at the end */
if (i != ']') {
- error(ERR_NONFATAL, "parser: expecting ]");
+ nasm_error(ERR_NONFATAL, "parser: expecting ]");
recover = true;
} else { /* we got the required ] */
i = stdscan(NULL, &tokval);
if (i != 0 && i != ',') {
- error(ERR_NONFATAL, "comma or end of line expected");
+ nasm_error(ERR_NONFATAL, "comma or end of line expected");
recover = true;
}
}
} else { /* immediate operand */
if (i != 0 && i != ',' && i != ':') {
- error(ERR_NONFATAL, "comma, colon or end of line expected");
+ nasm_error(ERR_NONFATAL, "comma, colon or end of line expected");
recover = true;
} else if (i == ':') {
result->oprs[operand].type |= COLON;
i = e->type, s = e->value; /* second has to be indexreg */
else if (e->value != 1) { /* If both want to be index */
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-592-invalid effective address");
result->opcode = -1;
return result;
}
if (e->type != 0) { /* is there an offset? */
if (e->type <= EXPR_REG_END) { /* in fact, is there an error? */
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-603-invalid effective address");
result->opcode = -1;
return result;
* Look for a segment base type.
*/
if (e->type && e->type < EXPR_SEGBASE) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-630-invalid effective address");
result->opcode = -1;
return result;
while (e->type && e->value == 0)
e++;
if (e->type && e->value != 1) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-637-invalid effective address");
result->opcode = -1;
return result;
while (e->type && e->value == 0)
e++;
if (e->type) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-650-invalid effective address");
result->opcode = -1;
return result;
}
if (e->type != 0) { /* there'd better be nothing left! */
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-663-invalid effective address");
result->opcode = -1;
return result;
unsigned int rs;
if (value->type >= EXPR_SIMPLE || value->value != 1) {
- error(ERR_NONFATAL, "invalid operand type");
+ nasm_error(ERR_NONFATAL, "invalid operand type");
result->opcode = -1;
return result;
}
*/
for (i = 1; value[i].type; i++)
if (value[i].value) {
- error(ERR_NONFATAL, "invalid operand type");
+ nasm_error(ERR_NONFATAL, "invalid operand type");
result->opcode = -1;
return result;
}
result->oprs[operand].basereg = value->type;
if (rs && (result->oprs[operand].type & SIZE_MASK) != rs)
- error(ERR_WARNING | ERR_PASS1,
+ nasm_error(ERR_WARNING | ERR_PASS1,
"register size specification ignored");
}
}
#ifndef NASM_PARSER_H
#define NASM_PARSER_H
-void parser_global_info(struct ofmt *output, struct location * locp);
-insn *parse_line(int pass, char *buffer, insn * result,
- efunc error, evalfunc evaluate, ldfunc ldef);
-void cleanup_insn(insn * instruction);
+void parser_global_info(struct location *locp);
+insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef);
+void cleanup_insn(insn *instruction);
#endif
%clear
%define
%defstr
+%deftok
%depend
%elif*
%else
%endmacro
%endrep
%error
+%exitmacro
%exitrep
%fatal
%iassign
%idefine
%idefstr
+%ideftok
%if*
%imacro
+%irmacro
%include
%ixdefine
%line
%push
%rep
%repl
+%rmacro
%rotate
%stacksize
%strcat
#include "hashtbl.h"
#include "quote.h"
#include "stdscan.h"
+#include "eval.h"
#include "tokens.h"
#include "tables.h"
typedef struct SMacro SMacro;
typedef struct MMacro MMacro;
+typedef struct MMacroInvocation MMacroInvocation;
typedef struct Context Context;
typedef struct Token Token;
typedef struct Blocks Blocks;
*/
struct MMacro {
MMacro *next;
+ MMacroInvocation *prev; /* previous invocation */
char *name;
int nparam_min, nparam_max;
bool casesense;
bool plus; /* is the last parameter greedy? */
bool nolist; /* is this macro listing-inhibited? */
- int64_t in_progress;
+ int64_t in_progress; /* is this macro currently being expanded? */
+ int32_t max_depth; /* maximum number of recursive expansions allowed */
Token *dlist; /* All defaults as one list */
Token **defaults; /* Parameter default pointers */
int ndefs; /* number of default parameters */
int lineno; /* Current line number on expansion */
};
+
+/* Store the definition of a multi-line macro, as defined in a
+ * previous recursive macro expansion.
+ */
+struct MMacroInvocation {
+ MMacroInvocation *prev; /* previous invocation */
+ Token **params; /* actual parameters */
+ Token *iline; /* invocation line */
+ unsigned int nparam, rotate;
+ int *paramlen;
+ uint64_t unique;
+};
+
+
/*
* The context stack is composed of a linked list of these.
*/
#define DIRECTIVE_FOUND 1
/*
+ * This define sets the upper limit for smacro and recursive mmacro
+ * expansions
+ */
+#define DEADMAN_LIMIT (1 << 20)
+
+/*
* Condition codes. Note that we use c_ prefix not C_ because C_ is
* used in nasm.h for the "real" condition codes. At _this_ level,
* we treat CXZ and ECXZ as condition codes, albeit non-invertible
static Include *istk;
static IncPath *ipath = NULL;
-static efunc _error; /* Pointer to client-provided error reporting function */
-static evalfunc evaluate;
-
static int pass; /* HACK: pass 0 = generate dependencies only */
static StrList **dephead, **deptail; /* Dependency list */
/* Handling unterminated string by UNV */
/*if (type == -1)
- {
- *tail = t = new_Token(NULL, TOK_STRING, line, p-line+1);
- t->text[p-line] = *line;
- tail = &t->next;
- }
- else */
+ {
+ *tail = t = new_Token(NULL, TOK_STRING, line, p-line+1);
+ t->text[p-line] = *line;
+ tail = &t->next;
+ }
+ else */
if (type != TOK_COMMENT) {
*tail = t = new_Token(NULL, type, line, p - line);
tail = &t->next;
Token *t;
int i;
- if (freeTokens == NULL) {
+ if (!freeTokens) {
freeTokens = (Token *) new_Block(TOKEN_BLOCKSIZE * sizeof(Token));
for (i = 0; i < TOKEN_BLOCKSIZE - 1; i++)
freeTokens[i].next = &freeTokens[i + 1];
t->next = next;
t->a.mac = NULL;
t->type = type;
- if (type == TOK_WHITESPACE || text == NULL) {
+ if (type == TOK_WHITESPACE || !text) {
t->text = NULL;
} else {
if (txtlen == 0)
break;
case PPC_IFMACRO:
- {
- bool found = false;
- MMacro searching, *mmac;
+ {
+ bool found = false;
+ MMacro searching, *mmac;
- skip_white_(tline);
- tline = expand_id(tline);
- if (!tok_type_(tline, TOK_ID)) {
- error(ERR_NONFATAL,
- "`%s' expects a macro name", pp_directives[ct]);
- goto fail;
- }
- searching.name = nasm_strdup(tline->text);
- searching.casesense = true;
- searching.plus = false;
- searching.nolist = false;
- searching.in_progress = 0;
- searching.rep_nest = NULL;
- searching.nparam_min = 0;
- searching.nparam_max = INT_MAX;
- tline = expand_smacro(tline->next);
- skip_white_(tline);
- if (!tline) {
- } else if (!tok_type_(tline, TOK_NUMBER)) {
- error(ERR_NONFATAL,
- "`%s' expects a parameter count or nothing",
- pp_directives[ct]);
- } else {
- searching.nparam_min = searching.nparam_max =
- readnum(tline->text, &j);
- if (j)
- error(ERR_NONFATAL,
- "unable to parse parameter count `%s'",
- tline->text);
- }
- if (tline && tok_is_(tline->next, "-")) {
- tline = tline->next->next;
- if (tok_is_(tline, "*"))
- searching.nparam_max = INT_MAX;
- else if (!tok_type_(tline, TOK_NUMBER))
- error(ERR_NONFATAL,
- "`%s' expects a parameter count after `-'",
- pp_directives[ct]);
- else {
- searching.nparam_max = readnum(tline->text, &j);
- if (j)
- error(ERR_NONFATAL,
- "unable to parse parameter count `%s'",
- tline->text);
- if (searching.nparam_min > searching.nparam_max)
- error(ERR_NONFATAL,
- "minimum parameter count exceeds maximum");
- }
- }
- if (tline && tok_is_(tline->next, "+")) {
- tline = tline->next;
- searching.plus = true;
- }
- mmac = (MMacro *) hash_findix(&mmacros, searching.name);
- while (mmac) {
- if (!strcmp(mmac->name, searching.name) &&
- (mmac->nparam_min <= searching.nparam_max
- || searching.plus)
- && (searching.nparam_min <= mmac->nparam_max
- || mmac->plus)) {
- found = true;
- break;
- }
- mmac = mmac->next;
+ skip_white_(tline);
+ tline = expand_id(tline);
+ if (!tok_type_(tline, TOK_ID)) {
+ error(ERR_NONFATAL,
+ "`%s' expects a macro name", pp_directives[ct]);
+ goto fail;
+ }
+ searching.name = nasm_strdup(tline->text);
+ searching.casesense = true;
+ searching.plus = false;
+ searching.nolist = false;
+ searching.in_progress = 0;
+ searching.max_depth = 0;
+ searching.rep_nest = NULL;
+ searching.nparam_min = 0;
+ searching.nparam_max = INT_MAX;
+ tline = expand_smacro(tline->next);
+ skip_white_(tline);
+ if (!tline) {
+ } else if (!tok_type_(tline, TOK_NUMBER)) {
+ error(ERR_NONFATAL,
+ "`%s' expects a parameter count or nothing",
+ pp_directives[ct]);
+ } else {
+ searching.nparam_min = searching.nparam_max =
+ readnum(tline->text, &j);
+ if (j)
+ error(ERR_NONFATAL,
+ "unable to parse parameter count `%s'",
+ tline->text);
+ }
+ if (tline && tok_is_(tline->next, "-")) {
+ tline = tline->next->next;
+ if (tok_is_(tline, "*"))
+ searching.nparam_max = INT_MAX;
+ else if (!tok_type_(tline, TOK_NUMBER))
+ error(ERR_NONFATAL,
+ "`%s' expects a parameter count after `-'",
+ pp_directives[ct]);
+ else {
+ searching.nparam_max = readnum(tline->text, &j);
+ if (j)
+ error(ERR_NONFATAL,
+ "unable to parse parameter count `%s'",
+ tline->text);
+ if (searching.nparam_min > searching.nparam_max)
+ error(ERR_NONFATAL,
+ "minimum parameter count exceeds maximum");
}
- if(tline && tline->next)
- error(ERR_WARNING|ERR_PASS1,
- "trailing garbage after %%ifmacro ignored");
- nasm_free(searching.name);
- j = found;
- break;
- }
+ }
+ if (tline && tok_is_(tline->next, "+")) {
+ tline = tline->next;
+ searching.plus = true;
+ }
+ mmac = (MMacro *) hash_findix(&mmacros, searching.name);
+ while (mmac) {
+ if (!strcmp(mmac->name, searching.name) &&
+ (mmac->nparam_min <= searching.nparam_max
+ || searching.plus)
+ && (searching.nparam_min <= mmac->nparam_max
+ || mmac->plus)) {
+ found = true;
+ break;
+ }
+ mmac = mmac->next;
+ }
+ if (tline && tline->next)
+ error(ERR_WARNING|ERR_PASS1,
+ "trailing garbage after %%ifmacro ignored");
+ nasm_free(searching.name);
+ j = found;
+ break;
+ }
case PPC_IFID:
needtype = TOK_ID;
return false;
}
+ def->prev = NULL;
def->name = nasm_strdup(tline->text);
def->plus = false;
def->nolist = false;
tline = tline->next;
def->nolist = true;
}
-
+
/*
* Handle default parameters.
*/
}
def->expansion = NULL;
- if(def->defaults &&
- def->ndefs > def->nparam_max - def->nparam_min &&
- !def->plus)
- error(ERR_WARNING|ERR_PASS1|ERR_WARN_MDP,
- "too many default macro parameters");
+ if (def->defaults && def->ndefs > def->nparam_max - def->nparam_min &&
+ !def->plus)
+ error(ERR_WARNING|ERR_PASS1|ERR_WARN_MDP,
+ "too many default macro parameters");
return true;
}
return sizes[bsii(str, size_names, elements(size_names))+1];
}
+/*
+ * nasm_unquote with error if the string contains NUL characters.
+ * If the string contains NUL characters, issue an error and return
+ * the C len, i.e. truncate at the NUL.
+ */
+static size_t nasm_unquote_cstr(char *qstr, enum preproc_token directive)
+{
+ size_t len = nasm_unquote(qstr, NULL);
+ size_t clen = strlen(qstr);
+
+ if (len != clen)
+ error(ERR_NONFATAL, "NUL character in `%s' directive",
+ pp_directives[directive]);
+
+ return clen;
+}
+
/**
* find and process preprocessor directive in passed line
* Find out if a line contains a preprocessor directive, and deal
* If we're in a %rep block, another %rep nests, so should be let through.
*/
if (defining && i != PP_MACRO && i != PP_IMACRO &&
+ i != PP_RMACRO && i != PP_IRMACRO &&
i != PP_ENDMACRO && i != PP_ENDM &&
(defining->name || (i != PP_ENDREP && i != PP_REP))) {
return NO_DIRECTIVE_FOUND;
}
if (defining) {
- if (i == PP_MACRO || i == PP_IMACRO) {
+ if (i == PP_MACRO || i == PP_IMACRO ||
+ i == PP_RMACRO || i == PP_IRMACRO) {
nested_mac_count++;
return NO_DIRECTIVE_FOUND;
} else if (nested_mac_count > 0) {
t = tline->next = expand_smacro(tline->next);
skip_white_(t);
if (!t || (t->type != TOK_STRING &&
- t->type != TOK_INTERNAL_STRING)) {
+ t->type != TOK_INTERNAL_STRING)) {
error(ERR_NONFATAL, "`%%depend' expects a file name");
free_tlist(origline);
return DIRECTIVE_FOUND; /* but we did _something_ */
"trailing garbage after `%%depend' ignored");
p = t->text;
if (t->type != TOK_INTERNAL_STRING)
- nasm_unquote(p, NULL);
+ nasm_unquote_cstr(p, i);
if (dephead && !in_list(*dephead, p)) {
StrList *sl = nasm_malloc(strlen(p)+1+sizeof sl->next);
sl->next = NULL;
skip_white_(t);
if (!t || (t->type != TOK_STRING &&
- t->type != TOK_INTERNAL_STRING)) {
+ t->type != TOK_INTERNAL_STRING)) {
error(ERR_NONFATAL, "`%%include' expects a file name");
free_tlist(origline);
return DIRECTIVE_FOUND; /* but we did _something_ */
"trailing garbage after `%%include' ignored");
p = t->text;
if (t->type != TOK_INTERNAL_STRING)
- nasm_unquote(p, NULL);
+ nasm_unquote_cstr(p, i);
inc = nasm_malloc(sizeof(Include));
inc->next = istk;
inc->conds = NULL;
error(ERR_WARNING|ERR_PASS1,
"trailing garbage after `%%use' ignored");
if (tline->type == TOK_STRING)
- nasm_unquote(tline->text, NULL);
+ nasm_unquote_cstr(tline->text, i);
use_pkg = nasm_stdmac_find_package(tline->text);
if (!use_pkg)
error(ERR_NONFATAL, "unknown `%%use' package: %s", tline->text);
/* Only error out if this is the final pass */
if (pass != 2 && i != PP_FATAL)
return DIRECTIVE_FOUND;
-
- tline->next = expand_smacro(tline->next);
- tline = tline->next;
- skip_white_(tline);
+
+ tline->next = expand_smacro(tline->next);
+ tline = tline->next;
+ skip_white_(tline);
t = tline ? tline->next : NULL;
skip_white_(t);
- if (tok_type_(tline, TOK_STRING) && !t) {
+ if (tok_type_(tline, TOK_STRING) && !t) {
/* The line contains only a quoted string */
p = tline->text;
- nasm_unquote(p, NULL);
+ nasm_unquote(p, NULL); /* Ignore NUL character truncation */
error(severity, "%s", p);
} else {
/* Not a quoted string, or more than a quoted string */
- p = detoken(tline, false);
+ p = detoken(tline, false);
error(severity, "%s", p);
nasm_free(p);
}
- free_tlist(origline);
+ free_tlist(origline);
return DIRECTIVE_FOUND;
}
if (!istk->conds)
error(ERR_FATAL, "`%s': no matching `%%if'", pp_directives[i]);
switch(istk->conds->state) {
- case COND_IF_TRUE:
- istk->conds->state = COND_DONE;
- break;
+ case COND_IF_TRUE:
+ istk->conds->state = COND_DONE;
+ break;
- case COND_DONE:
- case COND_NEVER:
- break;
+ case COND_DONE:
+ case COND_NEVER:
+ break;
- case COND_ELSE_TRUE:
- case COND_ELSE_FALSE:
- error_precond(ERR_WARNING|ERR_PASS1,
- "`%%elif' after `%%else' ignored");
- istk->conds->state = COND_NEVER;
- break;
+ case COND_ELSE_TRUE:
+ case COND_ELSE_FALSE:
+ error_precond(ERR_WARNING|ERR_PASS1,
+ "`%%elif' after `%%else' ignored");
+ istk->conds->state = COND_NEVER;
+ break;
- case COND_IF_FALSE:
- /*
- * IMPORTANT: In the case of %if, we will already have
- * called expand_mmac_params(); however, if we're
- * processing an %elif we must have been in a
- * non-emitting mode, which would have inhibited
- * the normal invocation of expand_mmac_params().
- * Therefore, we have to do it explicitly here.
- */
- j = if_condition(expand_mmac_params(tline->next), i);
- tline->next = NULL; /* it got freed */
- istk->conds->state =
- j < 0 ? COND_NEVER : j ? COND_IF_TRUE : COND_IF_FALSE;
- break;
+ case COND_IF_FALSE:
+ /*
+ * IMPORTANT: In the case of %if, we will already have
+ * called expand_mmac_params(); however, if we're
+ * processing an %elif we must have been in a
+ * non-emitting mode, which would have inhibited
+ * the normal invocation of expand_mmac_params().
+ * Therefore, we have to do it explicitly here.
+ */
+ j = if_condition(expand_mmac_params(tline->next), i);
+ tline->next = NULL; /* it got freed */
+ istk->conds->state =
+ j < 0 ? COND_NEVER : j ? COND_IF_TRUE : COND_IF_FALSE;
+ break;
}
free_tlist(origline);
return DIRECTIVE_FOUND;
if (!istk->conds)
error(ERR_FATAL, "`%%else': no matching `%%if'");
switch(istk->conds->state) {
- case COND_IF_TRUE:
- case COND_DONE:
- istk->conds->state = COND_ELSE_FALSE;
- break;
+ case COND_IF_TRUE:
+ case COND_DONE:
+ istk->conds->state = COND_ELSE_FALSE;
+ break;
- case COND_NEVER:
- break;
+ case COND_NEVER:
+ break;
- case COND_IF_FALSE:
- istk->conds->state = COND_ELSE_TRUE;
- break;
+ case COND_IF_FALSE:
+ istk->conds->state = COND_ELSE_TRUE;
+ break;
- case COND_ELSE_TRUE:
- case COND_ELSE_FALSE:
- error_precond(ERR_WARNING|ERR_PASS1,
- "`%%else' after `%%else' ignored.");
- istk->conds->state = COND_NEVER;
- break;
+ case COND_ELSE_TRUE:
+ case COND_ELSE_FALSE:
+ error_precond(ERR_WARNING|ERR_PASS1,
+ "`%%else' after `%%else' ignored.");
+ istk->conds->state = COND_NEVER;
+ break;
}
free_tlist(origline);
return DIRECTIVE_FOUND;
nasm_free(cond);
free_tlist(origline);
return DIRECTIVE_FOUND;
-
+
+ case PP_RMACRO:
+ case PP_IRMACRO:
case PP_MACRO:
case PP_IMACRO:
if (defining) {
- error(ERR_FATAL,
- "`%%%smacro': already defining a macro",
- (i == PP_IMACRO ? "i" : ""));
+ error(ERR_FATAL, "`%s': already defining a macro",
+ pp_directives[i]);
return DIRECTIVE_FOUND;
}
- defining = nasm_malloc(sizeof(MMacro));
- defining->casesense = (i == PP_MACRO);
+ defining = nasm_malloc(sizeof(MMacro));
+ defining->max_depth =
+ (i == PP_RMACRO) || (i == PP_IRMACRO) ? DEADMAN_LIMIT : 0;
+ defining->casesense = (i == PP_MACRO) || (i == PP_RMACRO);
if (!parse_mmacro_spec(tline, defining, pp_directives[i])) {
nasm_free(defining);
defining = NULL;
error(ERR_NONFATAL, "`%s': not defining a macro", tline->text);
return DIRECTIVE_FOUND;
}
- mmhead = (MMacro **) hash_findi_add(&mmacros, defining->name);
+ mmhead = (MMacro **) hash_findi_add(&mmacros, defining->name);
defining->next = *mmhead;
- *mmhead = defining;
+ *mmhead = defining;
defining = NULL;
free_tlist(origline);
return DIRECTIVE_FOUND;
+ case PP_EXITMACRO:
+ /*
+ * We must search along istk->expansion until we hit a
+ * macro-end marker for a macro with a name. Then we set
+ * its `in_progress' flag to 0.
+ */
+ for (l = istk->expansion; l; l = l->next)
+ if (l->finishes && l->finishes->name)
+ break;
+
+ if (l) {
+ l->finishes->in_progress = 0;
+ } else {
+ error(ERR_NONFATAL, "`%%exitmacro' not within `%%macro' block");
+ }
+ free_tlist(origline);
+ return DIRECTIVE_FOUND;
+
case PP_UNMACRO:
case PP_UNIMACRO:
{
case PP_ROTATE:
if (tline->next && tline->next->type == TOK_WHITESPACE)
tline = tline->next;
- if (tline->next == NULL) {
+ if (!tline->next) {
free_tlist(origline);
error(ERR_NONFATAL, "`%%rotate' missing rotate count");
return DIRECTIVE_FOUND;
tmp_defining = defining;
defining = nasm_malloc(sizeof(MMacro));
+ defining->prev = NULL;
defining->name = NULL; /* flags this macro as a %rep block */
defining->casesense = false;
defining->plus = false;
defining->nolist = nolist;
defining->in_progress = count;
+ defining->max_depth = 0;
defining->nparam_min = defining->nparam_max = 0;
defining->defaults = NULL;
defining->dlist = NULL;
define_smacro(ctx, mname, casesense, 0, macro_start);
free_tlist(origline);
return DIRECTIVE_FOUND;
+
+ case PP_DEFTOK:
+ case PP_IDEFTOK:
+ casesense = (i == PP_DEFTOK);
+
+ tline = tline->next;
+ skip_white_(tline);
+ tline = expand_id(tline);
+ if (!tline || (tline->type != TOK_ID &&
+ (tline->type != TOK_PREPROC_ID ||
+ tline->text[1] != '$'))) {
+ error(ERR_NONFATAL,
+ "`%s' expects a macro identifier as first parameter",
+ pp_directives[i]);
+ free_tlist(origline);
+ return DIRECTIVE_FOUND;
+ }
+ ctx = get_ctx(tline->text, &mname, false);
+ last = tline;
+ tline = expand_smacro(tline->next);
+ last->next = NULL;
+
+ t = tline;
+ while (tok_type_(t, TOK_WHITESPACE))
+ t = t->next;
+ /* t should now point to the string */
+ if (t->type != TOK_STRING) {
+ error(ERR_NONFATAL,
+ "`%s` requires string as second parameter",
+ pp_directives[i]);
+ free_tlist(tline);
+ free_tlist(origline);
+ return DIRECTIVE_FOUND;
+ }
+
+ nasm_unquote_cstr(t->text, i);
+ macro_start = tokenize(t->text);
+
+ /*
+ * We now have a macro name, an implicit parameter count of
+ * zero, and a numeric token to use as an expansion. Create
+ * and store an SMacro.
+ */
+ define_smacro(ctx, mname, casesense, 0, macro_start);
+ free_tlist(tline);
+ free_tlist(origline);
+ return DIRECTIVE_FOUND;
case PP_PATHSEARCH:
{
int i, j, k, m;
if (!t)
- return -1; /* Probably a %+ without a space */
+ return -1; /* Probably a %+ without a space */
skip_white_(t);
if (t->type != TOK_ID)
* Tokens from input to output a lot of the time, rather than
* actually bothering to destroy and replicate.)
*/
-#define DEADMAN_LIMIT (1 << 20)
static Token *expand_smacro(Token * tline)
{
* pain.
*/
/*tline = tline->next;
- skip_white_(tline); */
+ skip_white_(tline); */
do {
t = tline->next;
while (tok_type_(t, TOK_SMAC_END)) {
* This one is right. Just check if cycle removal
* prohibits us using it before we actually celebrate...
*/
- if (m->in_progress) {
-#if 0
- error(ERR_NONFATAL,
- "self-reference in multi-line macro `%s'", m->name);
-#endif
- nasm_free(params);
- return NULL;
- }
+ if (m->in_progress > m->max_depth) {
+ if (m->max_depth > 0) {
+ error(ERR_WARNING,
+ "reached maximum recursion depth of %i",
+ m->max_depth);
+ }
+ nasm_free(params);
+ return NULL;
+ }
/*
* It's right, and we can use it. Add its default
* parameters to the end of our list if necessary.
return NULL;
}
+
+/*
+ * Save MMacro invocation specific fields in
+ * preparation for a recursive macro expansion
+ */
+static void push_mmacro(MMacro *m)
+{
+ MMacroInvocation *i;
+
+ i = nasm_malloc(sizeof(MMacroInvocation));
+ i->prev = m->prev;
+ i->params = m->params;
+ i->iline = m->iline;
+ i->nparam = m->nparam;
+ i->rotate = m->rotate;
+ i->paramlen = m->paramlen;
+ i->unique = m->unique;
+ m->prev = i;
+}
+
+
+/*
+ * Restore MMacro invocation specific fields that were
+ * saved during a previous recursive macro expansion
+ */
+static void pop_mmacro(MMacro *m)
+{
+ MMacroInvocation *i;
+
+ if (m->prev) {
+ i = m->prev;
+ m->prev = i->prev;
+ m->params = i->params;
+ m->iline = i->iline;
+ m->nparam = i->nparam;
+ m->rotate = i->rotate;
+ m->paramlen = i->paramlen;
+ m->unique = i->unique;
+ nasm_free(i);
+ }
+}
+
+
/*
* Expand the multi-line macro call made by the given line, if
* there is one to be expanded. If there is, push the expansion on
if (tok_type_(t, TOK_WHITESPACE))
last = t, t = t->next;
}
- if (!tok_type_(t, TOK_ID) || (m = is_mmacro(t, ¶ms)) == NULL)
+ if (!tok_type_(t, TOK_ID) || !(m = is_mmacro(t, ¶ms)))
return 0;
last->next = NULL;
- mname = t->text;
+ mname = t->text;
tline = t;
}
ll->finishes = m;
ll->first = NULL;
istk->expansion = ll;
+
+ /*
+ * Save the previous MMacro expansion in the case of
+ * macro recursion
+ */
+ if (m->max_depth && m->in_progress)
+ push_mmacro(m);
- m->in_progress = true;
+ m->in_progress ++;
m->params = params;
m->iline = tline;
m->nparam = nparam;
vsnprintf(buff, sizeof(buff), fmt, arg);
if (istk && istk->mstk && istk->mstk->name)
- _error(severity, "(%s:%d) %s", istk->mstk->name,
+ nasm_error(severity, "(%s:%d) %s", istk->mstk->name,
istk->mstk->lineno, buff);
else
- _error(severity, "%s", buff);
+ nasm_error(severity, "%s", buff);
}
/*
}
static void
-pp_reset(char *file, int apass, efunc errfunc, evalfunc eval,
- ListGen * listgen, StrList **deplist)
+pp_reset(char *file, int apass, ListGen * listgen, StrList **deplist)
{
Token *t;
- _error = errfunc;
cstk = NULL;
istk = nasm_malloc(sizeof(Include));
istk->next = NULL;
any_extrastdmac = extrastdmac && *extrastdmac;
do_predef = true;
list = listgen;
- evaluate = eval;
/*
* 0 for dependencies, 1 for preparatory passes, 2 for final pass.
* therefore the parameter information needs to
* be freed.
*/
- nasm_free(m->params);
- free_tlist(m->iline);
- nasm_free(m->paramlen);
- l->finishes->in_progress = false;
+ if (m->prev) {
+ pop_mmacro(m);
+ l->finishes->in_progress --;
+ } else {
+ nasm_free(m->params);
+ free_tlist(m->iline);
+ nasm_free(m->paramlen);
+ l->finishes->in_progress = 0;
+ }
} else
free_mmacro(m);
}
static void pp_cleanup(int pass)
{
if (defining) {
- if(defining->name) {
+ if (defining->name) {
error(ERR_NONFATAL,
"end of file while still defining macro `%s'",
defining->name);
i->path = path ? nasm_strdup(path) : NULL;
i->next = NULL;
- if (ipath != NULL) {
+ if (ipath) {
IncPath *j = ipath;
- while (j->next != NULL)
+ while (j->next)
j = j->next;
j->next = i;
} else {
Token *def;
def = tokenize(definition);
- if(do_directive(def) == NO_DIRECTIVE_FOUND)
+ if (do_directive(def) == NO_DIRECTIVE_FOUND)
free_tlist(def);
}
{
struct RAA *result;
- if (posn < 0)
- nasm_malloc_error(ERR_PANIC, "negative position in raa_write");
+ nasm_assert(posn >= 0);
while ((UINT32_C(1) << (r->shift + LAYERSHIFT(r))) <= (uint32_t) posn) {
/*
{
void *p;
- if (s->wpos % s->elem_len)
- nasm_malloc_error(ERR_PANIC | ERR_NOFILE,
- "misaligned wpos in saa_wstruct");
+ nasm_assert((s->wpos % s->elem_len) == 0);
if (s->wpos + s->elem_len > s->blk_len) {
- if (s->wpos != s->blk_len)
- nasm_malloc_error(ERR_PANIC | ERR_NOFILE,
- "unfilled block in saa_wstruct");
-
+ nasm_assert(s->wpos == s->blk_len);
if (s->wptr + s->elem_len > s->length)
saa_extend(s);
s->wblk++;
if (s->rptr + s->elem_len > s->datalen)
return NULL;
- if (s->rpos % s->elem_len)
- nasm_malloc_error(ERR_PANIC | ERR_NOFILE,
- "misaligned rpos in saa_rstruct");
+ nasm_assert((s->rpos % s->elem_len) == 0);
if (s->rpos + s->elem_len > s->blk_len) {
s->rblk++;
{
char *d = data;
- if (s->rptr + len > s->datalen) {
- nasm_malloc_error(ERR_PANIC | ERR_NOFILE,
- "overrun in saa_rnbytes");
- return;
- }
+ nasm_assert(s->rptr + len <= s->datalen);
while (len) {
size_t l;
{
size_t ix;
- if (posn + len > s->datalen) {
- nasm_malloc_error(ERR_PANIC | ERR_NOFILE, "overrun in saa_fread");
- return;
- }
+ nasm_assert(posn + len <= s->datalen);
if (likely(s->blk_len == SAA_BLKLEN)) {
ix = posn >> SAA_BLKSHIFT;
{
size_t ix;
- if (posn > s->datalen) {
- /* Seek beyond the end of the existing array not supported */
- nasm_malloc_error(ERR_PANIC | ERR_NOFILE, "overrun in saa_fwrite");
- return;
- }
+ /* Seek beyond the end of the existing array not supported */
+ nasm_assert(posn <= s->datalen);
if (likely(s->blk_len == SAA_BLKLEN)) {
ix = posn >> SAA_BLKSHIFT;