diff options
58 files changed, 1964 insertions, 2312 deletions
@@ -51,6 +51,7 @@ TAGS /config.log /config.status /configure +/autom4te.cache /doc/*.dip /doc/*.hpj /doc/*.pdf diff --git a/Makefile.in b/Makefile.in index 1e2f8d59..c9f8928a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -20,7 +20,8 @@ datarootdir = @datarootdir@ CC = @CC@ CFLAGS = @CFLAGS@ -BUILD_CFLAGS = $(CFLAGS) @DEFS@ +CPPFLAGS = @CPPFLAGS@ +BUILD_CFLAGS = $(CPPFLAGS) $(CFLAGS) @DEFS@ INTERNAL_CFLAGS = -I$(srcdir) -I$(objdir) \ -I$(srcdir)/include -I$(objdir)/include \ -I$(srcdir)/x86 -I$(objdir)/x86 \ @@ -65,6 +66,7 @@ ifeq ($(TRACE),1) CFLAGS += -DNASM_TRACE endif +.SUFFIXES: .SUFFIXES: .c .i .s .$(O) .$(A) $(X) .1 .txt .xml .PHONY: all doc rdf install clean distclean cleaner spotless install_rdf test @@ -72,13 +74,13 @@ endif .PHONY: manpages nsis .c.$(O): - $(CC) -c $(ALL_CFLAGS) -o $@ $< + $(CC) -c $(ALL_CFLAGS) $(ALL_CFLAGS) -o $@ $< .c.s: - $(CC) -S $(ALL_CFLAGS) -o $@ $< + $(CC) -S $(ALL_CFLAGS) $(ALL_CFLAGS) -o $@ $< .c.i: - $(CC) -E $(ALL_CFLAGS) -o $@ $< + $(CC) -E $(ALL_CFLAGS) $(ALL_CFLAGS) -o $@ $< .txt.xml: $(ASCIIDOC) -b docbook -d manpage -o $@ $< @@ -86,16 +88,13 @@ endif .xml.1: $(XMLTO) man --skip-validation $< 2>/dev/null -# This rule is only used for rdoff, to allow common rules -.$(O)$(X): - $(CC) $(LDFLAGS) -o $@ $< $(RDFLIB) $(NASMLIB) $(LIBS) - #-- Begin File Lists --# NASM = asm/nasm.$(O) NDISASM = disasm/ndisasm.$(O) LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \ - stdlib/strnlen.$(O) \ + stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \ + \ nasmlib/ver.$(O) \ nasmlib/crc64.$(O) nasmlib/malloc.$(O) \ nasmlib/md5c.$(O) nasmlib/string.$(O) \ @@ -107,7 +106,9 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \ nasmlib/raa.$(O) nasmlib/saa.$(O) \ nasmlib/strlist.$(O) \ nasmlib/perfhash.$(O) nasmlib/badenum.$(O) \ + \ common/common.$(O) \ + \ x86/insnsa.$(O) x86/insnsb.$(O) x86/insnsd.$(O) x86/insnsn.$(O) \ x86/regs.$(O) x86/regvals.$(O) x86/regflags.$(O) x86/regdis.$(O) \ x86/disp8.$(O) x86/iflag.$(O) \ @@ -128,6 +129,7 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \ macros/macros.$(O) \ \ output/outform.$(O) output/outlib.$(O) output/legacy.$(O) \ + output/strtbl.$(O) \ output/nulldbg.$(O) output/nullout.$(O) \ output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \ output/outelf.$(O) \ @@ -139,6 +141,7 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \ SUBDIRS = stdlib nasmlib output asm disasm x86 common macros XSUBDIRS = test doc nsis rdoff +DEPDIRS = . include config x86 rdoff $(SUBDIRS) #-- End File Lists --# all: nasm$(X) ndisasm$(X) rdf @@ -151,10 +154,10 @@ $(NASMLIB): $(LIBOBJ) $(RANLIB) $(NASMLIB) nasm$(X): $(NASM) $(NASMLIB) - $(CC) $(LDFLAGS) -o nasm$(X) $(NASM) $(NASMLIB) $(LIBS) + $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o nasm$(X) $(NASM) $(NASMLIB) $(LIBS) ndisasm$(X): $(NDISASM) $(NASMLIB) - $(CC) $(LDFLAGS) -o ndisasm$(X) $(NDISASM) $(NASMLIB) $(LIBS) + $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o ndisasm$(X) $(NDISASM) $(NASMLIB) $(LIBS) #-- Begin Generated File Rules --# @@ -288,11 +291,19 @@ RDF2BINLINKS = rdoff/rdf2com$(X) rdoff/rdf2ith$(X) \ RDFLIB = rdoff/librdoff.$(A) RDFLIBS = $(RDFLIB) $(NASMLIB) +# This rule is only used for rdoff, to allow common rules +MAKERDF = $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $< $(RDFLIB) $(NASMLIB) $(LIBS) + rdoff/rdfdump$(X): rdoff/rdfdump.$(O) $(RDFLIBS) + $(MAKERDF) rdoff/ldrdf$(X): rdoff/ldrdf.$(O) $(RDFLIBS) + $(MAKERDF) rdoff/rdx$(X): rdoff/rdx.$(O) $(RDFLIBS) + $(MAKERDF) rdoff/rdflib$(X): rdoff/rdflib.$(O) $(RDFLIBS) + $(MAKERDF) rdoff/rdf2bin$(X): rdoff/rdf2bin.$(O) $(RDFLIBS) + $(MAKERDF) rdoff/rdf2com$(X): rdoff/rdf2bin$(X) $(RM_F) rdoff/rdf2com$(X) cd rdoff && $(LN_S) rdf2bin$(X) rdf2com$(X) @@ -334,12 +345,12 @@ nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh manpages: nasm.1 ndisasm.1 install: nasm$(X) ndisasm$(X) - $(MKDIR) -p $(INSTALLROOT)$(bindir) - $(INSTALL_PROGRAM) nasm$(X) $(INSTALLROOT)$(bindir)/nasm$(X) - $(INSTALL_PROGRAM) ndisasm$(X) $(INSTALLROOT)$(bindir)/ndisasm$(X) - $(MKDIR) -p $(INSTALLROOT)$(mandir)/man1 - $(INSTALL_DATA) $(srcdir)/nasm.1 $(INSTALLROOT)$(mandir)/man1/nasm.1 - $(INSTALL_DATA) $(srcdir)/ndisasm.1 $(INSTALLROOT)$(mandir)/man1/ndisasm.1 + $(MKDIR) -p $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) nasm$(X) $(DESTDIR)$(bindir)/nasm$(X) + $(INSTALL_PROGRAM) ndisasm$(X) $(DESTDIR)$(bindir)/ndisasm$(X) + $(MKDIR) -p $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) $(srcdir)/nasm.1 $(DESTDIR)$(mandir)/man1/nasm.1 + $(INSTALL_DATA) $(srcdir)/ndisasm.1 $(DESTDIR)$(mandir)/man1/ndisasm.1 clean: for d in . $(SUBDIRS) $(XSUBDIRS); do \ @@ -354,16 +365,17 @@ clean: distclean: clean $(RM_F) config.log config.status config/config.h - $(RM_F) Makefile for d in . $(SUBDIRS) $(XSUBDIRS); do \ $(RM_F) "$$d"/*~ "$$d"/*.bak "$$d"/*.lst "$$d"/*.bin ; \ done $(RM_F) test/*.$(O) $(RM_RF) autom4te*.cache + $(RM_F) Makefile *.dep cleaner: clean $(RM_F) $(PERLREQ) *.1 nasm.spec - cd doc && $(MAKE) clean + $(MAKE) -C doc clean + $(RM_F) *.dep spotless: distclean cleaner $(RM_F) doc/Makefile @@ -385,23 +397,23 @@ cscope: cscope -b -f cscope.out rdf_install install_rdf install_rdoff: - $(MKDIR) -p $(INSTALLROOT)$(bindir) + $(MKDIR) -p $(DESTDIR)$(bindir) for f in $(RDFPROGS); do \ - $(INSTALL_PROGRAM) "$$f" '$(INSTALLROOT)$(bindir)'/ ; \ + $(INSTALL_PROGRAM) "$$f" '$(DESTDIR)$(bindir)'/ ; \ done - cd '$(INSTALLROOT)$(bindir)' && \ + cd '$(DESTDIR)$(bindir)' && \ for f in $(RDF2BINLINKS); do \ bn=`basename "$$f"` && $(RM_F) "$$bn" && \ $(LN_S) rdf2bin$(X) "$$bn" ; \ done - $(MKDIR) -p $(INSTALLROOT)$(mandir)/man1 - $(INSTALL_DATA) $(srcdir)/rdoff/*.1 $(INSTALLROOT)$(mandir)/man1/ + $(MKDIR) -p $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) $(srcdir)/rdoff/*.1 $(DESTDIR)$(mandir)/man1/ doc: - cd doc && $(MAKE) all + $(MAKE) -C doc all doc_install install_doc: - cd doc && $(MAKE) install + $(MAKE) -C doc install everything: all manpages doc rdf @@ -440,416 +452,79 @@ golden: nasm$(X) cd test && $(RUNPERL) performtest.pl --golden --nasm=../nasm *.asm # -# This build dependencies in *ALL* makefiles. Partially for that reason, -# it's expected to be invoked manually. +# Rules to run autoreconf if necessary +# +configure: configure.ac aclocal.m4 + autoreconf + +config.status: configure + @if [ ! -f config.status ]; then \ + echo "*** ERROR: Need to run configure!" 1>&2 ; \ + exit 1; \ + fi + sh config.status --recheck + +Makefile: config.status Makefile.in doc/Makefile.in + sh config.status + +doc/Makefile: Makefile + +config/config.h: config.status + +# +# Does this version of this file have external dependencies? This definition +# will be automatically updated by mkdep.pl as needed. +# +EXTERNAL_DEPENDENCIES = 1 + +# +# Generate dependency information for this Makefile only. +# If this Makefile has external dependency information, then +# the dependency information will remain external, so it doesn't +# pollute the git logs. # -alldeps: perlreq tools/syncfiles.pl tools/mkdep.pl +Makefile.dep: $(PERLREQ) tools/mkdep.pl config.status + $(RUNPERL) tools/mkdep.pl -M Makefile.in -- $(DEPDIRS) + +dep: Makefile.dep + +# +# This build dependencies in *ALL* makefiles, and forces all +# dependencies to be inserted inline. For that reason, it should only +# be invoked manually or via "make dist". It should be run before +# creating release archives. +# +alldeps: $(PERLREQ) tools/syncfiles.pl tools/mkdep.pl + $(RUNPERL) tools/syncfiles.pl Makefile.in Mkfiles/*.mak + $(RUNPERL) tools/mkdep.pl -i -M Makefile.in Mkfiles/*.mak -- \ + $(DEPDIRS) + $(RM_F) *.dep + if [ -f config.status ]; then \ + if [ $(EXTERNAL_DEPENDENCIES) -eq 1 ]; then \ + sh config.status --recheck; \ + fi; \ + sh config.status; \ + fi + +# Strip internal dependency information from all Makefiles; this makes +# the output good for git checkin +cleandeps: $(PERLREQ) tools/syncfiles.pl tools/mkdep.pl $(RUNPERL) tools/syncfiles.pl Makefile.in Mkfiles/*.mak - $(RUNPERL) tools/mkdep.pl -M Makefile.in Mkfiles/*.mak -- \ - . include asm common config disasm macros nasmlib \ - output stdlib x86 rdoff - ./config.status + $(RUNPERL) tools/mkdep.pl -e -M Makefile.in Mkfiles/*.mak -- \ + $(DEPDIRS) + $(RM_F) *.dep + if [ -f config.status ]; then \ + if [ $(EXTERNAL_DEPENDENCIES) -eq 0 ]; then \ + sh config.status --recheck; \ + fi; \ + sh config.status; \ + fi #-- Magic hints to mkdep.pl --# # @object-ending: ".$(O)" # @path-separator: "/" +# @external: "Makefile.dep" +# @include-command: "-include" +# @selfrule: "1" #-- Everything below is generated by mkdep.pl - do not edit --# -asm/assemble.$(O): asm/assemble.c asm/assemble.h asm/directiv.h \ - asm/listing.h asm/pptok.h asm/preproc.h asm/tokens.h config/config.h \ - config/msvc.h config/unknown.h config/watcom.h include/compiler.h \ - include/disp8.h include/error.h include/iflag.h include/insns.h \ - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h \ - include/perfhash.h include/strlist.h include/tables.h x86/iflaggen.h \ - x86/insnsi.h x86/regs.h -asm/directbl.$(O): asm/directbl.c asm/directiv.h config/config.h \ - config/msvc.h config/unknown.h config/watcom.h include/compiler.h \ - include/nasmint.h include/nasmlib.h include/perfhash.h -asm/directiv.$(O): asm/directiv.c asm/assemble.h asm/directiv.h asm/eval.h \ - asm/float.h asm/listing.h asm/pptok.h asm/preproc.h asm/stdscan.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/error.h include/iflag.h include/labels.h \ - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h \ - include/perfhash.h include/strlist.h include/tables.h output/outform.h \ - x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/error.$(O): asm/error.c config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasmint.h \ - include/nasmlib.h -asm/eval.$(O): asm/eval.c asm/assemble.h asm/directiv.h asm/eval.h \ - asm/float.h asm/pptok.h asm/preproc.h config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/iflag.h include/labels.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h \ - include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/exprdump.$(O): asm/exprdump.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/nasm.h include/nasmint.h include/nasmlib.h \ - include/opflags.h include/perfhash.h include/strlist.h include/tables.h \ - x86/insnsi.h x86/regs.h -asm/exprlib.$(O): asm/exprlib.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/nasm.h include/nasmint.h include/nasmlib.h \ - include/opflags.h include/perfhash.h include/strlist.h include/tables.h \ - x86/insnsi.h x86/regs.h -asm/float.$(O): asm/float.c asm/directiv.h asm/float.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/insnsi.h x86/regs.h -asm/labels.$(O): asm/labels.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/error.h include/hashtbl.h include/labels.h \ - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h \ - include/perfhash.h include/strlist.h include/tables.h x86/insnsi.h \ - x86/regs.h -asm/listing.$(O): asm/listing.c asm/directiv.h asm/listing.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/insnsi.h x86/regs.h -asm/nasm.$(O): asm/nasm.c asm/assemble.h asm/directiv.h asm/eval.h \ - asm/float.h asm/listing.h asm/parser.h asm/pptok.h asm/preproc.h \ - asm/stdscan.h asm/tokens.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/iflag.h \ - include/insns.h include/labels.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/raa.h \ - include/saa.h include/strlist.h include/tables.h include/ver.h \ - output/outform.h x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/parser.$(O): asm/parser.c asm/assemble.h asm/directiv.h asm/eval.h \ - asm/float.h asm/parser.h asm/pptok.h asm/preproc.h asm/stdscan.h \ - asm/tokens.h config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/error.h include/iflag.h include/insns.h \ - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h \ - include/perfhash.h include/strlist.h include/tables.h x86/iflaggen.h \ - x86/insnsi.h x86/regs.h -asm/pptok.$(O): asm/pptok.c asm/pptok.h asm/preproc.h config/config.h \ - config/msvc.h config/unknown.h config/watcom.h include/compiler.h \ - include/hashtbl.h include/nasmint.h include/nasmlib.h -asm/pragma.$(O): asm/pragma.c asm/assemble.h asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/iflag.h \ - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h \ - include/perfhash.h include/strlist.h include/tables.h x86/iflaggen.h \ - x86/insnsi.h x86/regs.h -asm/preproc-nop.$(O): asm/preproc-nop.c asm/directiv.h asm/listing.h \ - asm/pptok.h asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/insnsi.h x86/regs.h -asm/preproc.$(O): asm/preproc.c asm/directiv.h asm/eval.h asm/listing.h \ - asm/pptok.h asm/preproc.h asm/quote.h asm/stdscan.h asm/tokens.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/error.h include/hashtbl.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/insnsi.h x86/regs.h -asm/quote.$(O): asm/quote.c asm/quote.h config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h -asm/rdstrnum.$(O): asm/rdstrnum.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/nasm.h include/nasmint.h include/nasmlib.h \ - include/opflags.h include/perfhash.h include/strlist.h include/tables.h \ - x86/insnsi.h x86/regs.h -asm/segalloc.$(O): asm/segalloc.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/tokens.h config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/iflag.h include/insns.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/stdscan.$(O): asm/stdscan.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/quote.h asm/stdscan.h asm/tokens.h config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/iflag.h include/insns.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h \ - include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/strfunc.$(O): asm/strfunc.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/nasm.h include/nasmint.h include/nasmlib.h \ - include/opflags.h include/perfhash.h include/strlist.h include/tables.h \ - x86/insnsi.h x86/regs.h -asm/tokhash.$(O): asm/tokhash.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/stdscan.h asm/tokens.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/hashtbl.h include/iflag.h \ - include/insns.h include/nasm.h include/nasmint.h include/nasmlib.h \ - include/opflags.h include/perfhash.h include/strlist.h include/tables.h \ - x86/iflaggen.h x86/insnsi.h x86/regs.h -common/common.$(O): common/common.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/tokens.h config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/iflag.h include/insns.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -disasm/disasm.$(O): disasm/disasm.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/tokens.h config/config.h config/msvc.h config/unknown.h config/watcom.h \ - disasm/disasm.h disasm/sync.h include/compiler.h include/disp8.h \ - include/iflag.h include/insns.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h \ - include/tables.h x86/iflaggen.h x86/insnsi.h x86/regdis.h x86/regs.h -disasm/ndisasm.$(O): disasm/ndisasm.c asm/directiv.h asm/pptok.h \ - asm/preproc.h asm/tokens.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h disasm/disasm.h disasm/sync.h include/compiler.h \ - include/error.h include/iflag.h include/insns.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h include/ver.h x86/iflaggen.h \ - x86/insnsi.h x86/regs.h -disasm/sync.$(O): disasm/sync.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h disasm/sync.h include/compiler.h \ - include/nasmint.h include/nasmlib.h -macros/macros.$(O): macros/macros.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/hashtbl.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h \ - include/tables.h output/outform.h x86/insnsi.h x86/regs.h -nasmlib/badenum.$(O): nasmlib/badenum.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h -nasmlib/bsi.$(O): nasmlib/bsi.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h -nasmlib/crc64.$(O): nasmlib/crc64.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/hashtbl.h \ - include/nasmint.h include/nasmlib.h -nasmlib/file.$(O): nasmlib/file.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h nasmlib/file.h -nasmlib/filename.$(O): nasmlib/filename.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h -nasmlib/hashtbl.$(O): nasmlib/hashtbl.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/hashtbl.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/insnsi.h x86/regs.h -nasmlib/ilog2.$(O): nasmlib/ilog2.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h -nasmlib/malloc.$(O): nasmlib/malloc.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h -nasmlib/md5c.$(O): nasmlib/md5c.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/md5.h \ - include/nasmint.h -nasmlib/mmap.$(O): nasmlib/mmap.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h nasmlib/file.h -nasmlib/path.$(O): nasmlib/path.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h -nasmlib/perfhash.$(O): nasmlib/perfhash.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/hashtbl.h \ - include/nasmint.h include/nasmlib.h include/perfhash.h -nasmlib/raa.$(O): nasmlib/raa.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h include/raa.h -nasmlib/rbtree.$(O): nasmlib/rbtree.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/rbtree.h -nasmlib/readnum.$(O): nasmlib/readnum.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/insnsi.h x86/regs.h -nasmlib/realpath.$(O): nasmlib/realpath.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h -nasmlib/saa.$(O): nasmlib/saa.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h include/saa.h -nasmlib/srcfile.$(O): nasmlib/srcfile.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/hashtbl.h \ - include/nasmint.h include/nasmlib.h -nasmlib/string.$(O): nasmlib/string.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h -nasmlib/strlist.$(O): nasmlib/strlist.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h include/strlist.h -nasmlib/ver.$(O): nasmlib/ver.c include/ver.h version.h -nasmlib/zerobuf.$(O): nasmlib/zerobuf.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h -output/codeview.$(O): output/codeview.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/hashtbl.h \ - include/md5.h include/nasm.h include/nasmint.h include/nasmlib.h \ - include/opflags.h include/perfhash.h include/saa.h include/strlist.h \ - include/tables.h output/outlib.h output/pecoff.h version.h x86/insnsi.h \ - x86/regs.h -output/legacy.$(O): output/legacy.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/error.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h \ - include/tables.h output/outlib.h x86/insnsi.h x86/regs.h -output/nulldbg.$(O): output/nulldbg.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h output/outlib.h x86/insnsi.h x86/regs.h -output/nullout.$(O): output/nullout.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h output/outlib.h x86/insnsi.h x86/regs.h -output/outaout.$(O): output/outaout.c asm/directiv.h asm/eval.h asm/pptok.h \ - asm/preproc.h asm/stdscan.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/raa.h include/saa.h include/strlist.h include/tables.h \ - output/outform.h output/outlib.h x86/insnsi.h x86/regs.h -output/outas86.$(O): output/outas86.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/raa.h include/saa.h include/strlist.h include/tables.h \ - output/outform.h output/outlib.h x86/insnsi.h x86/regs.h -output/outbin.$(O): output/outbin.c asm/directiv.h asm/eval.h asm/pptok.h \ - asm/preproc.h asm/stdscan.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/labels.h \ - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h \ - include/perfhash.h include/saa.h include/strlist.h include/tables.h \ - output/outform.h output/outlib.h x86/insnsi.h x86/regs.h -output/outcoff.$(O): output/outcoff.c asm/directiv.h asm/eval.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/raa.h include/saa.h include/strlist.h include/tables.h \ - output/outform.h output/outlib.h output/pecoff.h x86/insnsi.h x86/regs.h -output/outdbg.$(O): output/outdbg.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/tokens.h config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/error.h include/iflag.h include/insns.h \ - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h \ - include/perfhash.h include/strlist.h include/tables.h output/outform.h \ - output/outlib.h x86/iflaggen.h x86/insnsi.h x86/regs.h -output/outelf.$(O): output/outelf.c asm/directiv.h asm/eval.h asm/pptok.h \ - asm/preproc.h asm/stdscan.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/raa.h include/rbtree.h include/saa.h include/strlist.h \ - include/tables.h include/ver.h output/dwarf.h output/elf.h output/outelf.h \ - output/outform.h output/outlib.h output/stabs.h x86/insnsi.h x86/regs.h -output/outform.$(O): output/outform.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h \ - include/tables.h output/outform.h x86/insnsi.h x86/regs.h -output/outieee.$(O): output/outieee.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h include/ver.h output/outform.h \ - output/outlib.h x86/insnsi.h x86/regs.h -output/outlib.$(O): output/outlib.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/error.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h \ - include/tables.h output/outlib.h x86/insnsi.h x86/regs.h -output/outmacho.$(O): output/outmacho.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/labels.h \ - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h \ - include/perfhash.h include/raa.h include/rbtree.h include/saa.h \ - include/strlist.h include/tables.h include/ver.h output/dwarf.h \ - output/outform.h output/outlib.h x86/insnsi.h x86/regs.h -output/outobj.$(O): output/outobj.c asm/directiv.h asm/eval.h asm/pptok.h \ - asm/preproc.h asm/stdscan.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h include/ver.h output/outform.h \ - output/outlib.h x86/insnsi.h x86/regs.h -output/outrdf2.$(O): output/outrdf2.c asm/directiv.h asm/pptok.h \ - asm/preproc.h config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/rdoff.h include/saa.h include/strlist.h include/tables.h \ - output/outform.h output/outlib.h x86/insnsi.h x86/regs.h -rdoff/collectn.$(O): rdoff/collectn.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/collectn.h \ - rdoff/rdfutils.h -rdoff/hash.$(O): rdoff/hash.c config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/nasmint.h rdoff/hash.h -rdoff/ldrdf.$(O): rdoff/ldrdf.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/collectn.h \ - rdoff/ldsegs.h rdoff/rdfutils.h rdoff/rdlib.h rdoff/segtab.h rdoff/symtab.h -rdoff/rdf2bin.$(O): rdoff/rdf2bin.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/rdfload.h \ - rdoff/rdfutils.h -rdoff/rdfdump.$(O): rdoff/rdfdump.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/rdfutils.h -rdoff/rdflib.$(O): rdoff/rdflib.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/rdfutils.h -rdoff/rdfload.$(O): rdoff/rdfload.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/collectn.h \ - rdoff/rdfload.h rdoff/rdfutils.h rdoff/symtab.h -rdoff/rdlar.$(O): rdoff/rdlar.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - rdoff/rdlar.h -rdoff/rdlib.$(O): rdoff/rdlib.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/rdfutils.h \ - rdoff/rdlar.h rdoff/rdlib.h -rdoff/rdoff.$(O): rdoff/rdoff.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/rdfutils.h -rdoff/rdx.$(O): rdoff/rdx.c config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/error.h include/nasmint.h \ - include/nasmlib.h include/rdoff.h rdoff/rdfload.h rdoff/rdfutils.h \ - rdoff/symtab.h -rdoff/segtab.$(O): rdoff/segtab.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/rdfutils.h \ - rdoff/segtab.h -rdoff/symtab.$(O): rdoff/symtab.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h include/rdoff.h rdoff/hash.h \ - rdoff/rdfutils.h rdoff/symtab.h -stdlib/snprintf.$(O): stdlib/snprintf.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/nasmlib.h -stdlib/strlcpy.$(O): stdlib/strlcpy.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h -stdlib/strnlen.$(O): stdlib/strnlen.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h -stdlib/vsnprintf.$(O): stdlib/vsnprintf.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/error.h \ - include/nasmint.h include/nasmlib.h -x86/disp8.$(O): x86/disp8.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/disp8.h include/nasm.h include/nasmint.h \ - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h \ - include/tables.h x86/insnsi.h x86/regs.h -x86/iflag.$(O): x86/iflag.c config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/iflag.h include/nasmint.h \ - x86/iflaggen.h -x86/insnsa.$(O): x86/insnsa.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/tokens.h config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/iflag.h include/insns.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -x86/insnsb.$(O): x86/insnsb.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/tokens.h config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/iflag.h include/insns.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -x86/insnsd.$(O): x86/insnsd.c asm/directiv.h asm/pptok.h asm/preproc.h \ - asm/tokens.h config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/iflag.h include/insns.h include/nasm.h \ - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h \ - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -x86/insnsn.$(O): x86/insnsn.c config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/nasmint.h include/tables.h \ - x86/insnsi.h -x86/regdis.$(O): x86/regdis.c x86/regdis.h x86/regs.h -x86/regflags.$(O): x86/regflags.c asm/directiv.h asm/pptok.h asm/preproc.h \ - config/config.h config/msvc.h config/unknown.h config/watcom.h \ - include/compiler.h include/nasm.h include/nasmint.h include/nasmlib.h \ - include/opflags.h include/perfhash.h include/strlist.h include/tables.h \ - x86/insnsi.h x86/regs.h -x86/regs.$(O): x86/regs.c config/config.h config/msvc.h config/unknown.h \ - config/watcom.h include/compiler.h include/nasmint.h include/tables.h \ - x86/insnsi.h -x86/regvals.$(O): x86/regvals.c config/config.h config/msvc.h \ - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h \ - include/tables.h x86/insnsi.h +-include Makefile.dep diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index b8b6d3ad..430fa2d3 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -53,6 +53,7 @@ LN_S = copy O = obj A = lib X = .exe +.SUFFIXES: .SUFFIXES: .c .i .s .$(O) .$(A) .exe .1 .man .c.obj: @@ -68,7 +69,8 @@ NASM = asm\nasm.$(O) NDISASM = disasm\ndisasm.$(O) LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \ - stdlib\strnlen.$(O) \ + stdlib\strnlen.$(O) stdlib\strrchrnul.$(O) \ + \ nasmlib\ver.$(O) \ nasmlib\crc64.$(O) nasmlib\malloc.$(O) \ nasmlib\md5c.$(O) nasmlib\string.$(O) \ @@ -80,7 +82,9 @@ LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \ nasmlib\raa.$(O) nasmlib\saa.$(O) \ nasmlib\strlist.$(O) \ nasmlib\perfhash.$(O) nasmlib\badenum.$(O) \ + \ common\common.$(O) \ + \ x86\insnsa.$(O) x86\insnsb.$(O) x86\insnsd.$(O) x86\insnsn.$(O) \ x86\regs.$(O) x86\regvals.$(O) x86\regflags.$(O) x86\regdis.$(O) \ x86\disp8.$(O) x86\iflag.$(O) \ @@ -101,6 +105,7 @@ LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \ macros\macros.$(O) \ \ output\outform.$(O) output\outlib.$(O) output\legacy.$(O) \ + output\strtbl.$(O) \ output\nulldbg.$(O) output\nullout.$(O) \ output\outbin.$(O) output\outaout.$(O) output\outcoff.$(O) \ output\outelf.$(O) \ @@ -112,6 +117,7 @@ LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \ SUBDIRS = stdlib nasmlib output asm disasm x86 common macros XSUBDIRS = test doc nsis rdoff +DEPDIRS = . include config x86 rdoff $(SUBDIRS) #-- End File Lists --# NASMLIB = libnasm.$(A) @@ -261,11 +267,19 @@ RDF2BINLINKS = rdoff\rdf2com$(X) rdoff\rdf2ith$(X) \ RDFLIB = rdoff\librdoff.$(A) RDFLIBS = $(RDFLIB) $(NASMLIB) +# This rule is only used for rdoff, to allow common rules +MAKERDF = $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $< $(RDFLIB) $(NASMLIB) $(LIBS) + rdoff\rdfdump$(X): rdoff\rdfdump.$(O) $(RDFLIBS) + $(MAKERDF) rdoff\ldrdf$(X): rdoff\ldrdf.$(O) $(RDFLIBS) + $(MAKERDF) rdoff\rdx$(X): rdoff\rdx.$(O) $(RDFLIBS) + $(MAKERDF) rdoff\rdflib$(X): rdoff\rdflib.$(O) $(RDFLIBS) + $(MAKERDF) rdoff\rdf2bin$(X): rdoff\rdf2bin.$(O) $(RDFLIBS) + $(MAKERDF) rdoff\rdf2com$(X): rdoff\rdf2bin$(X) $(RM_F) rdoff\rdf2com$(X) cd rdoff && $(LN_S) rdf2bin$(X) rdf2com$(X) @@ -321,6 +335,7 @@ distclean: clean -del /f /s *.bak -del /f /s *.lst -del /f /s *.bin + -del /f /s *.dep -del /f output\*~ -del /f output\*.bak -del /f test\*.lst @@ -350,383 +365,40 @@ docs: everything: all docs nsis +# +# Does this version of this file have external dependencies? This definition +# will be automatically updated by mkdep.pl as needed. +# +EXTERNAL_DEPENDENCIES = 1 + +# +# Generate dependency information for this Makefile only. +# If this Makefile has external dependency information, then +# the dependency information will remain external, so it doesn't +# pollute the git logs. +# +msvc.dep: $(PERLREQ) tools\mkdep.pl + $(RUNPERL) tools\mkdep.pl -M Mkfiles\msvc.mak -- $(DEPDIRS) + +dep: msvc.dep + +# Include and/or generate msvc.dep as needed. This is too complex to +# use the include-command feature, but we can open-code it here. +!IF $(EXTERNAL_DEPENDENCIES) == 1 +!IFDEF MKDEP +!IF EXISTS(msvc.dep) +!INCLUDE msvc.dep +!ENDIF +!ELSEIF [$(MAKE) /c MKDEP=1 /f Mkfiles\msvc.mak msvc.dep] == 0 +!INCLUDE msvc.dep +!ELSE +!ERROR Unable to rebuild dependencies file msvc.dep +!ENDIF + #-- Magic hints to mkdep.pl --# # @object-ending: ".$(O)" # @path-separator: "\" # @exclude: "config/config.h" +# @external: "msvc.dep" +# @selfrule: "1" #-- Everything below is generated by mkdep.pl - do not edit --# -asm\assemble.$(O): asm\assemble.c asm\assemble.h asm\directiv.h \ - asm\listing.h asm\pptok.h asm\preproc.h asm\tokens.h config\msvc.h \ - config\unknown.h config\watcom.h include\compiler.h include\disp8.h \ - include\error.h include\iflag.h include\insns.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h x86\iflaggen.h x86\insnsi.h x86\regs.h -asm\directbl.$(O): asm\directbl.c asm\directiv.h config\msvc.h \ - config\unknown.h config\watcom.h include\compiler.h include\nasmint.h \ - include\nasmlib.h include\perfhash.h -asm\directiv.$(O): asm\directiv.c asm\assemble.h asm\directiv.h asm\eval.h \ - asm\float.h asm\listing.h asm\pptok.h asm\preproc.h asm\stdscan.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\error.h include\iflag.h include\labels.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h output\outform.h x86\iflaggen.h \ - x86\insnsi.h x86\regs.h -asm\error.$(O): asm\error.c config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasmint.h include\nasmlib.h -asm\eval.$(O): asm\eval.c asm\assemble.h asm\directiv.h asm\eval.h \ - asm\float.h asm\pptok.h asm\preproc.h config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\iflag.h \ - include\labels.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\strlist.h include\tables.h \ - x86\iflaggen.h x86\insnsi.h x86\regs.h -asm\exprdump.$(O): asm\exprdump.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\strlist.h include\tables.h x86\insnsi.h \ - x86\regs.h -asm\exprlib.$(O): asm\exprlib.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\strlist.h include\tables.h x86\insnsi.h \ - x86\regs.h -asm\float.$(O): asm\float.c asm\directiv.h asm\float.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h x86\insnsi.h x86\regs.h -asm\labels.$(O): asm\labels.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\error.h include\hashtbl.h include\labels.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h x86\insnsi.h x86\regs.h -asm\listing.$(O): asm\listing.c asm\directiv.h asm\listing.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h x86\insnsi.h x86\regs.h -asm\nasm.$(O): asm\nasm.c asm\assemble.h asm\directiv.h asm\eval.h \ - asm\float.h asm\listing.h asm\parser.h asm\pptok.h asm\preproc.h \ - asm\stdscan.h asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\iflag.h include\insns.h \ - include\labels.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\raa.h include\saa.h \ - include\strlist.h include\tables.h include\ver.h output\outform.h \ - x86\iflaggen.h x86\insnsi.h x86\regs.h -asm\parser.$(O): asm\parser.c asm\assemble.h asm\directiv.h asm\eval.h \ - asm\float.h asm\parser.h asm\pptok.h asm\preproc.h asm\stdscan.h \ - asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\iflag.h include\insns.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\strlist.h include\tables.h x86\iflaggen.h \ - x86\insnsi.h x86\regs.h -asm\pptok.$(O): asm\pptok.c asm\pptok.h asm\preproc.h config\msvc.h \ - config\unknown.h config\watcom.h include\compiler.h include\hashtbl.h \ - include\nasmint.h include\nasmlib.h -asm\pragma.$(O): asm\pragma.c asm\assemble.h asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\iflag.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h x86\iflaggen.h x86\insnsi.h x86\regs.h -asm\preproc-nop.$(O): asm\preproc-nop.c asm\directiv.h asm\listing.h \ - asm\pptok.h asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h x86\insnsi.h x86\regs.h -asm\preproc.$(O): asm\preproc.c asm\directiv.h asm\eval.h asm\listing.h \ - asm\pptok.h asm\preproc.h asm\quote.h asm\stdscan.h asm\tokens.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\error.h include\hashtbl.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h x86\insnsi.h x86\regs.h -asm\quote.$(O): asm\quote.c asm\quote.h config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h -asm\rdstrnum.$(O): asm\rdstrnum.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\strlist.h include\tables.h x86\insnsi.h \ - x86\regs.h -asm\segalloc.$(O): asm\segalloc.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\iflag.h include\insns.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h x86\iflaggen.h x86\insnsi.h x86\regs.h -asm\stdscan.$(O): asm\stdscan.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\quote.h asm\stdscan.h asm\tokens.h config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\iflag.h \ - include\insns.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\strlist.h include\tables.h \ - x86\iflaggen.h x86\insnsi.h x86\regs.h -asm\strfunc.$(O): asm\strfunc.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\strlist.h include\tables.h x86\insnsi.h \ - x86\regs.h -asm\tokhash.$(O): asm\tokhash.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\stdscan.h asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\hashtbl.h include\iflag.h include\insns.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\strlist.h include\tables.h x86\iflaggen.h \ - x86\insnsi.h x86\regs.h -common\common.$(O): common\common.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\iflag.h include\insns.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h x86\iflaggen.h x86\insnsi.h x86\regs.h -disasm\disasm.$(O): disasm\disasm.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\tokens.h config\msvc.h config\unknown.h config\watcom.h disasm\disasm.h \ - disasm\sync.h include\compiler.h include\disp8.h include\iflag.h \ - include\insns.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\strlist.h include\tables.h \ - x86\iflaggen.h x86\insnsi.h x86\regdis.h x86\regs.h -disasm\ndisasm.$(O): disasm\ndisasm.c asm\directiv.h asm\pptok.h \ - asm\preproc.h asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - disasm\disasm.h disasm\sync.h include\compiler.h include\error.h \ - include\iflag.h include\insns.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h include\ver.h x86\iflaggen.h x86\insnsi.h x86\regs.h -disasm\sync.$(O): disasm\sync.c config\msvc.h config\unknown.h \ - config\watcom.h disasm\sync.h include\compiler.h include\nasmint.h \ - include\nasmlib.h -macros\macros.$(O): macros\macros.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\hashtbl.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\strlist.h include\tables.h \ - output\outform.h x86\insnsi.h x86\regs.h -nasmlib\badenum.$(O): nasmlib\badenum.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h -nasmlib\bsi.$(O): nasmlib\bsi.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h -nasmlib\crc64.$(O): nasmlib\crc64.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\hashtbl.h include\nasmint.h \ - include\nasmlib.h -nasmlib\file.$(O): nasmlib\file.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h nasmlib\file.h -nasmlib\filename.$(O): nasmlib\filename.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h -nasmlib\hashtbl.$(O): nasmlib\hashtbl.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\hashtbl.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h x86\insnsi.h x86\regs.h -nasmlib\ilog2.$(O): nasmlib\ilog2.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h -nasmlib\malloc.$(O): nasmlib\malloc.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h -nasmlib\md5c.$(O): nasmlib\md5c.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\md5.h include\nasmint.h -nasmlib\mmap.$(O): nasmlib\mmap.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h nasmlib\file.h -nasmlib\path.$(O): nasmlib\path.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h -nasmlib\perfhash.$(O): nasmlib\perfhash.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\hashtbl.h include\nasmint.h \ - include\nasmlib.h include\perfhash.h -nasmlib\raa.$(O): nasmlib\raa.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h \ - include\raa.h -nasmlib\rbtree.$(O): nasmlib\rbtree.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\rbtree.h -nasmlib\readnum.$(O): nasmlib\readnum.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h x86\insnsi.h x86\regs.h -nasmlib\realpath.$(O): nasmlib\realpath.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h -nasmlib\saa.$(O): nasmlib\saa.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h \ - include\saa.h -nasmlib\srcfile.$(O): nasmlib\srcfile.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\hashtbl.h include\nasmint.h \ - include\nasmlib.h -nasmlib\string.$(O): nasmlib\string.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h -nasmlib\strlist.$(O): nasmlib\strlist.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h \ - include\strlist.h -nasmlib\ver.$(O): nasmlib\ver.c include\ver.h version.h -nasmlib\zerobuf.$(O): nasmlib\zerobuf.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h -output\codeview.$(O): output\codeview.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\hashtbl.h include\md5.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\saa.h include\strlist.h include\tables.h \ - output\outlib.h output\pecoff.h version.h x86\insnsi.h x86\regs.h -output\legacy.$(O): output\legacy.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\error.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\strlist.h include\tables.h \ - output\outlib.h x86\insnsi.h x86\regs.h -output\nulldbg.$(O): output\nulldbg.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h output\outlib.h x86\insnsi.h x86\regs.h -output\nullout.$(O): output\nullout.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h output\outlib.h x86\insnsi.h x86\regs.h -output\outaout.$(O): output\outaout.c asm\directiv.h asm\eval.h asm\pptok.h \ - asm\preproc.h asm\stdscan.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\raa.h \ - include\saa.h include\strlist.h include\tables.h output\outform.h \ - output\outlib.h x86\insnsi.h x86\regs.h -output\outas86.$(O): output\outas86.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\raa.h \ - include\saa.h include\strlist.h include\tables.h output\outform.h \ - output\outlib.h x86\insnsi.h x86\regs.h -output\outbin.$(O): output\outbin.c asm\directiv.h asm\eval.h asm\pptok.h \ - asm\preproc.h asm\stdscan.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\labels.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\saa.h include\strlist.h include\tables.h output\outform.h \ - output\outlib.h x86\insnsi.h x86\regs.h -output\outcoff.$(O): output\outcoff.c asm\directiv.h asm\eval.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\raa.h \ - include\saa.h include\strlist.h include\tables.h output\outform.h \ - output\outlib.h output\pecoff.h x86\insnsi.h x86\regs.h -output\outdbg.$(O): output\outdbg.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\iflag.h include\insns.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\strlist.h include\tables.h output\outform.h \ - output\outlib.h x86\iflaggen.h x86\insnsi.h x86\regs.h -output\outelf.$(O): output\outelf.c asm\directiv.h asm\eval.h asm\pptok.h \ - asm\preproc.h asm\stdscan.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\raa.h \ - include\rbtree.h include\saa.h include\strlist.h include\tables.h \ - include\ver.h output\dwarf.h output\elf.h output\outelf.h output\outform.h \ - output\outlib.h output\stabs.h x86\insnsi.h x86\regs.h -output\outform.$(O): output\outform.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\strlist.h include\tables.h \ - output\outform.h x86\insnsi.h x86\regs.h -output\outieee.$(O): output\outieee.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h include\ver.h output\outform.h output\outlib.h \ - x86\insnsi.h x86\regs.h -output\outlib.$(O): output\outlib.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\error.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\strlist.h include\tables.h \ - output\outlib.h x86\insnsi.h x86\regs.h -output\outmacho.$(O): output\outmacho.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\labels.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\raa.h include\rbtree.h include\saa.h include\strlist.h \ - include\tables.h include\ver.h output\dwarf.h output\outform.h \ - output\outlib.h x86\insnsi.h x86\regs.h -output\outobj.$(O): output\outobj.c asm\directiv.h asm\eval.h asm\pptok.h \ - asm\preproc.h asm\stdscan.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\strlist.h \ - include\tables.h include\ver.h output\outform.h output\outlib.h \ - x86\insnsi.h x86\regs.h -output\outrdf2.$(O): output\outrdf2.c asm\directiv.h asm\pptok.h \ - asm\preproc.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasm.h include\nasmint.h \ - include\nasmlib.h include\opflags.h include\perfhash.h include\rdoff.h \ - include\saa.h include\strlist.h include\tables.h output\outform.h \ - output\outlib.h x86\insnsi.h x86\regs.h -rdoff\collectn.$(O): rdoff\collectn.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\collectn.h rdoff\rdfutils.h -rdoff\hash.$(O): rdoff\hash.c config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\nasmint.h rdoff\hash.h -rdoff\ldrdf.$(O): rdoff\ldrdf.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\collectn.h rdoff\ldsegs.h \ - rdoff\rdfutils.h rdoff\rdlib.h rdoff\segtab.h rdoff\symtab.h -rdoff\rdf2bin.$(O): rdoff\rdf2bin.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\rdfload.h rdoff\rdfutils.h -rdoff\rdfdump.$(O): rdoff\rdfdump.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\rdfutils.h -rdoff\rdflib.$(O): rdoff\rdflib.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\rdfutils.h -rdoff\rdfload.$(O): rdoff\rdfload.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\collectn.h rdoff\rdfload.h \ - rdoff\rdfutils.h rdoff\symtab.h -rdoff\rdlar.$(O): rdoff\rdlar.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h rdoff\rdlar.h -rdoff\rdlib.$(O): rdoff\rdlib.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\rdfutils.h rdoff\rdlar.h \ - rdoff\rdlib.h -rdoff\rdoff.$(O): rdoff\rdoff.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\rdfutils.h -rdoff\rdx.$(O): rdoff\rdx.c config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\error.h include\nasmint.h include\nasmlib.h \ - include\rdoff.h rdoff\rdfload.h rdoff\rdfutils.h rdoff\symtab.h -rdoff\segtab.$(O): rdoff\segtab.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\rdfutils.h rdoff\segtab.h -rdoff\symtab.$(O): rdoff\symtab.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h include\rdoff.h rdoff\hash.h rdoff\rdfutils.h \ - rdoff\symtab.h -stdlib\snprintf.$(O): stdlib\snprintf.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\nasmlib.h -stdlib\strlcpy.$(O): stdlib\strlcpy.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h -stdlib\strnlen.$(O): stdlib\strnlen.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h -stdlib\vsnprintf.$(O): stdlib\vsnprintf.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\error.h include\nasmint.h \ - include\nasmlib.h -x86\disp8.$(O): x86\disp8.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\disp8.h include\nasm.h include\nasmint.h include\nasmlib.h \ - include\opflags.h include\perfhash.h include\strlist.h include\tables.h \ - x86\insnsi.h x86\regs.h -x86\iflag.$(O): x86\iflag.c config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\iflag.h include\nasmint.h x86\iflaggen.h -x86\insnsa.$(O): x86\insnsa.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\iflag.h include\insns.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h x86\iflaggen.h x86\insnsi.h x86\regs.h -x86\insnsb.$(O): x86\insnsb.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\iflag.h include\insns.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h x86\iflaggen.h x86\insnsi.h x86\regs.h -x86\insnsd.$(O): x86\insnsd.c asm\directiv.h asm\pptok.h asm\preproc.h \ - asm\tokens.h config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\iflag.h include\insns.h include\nasm.h \ - include\nasmint.h include\nasmlib.h include\opflags.h include\perfhash.h \ - include\strlist.h include\tables.h x86\iflaggen.h x86\insnsi.h x86\regs.h -x86\insnsn.$(O): x86\insnsn.c config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\nasmint.h include\tables.h x86\insnsi.h -x86\regdis.$(O): x86\regdis.c x86\regdis.h x86\regs.h -x86\regflags.$(O): x86\regflags.c asm\directiv.h asm\pptok.h asm\preproc.h \ - config\msvc.h config\unknown.h config\watcom.h include\compiler.h \ - include\nasm.h include\nasmint.h include\nasmlib.h include\opflags.h \ - include\perfhash.h include\strlist.h include\tables.h x86\insnsi.h \ - x86\regs.h -x86\regs.$(O): x86\regs.c config\msvc.h config\unknown.h config\watcom.h \ - include\compiler.h include\nasmint.h include\tables.h x86\insnsi.h -x86\regvals.$(O): x86\regvals.c config\msvc.h config\unknown.h \ - config\watcom.h include\compiler.h include\nasmint.h include\tables.h \ - x86\insnsi.h diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 516c3f03..9acb50a9 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -54,7 +54,8 @@ NASM = asm/nasm.$(O) NDISASM = disasm/ndisasm.$(O) LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) & - stdlib/strnlen.$(O) & + stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) & + & nasmlib/ver.$(O) & nasmlib/crc64.$(O) nasmlib/malloc.$(O) & nasmlib/md5c.$(O) nasmlib/string.$(O) & @@ -66,7 +67,9 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) & nasmlib/raa.$(O) nasmlib/saa.$(O) & nasmlib/strlist.$(O) & nasmlib/perfhash.$(O) nasmlib/badenum.$(O) & + & common/common.$(O) & + & x86/insnsa.$(O) x86/insnsb.$(O) x86/insnsd.$(O) x86/insnsn.$(O) & x86/regs.$(O) x86/regvals.$(O) x86/regflags.$(O) x86/regdis.$(O) & x86/disp8.$(O) x86/iflag.$(O) & @@ -87,6 +90,7 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) & macros/macros.$(O) & & output/outform.$(O) output/outlib.$(O) output/legacy.$(O) & + output/strtbl.$(O) & output/nulldbg.$(O) output/nullout.$(O) & output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) & output/outelf.$(O) & @@ -98,6 +102,7 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) & SUBDIRS = stdlib nasmlib output asm disasm x86 common macros XSUBDIRS = test doc nsis rdoff +DEPDIRS = . include config x86 rdoff $(SUBDIRS) #-- End File Lists --# what: .SYMBOLIC @@ -329,378 +334,3 @@ alldeps: perlreq .SYMBOLIC # @exclude: "config/config.h" # @continuation: "&" #-- Everything below is generated by mkdep.pl - do not edit --# -asm/assemble.$(O): asm/assemble.c asm/assemble.h asm/directiv.h & - asm/listing.h asm/pptok.h asm/preproc.h asm/tokens.h config/msvc.h & - config/unknown.h config/watcom.h include/compiler.h include/disp8.h & - include/error.h include/iflag.h include/insns.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/directbl.$(O): asm/directbl.c asm/directiv.h config/msvc.h & - config/unknown.h config/watcom.h include/compiler.h include/nasmint.h & - include/nasmlib.h include/perfhash.h -asm/directiv.$(O): asm/directiv.c asm/assemble.h asm/directiv.h asm/eval.h & - asm/float.h asm/listing.h asm/pptok.h asm/preproc.h asm/stdscan.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/error.h include/iflag.h include/labels.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h output/outform.h x86/iflaggen.h & - x86/insnsi.h x86/regs.h -asm/error.$(O): asm/error.c config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasmint.h include/nasmlib.h -asm/eval.$(O): asm/eval.c asm/assemble.h asm/directiv.h asm/eval.h & - asm/float.h asm/pptok.h asm/preproc.h config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/iflag.h & - include/labels.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/strlist.h include/tables.h & - x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/exprdump.$(O): asm/exprdump.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/strlist.h include/tables.h x86/insnsi.h & - x86/regs.h -asm/exprlib.$(O): asm/exprlib.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/strlist.h include/tables.h x86/insnsi.h & - x86/regs.h -asm/float.$(O): asm/float.c asm/directiv.h asm/float.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h x86/insnsi.h x86/regs.h -asm/labels.$(O): asm/labels.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/error.h include/hashtbl.h include/labels.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h x86/insnsi.h x86/regs.h -asm/listing.$(O): asm/listing.c asm/directiv.h asm/listing.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h x86/insnsi.h x86/regs.h -asm/nasm.$(O): asm/nasm.c asm/assemble.h asm/directiv.h asm/eval.h & - asm/float.h asm/listing.h asm/parser.h asm/pptok.h asm/preproc.h & - asm/stdscan.h asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/iflag.h include/insns.h & - include/labels.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/raa.h include/saa.h & - include/strlist.h include/tables.h include/ver.h output/outform.h & - x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/parser.$(O): asm/parser.c asm/assemble.h asm/directiv.h asm/eval.h & - asm/float.h asm/parser.h asm/pptok.h asm/preproc.h asm/stdscan.h & - asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/iflag.h include/insns.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/strlist.h include/tables.h x86/iflaggen.h & - x86/insnsi.h x86/regs.h -asm/pptok.$(O): asm/pptok.c asm/pptok.h asm/preproc.h config/msvc.h & - config/unknown.h config/watcom.h include/compiler.h include/hashtbl.h & - include/nasmint.h include/nasmlib.h -asm/pragma.$(O): asm/pragma.c asm/assemble.h asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/iflag.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/preproc-nop.$(O): asm/preproc-nop.c asm/directiv.h asm/listing.h & - asm/pptok.h asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h x86/insnsi.h x86/regs.h -asm/preproc.$(O): asm/preproc.c asm/directiv.h asm/eval.h asm/listing.h & - asm/pptok.h asm/preproc.h asm/quote.h asm/stdscan.h asm/tokens.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/error.h include/hashtbl.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h x86/insnsi.h x86/regs.h -asm/quote.$(O): asm/quote.c asm/quote.h config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h -asm/rdstrnum.$(O): asm/rdstrnum.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/strlist.h include/tables.h x86/insnsi.h & - x86/regs.h -asm/segalloc.$(O): asm/segalloc.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/iflag.h include/insns.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/stdscan.$(O): asm/stdscan.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/quote.h asm/stdscan.h asm/tokens.h config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/iflag.h & - include/insns.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/strlist.h include/tables.h & - x86/iflaggen.h x86/insnsi.h x86/regs.h -asm/strfunc.$(O): asm/strfunc.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/strlist.h include/tables.h x86/insnsi.h & - x86/regs.h -asm/tokhash.$(O): asm/tokhash.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/stdscan.h asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/hashtbl.h include/iflag.h include/insns.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/strlist.h include/tables.h x86/iflaggen.h & - x86/insnsi.h x86/regs.h -common/common.$(O): common/common.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/iflag.h include/insns.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -disasm/disasm.$(O): disasm/disasm.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/tokens.h config/msvc.h config/unknown.h config/watcom.h disasm/disasm.h & - disasm/sync.h include/compiler.h include/disp8.h include/iflag.h & - include/insns.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/strlist.h include/tables.h & - x86/iflaggen.h x86/insnsi.h x86/regdis.h x86/regs.h -disasm/ndisasm.$(O): disasm/ndisasm.c asm/directiv.h asm/pptok.h & - asm/preproc.h asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - disasm/disasm.h disasm/sync.h include/compiler.h include/error.h & - include/iflag.h include/insns.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h include/ver.h x86/iflaggen.h x86/insnsi.h x86/regs.h -disasm/sync.$(O): disasm/sync.c config/msvc.h config/unknown.h & - config/watcom.h disasm/sync.h include/compiler.h include/nasmint.h & - include/nasmlib.h -macros/macros.$(O): macros/macros.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/hashtbl.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/strlist.h include/tables.h & - output/outform.h x86/insnsi.h x86/regs.h -nasmlib/badenum.$(O): nasmlib/badenum.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h -nasmlib/bsi.$(O): nasmlib/bsi.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h -nasmlib/crc64.$(O): nasmlib/crc64.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/hashtbl.h include/nasmint.h & - include/nasmlib.h -nasmlib/file.$(O): nasmlib/file.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h nasmlib/file.h -nasmlib/filename.$(O): nasmlib/filename.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h -nasmlib/hashtbl.$(O): nasmlib/hashtbl.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/hashtbl.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h x86/insnsi.h x86/regs.h -nasmlib/ilog2.$(O): nasmlib/ilog2.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h -nasmlib/malloc.$(O): nasmlib/malloc.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h -nasmlib/md5c.$(O): nasmlib/md5c.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/md5.h include/nasmint.h -nasmlib/mmap.$(O): nasmlib/mmap.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h nasmlib/file.h -nasmlib/path.$(O): nasmlib/path.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h -nasmlib/perfhash.$(O): nasmlib/perfhash.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/hashtbl.h include/nasmint.h & - include/nasmlib.h include/perfhash.h -nasmlib/raa.$(O): nasmlib/raa.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h & - include/raa.h -nasmlib/rbtree.$(O): nasmlib/rbtree.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/rbtree.h -nasmlib/readnum.$(O): nasmlib/readnum.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h x86/insnsi.h x86/regs.h -nasmlib/realpath.$(O): nasmlib/realpath.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h -nasmlib/saa.$(O): nasmlib/saa.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h & - include/saa.h -nasmlib/srcfile.$(O): nasmlib/srcfile.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/hashtbl.h include/nasmint.h & - include/nasmlib.h -nasmlib/string.$(O): nasmlib/string.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h -nasmlib/strlist.$(O): nasmlib/strlist.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h & - include/strlist.h -nasmlib/ver.$(O): nasmlib/ver.c include/ver.h version.h -nasmlib/zerobuf.$(O): nasmlib/zerobuf.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h -output/codeview.$(O): output/codeview.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/hashtbl.h include/md5.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/saa.h include/strlist.h include/tables.h & - output/outlib.h output/pecoff.h version.h x86/insnsi.h x86/regs.h -output/legacy.$(O): output/legacy.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/error.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/strlist.h include/tables.h & - output/outlib.h x86/insnsi.h x86/regs.h -output/nulldbg.$(O): output/nulldbg.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h output/outlib.h x86/insnsi.h x86/regs.h -output/nullout.$(O): output/nullout.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h output/outlib.h x86/insnsi.h x86/regs.h -output/outaout.$(O): output/outaout.c asm/directiv.h asm/eval.h asm/pptok.h & - asm/preproc.h asm/stdscan.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/raa.h & - include/saa.h include/strlist.h include/tables.h output/outform.h & - output/outlib.h x86/insnsi.h x86/regs.h -output/outas86.$(O): output/outas86.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/raa.h & - include/saa.h include/strlist.h include/tables.h output/outform.h & - output/outlib.h x86/insnsi.h x86/regs.h -output/outbin.$(O): output/outbin.c asm/directiv.h asm/eval.h asm/pptok.h & - asm/preproc.h asm/stdscan.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/labels.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/saa.h include/strlist.h include/tables.h output/outform.h & - output/outlib.h x86/insnsi.h x86/regs.h -output/outcoff.$(O): output/outcoff.c asm/directiv.h asm/eval.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/raa.h & - include/saa.h include/strlist.h include/tables.h output/outform.h & - output/outlib.h output/pecoff.h x86/insnsi.h x86/regs.h -output/outdbg.$(O): output/outdbg.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/iflag.h include/insns.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/strlist.h include/tables.h output/outform.h & - output/outlib.h x86/iflaggen.h x86/insnsi.h x86/regs.h -output/outelf.$(O): output/outelf.c asm/directiv.h asm/eval.h asm/pptok.h & - asm/preproc.h asm/stdscan.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/raa.h & - include/rbtree.h include/saa.h include/strlist.h include/tables.h & - include/ver.h output/dwarf.h output/elf.h output/outelf.h output/outform.h & - output/outlib.h output/stabs.h x86/insnsi.h x86/regs.h -output/outform.$(O): output/outform.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/strlist.h include/tables.h & - output/outform.h x86/insnsi.h x86/regs.h -output/outieee.$(O): output/outieee.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h include/ver.h output/outform.h output/outlib.h & - x86/insnsi.h x86/regs.h -output/outlib.$(O): output/outlib.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/error.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/strlist.h include/tables.h & - output/outlib.h x86/insnsi.h x86/regs.h -output/outmacho.$(O): output/outmacho.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/labels.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/raa.h include/rbtree.h include/saa.h include/strlist.h & - include/tables.h include/ver.h output/dwarf.h output/outform.h & - output/outlib.h x86/insnsi.h x86/regs.h -output/outobj.$(O): output/outobj.c asm/directiv.h asm/eval.h asm/pptok.h & - asm/preproc.h asm/stdscan.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/strlist.h & - include/tables.h include/ver.h output/outform.h output/outlib.h & - x86/insnsi.h x86/regs.h -output/outrdf2.$(O): output/outrdf2.c asm/directiv.h asm/pptok.h & - asm/preproc.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasm.h include/nasmint.h & - include/nasmlib.h include/opflags.h include/perfhash.h include/rdoff.h & - include/saa.h include/strlist.h include/tables.h output/outform.h & - output/outlib.h x86/insnsi.h x86/regs.h -rdoff/collectn.$(O): rdoff/collectn.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/collectn.h rdoff/rdfutils.h -rdoff/hash.$(O): rdoff/hash.c config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/nasmint.h rdoff/hash.h -rdoff/ldrdf.$(O): rdoff/ldrdf.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/collectn.h rdoff/ldsegs.h & - rdoff/rdfutils.h rdoff/rdlib.h rdoff/segtab.h rdoff/symtab.h -rdoff/rdf2bin.$(O): rdoff/rdf2bin.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/rdfload.h rdoff/rdfutils.h -rdoff/rdfdump.$(O): rdoff/rdfdump.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/rdfutils.h -rdoff/rdflib.$(O): rdoff/rdflib.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/rdfutils.h -rdoff/rdfload.$(O): rdoff/rdfload.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/collectn.h rdoff/rdfload.h & - rdoff/rdfutils.h rdoff/symtab.h -rdoff/rdlar.$(O): rdoff/rdlar.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h rdoff/rdlar.h -rdoff/rdlib.$(O): rdoff/rdlib.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/rdfutils.h rdoff/rdlar.h & - rdoff/rdlib.h -rdoff/rdoff.$(O): rdoff/rdoff.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/rdfutils.h -rdoff/rdx.$(O): rdoff/rdx.c config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/error.h include/nasmint.h include/nasmlib.h & - include/rdoff.h rdoff/rdfload.h rdoff/rdfutils.h rdoff/symtab.h -rdoff/segtab.$(O): rdoff/segtab.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/rdfutils.h rdoff/segtab.h -rdoff/symtab.$(O): rdoff/symtab.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h include/rdoff.h rdoff/hash.h rdoff/rdfutils.h & - rdoff/symtab.h -stdlib/snprintf.$(O): stdlib/snprintf.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/nasmlib.h -stdlib/strlcpy.$(O): stdlib/strlcpy.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h -stdlib/strnlen.$(O): stdlib/strnlen.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h -stdlib/vsnprintf.$(O): stdlib/vsnprintf.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/error.h include/nasmint.h & - include/nasmlib.h -x86/disp8.$(O): x86/disp8.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/disp8.h include/nasm.h include/nasmint.h include/nasmlib.h & - include/opflags.h include/perfhash.h include/strlist.h include/tables.h & - x86/insnsi.h x86/regs.h -x86/iflag.$(O): x86/iflag.c config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/iflag.h include/nasmint.h x86/iflaggen.h -x86/insnsa.$(O): x86/insnsa.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/iflag.h include/insns.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -x86/insnsb.$(O): x86/insnsb.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/iflag.h include/insns.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -x86/insnsd.$(O): x86/insnsd.c asm/directiv.h asm/pptok.h asm/preproc.h & - asm/tokens.h config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/iflag.h include/insns.h include/nasm.h & - include/nasmint.h include/nasmlib.h include/opflags.h include/perfhash.h & - include/strlist.h include/tables.h x86/iflaggen.h x86/insnsi.h x86/regs.h -x86/insnsn.$(O): x86/insnsn.c config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/nasmint.h include/tables.h x86/insnsi.h -x86/regdis.$(O): x86/regdis.c x86/regdis.h x86/regs.h -x86/regflags.$(O): x86/regflags.c asm/directiv.h asm/pptok.h asm/preproc.h & - config/msvc.h config/unknown.h config/watcom.h include/compiler.h & - include/nasm.h include/nasmint.h include/nasmlib.h include/opflags.h & - include/perfhash.h include/strlist.h include/tables.h x86/insnsi.h & - x86/regs.h -x86/regs.$(O): x86/regs.c config/msvc.h config/unknown.h config/watcom.h & - include/compiler.h include/nasmint.h include/tables.h x86/insnsi.h -x86/regvals.$(O): x86/regvals.c config/msvc.h config/unknown.h & - config/watcom.h include/compiler.h include/nasmint.h include/tables.h & - x86/insnsi.h @@ -1,7 +1,18 @@ dnl -------------------------------------------------------------------------- -dnl PA_ADD_CFLAGS() +dnl PA_SYM(prefix, string) dnl -dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation +dnl Convert a (semi-) arbitrary string to a CPP symbol +dnl -------------------------------------------------------------------------- +AC_DEFUN(PA_SYM, +[[$1]m4_bpatsubsts(m4_toupper([$2]),[[^ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]+],[_],[^._?\(.*\)_.$],[[\1]])]) + +dnl -------------------------------------------------------------------------- +dnl PA_ADD_CFLAGS(flag [,actual_flag]) +dnl +dnl Attempt to add the given option to CFLAGS, if it doesn't break +dnl compilation. If the option to be tested is different than the +dnl option that should actually be added, add the option to be +dnl actually added as a second argument. dnl -------------------------------------------------------------------------- AC_DEFUN(PA_ADD_CFLAGS, [AC_MSG_CHECKING([if $CC accepts $1]) @@ -10,12 +21,14 @@ AC_DEFUN(PA_ADD_CFLAGS, AC_TRY_LINK(AC_INCLUDES_DEFAULT, [printf("Hello, World!\n");], [AC_MSG_RESULT([yes]) - CFLAGS="$pa_add_cflags__old_cflags ifelse([$2],[],[$1],[$2])"], + CFLAGS="$pa_add_cflags__old_cflags ifelse([$2],[],[$1],[$2])" + AC_DEFINE(PA_SYM([CFLAG_],[$1]), 1, + [Define to 1 if compiled with the `$1' compiler flag])], [AC_MSG_RESULT([no]) CFLAGS="$pa_add_cflags__old_cflags"])]) dnl -------------------------------------------------------------------------- -dnl PA_ADD_CLDFLAGS() +dnl PA_ADD_CLDFLAGS(flag [,actual_flag]) dnl dnl Attempt to add the given option to CFLAGS and LDFLAGS, dnl if it doesn't break compilation @@ -30,24 +43,33 @@ AC_DEFUN(PA_ADD_CLDFLAGS, [printf("Hello, World!\n");], [AC_MSG_RESULT([yes]) CFLAGS="$pa_add_cldflags__old_cflags ifelse([$2],[],[$1],[$2])" - LDFLAGS="$pa_add_cldflags__old_ldflags ifelse([$2],[],[$1],[$2])"], + LDFLAGS="$pa_add_cldflags__old_ldflags ifelse([$2],[],[$1],[$2])" + AC_DEFINE(PA_SYM([CFLAG_],[$1]), 1, + [Define to 1 if compiled with the `$1' compiler flag])], [AC_MSG_RESULT([no]) CFLAGS="$pa_add_cldflags__old_cflags" LDFLAGS="$pa_add_cldflags__old_ldflags"])]) dnl -------------------------------------------------------------------------- -dnl PA_HAVE_FUNC +dnl PA_HAVE_FUNC(func_name) dnl dnl Look for a function with the specified arguments which could be dnl a builtin/intrinsic function. dnl -------------------------------------------------------------------------- AC_DEFUN(PA_HAVE_FUNC, [AC_MSG_CHECKING([for $1]) -AC_TRY_LINK([], [(void)$1$2;], -AC_MSG_RESULT([yes]) -AC_DEFINE(m4_toupper([HAVE_$1]), [1], - [Define to 1 if you have the `$1' intrinsic function.]), -AC_MSG_RESULT([no]))]) + AC_LINK_IFELSE([AC_LANG_SOURCE([ +AC_INCLUDES_DEFAULT +int main(void) { + (void)$1$2; + return 0; +} + ])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(AS_TR_CPP([HAVE_$1]), 1, + [Define to 1 if you have the `$1' intrinsic function.])], + [AC_MSG_RESULT([no])]) +]) dnl -------------------------------------------------------------------------- dnl PA_LIBEXT @@ -70,7 +92,7 @@ AC_MSG_RESULT([$LIBEXT]) AC_SUBST([LIBEXT])]) dnl -------------------------------------------------------------------------- -dnl PA_FUNC_ATTRIBUTE +dnl PA_FUNC_ATTRIBUTE(attribute_name) dnl dnl See if this compiler supports the equivalent of a specific gcc dnl attribute on a function, using the __attribute__(()) syntax. @@ -81,7 +103,7 @@ dnl -------------------------------------------------------------------------- AC_DEFUN(PA_FUNC_ATTRIBUTE, [AC_MSG_CHECKING([if $CC supports the $1 function attribute]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -#include <stdarg.h> +AC_INCLUDES_DEFAULT extern ifelse([$3],[],[void *],[$3]) __attribute__(($1$2)) bar(ifelse([$4],[],[int],[$4])); void *foo(void); @@ -91,7 +113,7 @@ void *foo(void) } ])], [AC_MSG_RESULT([yes]) - AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_$1]), 1, + AC_DEFINE(PA_SYM([HAVE_FUNC_ATTRIBUTE_],[$1]), 1, [Define to 1 if your compiler supports __attribute__(($1)) on functions])], [AC_MSG_RESULT([no])]) ]) @@ -106,7 +128,7 @@ dnl -------------------------------------------------------------------------- AC_DEFUN(PA_FUNC_ATTRIBUTE_ERROR, [AC_MSG_CHECKING([if $CC supports the error function attribute]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -#include <stdarg.h> +AC_INCLUDES_DEFAULT extern void __attribute__((error("message"))) barf(void); void foo(void); void foo(void) @@ -116,14 +138,14 @@ void foo(void) } ])], [AC_MSG_RESULT([yes]) - AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_ERROR]), 1, + AC_DEFINE([HAVE_FUNC_ATTRIBUTE_ERROR], 1, [Define to 1 if your compiler supports __attribute__((error)) on functions])], [AC_MSG_RESULT([no])]) ]) dnl -------------------------------------------------------------------------- -dnl PA_ARG_ENABLED -dnl PA_ARG_DISABLED +dnl PA_ARG_ENABLED(option, helptext [,enabled_action [,disabled_action]]) +dnl PA_ARG_DISABLED(option, helptext [,disabled_action [,enabled_action]]) dnl dnl Simpler-to-use versions of AC_ARG_ENABLED, that include the dnl test for $enableval and the AS_HELP_STRING definition @@ -137,3 +159,43 @@ AC_DEFUN(PA_ARG_DISABLED, [AC_ARG_ENABLE([$1],[AS_HELP_STRING([--disable-$1],[$2])], [], [enableval=yes]) AS_IF([test x"$enableval" = xno], [$3], [$4]) ]) + +dnl -------------------------------------------------------------------------- +dnl PA_ADD_HEADERS(headers...) +dnl +dnl Call AC_CHECK_HEADERS(), and add to ac_includes_default if found +dnl -------------------------------------------------------------------------- +AC_DEFUN(_PA_ADD_HEADER, +[AC_CHECK_HEADERS([$1],[ac_includes_default="$ac_includes_default +#include <$1>" +])]) + +AC_DEFUN(PA_ADD_HEADERS, +[m4_map_args_w([$1],[_PA_ADD_HEADER(],[)])]) + +dnl -------------------------------------------------------------------------- +dnl PA_CHECK_BAD_STDC_INLINE +dnl +dnl Some versions of gcc seem to apply -Wmissing-prototypes to C99 +dnl inline functions, which means we need to use GNU inline syntax +dnl -------------------------------------------------------------------------- +AC_DEFUN(PA_CHECK_BAD_STDC_INLINE, +[AC_MSG_CHECKING([if $CC supports C99 external inlines]) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +AC_INCLUDES_DEFAULT + +/* Don't mistake GNU inlines for c99 */ +#ifdef __GNUC_GNU_INLINE__ +# error "Using gnu inline standard" +#endif + +inline int foo(int x) +{ + return x+1; +} + ])], + [AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_STDC_INLINE, 1, + [Define to 1 if your compiler supports C99 extern inline])], + [AC_MSG_RESULT([no]) + PA_ADD_CFLAGS([-fgnu89-inline])])]) diff --git a/asm/assemble.c b/asm/assemble.c index 3bfccec0..561bba55 100644 --- a/asm/assemble.c +++ b/asm/assemble.c @@ -335,13 +335,12 @@ static void out(struct out_data *data) { static int32_t lineno = 0; /* static!!! */ static const char *lnfname = NULL; - int asize; - const int amax = ofmt->maxbits >> 3; /* Maximum address size in bytes */ union { uint8_t b[8]; uint64_t q; } xdata; - uint64_t size = data->size; + size_t asize, amax; + uint64_t zeropad = 0; int64_t addrval; int32_t fixseg; /* Segment for which to produce fixed data */ @@ -364,27 +363,29 @@ static void out(struct out_data *data) goto address; address: + nasm_assert(data->size <= 8); asize = data->size; - nasm_assert(asize <= 8); + amax = ofmt->maxbits >> 3; /* Maximum address size in bytes */ if (data->tsegment == fixseg && data->twrt == NO_SEG) { - uint8_t *q = xdata.b; - warn_overflow_out(addrval, asize, data->sign); - - WRITEADDR(q, addrval, asize); + xdata.q = cpu_to_le64(addrval); data->data = xdata.b; data->type = OUT_RAWDATA; - asize = 0; /* No longer an address */ + asize = amax = 0; /* No longer an address */ } break; + case OUT_SEGMENT: + nasm_assert(data->size <= 8); + asize = data->size; + amax = 2; + break; + default: - asize = 0; /* Not an address */ + asize = amax = 0; /* Not an address */ break; } - lfmt->output(data); - /* * this call to src_get determines when we call the * debug-format-specific "linenum" function @@ -397,28 +398,35 @@ static void out(struct out_data *data) if (src_get(&lineno, &lnfname)) dfmt->linenum(lnfname, lineno, data->segment); - if (asize && asize > amax) { - if (data->type != OUT_ADDRESS || data->sign == OUT_SIGNED) { + if (asize > amax) { + if (data->type == OUT_RELADDR || data->sign == OUT_SIGNED) { nasm_error(ERR_NONFATAL, - "%d-bit signed relocation unsupported by output format %s\n", - asize << 3, ofmt->shortname); + "%u-bit signed relocation unsupported by output format %s", + (unsigned int)(asize << 3), ofmt->shortname); } else { nasm_error(ERR_WARNING | ERR_WARN_ZEXTRELOC, - "%d-bit unsigned relocation zero-extended from %d bits\n", - asize << 3, ofmt->maxbits); - data->size = amax; - ofmt->output(data); - data->insoffs += amax; - data->offset += amax; - data->size = size = asize - amax; + "%u-bit %s relocation zero-extended from %u bits", + (unsigned int)(asize << 3), + data->type == OUT_SEGMENT ? "segment" : "unsigned", + (unsigned int)(amax << 3)); } - data->data = zero_buffer; - data->type = OUT_RAWDATA; + zeropad = data->size - amax; + data->size = amax; } - + lfmt->output(data); ofmt->output(data); - data->offset += size; - data->insoffs += size; + data->offset += data->size; + data->insoffs += data->size; + + if (zeropad) { + data->type = OUT_ZERODATA; + data->size = zeropad; + lfmt->output(data); + ofmt->output(data); + data->offset += zeropad; + data->insoffs += zeropad; + data->size += zeropad; /* Restore original size value */ + } } static inline void out_rawdata(struct out_data *data, const void *rawdata, @@ -445,13 +453,37 @@ static inline void out_reserve(struct out_data *data, uint64_t size) out(data); } -static inline void out_imm(struct out_data *data, const struct operand *opx, - int size, enum out_sign sign) +static void out_segment(struct out_data *data, const struct operand *opx) +{ + if (opx->opflags & OPFLAG_RELATIVE) + nasm_error(ERR_NONFATAL, "segment references cannot be relative"); + + data->type = OUT_SEGMENT; + data->sign = OUT_UNSIGNED; + data->size = 2; + data->toffset = opx->offset; + data->tsegment = ofmt->segbase(opx->segment | 1); + data->twrt = opx->wrt; + out(data); +} + +static void out_imm(struct out_data *data, const struct operand *opx, + int size, enum out_sign sign) { - data->type = - (opx->opflags & OPFLAG_RELATIVE) ? OUT_RELADDR : OUT_ADDRESS; + if (opx->segment != NO_SEG && (opx->segment & 1)) { + /* + * This is actually a segment reference, but eval() has + * already called ofmt->segbase() for us. Sigh. + */ + if (size < 2) + nasm_error(ERR_NONFATAL, "segment reference must be 16 bits"); + + data->type = OUT_SEGMENT; + } else { + data->type = (opx->opflags & OPFLAG_RELATIVE) + ? OUT_RELADDR : OUT_ADDRESS; + } data->sign = sign; - data->size = size; data->toffset = opx->offset; data->tsegment = opx->segment; data->twrt = opx->wrt; @@ -463,6 +495,7 @@ static inline void out_imm(struct out_data *data, const struct operand *opx, * already occurred. */ data->relbase = 0; + data->size = size; out(data); } @@ -482,18 +515,6 @@ static void out_reladdr(struct out_data *data, const struct operand *opx, out(data); } -static inline void out_segment(struct out_data *data, - const struct operand *opx) -{ - data->type = OUT_SEGMENT; - data->sign = OUT_UNSIGNED; - data->size = 2; - data->toffset = opx->offset; /* Is this really needed/wanted? */ - data->tsegment = ofmt->segbase(opx->segment + 1); - data->twrt = opx->wrt; - out(data); -} - static bool jmp_match(int32_t segment, int64_t offset, int bits, insn * ins, const struct itemplate *temp) { @@ -545,10 +566,9 @@ int64_t assemble(int32_t segment, int64_t start, int bits, insn *instruction) data.offset = start; data.segment = segment; data.itemp = NULL; - data.sign = OUT_WRAP; data.bits = bits; - wsize = idata_bytes(instruction->opcode); + wsize = db_bytes(instruction->opcode); if (wsize == -1) return 0; @@ -563,12 +583,19 @@ int64_t assemble(int32_t segment, int64_t start, int bits, insn *instruction) " instruction"); } else { data.insoffs = 0; - data.type = e->relative ? OUT_RELADDR : OUT_ADDRESS; data.inslen = data.size = wsize; data.toffset = e->offset; - data.tsegment = e->segment; data.twrt = e->wrt; data.relbase = 0; + if (e->segment != NO_SEG && (e->segment & 1)) { + data.tsegment = e->segment; + data.type = OUT_SEGMENT; + data.sign = OUT_UNSIGNED; + } else { + data.tsegment = e->segment; + data.type = e->relative ? OUT_RELADDR : OUT_ADDRESS; + data.sign = OUT_WRAP; + } out(&data); } } else if (e->type == EOT_DB_STRING || @@ -684,7 +711,6 @@ int64_t assemble(int32_t segment, int64_t start, int bits, insn *instruction) end_incbin: lfmt->downlevel(LIST_INCBIN); if (instruction->times > 1) { - lfmt->set_offset(start); lfmt->uplevel(LIST_TIMES); lfmt->downlevel(LIST_TIMES); } @@ -790,7 +816,7 @@ int64_t insn_size(int32_t segment, int64_t offset, int bits, insn *instruction) int32_t isize, osize, wsize; isize = 0; - wsize = idata_bytes(instruction->opcode); + wsize = db_bytes(instruction->opcode); nasm_assert(wsize > 0); list_for_each(e, instruction->eops) { diff --git a/asm/directiv.c b/asm/directiv.c index 4c30323a..7c741685 100644 --- a/asm/directiv.c +++ b/asm/directiv.c @@ -44,6 +44,7 @@ #include "nasm.h" #include "nasmlib.h" +#include "ilog2.h" #include "error.h" #include "float.h" #include "stdscan.h" diff --git a/asm/directiv.dat b/asm/directiv.dat index 2dcaa76f..ebf66148 100644 --- a/asm/directiv.dat +++ b/asm/directiv.dat @@ -90,3 +90,4 @@ subsections_via_symbols ; macho no_dead_strip ; macho maxdump ; dbg nodepend ; obj +noseclabels ; dbg @@ -45,6 +45,7 @@ #include "nasm.h" #include "nasmlib.h" +#include "ilog2.h" #include "error.h" #include "eval.h" #include "labels.h" diff --git a/asm/listing.c b/asm/listing.c index 05ef0012..9409aa90 100644 --- a/asm/listing.c +++ b/asm/listing.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- * - * + * * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. @@ -14,7 +14,7 @@ * 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 @@ -114,7 +114,7 @@ static void list_emit(void) fprintf(listfp, "%6"PRId32" ", listlineno); for (i = 0; i < LIST_HEXBIT; i++) putc('*', listfp); - + if (listlevel_e) fprintf(listfp, " %s<%d>", (listlevel < 10 ? " " : ""), listlevel_e); @@ -202,15 +202,23 @@ static void list_output(const struct out_data *data) char q[20]; uint64_t size = data->size; uint64_t offset = data->offset; + const uint8_t *p = data->data; + if (!listp || suppress || user_nolist) return; switch (data->type) { + case OUT_ZERODATA: + if (size > 16) { + snprintf(q, sizeof(q), "<zero %08"PRIX64">", size); + list_out(offset, q); + } else { + p = zero_buffer; + /* fall through */ + } case OUT_RAWDATA: { - const uint8_t *p = data->data; - if (size == 0 && !listdata[0]) listoffset = data->offset; while (size--) { @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2017 The NASM Authors - All Rights Reserved + * Copyright 1996-2018 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -75,7 +75,7 @@ struct forwrefinfo { /* info held on forward refs. */ }; static void parse_cmdline(int, char **, int); -static void assemble_file(char *, StrList **); +static void assemble_file(const char *, StrList **); static bool is_suppressed_warning(int severity); static bool skip_this_pass(int severity); static void nasm_verror_gnu(int severity, const char *fmt, va_list args); @@ -86,6 +86,11 @@ static void usage(void); static bool using_debug_info, opt_verbose_info; static const char *debug_format; +#ifndef ABORT_ON_PANIC +# define ABORT_ON_PANIC 0 +#endif +static bool abort_on_panic = ABORT_ON_PANIC; + bool tasm_compatible_mode = false; int pass0, passn; static int pass1, pass2; /* XXX: Get rid of these, they are redundant */ @@ -94,10 +99,11 @@ int globalbnd = 0; struct compile_time official_compile_time; -static char inname[FILENAME_MAX]; -static char outname[FILENAME_MAX]; -static char listname[FILENAME_MAX]; -static char errname[FILENAME_MAX]; +const char *inname; +const char *outname; +static const char *listname; +static const char *errname; + static int globallineno; /* for forward-reference tracking */ /* static int pass = 0; */ const struct ofmt *ofmt = &OF_DEFAULT; @@ -383,6 +389,10 @@ int main(int argc, char **argv) if (ofmt->stdmac) preproc->extra_stdmac(ofmt->stdmac); + /* no output file name? */ + if (!outname) + outname = filename_set_extension(inname, ofmt->extension); + /* define some macros dependent of command-line */ define_macros_late(); @@ -398,8 +408,6 @@ int main(int argc, char **argv) preproc->include_path(NULL); /* "assume generated" */ preproc->reset(inname, 0, depend_ptr); - if (outname[0] == '\0') - ofmt->filename(inname, outname); ofile = NULL; while ((line = preproc->getline())) nasm_free(line); @@ -410,7 +418,7 @@ int main(int argc, char **argv) int32_t prior_linnum = 0; int lineinc = 0; - if (*outname) { + if (outname) { ofile = nasm_open_write(outname, NF_TEXT); if (!ofile) nasm_fatal(ERR_NOFILE, @@ -456,15 +464,6 @@ int main(int argc, char **argv) } if (operating_mode & OP_NORMAL) { - /* - * We must call ofmt->filename _anyway_, even if the user - * has specified their own output file, because some - * formats (eg OBJ and COFF) use ofmt->filename to find out - * the name of the input file and then put that inside the - * file. - */ - ofmt->filename(inname, outname); - ofile = nasm_open_write(outname, (ofmt->flags & OFMT_TEXT) ? NF_TEXT : NF_BINARY); if (!ofile) nasm_fatal(ERR_NOFILE, @@ -537,15 +536,12 @@ static char *get_param(char *p, char *q, bool *advance) /* * Copy a filename */ -static void copy_filename(char *dst, const char *src) +static void copy_filename(const char **dst, const char *src, const char *what) { - size_t len = strlen(src); + if (*dst) + nasm_fatal(0, "more than one %s file specified: %s\n", what, src); - if (len >= (size_t)FILENAME_MAX) { - nasm_fatal(ERR_NOFILE, "file name too long"); - return; - } - strncpy(dst, src, FILENAME_MAX); + *dst = nasm_strdup(src); } /* @@ -699,19 +695,25 @@ static char *quote_for_wmake(const char *str) return os; } -struct textargs { - const char *label; - int value; -}; - enum text_options { + OPT_BOGUS, + OPT_VERSION, + OPT_ABORT_ON_PANIC, OPT_PREFIX, OPT_POSTFIX }; +struct textargs { + const char *label; + enum text_options opt; + bool need_arg; +}; static const struct textargs textopts[] = { - {"prefix", OPT_PREFIX}, - {"postfix", OPT_POSTFIX}, - {NULL, 0} + {"v", OPT_VERSION, false}, + {"version", OPT_VERSION, false}, + {"abort-on-panic", OPT_ABORT_ON_PANIC, false}, + {"prefix", OPT_PREFIX, true}, + {"postfix", OPT_POSTFIX, true}, + {NULL, OPT_BOGUS, false} }; static void show_version(void) @@ -746,7 +748,7 @@ static bool process_arg(char *p, char *q, int pass) case 'o': /* output file */ if (pass == 2) - copy_filename(outname, param); + copy_filename(&outname, param, "output"); break; case 'f': /* output format */ @@ -832,12 +834,12 @@ static bool process_arg(char *p, char *q, int pass) case 'l': /* listing file */ if (pass == 2) - copy_filename(listname, param); + copy_filename(&listname, param, "listing"); break; case 'Z': /* error messages file */ if (pass == 1) - copy_filename(errname, param); + copy_filename(&errname, param, "error"); break; case 'F': /* specify debug format */ @@ -1031,61 +1033,49 @@ static bool process_arg(char *p, char *q, int pass) case '-': { - int s; + const struct textargs *tx; if (p[2] == 0) { /* -- => stop processing options */ - stopoptions = 1; + stopoptions = true; break; } - if (!nasm_stricmp(p, "--v")) - show_version(); - - if (!nasm_stricmp(p, "--version")) - show_version(); + for (tx = textopts; tx->label; tx++) { + if (!nasm_stricmp(p + 2, tx->label)) + break; + } - for (s = 0; textopts[s].label; s++) { - if (!nasm_stricmp(p + 2, textopts[s].label)) { + if (tx->need_arg) { + if (!q) { + nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, + "option `--%s' requires an argument", + p + 2); break; } + advance = true; } - switch (s) { + switch (tx->opt) { + case OPT_VERSION: + show_version(); + break; + case OPT_ABORT_ON_PANIC: + abort_on_panic = true; + break; case OPT_PREFIX: + if (pass == 2) + strlcpy(lprefix, q, PREFIX_MAX); + break; case OPT_POSTFIX: - { - if (!q) { - nasm_error(ERR_NONFATAL | ERR_NOFILE | - ERR_USAGE, - "option `--%s' requires an argument", - p + 2); - break; - } else { - advance = 1, param = q; - } - - switch (s) { - case OPT_PREFIX: - if (pass == 2) - strlcpy(lprefix, param, PREFIX_MAX); - break; - case OPT_POSTFIX: - if (pass == 2) - strlcpy(lpostfix, param, POSTFIX_MAX); - break; - default: - panic(); - break; - } - break; - } - + if (pass == 2) + strlcpy(lpostfix, q, POSTFIX_MAX); + break; + case OPT_BOGUS: + nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, + "unrecognized option `--%s'", p + 2); + break; default: - { - nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, - "unrecognised option `--%s'", p + 2); - break; - } + panic(); } break; } @@ -1096,12 +1086,8 @@ static bool process_arg(char *p, char *q, int pass) break; } } else if (pass == 2) { - if (*inname) { - nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, - "more than one input file specified"); - } else { - copy_filename(inname, p); - } + /* In theory we could allow multiple input files... */ + copy_filename(&inname, p, "input"); } return advance; @@ -1215,8 +1201,6 @@ static void parse_cmdline(int argc, char **argv, int pass) char *envreal, *envcopy = NULL, *p; int i; - *inname = *outname = *listname = *errname = '\0'; - /* Initialize all the warnings to their default state */ for (i = 0; i < ERR_WARN_ALL; i++) { warning_state_init[i] = warning_state[i] = @@ -1274,18 +1258,16 @@ static void parse_cmdline(int argc, char **argv, int pass) if (pass != 2) return; - if (!*inname) - nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, - "no input file specified"); - else if (!strcmp(inname, errname) || - !strcmp(inname, outname) || - !strcmp(inname, listname) || + if (!inname) + nasm_fatal(ERR_NOFILE | ERR_USAGE, "no input file specified"); + + else if ((errname && !strcmp(inname, errname)) || + (outname && !strcmp(inname, outname)) || + (listname && !strcmp(inname, listname)) || (depend_file && !strcmp(inname, depend_file))) - nasm_fatal(ERR_NOFILE | ERR_USAGE, - "file `%s' is both input and output file", - inname); + nasm_fatal(ERR_USAGE, "will not overwrite input file"); - if (*errname) { + if (errname) { error_file = nasm_open_write(errname, NF_TEXT); if (!error_file) { error_file = stderr; /* Revert to default! */ @@ -1296,7 +1278,7 @@ static void parse_cmdline(int argc, char **argv, int pass) } } -static void assemble_file(char *fname, StrList **depend_ptr) +static void assemble_file(const char *fname, StrList **depend_ptr) { char *line; insn output_ins; @@ -1336,7 +1318,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) cpu = cmd_cpu; if (pass0 == 2) { lfmt->init(listname); - } else if (passn == 1 && *listname) { + } else if (passn == 1 && listname) { /* Remove the list file in case we die before the output pass */ remove(listname); } @@ -1644,15 +1626,19 @@ static void nasm_verror_gnu(int severity, const char *fmt, va_list ap) if (is_suppressed_warning(severity)) return; - if (!(severity & ERR_NOFILE)) + if (!(severity & ERR_NOFILE)) { src_get(&lineno, ¤tfile); + if (!currentfile || (severity & ERR_TOPFILE)) { + currentfile = inname[0] ? inname : outname[0] ? outname : NULL; + lineno = 0; + } + } if (!skip_this_pass(severity)) { - if (currentfile) { - fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno); - } else { - fputs("nasm: ", error_file); - } + if (!lineno) + fprintf(error_file, "%s:", currentfile ? currentfile : "nasm"); + else + fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno); } nasm_verror_common(severity, fmt, ap); @@ -1838,7 +1824,10 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) break; /* placate silly compilers */ case ERR_PANIC: fflush(NULL); - /* abort(); */ /* halt, catch fire, and dump core */ + + if (abort_on_panic) + abort(); /* halt, catch fire, dump core/stop debugger */ + if (ofile) { fclose(ofile); remove(outname); diff --git a/asm/parser.c b/asm/parser.c index bbe3e588..2ad37ceb 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -665,7 +665,7 @@ is_float: eop->type = EOT_DB_STRING; result->eops_float = true; - eop->stringlen = idata_bytes(result->opcode); + eop->stringlen = db_bytes(result->opcode); if (eop->stringlen > 16) { nasm_error(ERR_NONFATAL, "floating-point constant" " encountered in DY or DZ instruction"); @@ -1128,7 +1128,7 @@ is_expression: * Transform RESW, RESD, RESQ, REST, RESO, RESY, RESZ into RESB. */ if (opcode_is_resb(result->opcode)) { - result->oprs[0].offset *= resv_bytes(result->opcode); + result->oprs[0].offset *= resb_bytes(result->opcode); result->oprs[0].offset *= result->times; result->times = 1; result->opcode = I_RESB; diff --git a/asm/preproc-nop.c b/asm/preproc-nop.c index 3d2c57cf..186e87d2 100644 --- a/asm/preproc-nop.c +++ b/asm/preproc-nop.c @@ -63,7 +63,7 @@ static void nop_init(void) /* Nothing to do */ } -static void nop_reset(char *file, int pass, StrList **deplist) +static void nop_reset(const char *file, int pass, StrList **deplist) { src_set(0, file); nop_lineinc = 1; diff --git a/asm/preproc.c b/asm/preproc.c index 475926d8..744747fd 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -4970,7 +4970,7 @@ static void pp_verror(int severity, const char *fmt, va_list arg) } static void -pp_reset(char *file, int apass, StrList **deplist) +pp_reset(const char *file, int apass, StrList **deplist) { Token *t; @@ -2,8 +2,7 @@ # # Simple script to run the appropriate autotools from a repository. # -autoheader -autoconf +autoreconf rm -rf autom4te.cache config.log config.status rm -f Makefile rdoff/Makefile doc/Makefile rm -f config.h.in config.h config/config.h diff --git a/common/common.c b/common/common.c index fb3e890d..13237994 100644 --- a/common/common.c +++ b/common/common.c @@ -62,61 +62,3 @@ const char *prefix_name(int token) return prefix_names[prefix]; } - -/* - * initialized data bytes length from opcode - */ -int idata_bytes(enum opcode opcode) -{ - switch (opcode) { - case I_DB: - return 1; - case I_DW: - return 2; - case I_DD: - return 4; - case I_DQ: - return 8; - case I_DT: - return 10; - case I_DO: - return 16; - case I_DY: - return 32; - case I_DZ: - return 64; - case I_none: - return -1; - default: - return 0; - } -} - -/* - * Uninitialized data bytes length from opcode - */ -int resv_bytes(enum opcode opcode) -{ - switch (opcode) { - case I_RESB: - return 1; - case I_RESW: - return 2; - case I_RESD: - return 4; - case I_RESQ: - return 8; - case I_REST: - return 10; - case I_RESO: - return 16; - case I_RESY: - return 32; - case I_RESZ: - return 64; - case I_none: - return -1; - default: - return 0; - } -} diff --git a/configure.ac b/configure.ac index d6b61b49..7f1e1ce6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ -dnl Process this file with autoconf 2.63 or later to produce +dnl Process this file with autoconf 2.69 or later to produce dnl a configure script. -AC_PREREQ(2.63) +AC_PREREQ(2.69) AC_INIT(config/config.h.in) AC_CONFIG_HEADERS(config/config.h) @@ -43,6 +43,13 @@ AS_IF([test x"$pa_init_cflags" = x], AS_IF([test x"$pa_optimize" = "x-O0"], [PA_ADD_CFLAGS([-fno-omit-frame-pointer])]) +dnl Abort on panic +PA_ARG_ENABLED([panic-abort], + [call abort() on panic to trap in the debugger], + [AC_DEFINE(ABORT_ON_PANIC)]) +AH_TEMPLATE(ABORT_ON_PANIC, +[Define to 1 to call abort() on panics (internal errors), for debugging.]) + dnl Check for library extension PA_LIBEXT @@ -99,7 +106,6 @@ AC_CHECK_HEADERS(stdnoreturn.h) AC_CHECK_HEADERS(io.h) AC_CHECK_HEADERS(fcntl.h) AC_CHECK_HEADERS(unistd.h) -AC_CHECK_HEADERS(sys/param.h) AC_CHECK_HEADERS(sys/mman.h) AC_CHECK_HEADERS(sys/types.h) AC_CHECK_HEADERS(sys/stat.h) @@ -109,6 +115,7 @@ AC_CHECK_FUNCS(strcasecmp stricmp) AC_CHECK_FUNCS(strncasecmp strnicmp) AC_CHECK_FUNCS(strsep) AC_CHECK_FUNCS(strnlen) +AC_CHECK_FUNCS(strrchrnul) AC_CHECK_FUNCS(getuid) AC_CHECK_FUNCS(getgid) @@ -130,15 +137,21 @@ AC_CHECK_FUNCS(sysconf) AC_CHECK_FUNCS([access _access faccessat]) +PA_HAVE_FUNC(__builtin_expect, (1,1)) + +dnl ilog2() building blocks +PA_ADD_HEADERS(intrin.h) PA_HAVE_FUNC(__builtin_clz, (0U)) PA_HAVE_FUNC(__builtin_clzl, (0UL)) PA_HAVE_FUNC(__builtin_clzll, (0ULL)) -PA_HAVE_FUNC(__builtin_expect, (1,1)) +PA_HAVE_FUNC(_BitScanReverse, (0)) +PA_HAVE_FUNC(_BitScanReverse64, (0)) -dnl Functions for which we have replacements available in lib/ +dnl Functions for which we have replacements available in stdlib/ AC_CHECK_FUNCS([vsnprintf _vsnprintf]) AC_CHECK_FUNCS([snprintf _snprintf]) AC_CHECK_FUNCS([strlcpy]) +AC_CHECK_FUNCS([strrchrnul]) dnl These types are POSIX-specific, and Windows does it differently... AC_CHECK_TYPES([struct _stati64]) @@ -156,6 +169,7 @@ AC_CHECK_DECLS(strnicmp) AC_CHECK_DECLS(strsep) AC_CHECK_DECLS(strlcpy) AC_CHECK_DECLS(strnlen) +AC_CHECK_DECLS(strrchrnul) dnl Check for missing types AC_TYPE_UINTPTR_T @@ -169,6 +183,34 @@ PA_ARG_DISABLED([pdf-compression], AC_SUBST([PDFOPT]) dnl +dnl Look for byte-swapping support... +dnl +PA_ADD_HEADERS(endian.h sys/endian.h machine/endian.h) +PA_HAVE_FUNC(cpu_to_le16, (0)) +PA_HAVE_FUNC(cpu_to_le32, (0)) +PA_HAVE_FUNC(cpu_to_le64, (0)) +PA_HAVE_FUNC(__cpu_to_le16, (0)) +PA_HAVE_FUNC(__cpu_to_le32, (0)) +PA_HAVE_FUNC(__cpu_to_le64, (0)) +PA_HAVE_FUNC(htole16, (0)) +PA_HAVE_FUNC(htole32, (0)) +PA_HAVE_FUNC(htole64, (0)) +PA_HAVE_FUNC(__bswap_16, (0)) +PA_HAVE_FUNC(__bswap_32, (0)) +PA_HAVE_FUNC(__bswap_64, (0)) +PA_HAVE_FUNC(__builtin_bswap16, (0)) +PA_HAVE_FUNC(__builtin_bswap32, (0)) +PA_HAVE_FUNC(__builtin_bswap64, (0)) +PA_HAVE_FUNC(_byteswap_ushort, (0)) +PA_HAVE_FUNC(_byteswap_ulong, (0)) +PA_HAVE_FUNC(_byteswap_uint64, (0)) + +dnl +dnl Check for __builtin_constant_p() +dnl +PA_HAVE_FUNC(__builtin_constant_p, (0)) + +dnl dnl Check for supported gcc attributes; some compilers (e.g. Sun CC) dnl support these, but don't define __GNUC__ as they don't support dnl some other features of gcc. @@ -245,6 +287,13 @@ PA_ARG_ENABLED([werror], ) dnl +dnl On some versions of gcc, -Werror=missing-prototypes causes problems +dnl with C99-style external inlines. Test this *after* adding the -Werror +dnl options. +dnl +PA_CHECK_BAD_STDC_INLINE + +dnl dnl support ccache dnl PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], []) diff --git a/doc/Makefile.in b/doc/Makefile.in index 2ddfd1ee..27e6fadb 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -9,7 +9,8 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ mandir = @mandir@ -docdir = $(prefix)/doc/nasm +docdir = @docdir@ +htmldir = @htmldir@ infodir = @infodir@ datarootdir = @datarootdir@ @@ -21,6 +22,7 @@ PERL = perl -I$(srcdir) PDFOPT = @PDFOPT@ +MKDIR = mkdir RM_F = rm -f RM_RF = rm -rf CP_F = cp -f @@ -32,6 +34,7 @@ HTMLAUX = nasmdoc.css local.css nasmlogw.png SRCS = nasmdoc.src inslist.src changes.src version.src OUT = html nasmdoc.txt nasmdoc.pdf +.SUFFIXES: .SUFFIXES: .pfa .ph all: $(OUT) @@ -41,7 +44,7 @@ inslist.src: inslist.pl ../x86/insns.dat .PHONY: html html: $(HTMLAUX) - mkdir -p html + $(MKDIR) -p html for f in $(HTMLAUX); do $(CP_UF) "$(srcdir)/$$f" html/; done $(MAKE) html/nasmdoc0.html @@ -81,6 +84,7 @@ spotless: clean -$(RM_F) *.hlp nasmdoc.txt *.inf *.pdf *.dvi install: all - mkdir -p $(INSTALLROOT)$(docdir)/html - $(INSTALL_DATA) html/* $(INSTALLROOT)$(docdir)/html - $(INSTALL_DATA) nasmdoc.pdf nasmdoc.txt $(INSTALLROOT)$(docdir) + $(MKDIR) -p $(DESTDIR)$(htmldir) + $(INSTALL_DATA) html/* $(DESTDIR)$(htmldir) + $(MKDIR) -p $(DESTDIR)$(docdir) + $(INSTALL_DATA) nasmdoc.pdf nasmdoc.txt $(DESTDIR)$(docdir) diff --git a/include/bytesex.h b/include/bytesex.h new file mode 100644 index 00000000..186d5618 --- /dev/null +++ b/include/bytesex.h @@ -0,0 +1,261 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 1996-2017 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. + * + * ----------------------------------------------------------------------- */ + +/* + * bytesex.h - byte order helper functions + * + * In this function, be careful about getting X86_MEMORY versus + * LITTLE_ENDIAN correct: X86_MEMORY also means we are allowed to + * do unaligned memory references, and is probabilistic. + */ + +#ifndef NASM_BYTEORD_H +#define NASM_BYTEORD_H + +#include "compiler.h" + +/* + * Some handy macros that will probably be of use in more than one + * output format: convert integers into little-endian byte packed + * format in memory. + */ + +#define WRITECHAR(p,v) \ + do { \ + uint8_t *_wc_p = (uint8_t *)(p); \ + *_wc_p++ = (v); \ + (p) = (void *)_wc_p; \ + } while (0) + +#if X86_MEMORY + +#define WRITESHORT(p,v) \ + do { \ + uint16_t *_ws_p = (uint16_t *)(p); \ + *_ws_p++ = (v); \ + (p) = (void *)_ws_p; \ + } while (0) + +#define WRITELONG(p,v) \ + do { \ + uint32_t *_wl_p = (uint32_t *)(p); \ + *_wl_p++ = (v); \ + (p) = (void *)_wl_p; \ + } while (0) + +#define WRITEDLONG(p,v) \ + do { \ + uint64_t *_wq_p = (uint64_t *)(p); \ + *_wq_p++ = (v); \ + (p) = (void *)_wq_p; \ + } while (0) + +#else /* !X86_MEMORY */ + +#define WRITESHORT(p,v) \ + do { \ + uint8_t *_ws_p = (uint8_t *)(p); \ + const uint16_t _ws_v = (v); \ + WRITECHAR(_ws_p, _ws_v); \ + WRITECHAR(_ws_p, _ws_v >> 8); \ + (p) = (void *)_ws_p; \ + } while (0) + +#define WRITELONG(p,v) \ + do { \ + uint8_t *_wl_p = (uint8_t *)(p); \ + const uint32_t _wl_v = (v); \ + WRITESHORT(_wl_p, _wl_v); \ + WRITESHORT(_wl_p, _wl_v >> 16); \ + (p) = (void *)_wl_p; \ + } while (0) + +#define WRITEDLONG(p,v) \ + do { \ + uint8_t *_wq_p = (uint8_t *)(p); \ + const uint64_t _wq_v = (v); \ + WRITELONG(_wq_p, _wq_v); \ + WRITELONG(_wq_p, _wq_v >> 32); \ + (p) = (void *)_wq_p; \ + } while (0) + +#endif /* X86_MEMORY */ + +/* + * Endian control functions which work on a single integer + */ +#ifdef WORDS_LITTLEENDIAN + +#ifndef HAVE_CPU_TO_LE16 +# define cpu_to_le16(v) ((uint16_t)(v)) +#endif +#ifndef HAVE_CPU_TO_LE32 +# define cpu_to_le32(v) ((uint32_t)(v)) +#endif +#ifndef HAVE_CPU_TO_LE64 +# define cpu_to_le64(v) ((uint64_t)(v)) +#endif + +#elif defined(WORDS_BIGENDIAN) + +#ifndef HAVE_CPU_TO_LE16 +static inline uint16_t cpu_to_le16(uint16_t v) +{ +# ifdef HAVE___CPU_TO_LE16 + return __cpu_to_le16(v); +# elif defined(HAVE_HTOLE16) + return htole16(v); +# elif defined(HAVE___BSWAP_16) + return __bswap_16(v); +# elif defined(HAVE___BUILTIN_BSWAP16) + return __builtin_bswap16(v); +# elif defined(HAVE__BYTESWAP_USHORT) && (USHRT_MAX == 0xffffU) + return _byteswap_ushort(v); +# else + return (v << 8) | (v >> 8); +# endif +} +#endif + +#ifndef HAVE_CPU_TO_LE32 +static inline uint32_t cpu_to_le32(uint32_t v) +{ +# ifdef HAVE___CPU_TO_LE32 + return __cpu_to_le32(v); +# elif defined(HAVE_HTOLE32) + return htole32(v); +# elif defined(HAVE___BSWAP_32) + return __bswap_32(v); +# elif defined(HAVE___BUILTIN_BSWAP32) + return __builtin_bswap32(v); +# elif defined(HAVE__BYTESWAP_ULONG) && (ULONG_MAX == 0xffffffffUL) + return _byteswap_ulong(v); +# else + v = ((v << 8) & 0xff00ff00 ) | + ((v >> 8) & 0x00ff00ff); + return (v << 16) | (v >> 16); +# endif +} +#endif + +#ifndef HAVE_CPU_TO_LE64 +static inline uint64_t cpu_to_le64(uint64_t v) +{ +# ifdef HAVE___CPU_TO_LE64 + return __cpu_to_le64(v); +# elif defined(HAVE_HTOLE64) + return htole64(v); +# elif defined(HAVE___BSWAP_64) + return __bswap_64(v); +# elif defined(HAVE___BUILTIN_BSWAP64) + return __builtin_bswap64(v); +# elif defined(HAVE__BYTESWAP_UINT64) + return _byteswap_uint64(v); +# else + v = ((v << 8) & 0xff00ff00ff00ff00ull) | + ((v >> 8) & 0x00ff00ff00ff00ffull); + v = ((v << 16) & 0xffff0000ffff0000ull) | + ((v >> 16) & 0x0000ffff0000ffffull); + return (v << 32) | (v >> 32); +# endif +} +#endif + +#else /* not WORDS_LITTLEENDIAN or WORDS_BIGENDIAN */ + +static inline uint16_t cpu_to_le16(uint16_t v) +{ + union u16 { + uint16_t v; + uint8_t c[2]; + } x; + uint8_t *cp = &x.c; + + WRITESHORT(cp, v); + return x.v; +} + +static inline uint32_t cpu_to_le32(uint32_t v) +{ + union u32 { + uint32_t v; + uint8_t c[4]; + } x; + uint8_t *cp = &x.c; + + WRITELONG(cp, v); + return x.v; +} + +static inline uint64_t cpu_to_le64(uint64_t v) +{ + union u64 { + uint64_t v; + uint8_t c[8]; + } x; + uint8_t *cp = &x.c; + + WRITEDLONG(cp, v); + return x.v; +} + +#endif + +#define WRITEADDR(p,v,s) \ + do { \ + switch (is_constant(s) ? (s) : 0) { \ + case 1: \ + WRITECHAR(p,v); \ + break; \ + case 2: \ + WRITESHORT(p,v); \ + break; \ + case 4: \ + WRITELONG(p,v); \ + break; \ + case 8: \ + WRITEDLONG(p,v); \ + break; \ + default: \ + { \ + const uint64_t _wa_v = cpu_to_le64(v); \ + const size_t _wa_s = (s); \ + uint8_t * const _wa_p = (uint8_t *)(p); \ + memcpy(_wa_p, &_wa_v, _wa_s); \ + (p) = (void *)(_wa_p + _wa_s); \ + } \ + break; \ + } \ + } while (0) + +#endif /* NASM_BYTESEX_H */ diff --git a/include/compiler.h b/include/compiler.h index 79a9ef2e..95fd5ec4 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -87,6 +87,53 @@ # include <sys/types.h> #endif +#ifdef HAVE_ENDIAN_H +# include <endian.h> +#elif defined(HAVE_SYS_ENDIAN_H) +# include <sys/endian.h> +#elif defined(HAVE_MACHINE_ENDIAN_H) +# include <machine/endian.h> +#endif + +/* + * If we have BYTE_ORDER defined, or the compiler provides + * __BIG_ENDIAN__ or __LITTLE_ENDIAN__, trust it over what autoconf + * came up with, especially since autoconf obviously can't figure + * things out for a universal compiler. + */ +#if defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +# undef WORDS_LITTLEENDIAN +# undef WORDS_BIGENDIAN +# define WORDS_BIGENDIAN 1 +#elif defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +# undef WORDS_LITTLEENDIAN +# undef WORDS_BIGENDIAN +# define WORDS_LITTLEENDIAN 1 +#elif defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) +# undef WORDS_LITTLEENDIAN +# undef WORDS_BIGENDIAN +# if BYTE_ORDER == LITTLE_ENDIAN +# define WORDS_LITTLEENDIAN 1 +# elif BYTE_ORDER == BIG_ENDIAN +# define WORDS_BIGENDIAN 1 +# endif +#endif + +/* + * Define this to 1 for faster performance if this is a littleendian + * platform *and* it can do arbitrary unaligned memory references. It + * is safe to leave it defined to 0 even if that is true. + */ +#if defined(__386__) || defined(__i386__) || defined(__x86_64__) \ + || defined(_M_IX86) || defined(_M_X64) +# define X86_MEMORY 1 +# undef WORDS_BIGENDIAN +# undef WORDS_LITTLEENDIAN +# define WORDS_LITTLEENDIAN 1 +#else +# define X86_MEMORY 0 +#endif + /* Some versions of MSVC have these only with underscores in front */ #ifndef HAVE_SNPRINTF # ifdef HAVE__SNPRINTF @@ -108,6 +155,10 @@ int vsnprintf(char *, size_t, const char *, va_list); size_t strlcpy(char *, const char *, size_t); #endif +#if !defined(HAVE_STRCHRNUL) || !HAVE_DECL_STRCHRNUL +char *strrchrnul(const char *, int); +#endif + #ifndef __cplusplus /* C++ has false, true, bool as keywords */ # ifdef HAVE_STDBOOL_H # include <stdbool.h> @@ -161,17 +212,32 @@ size_t strnlen(const char *s, size_t maxlen); #endif /* - * Define this to 1 for faster performance if this is a littleendian - * platform which can do unaligned memory references. It is safe - * to leave it defined to 0 even if that is true. + * Hack to support external-linkage inline functions */ -#if defined(__386__) || defined(__i386__) || defined(__x86_64__) -# define X86_MEMORY 1 -# ifndef WORDS_LITTLEENDIAN -# define WORDS_LITTLEENDIAN 1 +#ifndef HAVE_STDC_INLINE +# ifdef __GNUC__ +# ifdef __GNUC_STDC_INLINE__ +# define HAVE_STDC_INLINE +# else +# define HAVE_GNU_INLINE +# endif +# elif defined(__GNUC_GNU_INLINE__) +/* Some other compiler implementing only GNU inline semantics? */ +# define HAVE_GNU_INLINE +# elif defined(__STDC_VERSION__) +# if __STDC_VERSION__ >= 199901L +# define HAVE_STDC_INLINE +# endif # endif +#endif + +#ifdef HAVE_STDC_INLINE +# define extern_inline inline +#elif defined(HAVE_GNU_INLINE) +# define extern_inline extern inline +# define inline_prototypes #else -# define X86_MEMORY 0 +# define inline_prototypes #endif /* @@ -202,9 +268,9 @@ size_t strnlen(const char *s, size_t maxlen); #endif #ifdef HAVE_FUNC_ATTRIBUTE_ALLOC_SIZE -# define safe_malloc(s) safe_alloc __attribute__((alloc_size(s))) -# define safe_malloc2(s1,s2) safe_alloc __attribute__((alloc_size(s1,s2))) -# define safe_realloc(s) never_null __attribute__((alloc_size(s))) +# define safe_malloc(s) safe_alloc __attribute__((alloc_size(s))) +# define safe_malloc2(s1,s2) safe_alloc __attribute__((alloc_size(s1,s2))) +# define safe_realloc(s) never_null __attribute__((alloc_size(s))) #else # define safe_malloc(s) safe_alloc # define safe_malloc2(s1,s2) safe_alloc @@ -255,6 +321,13 @@ size_t strnlen(const char *s, size_t maxlen); # define pure_func #endif +/* Determine probabilistically if something is a compile-time constant */ +#ifdef HAVE___BUILTIN_CONSTANT_P +# define is_constant(x) __builtin_constant_p(x) +#else +# define is_constant(x) false +#endif + /* Watcom doesn't handle switch statements with 64-bit types, hack around it */ #ifdef __WATCOMC__ # define BOGUS_CASE 0x76543210 diff --git a/include/error.h b/include/error.h index b1e42ba9..c49377eb 100644 --- a/include/error.h +++ b/include/error.h @@ -71,13 +71,14 @@ static inline vefunc nasm_set_verror(vefunc ve) * and dump core for reference */ #define ERR_MASK 0x00000007 /* mask off the above codes */ #define ERR_NOFILE 0x00000010 /* don't give source file name/line */ -#define ERR_USAGE 0x00000020 /* print a usage message */ -#define ERR_PASS1 0x00000040 /* only print this error on pass one */ -#define ERR_PASS2 0x00000080 - -#define ERR_NO_SEVERITY 0x00000100 /* suppress printing severity */ -#define ERR_PP_PRECOND 0x00000200 /* for preprocessor use */ -#define ERR_PP_LISTMACRO 0x00000400 /* from preproc->error_list_macros() */ +#define ERR_TOPFILE 0x00000020 /* give the top input file name only */ +#define ERR_USAGE 0x00000040 /* print a usage message */ +#define ERR_PASS1 0x00000080 /* only print this error on pass one */ +#define ERR_PASS2 0x00000100 /* only print this error on pass one */ + +#define ERR_NO_SEVERITY 0x00000200 /* suppress printing severity */ +#define ERR_PP_PRECOND 0x00000400 /* for preprocessor use */ +#define ERR_PP_LISTMACRO 0x00000800 /* from preproc->error_list_macros() */ /* * These codes define specific types of suppressible warning. diff --git a/include/hashtbl.h b/include/hashtbl.h index da618c8a..25f2d2d5 100644 --- a/include/hashtbl.h +++ b/include/hashtbl.h @@ -81,5 +81,6 @@ void *hash_iterate(const struct hash_table *head, struct hash_tbl_node **iterator, const char **key); void hash_free(struct hash_table *head); +void hash_free_all(struct hash_table *head, bool free_keys); #endif /* NASM_HASHTBL_H */ diff --git a/include/iflag.h b/include/iflag.h index 48e61238..5280703e 100644 --- a/include/iflag.h +++ b/include/iflag.h @@ -2,11 +2,11 @@ #define NASM_IFLAG_H #include "compiler.h" +#include "ilog2.h" #include <string.h> #include "iflaggen.h" -#include "nasmlib.h" /* For ilog2_32() */ #define IF_GENBIT(bit) (UINT32_C(1) << (bit)) diff --git a/include/ilog2.h b/include/ilog2.h new file mode 100644 index 00000000..445ba56b --- /dev/null +++ b/include/ilog2.h @@ -0,0 +1,208 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 1996-2017 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. + * + * ----------------------------------------------------------------------- */ + +#ifndef ILOG2_H +#define ILOG2_H + +#include "compiler.h" +#include <limits.h> + +#ifdef ILOG2_C /* For generating the out-of-line functions */ +# undef extern_inline +# define extern_inline +# define inline_prototypes +#endif + +#ifdef inline_prototypes +extern int const_func ilog2_32(uint32_t v); +extern int const_func ilog2_64(uint64_t v); +extern int const_func ilog2_64(uint64_t vv); +extern int const_func alignlog2_32(uint32_t v); +extern int const_func alignlog2_64(uint64_t v); +#endif + +#ifdef extern_inline + +#define ROUND(v, a, w) \ + do { \ + if (v & (((UINT32_C(1) << w) - 1) << w)) { \ + a += w; \ + v >>= w; \ + } \ + } while (0) + + +#if defined(__GNUC__) && defined(__x86_64__) + +extern_inline int const_func ilog2_32(uint32_t v) +{ + int n; + + __asm__("bsrl %1,%0" + : "=r" (n) + : "rm" (v), "0" (0)); + return n; +} + +#elif defined(__GNUC__) && defined(__i386__) + +extern_inline int const_func ilog2_32(uint32_t v) +{ + int n; + +#ifdef __i686__ + __asm__("bsrl %1,%0 ; cmovz %2,%0\n" + : "=&r" (n) + : "rm" (v), "r" (0)); +#else + __asm__("bsrl %1,%0 ; jnz 1f ; xorl %0,%0\n" + "1:" + : "=&r" (n) + : "rm" (v)); +#endif + return n; +} + +#elif defined(HAVE___BUILTIN_CLZ) && INT_MAX == 2147483647 + +extern_inline int const_func ilog2_32(uint32_t v) +{ + if (!v) + return 0; + + return __builtin_clz(v) ^ 31; +} + +#elif defined(HAVE__BITSCANREVERSE) + +extern_inline int const_func ilog2_32(uint32_t v) +{ + unsigned long ix; + return _BitScanReverse(&ix, v) ? v : 0; +} + +#else + +extern_inline int const_func ilog2_32(uint32_t v) +{ + int p = 0; + + ROUND(v, p, 16); + ROUND(v, p, 8); + ROUND(v, p, 4); + ROUND(v, p, 2); + ROUND(v, p, 1); + + return p; +} + +#endif + +#if defined(__GNUC__) && defined(__x86_64__) + +extern_inline int const_func ilog2_64(uint64_t v) +{ + uint64_t n; + + __asm__("bsrq %1,%0" + : "=r" (n) + : "rm" (v), "0" (UINT64_C(0))); + return n; +} + +#elif defined(HAVE__BUILTIN_CLZLL) && LLONG_MAX == 9223372036854775807LL + +extern_inline int const_func ilog2_64(uint64_t v) +{ + if (!v) + return 0; + + return __builtin_clzll(v) ^ 63; +} + +#elif defined(HAVE__BITSCANREVERSE64) + +extern_inline int const_func ilog2_64(uint64_t v) +{ + unsigned long ix; + return _BitScanReverse64(&ix, v) ? ix : 0; +} + +#else + +extern_inline int const_func ilog2_64(uint64_t vv) +{ + int p = 0; + uint32_t v; + + v = vv >> 32; + if (v) + p += 32; + else + v = vv; + + ROUND(v, p, 16); + ROUND(v, p, 8); + ROUND(v, p, 4); + ROUND(v, p, 2); + ROUND(v, p, 1); + + return p; +} + +#endif + +/* + * v == 0 ? 0 : is_power2(x) ? ilog2_X(v) : -1 + */ +extern_inline int const_func alignlog2_32(uint32_t v) +{ + if (unlikely(v & (v-1))) + return -1; /* invalid alignment */ + + return ilog2_32(v); +} + +extern_inline int const_func alignlog2_64(uint64_t v) +{ + if (unlikely(v & (v-1))) + return -1; /* invalid alignment */ + + return ilog2_64(v); +} + +#undef ROUND + +#endif /* extern_inline */ + +#endif /* ILOG2_H */ diff --git a/include/insns.h b/include/insns.h index 23d0ea91..00de2887 100644 --- a/include/insns.h +++ b/include/insns.h @@ -54,23 +54,79 @@ extern const uint8_t nasm_bytecodes[]; */ #define ITEMPLATE_END {I_none,0,{0,},{0,},NULL,0} -/* Width of Dx and RESx instructions */ -int const_func idata_bytes(enum opcode opcode); -int const_func resv_bytes(enum opcode opcode); - /* * Pseudo-op tests */ /* DB-type instruction (DB, DW, ...) */ -static inline bool opcode_is_db(enum opcode opcode) +static inline bool const_func opcode_is_db(enum opcode opcode) { - return idata_bytes(opcode) > 0; + return opcode >= I_DB && opcode < I_RESB; } /* RESB-type instruction (RESB, RESW, ...) */ -static inline bool opcode_is_resb(enum opcode opcode) +static inline bool const_func opcode_is_resb(enum opcode opcode) +{ + return opcode >= I_RESB && opcode < I_INCBIN; +} + +/* Width of Dx and RESx instructions */ + +/* + * initialized data bytes length from opcode + */ +static inline int const_func db_bytes(enum opcode opcode) +{ + switch (opcode) { + case I_DB: + return 1; + case I_DW: + return 2; + case I_DD: + return 4; + case I_DQ: + return 8; + case I_DT: + return 10; + case I_DO: + return 16; + case I_DY: + return 32; + case I_DZ: + return 64; + case I_none: + return -1; + default: + return 0; + } +} + +/* + * Uninitialized data bytes length from opcode + */ +static inline int const_func resb_bytes(enum opcode opcode) { - return resv_bytes(opcode) > 0; + switch (opcode) { + case I_RESB: + return 1; + case I_RESW: + return 2; + case I_RESD: + return 4; + case I_RESQ: + return 8; + case I_REST: + return 10; + case I_RESO: + return 16; + case I_RESY: + return 32; + case I_RESZ: + return 64; + case I_none: + return -1; + default: + return 0; + } } #endif /* NASM_INSNS_H */ diff --git a/include/nasm.h b/include/nasm.h index d28fe38c..48590f20 100644 --- a/include/nasm.h +++ b/include/nasm.h @@ -64,10 +64,6 @@ extern struct compile_time official_compile_time; #define NO_SEG -1L /* null segment value */ #define SEG_ABS 0x40000000L /* mask for far-absolute segments */ -#ifndef FILENAME_MAX -#define FILENAME_MAX 256 -#endif - #ifndef PREFIX_MAX #define PREFIX_MAX 10 #endif @@ -100,6 +96,7 @@ struct ofmt; enum out_type { OUT_RAWDATA, /* Plain bytes */ OUT_RESERVE, /* Reserved bytes (RESB et al) */ + OUT_ZERODATA, /* Initialized data, but all zero */ OUT_ADDRESS, /* An address (symbol value) */ OUT_RELADDR, /* A relative address */ OUT_SEGMENT, /* A segment number */ @@ -353,7 +350,7 @@ struct preproc_ops { * of the pass, an error reporting function, an evaluator * function, and a listing generator to talk to. */ - void (*reset)(char *file, int pass, StrList **deplist); + void (*reset)(const char *file, int pass, StrList **deplist); /* * Called to fetch a line of preprocessed source. The line @@ -782,6 +779,11 @@ struct ofmt { const char *shortname; /* + * Default output filename extension, or a null string + */ + const char *extension; + + /* * Output format flags. */ #define OFMT_TEXT 1 /* Text file format */ @@ -928,25 +930,6 @@ struct ofmt { (*directive)(enum directive directive, char *value, int pass); /* - * This procedure is called before anything else - even before - * the "init" routine - and is passed the name of the input - * file from which this output file is being generated. It - * should return its preferred name for the output file in - * `outname', if outname[0] is not '\0', and do nothing to - * `outname' otherwise. Since it is called before the driver is - * properly initialized, it has to be passed its error handler - * separately. - * - * This procedure may also take its own copy of the input file - * name for use in writing the output file: it is _guaranteed_ - * that it will be called before the "init" routine. - * - * The parameter `outname' points to an area of storage - * guaranteed to be at least FILENAME_MAX in size. - */ - void (*filename)(char *inname, char *outname); - - /* * This procedure is called after assembly finishes, to allow * the output driver to clean itself up and free its memory. * Typically, it will also be the point at which the object @@ -1243,4 +1226,7 @@ extern int globalbits; /* 16, 32 or 64-bit mode */ extern int globalrel; /* default to relative addressing? */ extern int globalbnd; /* default to using bnd prefix? */ +extern const char *inname; /* primary input filename */ +extern const char *outname; /* output filename */ + #endif diff --git a/include/nasmlib.h b/include/nasmlib.h index 69b81b7e..5bbfe457 100644 --- a/include/nasmlib.h +++ b/include/nasmlib.h @@ -39,6 +39,7 @@ #define NASM_NASMLIB_H #include "compiler.h" +#include "bytesex.h" #include <ctype.h> #include <stdio.h> @@ -193,10 +194,9 @@ int64_t readstrnum(char *str, int length, bool *warn); int32_t seg_alloc(void); /* - * 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 + * Add/replace or remove an extension to the end of a filename */ -void standard_extension(char *inname, char *outname, char *extension); +const char *filename_set_extension(const char *inname, const char *extension); /* * Utility macros... @@ -245,103 +245,7 @@ void standard_extension(char *inname, char *outname, char *extension); #define IS_ALIGNED(v, a) (((v) & ((a) - 1)) == 0) /* - * some handy macros that will probably be of use in more than one - * output format: convert integers into little-endian byte packed - * format in memory - */ - -#if X86_MEMORY - -#define WRITECHAR(p,v) \ - do { \ - *(uint8_t *)(p) = (v); \ - (p) += 1; \ - } while (0) - -#define WRITESHORT(p,v) \ - do { \ - *(uint16_t *)(p) = (v); \ - (p) += 2; \ - } while (0) - -#define WRITELONG(p,v) \ - do { \ - *(uint32_t *)(p) = (v); \ - (p) += 4; \ - } while (0) - -#define WRITEDLONG(p,v) \ - do { \ - *(uint64_t *)(p) = (v); \ - (p) += 8; \ - } while (0) - -#define WRITEADDR(p,v,s) \ - do { \ - uint64_t _wa_v = (v); \ - memcpy((p), &_wa_v, (s)); \ - (p) += (s); \ - } while (0) - -#else /* !X86_MEMORY */ - -#define WRITECHAR(p,v) \ - do { \ - uint8_t *_wc_p = (uint8_t *)(p); \ - uint8_t _wc_v = (v); \ - _wc_p[0] = _wc_v; \ - (p) = (void *)(_wc_p + 1); \ - } while (0) - -#define WRITESHORT(p,v) \ - do { \ - uint8_t *_ws_p = (uint8_t *)(p); \ - uint16_t _ws_v = (v); \ - _ws_p[0] = _ws_v; \ - _ws_p[1] = _ws_v >> 8; \ - (p) = (void *)(_ws_p + 2); \ - } while (0) - -#define WRITELONG(p,v) \ - do { \ - uint8_t *_wl_p = (uint8_t *)(p); \ - uint32_t _wl_v = (v); \ - _wl_p[0] = _wl_v; \ - _wl_p[1] = _wl_v >> 8; \ - _wl_p[2] = _wl_v >> 16; \ - _wl_p[3] = _wl_v >> 24; \ - (p) = (void *)(_wl_p + 4); \ - } while (0) - -#define WRITEDLONG(p,v) \ - do { \ - uint8_t *_wq_p = (uint8_t *)(p); \ - uint64_t _wq_v = (v); \ - _wq_p[0] = _wq_v; \ - _wq_p[1] = _wq_v >> 8; \ - _wq_p[2] = _wq_v >> 16; \ - _wq_p[3] = _wq_v >> 24; \ - _wq_p[4] = _wq_v >> 32; \ - _wq_p[5] = _wq_v >> 40; \ - _wq_p[6] = _wq_v >> 48; \ - _wq_p[7] = _wq_v >> 56; \ - (p) = (void *)(_wq_p + 8); \ - } while (0) - -#define WRITEADDR(p,v,s) \ - do { \ - int _wa_s = (s); \ - uint64_t _wa_v = (v); \ - while (_wa_s--) { \ - WRITECHAR(p,_wa_v); \ - _wa_v >>= 8; \ - } \ - } while(0) - -#endif - -/* - * and routines to do the same thing to a file + * Routines to write littleendian data to a file */ #define fwriteint8_t(d,f) putc(d,f) void fwriteint16_t(uint16_t data, FILE * fp); @@ -507,16 +411,4 @@ static inline int64_t const_func signed_bits(int64_t value, int bits) /* check if value is power of 2 */ #define is_power2(v) ((v) && ((v) & ((v) - 1)) == 0) -/* - * floor(log2(v)) - */ -int const_func ilog2_32(uint32_t v); -int const_func ilog2_64(uint64_t v); - -/* - * v == 0 ? 0 : is_power2(x) ? ilog2_X(v) : -1 - */ -int const_func alignlog2_32(uint32_t v); -int const_func alignlog2_64(uint64_t v); - #endif diff --git a/nasm.spec.in b/nasm.spec.in index d6102846..317e2d80 100644 --- a/nasm.spec.in +++ b/nasm.spec.in @@ -54,7 +54,7 @@ xz -9ef doc/nasmdoc.pdf rm -rf "%{buildroot}" mkdir -p "%{buildroot}"/%{_bindir} mkdir -p "%{buildroot}"/%{_mandir}/man1 -make INSTALLROOT="%{buildroot}" install install_rdf +make DESTDIR="%{buildroot}" install install_rdf %files %doc AUTHORS CHANGES README TODO diff --git a/nasmlib/file.c b/nasmlib/file.c index 51f07309..c0b4e781 100644 --- a/nasmlib/file.c +++ b/nasmlib/file.c @@ -50,61 +50,30 @@ void nasm_write(const void *ptr, size_t size, FILE *f) nasm_fatal(0, "unable to write output: %s", strerror(errno)); } -#ifdef WORDS_LITTLEENDIAN - void fwriteint16_t(uint16_t data, FILE * fp) { + data = cpu_to_le16(data); nasm_write(&data, 2, fp); } void fwriteint32_t(uint32_t data, FILE * fp) { + data = cpu_to_le32(data); nasm_write(&data, 4, fp); } void fwriteint64_t(uint64_t data, FILE * fp) { + data = cpu_to_le64(data); nasm_write(&data, 8, fp); } void fwriteaddr(uint64_t data, int size, FILE * fp) { + data = cpu_to_le64(data); nasm_write(&data, size, fp); } -#else /* not WORDS_LITTLEENDIAN */ - -void fwriteint16_t(uint16_t data, FILE * fp) -{ - char buffer[2], *p = buffer; - WRITESHORT(p, data); - nasm_write(buffer, 2, fp); -} - -void fwriteint32_t(uint32_t data, FILE * fp) -{ - char buffer[4], *p = buffer; - WRITELONG(p, data); - nasm_write(buffer, 4, fp); -} - -void fwriteint64_t(uint64_t data, FILE * fp) -{ - char buffer[8], *p = buffer; - WRITEDLONG(p, data); - nasm_write(buffer, 8, fp); -} - -void fwriteaddr(uint64_t data, int size, FILE * fp) -{ - char buffer[8], *p = buffer; - WRITEADDR(p, data, size); - nasm_write(buffer, size, fp); -} - -#endif - - void fwritezero(off_t bytes, FILE *fp) { size_t blksize; diff --git a/nasmlib/filename.c b/nasmlib/filename.c index 799eb89a..172ae0bc 100644 --- a/nasmlib/filename.c +++ b/nasmlib/filename.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * - * - * Copyright 1996-2016 The NASM Authors - All Rights Reserved + * + * Copyright 1996-2017 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -14,7 +14,7 @@ * 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 @@ -39,31 +39,25 @@ #include "nasmlib.h" #include "error.h" -void standard_extension(char *inname, char *outname, char *extension) +/* + * Add/modify a filename extension, assumed to be a period-delimited + * field at the very end of the filename. Returns a newly allocated + * string buffer. + */ +const char *filename_set_extension(const char *inname, const char *extension) { - char *p, *q; + const char *q = inname; + char *p; + size_t elen = strlen(extension); + size_t baselen; + + q = strrchrnul(inname, '.'); /* find extension or end of string */ + baselen = q - inname; + + p = nasm_malloc(baselen + elen + 1); + + memcpy(p, inname, baselen); + memcpy(p+baselen, extension, elen+1); - if (*outname) /* file name already exists, */ - return; /* so do nothing */ - q = inname; - p = outname; - while (*q) - *p++ = *q++; /* copy, and find end of string */ - *p = '\0'; /* terminate it */ - while (p > outname && *--p != '.') ; /* find final period (or whatever) */ - if (*p != '.') - while (*p) - p++; /* go back to end if none found */ - if (!strcmp(p, extension)) { /* is the extension already there? */ - if (*extension) - nasm_error(ERR_WARNING | ERR_NOFILE, - "file name already ends in `%s': " - "output will be in `nasm.out'", extension); - else - 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); + return p; } diff --git a/nasmlib/hashtbl.c b/nasmlib/hashtbl.c index 7f8fca63..bc0776b8 100644 --- a/nasmlib/hashtbl.c +++ b/nasmlib/hashtbl.c @@ -222,7 +222,9 @@ void *hash_iterate(const struct hash_table *head, /* * Free the hash itself. Doesn't free the data elements; use - * hash_iterate() to do that first, if needed. + * hash_iterate() to do that first, if needed. This function is normally + * used when the hash data entries are either freed separately, or + * compound objects which can't be freed in a single operation. */ void hash_free(struct hash_table *head) { @@ -230,3 +232,25 @@ void hash_free(struct hash_table *head) head->table = NULL; nasm_free(p); } + +/* + * Frees the hash *and* all data elements. This is applicable only in + * the case where the data element is a single allocation. If the + * second argument is false, the key string is part of the data + * allocation or belongs to an allocation which will be freed + * separately, if it is true the keys are also freed. + */ +void hash_free_all(struct hash_table *head, bool free_keys) +{ + struct hash_tbl_node *iter = NULL; + const char *keyp; + void *d; + + while ((d = hash_iterate(head, &iter, &keyp))) { + nasm_free(d); + if (free_keys) + nasm_free((void *)keyp); + } + + hash_free(head); +} diff --git a/nasmlib/ilog2.c b/nasmlib/ilog2.c index 1bd24dba..cba22248 100644 --- a/nasmlib/ilog2.c +++ b/nasmlib/ilog2.c @@ -1,168 +1,2 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 1996-2017 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 "compiler.h" -#include "nasmlib.h" -#include <limits.h> - -#define ROUND(v, a, w) \ - do { \ - if (v & (((UINT32_C(1) << w) - 1) << w)) { \ - a += w; \ - v >>= w; \ - } \ - } while (0) - - -#if defined(__GNUC__) && defined(__x86_64__) - -int ilog2_32(uint32_t v) -{ - int n; - - __asm__("bsrl %1,%0" - : "=r" (n) - : "rm" (v), "0" (0)); - return n; -} - -#elif defined(__GNUC__) && defined(__i386__) - -int ilog2_32(uint32_t v) -{ - int n; - -#ifdef __i686__ - __asm__("bsrl %1,%0 ; cmovz %2,%0\n" - : "=&r" (n) - : "rm" (v), "r" (0)); -#else - __asm__("bsrl %1,%0 ; jnz 1f ; xorl %0,%0\n" - "1:" - : "=&r" (n) - : "rm" (v)); -#endif - return n; -} - -#elif defined(HAVE___BUILTIN_CLZ) && INT_MAX == 2147483647 - -int ilog2_32(uint32_t v) -{ - if (!v) - return 0; - - return __builtin_clz(v) ^ 31; -} - -#else - -int ilog2_32(uint32_t v) -{ - int p = 0; - - ROUND(v, p, 16); - ROUND(v, p, 8); - ROUND(v, p, 4); - ROUND(v, p, 2); - ROUND(v, p, 1); - - return p; -} - -#endif - -#if defined(__GNUC__) && defined(__x86_64__) - -int ilog2_64(uint64_t v) -{ - uint64_t n; - - __asm__("bsrq %1,%0" - : "=r" (n) - : "rm" (v), "0" (UINT64_C(0))); - return n; -} - -#elif defined(HAVE__BUILTIN_CLZLL) && LLONG_MAX == 9223372036854775807LL - -int ilog2_64(uint64_t v) -{ - if (!v) - return 0; - - return __builtin_clzll(v) ^ 63; -} - -#else - -int ilog2_64(uint64_t vv) -{ - int p = 0; - uint32_t v; - - v = vv >> 32; - if (v) - p += 32; - else - v = vv; - - ROUND(v, p, 16); - ROUND(v, p, 8); - ROUND(v, p, 4); - ROUND(v, p, 2); - ROUND(v, p, 1); - - return p; -} - -#endif - -/* - * v == 0 ? 0 : is_power2(x) ? ilog2_X(v) : -1 - */ -int alignlog2_32(uint32_t v) -{ - if (unlikely(v & (v-1))) - return -1; /* invalid alignment */ - - return ilog2_32(v); -} - -int alignlog2_64(uint64_t v) -{ - if (unlikely(v & (v-1))) - return -1; /* invalid alignment */ - - return ilog2_64(v); -} +#define ILOG2_C +#include "ilog2.h" diff --git a/nasmlib/saa.c b/nasmlib/saa.c index 1d457ac6..fe7741a4 100644 --- a/nasmlib/saa.c +++ b/nasmlib/saa.c @@ -299,84 +299,30 @@ void saa_write8(struct SAA *s, uint8_t v) saa_wbytes(s, &v, 1); } -#ifdef WORDS_LITTLEENDIAN - void saa_write16(struct SAA *s, uint16_t v) { + v = cpu_to_le16(v); saa_wbytes(s, &v, 2); } void saa_write32(struct SAA *s, uint32_t v) { + v = cpu_to_le32(v); saa_wbytes(s, &v, 4); } void saa_write64(struct SAA *s, uint64_t v) { + v = cpu_to_le64(v); saa_wbytes(s, &v, 8); } void saa_writeaddr(struct SAA *s, uint64_t v, size_t len) { + v = cpu_to_le64(v); saa_wbytes(s, &v, len); } -#else /* not WORDS_LITTLEENDIAN */ - -void saa_write16(struct SAA *s, uint16_t v) -{ - uint8_t b[2]; - - b[0] = v; - b[1] = v >> 8; - saa_wbytes(s, b, 2); -} - -void saa_write32(struct SAA *s, uint32_t v) -{ - uint8_t b[4]; - - b[0] = v; - b[1] = v >> 8; - b[2] = v >> 16; - b[3] = v >> 24; - saa_wbytes(s, b, 4); -} - -void saa_write64(struct SAA *s, uint64_t v) -{ - uint8_t b[8]; - - b[0] = v; - b[1] = v >> 8; - b[2] = v >> 16; - b[3] = v >> 24; - b[4] = v >> 32; - b[5] = v >> 40; - b[6] = v >> 48; - b[7] = v >> 56; - - saa_wbytes(s, b, 8); -} - -void saa_writeaddr(struct SAA *s, uint64_t v, size_t len) -{ - uint8_t b[8]; - - b[0] = v; - b[1] = v >> 8; - b[2] = v >> 16; - b[3] = v >> 24; - b[4] = v >> 32; - b[5] = v >> 40; - b[6] = v >> 48; - b[7] = v >> 56; - - saa_wbytes(s, b, len); -} - -#endif /* WORDS_LITTLEENDIAN */ - /* write unsigned LEB128 value to SAA */ void saa_wleb128u(struct SAA *psaa, int value) { diff --git a/nasmlib/srcfile.c b/nasmlib/srcfile.c index 7bee0176..6fbe763f 100644 --- a/nasmlib/srcfile.c +++ b/nasmlib/srcfile.c @@ -55,13 +55,7 @@ void src_init(void) void src_free(void) { - struct hash_tbl_node *iter = NULL; - void *dp; - - while ((dp = hash_iterate(&filename_hash, &iter, NULL)) != NULL) - nasm_free(dp); - - hash_free(&filename_hash); + hash_free_all(&filename_hash, false); } /* diff --git a/output/codeview.c b/output/codeview.c index c60d4920..c8a90e91 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -314,7 +314,7 @@ static void cv8_cleanup(void) struct coff_Section *symbol_sect = coff_sects[cv8_state.symbol_sect]; struct coff_Section *type_sect = coff_sects[cv8_state.type_sect]; - cv8_state.outfile.name = nasm_realpath(coff_outfile); + cv8_state.outfile.name = nasm_realpath(outname); cv8_state.outfile.namebytes = strlen(cv8_state.outfile.name) + 1; build_symbol_table(symbol_sect); diff --git a/output/dwarf.h b/output/dwarf.h index cc3c530c..e672819c 100644 --- a/output/dwarf.h +++ b/output/dwarf.h @@ -460,11 +460,30 @@ enum dwarf_language { DW_LANG_ObjC_plus_plus = 0x0011, DW_LANG_UPC = 0x0012, DW_LANG_D = 0x0013, + DW_LANG_Python = 0x0014, + DW_LANG_OpenCL = 0x0015, + DW_LANG_Go = 0x0016, + DW_LANG_Modula3 = 0x0017, + DW_LANG_Haskell = 0x0018, + DW_LANG_C_plus_plus_03 = 0x0019, + DW_LANG_C_plus_plus_11 = 0x001a, + DW_LANG_OCaml = 0x001b, + DW_LANG_Rust = 0x001c, + DW_LANG_C11 = 0x001d, + DW_LANG_Swift = 0x001e, + DW_LANG_Julia = 0x001f, + DW_LANG_Dylan = 0x0020, + DW_LANG_C_plus_plus_14 = 0x0021, + DW_LANG_Fortran03 = 0x0022, + DW_LANG_Fortran08 = 0x0023, + DW_LANG_RenderScript = 0x0024, DW_LANG_Mips_Assembler = 0x8001, DW_LANG_lo_user = 0x8000, - DW_LANG_hi_user = 0xffff + DW_LANG_hi_user = 0xffff, + + DW_LANG_Rust_old = 0x9000 }; enum dwarf_identifier_case { @@ -475,12 +494,17 @@ enum dwarf_identifier_case { }; enum dwarf_calling_conversion { - DW_CC_normal = 0x01, - DW_CC_program = 0x02, - DW_CC_nocall = 0x03, + DW_CC_normal = 0x01, + DW_CC_program = 0x02, + DW_CC_nocall = 0x03, + DW_CC_pass_by_reference = 0x4, + DW_CC_pass_by_value = 0x5, + + DW_CC_lo_user = 0x40, + DW_CC_hi_user = 0xff, - DW_CC_lo_user = 0x40, - DW_CC_hi_user = 0xff + DW_CC_GNU_renesas_sh = 0x40, + DW_CC_GNU_borland_fastcall_i386 = 0x41 }; enum dwarf_inline { @@ -520,6 +544,7 @@ enum dwarf_line_number_extended { DW_LNE_end_sequence = 0x01, DW_LNE_set_address = 0x02, DW_LNE_define_file = 0x03, + DW_LNE_set_discriminator= 0x04, DW_LNE_lo_user = 0x80, DW_LNE_hi_user = 0xff }; diff --git a/output/elf.h b/output/elf.h index 4ae818a9..32f5b47a 100644 --- a/output/elf.h +++ b/output/elf.h @@ -317,6 +317,7 @@ typedef struct elf64_dyn { #define ELF32_R_SYM(x) ((x) >> 8) #define ELF32_R_TYPE(x) ((x) & 0xff) +#define ELF32_R_INFO(s,t) (((Elf32_Word)(s) << 8) + ELF32_R_TYPE(t)) typedef struct elf32_rel { Elf32_Addr r_offset; @@ -351,6 +352,7 @@ enum reloc32_type { #define ELF64_R_SYM(x) ((x) >> 32) #define ELF64_R_TYPE(x) ((x) & 0xffffffff) +#define ELF64_R_INFO(s,t) (((Elf64_Xword)(s) << 32) + ELF64_R_TYPE(t)) typedef struct elf64_rel { Elf64_Addr r_offset; diff --git a/output/legacy.c b/output/legacy.c index 38d6d7e0..39793205 100644 --- a/output/legacy.c +++ b/output/legacy.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 2016 The NASM Authors - All Rights Reserved + * Copyright 2016-2017 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -89,8 +89,9 @@ void nasm_do_legacy_output(const struct out_data *data) case OUT_SEGMENT: type = OUT_ADDRESS; - dptr = &zero_buffer; + dptr = zero_buffer; size = (data->sign == OUT_SIGNED) ? -data->size : data->size; + tsegment |= 1; break; case OUT_ADDRESS: @@ -103,6 +104,17 @@ void nasm_do_legacy_output(const struct out_data *data) tsegment = twrt = NO_SEG; break; + case OUT_ZERODATA: + tsegment = twrt = NO_SEG; + type = OUT_RAWDATA; + dptr = zero_buffer; + while (size > ZERO_BUF_SIZE) { + ofmt->legacy_output(data->segment, dptr, type, + ZERO_BUF_SIZE, tsegment, twrt); + size -= ZERO_BUF_SIZE; + } + break; + default: panic(); break; diff --git a/output/outaout.c b/output/outaout.c index 83859d97..5dab46c0 100644 --- a/output/outaout.c +++ b/output/outaout.c @@ -894,11 +894,6 @@ static int32_t aout_segbase(int32_t segment) return segment; } -static void aout_filename(char *inname, char *outname) -{ - standard_extension(inname, outname, ".o"); -} - extern macros_t aout_stdmac[]; #endif /* OF_AOUT || OF_AOUTB */ @@ -908,6 +903,7 @@ extern macros_t aout_stdmac[]; const struct ofmt of_aout = { "Linux a.out object files", "aout", + ".o", 0, 32, null_debug_arr, @@ -921,7 +917,6 @@ const struct ofmt of_aout = { null_sectalign, aout_segbase, null_directive, - aout_filename, aout_cleanup, NULL /* pragma list */ }; @@ -933,6 +928,7 @@ const struct ofmt of_aout = { const struct ofmt of_aoutb = { "NetBSD/FreeBSD a.out object files", "aoutb", + ".o", 0, 32, null_debug_arr, @@ -946,7 +942,6 @@ const struct ofmt of_aoutb = { null_sectalign, aout_segbase, null_directive, - aout_filename, aout_cleanup, NULL /* pragma list */ }; diff --git a/output/outas86.c b/output/outas86.c index 59b10e71..18781950 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2013 The NASM Authors - All Rights Reserved + * Copyright 1996-2017 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -91,8 +91,6 @@ struct Section { struct Piece *head, *last, **tail; }; -static char as86_module[FILENAME_MAX]; - static struct Section stext, sdata; static uint32_t bsslen; static int32_t bssindex; @@ -103,13 +101,13 @@ static uint32_t nsyms; static struct RAA *bsym; static struct SAA *strs; -static uint32_t strslen; +static size_t strslen; static int as86_reloc_size; static void as86_write(void); static void as86_write_section(struct Section *, int); -static int as86_add_string(char *name); +static size_t as86_add_string(const char *name); static void as86_sect_write(struct Section *, const uint8_t *, uint32_t); @@ -135,7 +133,8 @@ static void as86_init(void) strs = saa_init(1L); strslen = 0; - as86_add_string(as86_module); + /* as86 module name = input file minus extension */ + as86_add_string(filename_set_extension(inname, "")); } static void as86_cleanup(void) @@ -183,12 +182,12 @@ static int32_t as86_section_names(char *name, int pass, int *bits) return NO_SEG; } -static int as86_add_string(char *name) +static size_t as86_add_string(const char *name) { - int pos = strslen; - int length = strlen(name); + size_t pos = strslen; + size_t length = strlen(name); - saa_wbytes(strs, name, (int32_t)(length + 1)); + saa_wbytes(strs, name, length + 1); strslen += 1 + length; return pos; @@ -611,24 +610,12 @@ static int32_t as86_segbase(int32_t segment) return segment; } -static void as86_filename(char *inname, char *outname) -{ - char *p; - - if ((p = strrchr(inname, '.')) != NULL) { - strncpy(as86_module, inname, p - inname); - as86_module[p - inname] = '\0'; - } else - strcpy(as86_module, inname); - - standard_extension(inname, outname, ".o"); -} - extern macros_t as86_stdmac[]; const struct ofmt of_as86 = { "Linux as86 (bin86 version 0.3) object files", "as86", + ".o", 0, 32, null_debug_arr, @@ -642,7 +629,6 @@ const struct ofmt of_as86 = { null_sectalign, as86_segbase, null_directive, - as86_filename, as86_cleanup, NULL /* pragma list */ }; diff --git a/output/outbin.c b/output/outbin.c index 7f694c4f..e28b809e 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2013 The NASM Authors - All Rights Reserved + * Copyright 1996-2017 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -161,7 +161,6 @@ static int origin_defined; #define MAP_SECTIONS 4 #define MAP_SYMBOLS 8 static int map_control = 0; -static char *infile, *outfile; extern macros_t bin_stdmac[]; @@ -580,7 +579,7 @@ static void bin_cleanup(void) for (h = 63; h; h--) fputc('-', rf); fprintf(rf, "\n\nSource file: %s\nOutput file: %s\n\n", - infile, outfile); + inname, outname); if (map_control & MAP_ORIGIN) { /* Display program origin. */ fprintf(rf, "-- Program origin "); @@ -1371,27 +1370,6 @@ bin_directive(enum directive directive, char *args, int pass) } } -static void bin_filename(char *inname, char *outname) -{ - standard_extension(inname, outname, ""); - infile = inname; - outfile = outname; -} - -static void ith_filename(char *inname, char *outname) -{ - standard_extension(inname, outname, ".ith"); - infile = inname; - outfile = outname; -} - -static void srec_filename(char *inname, char *outname) -{ - standard_extension(inname, outname, ".srec"); - infile = inname; - outfile = outname; -} - static int32_t bin_segbase(int32_t segment) { return segment; @@ -1650,6 +1628,7 @@ static void do_output_srec(void) const struct ofmt of_bin = { "flat-form binary files (e.g. DOS .COM, .SYS)", "bin", + "", 0, 64, null_debug_arr, @@ -1663,7 +1642,6 @@ const struct ofmt of_bin = { bin_sectalign, bin_segbase, bin_directive, - bin_filename, bin_cleanup, NULL /* pragma list */ }; @@ -1671,6 +1649,7 @@ const struct ofmt of_bin = { const struct ofmt of_ith = { "Intel hex", "ith", + ".ith", /* really should have been ".hex"... */ OFMT_TEXT, 64, null_debug_arr, @@ -1684,7 +1663,6 @@ const struct ofmt of_ith = { bin_sectalign, bin_segbase, bin_directive, - ith_filename, bin_cleanup, NULL /* pragma list */ }; @@ -1692,6 +1670,7 @@ const struct ofmt of_ith = { const struct ofmt of_srec = { "Motorola S-records", "srec", + ".srec", OFMT_TEXT, 64, null_debug_arr, @@ -1705,7 +1684,6 @@ const struct ofmt of_srec = { bin_sectalign, bin_segbase, bin_directive, - srec_filename, bin_cleanup, NULL /* pragma list */ }; diff --git a/output/outcoff.c b/output/outcoff.c index df3dab72..54aed727 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2014 The NASM Authors - All Rights Reserved + * Copyright 1996-2017 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -46,6 +46,7 @@ #include "nasm.h" #include "nasmlib.h" +#include "ilog2.h" #include "error.h" #include "saa.h" #include "raa.h" @@ -105,9 +106,6 @@ bool win32, win64; static int32_t imagebase_sect; #define WRT_IMAGEBASE "..imagebase" -char coff_infile[FILENAME_MAX]; -char coff_outfile[FILENAME_MAX]; - /* * Some common section flags by default */ @@ -1079,7 +1077,7 @@ static void coff_write_symbols(void) * The `.file' record, and the file name auxiliary record. */ coff_symbol(".file", 0L, 0L, -2, 0, 0x67, 1); - strncpy(filename, coff_infile, 18); + strncpy(filename, inname, 18); nasm_write(filename, 18, ofile); /* @@ -1142,20 +1140,6 @@ static int32_t coff_segbase(int32_t segment) return segment; } -static void coff_std_filename(char *inname, char *outname) -{ - strcpy(coff_infile, inname); - standard_extension(inname, outname, ".o"); - strcpy(coff_outfile, outname); -} - -static void coff_win32_filename(char *inname, char *outname) -{ - strcpy(coff_infile, inname); - standard_extension(inname, outname, ".obj"); - strcpy(coff_outfile, outname); -} - extern macros_t coff_stdmac[]; #endif /* defined(OF_COFF) || defined(OF_WIN32) */ @@ -1165,6 +1149,7 @@ extern macros_t coff_stdmac[]; const struct ofmt of_coff = { "COFF (i386) object files (e.g. DJGPP for DOS)", "coff", + ".o", 0, 32, null_debug_arr, @@ -1178,7 +1163,6 @@ const struct ofmt of_coff = { coff_sectalign, coff_segbase, coff_directives, - coff_std_filename, coff_cleanup, NULL /* pragma list */ }; @@ -1194,6 +1178,7 @@ static const struct dfmt * const win32_debug_arr[2] = { &df_cv8, NULL }; const struct ofmt of_win32 = { "Microsoft Win32 (i386) object files", "win32", + ".obj", 0, 32, win32_debug_arr, @@ -1207,7 +1192,6 @@ const struct ofmt of_win32 = { coff_sectalign, coff_segbase, coff_directives, - coff_win32_filename, coff_cleanup, NULL /* pragma list */ }; @@ -1221,6 +1205,7 @@ static const struct dfmt * const win64_debug_arr[2] = { &df_cv8, NULL }; const struct ofmt of_win64 = { "Microsoft Win64 (x86-64) object files", "win64", + ".obj", 0, 64, win64_debug_arr, @@ -1234,7 +1219,6 @@ const struct ofmt of_win64 = { coff_sectalign, coff_segbase, coff_directives, - coff_win32_filename, coff_cleanup, NULL /* pragma list */ }; diff --git a/output/outdbg.c b/output/outdbg.c index e74193b0..c57e0af0 100644 --- a/output/outdbg.c +++ b/output/outdbg.c @@ -59,12 +59,15 @@ struct Section { } *dbgsect; static unsigned long dbg_max_data_dump = 128; +static bool section_labels = true; const struct ofmt of_dbg; static void dbg_init(void) { dbgsect = NULL; fprintf(ofile, "NASM Output format debug dump\n"); + fprintf(ofile, "input file = %s\n", inname); + fprintf(ofile, "output file = %s\n", outname); } static void dbg_cleanup(void) @@ -78,7 +81,8 @@ static void dbg_cleanup(void) } } -static int32_t dbg_section_names(char *name, int pass, int *bits) +static int32_t dbg_add_section(char *name, int pass, int *bits, + const char *whatwecallit) { int seg; @@ -88,12 +92,13 @@ static int32_t dbg_section_names(char *name, int pass, int *bits) if (!name) *bits = 16; - if (!name) + if (!name) { fprintf(ofile, "section_name on init: returning %d\n", seg = seg_alloc()); - else { + } else { int n = strcspn(name, " \t"); char *sname = nasm_strndup(name, n); + char *tail = nasm_skip_spaces(name+n); struct Section *s; seg = NO_SEG; @@ -107,13 +112,21 @@ static int32_t dbg_section_names(char *name, int pass, int *bits) s->number = seg = seg_alloc(); s->next = dbgsect; dbgsect = s; - fprintf(ofile, "section_name %s (pass %d): returning %d\n", - name, pass, seg); + fprintf(ofile, "%s %s (%s) pass %d: returning %d\n", + whatwecallit, name, tail, pass, seg); + + if (section_labels) + define_label(s->name, s->number + 1, 0, NULL, false, false); } } return seg; } +static int32_t dbg_section_names(char *name, int pass, int *bits) +{ + return dbg_add_section(name, pass, bits, "section_names"); +} + static void dbg_deflabel(char *name, int32_t segment, int64_t offset, int is_global, char *special) { @@ -128,6 +141,7 @@ static const char *out_type(enum out_type type) static const char *out_types[] = { "rawdata", "reserve", + "zerodata", "address", "reladdr", "segment" @@ -288,6 +302,23 @@ static int32_t dbg_segbase(int32_t segment) static enum directive_result dbg_directive(enum directive directive, char *value, int pass) { + switch (directive) { + /* + * The .obj GROUP directive is nontrivial to emulate in a macro. + * It effectively creates a "pseudo-section" containing the first + * space-separated argument; the rest we ignore. + */ + case D_GROUP: + { + int dummy; + dbg_add_section(value, pass, &dummy, "directive:group"); + break; + } + + default: + break; + } + fprintf(ofile, "directive [%s] value [%s] (pass %d)\n", directive_dname(directive), value, pass); return DIRR_OK; @@ -309,34 +340,37 @@ dbg_pragma(const struct pragma *pragma) pragma->opname, directive_dname(pragma->opcode), pragma->tail); - if (pragma->facility == &dbg_pragma_list[0] && - pragma->opcode == D_MAXDUMP) { - if (!nasm_stricmp(pragma->tail, "unlimited")) { - dbg_max_data_dump = -1UL; - } else { - char *ep; - unsigned long arg; - - errno = 0; - arg = strtoul(pragma->tail, &ep, 0); - if (errno || *nasm_skip_spaces(ep)) { - nasm_error(ERR_WARNING | ERR_WARN_BAD_PRAGMA | ERR_PASS2, - "invalid %%pragma dbg maxdump argument"); - return DIRR_ERROR; + if (pragma->facility == &dbg_pragma_list[0]) { + switch (pragma->opcode) { + case D_MAXDUMP: + if (!nasm_stricmp(pragma->tail, "unlimited")) { + dbg_max_data_dump = -1UL; } else { - dbg_max_data_dump = arg; + char *ep; + unsigned long arg; + + errno = 0; + arg = strtoul(pragma->tail, &ep, 0); + if (errno || *nasm_skip_spaces(ep)) { + nasm_error(ERR_WARNING | ERR_WARN_BAD_PRAGMA | ERR_PASS2, + "invalid %%pragma dbg maxdump argument"); + return DIRR_ERROR; + } else { + dbg_max_data_dump = arg; + } } + break; + case D_NOSECLABELS: + section_labels = false; + break; + + default: + break; } } - return DIRR_OK; } -static void dbg_filename(char *inname, char *outname) -{ - standard_extension(inname, outname, ".dbg"); -} - static const char * const types[] = { "unknown", "label", "byte", "word", "dword", "float", "qword", "tbyte" }; @@ -401,14 +435,17 @@ static const struct dfmt * const debug_debug_arr[3] = { NULL }; +extern macros_t dbg_stdmac[]; + const struct ofmt of_dbg = { "Trace of all info passed to output stage", "dbg", + ".dbg", OFMT_TEXT, 64, debug_debug_arr, &debug_debug_form, - NULL, + dbg_stdmac, dbg_init, dbg_out, dbg_legacy_out, @@ -417,7 +454,6 @@ const struct ofmt of_dbg = { dbg_sectalign, dbg_segbase, dbg_directive, - dbg_filename, dbg_cleanup, dbg_pragma_list }; diff --git a/output/outdbg.mac b/output/outdbg.mac new file mode 100644 index 00000000..4f68d63c --- /dev/null +++ b/output/outdbg.mac @@ -0,0 +1,53 @@ +;; -------------------------------------------------------------------------- +;; +;; Copyright 1996-2017 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. +;; +;; -------------------------------------------------------------------------- + +; +; Define a few macros which lets the dbg format process files intended +; for the .obj format. +; +OUT: dbg +%define __SECT__ [section .text] +%imacro group 1+.nolist +[group %1] +%endmacro +%imacro uppercase 0+.nolist + %pragma dbg uppercase %1 +%endmacro +%imacro export 1+.nolist + %pragma dbg export %1 +%endmacro +%imacro import 1+.nolist + %pragma dbg import %1 +%endmacro +%macro __NASM_CDecl__ 1 +%endmacro diff --git a/output/outelf.c b/output/outelf.c index deac27fc..4d047611 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -209,9 +209,9 @@ const struct elf_known_section elf_known_sections[] = { }; /* parse section attributes */ -void elf_section_attrib(char *name, char *attr, int pass, - uint32_t *flags_and, uint32_t *flags_or, - uint64_t *align, int *type) +static void elf_section_attrib(char *name, char *attr, int pass, + uint32_t *flags_and, uint32_t *flags_or, + uint64_t *align, int *type) { char *opt, *val, *next; @@ -1610,46 +1610,60 @@ static void elf_write(void) * Output the ELF header. */ if (is_elf32() || is_elfx32()) { - nasm_write("\177ELF\1\1\1", 7, ofile); - fputc(elf_osabi, ofile); - fputc(elf_abiver, ofile); - fwritezero(7, ofile); - fwriteint16_t(ET_REL, ofile); /* relocatable file */ - fwriteint16_t(is_elf32() ? EM_386 : EM_X86_64, ofile); /* 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, ofile); /* 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(sizeof(Elf32_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 */ - - fwriteint32_t(0L, ofile); /* align to 0x40 bytes */ - fwriteint32_t(0L, ofile); - fwriteint32_t(0L, ofile); + Elf32_Ehdr ehdr; + + nasm_zero(ehdr.e_ident); + memcpy(ehdr.e_ident, ELFMAG, SELFMAG); + ehdr.e_ident[EI_CLASS] = ELFCLASS32; + ehdr.e_ident[EI_DATA] = ELFDATA2LSB; + ehdr.e_ident[EI_VERSION] = EV_CURRENT; + ehdr.e_ident[EI_OSABI] = elf_osabi; + ehdr.e_ident[EI_ABIVERSION] = elf_abiver; + + ehdr.e_type = cpu_to_le16(ET_REL); + ehdr.e_machine = cpu_to_le16(is_elf32() ? EM_386 : EM_X86_64); + ehdr.e_version = cpu_to_le16(EV_CURRENT); + ehdr.e_entry = 0; + ehdr.e_phoff = 0; + ehdr.e_shoff = sizeof(Elf64_Ehdr); + ehdr.e_flags = 0; + ehdr.e_ehsize = cpu_to_le16(sizeof(Elf32_Ehdr)); + ehdr.e_phentsize = 0; + ehdr.e_phnum = 0; + ehdr.e_shentsize = cpu_to_le16(sizeof(Elf32_Shdr)); + ehdr.e_shnum = cpu_to_le16(nsections); + ehdr.e_shstrndx = cpu_to_le16(sec_shstrtab); + + nasm_write(&ehdr, sizeof(ehdr), ofile); + fwritezero(sizeof(Elf64_Ehdr) - sizeof(Elf32_Ehdr), ofile); } else { + Elf64_Ehdr ehdr; + nasm_assert(is_elf64()); - nasm_write("\177ELF\2\1\1", 7, 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, ofile); /* 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 */ + + nasm_zero(ehdr.e_ident); + memcpy(ehdr.e_ident, ELFMAG, SELFMAG); + ehdr.e_ident[EI_CLASS] = ELFCLASS64; + ehdr.e_ident[EI_DATA] = ELFDATA2LSB; + ehdr.e_ident[EI_VERSION] = EV_CURRENT; + ehdr.e_ident[EI_OSABI] = elf_osabi; + ehdr.e_ident[EI_ABIVERSION] = elf_abiver; + + ehdr.e_type = cpu_to_le16(ET_REL); + ehdr.e_machine = cpu_to_le16(EM_X86_64); + ehdr.e_version = cpu_to_le16(EV_CURRENT); + ehdr.e_entry = 0; + ehdr.e_phoff = 0; + ehdr.e_shoff = sizeof(Elf64_Ehdr); + ehdr.e_flags = 0; + ehdr.e_ehsize = cpu_to_le16(sizeof(Elf64_Ehdr)); + ehdr.e_phentsize = 0; + ehdr.e_phnum = 0; + ehdr.e_shentsize = cpu_to_le16(sizeof(Elf64_Shdr)); + ehdr.e_shnum = cpu_to_le16(nsections); + ehdr.e_shstrndx = cpu_to_le16(sec_shstrtab); + + nasm_write(&ehdr, sizeof(ehdr), ofile); } /* @@ -1665,7 +1679,7 @@ static void elf_write(void) * Now output the section header table. */ - elf_foffs = 0x40 + (is_elf64() ? sizeof(Elf64_Shdr): sizeof(Elf32_Shdr)) * nsections; + elf_foffs = sizeof(Elf64_Ehdr) + (is_elf64() ? sizeof(Elf64_Shdr): sizeof(Elf32_Shdr)) * nsections; align = ALIGN(elf_foffs, SEC_FILEALIGN) - elf_foffs; elf_foffs += align; elf_nsect = 0; @@ -1825,68 +1839,72 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) { struct SAA *s = saa_init(1L); struct elf_symbol *sym; - uint8_t entry[24], *p; int i; + size_t usize = is_elf64() ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym); + union { + Elf32_Sym sym32; + Elf64_Sym sym64; + } u; + *len = *local = 0; /* - * First, an all-zeros entry, required by the ELF spec. + * Zero symbol first as required by spec. */ - saa_wbytes(s, NULL, is_elf64() ? 24L : 16L); /* null symbol table entry */ - *len += is_elf64() ? 24L : 16L; + saa_wbytes(s, NULL, usize); + *len += usize; (*local)++; /* * Next, an entry for the file name. */ - p = entry; if (is_elf64()) { - WRITELONG(p, 1); /* we know it's 1st entry in strtab */ - WRITESHORT(p, STT_FILE); /* type FILE */ - WRITESHORT(p, SHN_ABS); - WRITEDLONG(p, (uint64_t) 0); /* no value */ - WRITEDLONG(p, (uint64_t) 0); /* no size either */ - saa_wbytes(s, entry, 24L); - *len += 24; - (*local)++; + u.sym64.st_name = cpu_to_le32(1); + u.sym64.st_info = ELF64_ST_INFO(STB_LOCAL, STT_FILE); + u.sym64.st_other = 0; + u.sym64.st_shndx = cpu_to_le16(SHN_ABS); + u.sym64.st_value = 0; + u.sym64.st_size = 0; } else { - WRITELONG(p, 1); /* we know it's 1st entry in strtab */ - WRITELONG(p, 0); /* no value */ - WRITELONG(p, 0); /* no size either */ - WRITESHORT(p, STT_FILE); /* type FILE */ - WRITESHORT(p, SHN_ABS); - saa_wbytes(s, entry, 16L); - *len += 16; - (*local)++; + u.sym32.st_name = cpu_to_le32(1); + u.sym32.st_value = 0; + u.sym32.st_size = 0; + u.sym32.st_info = ELF32_ST_INFO(STB_LOCAL, STT_FILE); + u.sym32.st_other = 0; + u.sym32.st_shndx = cpu_to_le16(SHN_ABS); } + saa_wbytes(s, &u, usize); + *len += usize; + (*local)++; + /* * Now some standard symbols defining the segments, for relocation * purposes. */ if (is_elf64()) { + u.sym64.st_name = 0; + u.sym64.st_other = 0; + u.sym64.st_value = 0; + u.sym64.st_size = 0; for (i = 1; i <= nsects; i++) { - p = entry; - WRITELONG(p, 0); /* no symbol name */ - WRITESHORT(p, STT_SECTION); /* type, binding, and visibility */ - WRITESHORT(p, i); /* section id */ - WRITEDLONG(p, (uint64_t) 0); /* offset zero */ - WRITEDLONG(p, (uint64_t) 0); /* size zero */ - saa_wbytes(s, entry, 24L); - *len += 24; + u.sym64.st_info = ELF64_ST_INFO(STB_LOCAL, STT_SECTION); + u.sym64.st_shndx = cpu_to_le16(i); + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; } } else { + u.sym32.st_name = 0; + u.sym32.st_value = 0; + u.sym32.st_size = 0; + u.sym32.st_other = 0; for (i = 1; i <= nsects; i++) { - p = entry; - WRITELONG(p, 0); /* no symbol name */ - WRITELONG(p, 0); /* offset zero */ - WRITELONG(p, 0); /* size zero */ - WRITESHORT(p, STT_SECTION); /* type, binding, and visibility */ - WRITESHORT(p, i); /* section id */ - saa_wbytes(s, entry, 16L); - *len += 16; + u.sym32.st_info = ELF32_ST_INFO(STB_LOCAL, STT_SECTION); + u.sym32.st_shndx = cpu_to_le16(i); + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; } } @@ -1899,15 +1917,14 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) while ((sym = saa_rstruct(syms))) { if (sym->type & SYM_GLOBAL) continue; - p = entry; - WRITELONG(p, sym->strpos); /* index into symbol string table */ - WRITECHAR(p, sym->type); /* type and binding */ - WRITECHAR(p, sym->other); /* visibility */ - WRITESHORT(p, sym->section); /* index into section header table */ - WRITEDLONG(p, (int64_t)sym->symv.key); /* value of symbol */ - WRITEDLONG(p, (int64_t)sym->size); /* size of symbol */ - saa_wbytes(s, entry, 24L); - *len += 24; + u.sym64.st_name = cpu_to_le32(sym->strpos); + u.sym64.st_info = sym->type; + u.sym64.st_other = sym->other; + u.sym64.st_shndx = cpu_to_le16(sym->section); + u.sym64.st_value = cpu_to_le64(sym->symv.key); + u.sym64.st_size = cpu_to_le64(sym->size); + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; } /* @@ -1916,49 +1933,48 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) */ if (dfmt_is_dwarf()) { dwarf_infosym = *local; - p = entry; - WRITELONG(p, 0); /* no symbol name */ - WRITESHORT(p, STT_SECTION); /* type, binding, and visibility */ - WRITESHORT(p, debug_info); /* section id */ - WRITEDLONG(p, (uint64_t) 0); /* offset zero */ - WRITEDLONG(p, (uint64_t) 0); /* size zero */ - saa_wbytes(s, entry, 24L); - *len += 24; + u.sym64.st_name = 0; + u.sym64.st_info = ELF64_ST_INFO(STB_LOCAL, STT_SECTION); + u.sym64.st_other = 0; + u.sym64.st_shndx = cpu_to_le16(debug_info); + u.sym64.st_value = 0; + u.sym64.st_size = 0; + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; dwarf_abbrevsym = *local; - p = entry; - WRITELONG(p, 0); /* no symbol name */ - WRITESHORT(p, STT_SECTION); /* type, binding, and visibility */ - WRITESHORT(p, debug_abbrev); /* section id */ - WRITEDLONG(p, (uint64_t) 0); /* offset zero */ - WRITEDLONG(p, (uint64_t) 0); /* size zero */ - saa_wbytes(s, entry, 24L); - *len += 24; + u.sym64.st_name = 0; + u.sym64.st_info = ELF64_ST_INFO(STB_LOCAL, STT_SECTION); + u.sym64.st_other = 0; + u.sym64.st_shndx = cpu_to_le16(debug_abbrev); + u.sym64.st_value = 0; + u.sym64.st_size = 0; + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; dwarf_linesym = *local; - p = entry; - WRITELONG(p, 0); /* no symbol name */ - WRITESHORT(p, STT_SECTION); /* type, binding, and visibility */ - WRITESHORT(p, debug_line); /* section id */ - WRITEDLONG(p, (uint64_t) 0); /* offset zero */ - WRITEDLONG(p, (uint64_t) 0); /* size zero */ - saa_wbytes(s, entry, 24L); - *len += 24; + u.sym64.st_name = 0; + u.sym64.st_info = ELF64_ST_INFO(STB_LOCAL, STT_SECTION); + u.sym64.st_other = 0; + u.sym64.st_shndx = cpu_to_le16(debug_line); + u.sym64.st_value = 0; + u.sym64.st_size = 0; + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; } } else { while ((sym = saa_rstruct(syms))) { if (sym->type & SYM_GLOBAL) continue; - p = entry; - WRITELONG(p, sym->strpos); - WRITELONG(p, sym->symv.key); - WRITELONG(p, sym->size); - WRITECHAR(p, sym->type); /* type and binding */ - WRITECHAR(p, sym->other); /* visibility */ - WRITESHORT(p, sym->section); - saa_wbytes(s, entry, 16L); - *len += 16; + u.sym32.st_name = cpu_to_le32(sym->strpos); + u.sym32.st_value = cpu_to_le32(sym->symv.key); + u.sym32.st_size = cpu_to_le32(sym->size); + u.sym32.st_info = sym->type; + u.sym32.st_other = sym->other; + u.sym32.st_shndx = cpu_to_le16(sym->section); + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; } /* @@ -1967,34 +1983,34 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) */ if (dfmt_is_dwarf()) { dwarf_infosym = *local; - p = entry; - WRITELONG(p, 0); /* no symbol name */ - WRITELONG(p, (uint32_t) 0); /* offset zero */ - WRITELONG(p, (uint32_t) 0); /* size zero */ - WRITESHORT(p, STT_SECTION); /* type, binding, and visibility */ - WRITESHORT(p, sec_debug_info); /* section id */ - saa_wbytes(s, entry, 16L); - *len += 16; + u.sym32.st_name = 0; + u.sym32.st_value = 0; + u.sym32.st_size = 0; + u.sym32.st_info = ELF32_ST_INFO(STB_LOCAL, STT_SECTION); + u.sym32.st_other = 0; + u.sym32.st_shndx = cpu_to_le16(sec_debug_info); + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; dwarf_abbrevsym = *local; - p = entry; - WRITELONG(p, 0); /* no symbol name */ - WRITELONG(p, (uint32_t) 0); /* offset zero */ - WRITELONG(p, (uint32_t) 0); /* size zero */ - WRITESHORT(p, STT_SECTION); /* type, binding, and visibility */ - WRITESHORT(p, sec_debug_abbrev); /* section id */ - saa_wbytes(s, entry, 16L); - *len += 16; + u.sym32.st_name = 0; + u.sym32.st_value = 0; + u.sym32.st_size = 0; + u.sym32.st_info = ELF32_ST_INFO(STB_LOCAL, STT_SECTION); + u.sym32.st_other = 0; + u.sym32.st_shndx = cpu_to_le16(sec_debug_abbrev); + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; dwarf_linesym = *local; - p = entry; - WRITELONG(p, 0); /* no symbol name */ - WRITELONG(p, (uint32_t) 0); /* offset zero */ - WRITELONG(p, (uint32_t) 0); /* size zero */ - WRITESHORT(p, STT_SECTION); /* type, binding, and visibility */ - WRITESHORT(p, sec_debug_line); /* section id */ - saa_wbytes(s, entry, 16L); - *len += 16; + u.sym32.st_name = 0; + u.sym32.st_value = 0; + u.sym32.st_size = 0; + u.sym32.st_info = ELF32_ST_INFO(STB_LOCAL, STT_SECTION); + u.sym32.st_other = 0; + u.sym32.st_shndx = cpu_to_le16(sec_debug_line); + saa_wbytes(s, &u, usize); + *len += usize; (*local)++; } } @@ -2007,29 +2023,27 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) while ((sym = saa_rstruct(syms))) { if (!(sym->type & SYM_GLOBAL)) continue; - p = entry; - WRITELONG(p, sym->strpos); - WRITECHAR(p, sym->type); /* type and binding */ - WRITECHAR(p, sym->other); /* visibility */ - WRITESHORT(p, sym->section); - WRITEDLONG(p, (int64_t)sym->symv.key); - WRITEDLONG(p, (int64_t)sym->size); - saa_wbytes(s, entry, 24L); - *len += 24; + u.sym64.st_name = cpu_to_le32(sym->strpos); + u.sym64.st_info = sym->type; + u.sym64.st_other = sym->other; + u.sym64.st_shndx = cpu_to_le16(sym->section); + u.sym64.st_value = cpu_to_le64(sym->symv.key); + u.sym64.st_size = cpu_to_le64(sym->size); + saa_wbytes(s, &u, usize); + *len += usize; } } else { while ((sym = saa_rstruct(syms))) { if (!(sym->type & SYM_GLOBAL)) continue; - p = entry; - WRITELONG(p, sym->strpos); - WRITELONG(p, sym->symv.key); - WRITELONG(p, sym->size); - WRITECHAR(p, sym->type); /* type and binding */ - WRITECHAR(p, sym->other); /* visibility */ - WRITESHORT(p, sym->section); - saa_wbytes(s, entry, 16L); - *len += 16; + u.sym32.st_name = cpu_to_le32(sym->strpos); + u.sym32.st_value = cpu_to_le32(sym->symv.key); + u.sym32.st_size = cpu_to_le32(sym->size); + u.sym32.st_info = sym->type; + u.sym32.st_other = sym->other; + u.sym32.st_shndx = cpu_to_le16(sym->section); + saa_wbytes(s, &u, usize); + *len += usize; } } @@ -2039,9 +2053,16 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r) { struct SAA *s; - uint8_t *p, entry[24]; int32_t global_offset; + size_t usize = is_elf64() ? sizeof(Elf64_Rela) : + (is_elfx32() ? sizeof(Elf32_Rela) : sizeof(Elf32_Rel)); + union { + Elf32_Rel rel32; + Elf32_Rela rela32; + Elf64_Rela rela64; + } u; + if (!r) return NULL; @@ -2062,11 +2083,10 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r) if (sym >= GLOBAL_TEMP_BASE) sym += global_offset; - p = entry; - WRITELONG(p, r->address); - WRITELONG(p, (sym << 8) + r->type); - saa_wbytes(s, entry, 8L); - *len += 8; + u.rel32.r_offset = cpu_to_le32(r->address); + u.rel32.r_info = cpu_to_le32(ELF32_R_INFO(sym, r->type)); + saa_wbytes(s, &u, usize); + *len += usize; r = r->next; } @@ -2077,12 +2097,11 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r) if (sym >= GLOBAL_TEMP_BASE) sym += global_offset; - p = entry; - WRITELONG(p, r->address); - WRITELONG(p, (sym << 8) + r->type); - WRITELONG(p, r->offset); - saa_wbytes(s, entry, 12L); - *len += 12; + u.rela32.r_offset = cpu_to_le32(r->address); + u.rela32.r_info = cpu_to_le32(ELF32_R_INFO(sym, r->type)); + u.rela32.r_addend = cpu_to_le32(r->offset); + saa_wbytes(s, &u, usize); + *len += usize; r = r->next; } @@ -2094,13 +2113,11 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r) if (sym >= GLOBAL_TEMP_BASE) sym += global_offset; - p = entry; - WRITEDLONG(p, r->address); - WRITELONG(p, r->type); - WRITELONG(p, sym); - WRITEDLONG(p, r->offset); - saa_wbytes(s, entry, 24L); - *len += 24; + u.rela64.r_offset = cpu_to_le64(r->address); + u.rela64.r_info = cpu_to_le64(ELF64_R_INFO(sym, r->type)); + u.rela64.r_addend = cpu_to_le64(r->offset); + saa_wbytes(s, &u, usize); + *len += usize; r = r->next; } @@ -2113,39 +2130,47 @@ static void elf_section_header(int name, int type, uint64_t flags, void *data, bool is_saa, uint64_t datalen, int link, int info, int align, int eltsize) { + union { + Elf32_Shdr shdr32; + Elf64_Shdr shdr64; + } shdr; + elf_sects[elf_nsect].data = data; elf_sects[elf_nsect].len = datalen; elf_sects[elf_nsect].is_saa = is_saa; elf_nsect++; if (is_elf32() || is_elfx32()) { - 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); + shdr.shdr32.sh_name = cpu_to_le32(name); + shdr.shdr32.sh_type = cpu_to_le32(type); + shdr.shdr32.sh_flags = cpu_to_le32(flags); + shdr.shdr32.sh_addr = 0; + shdr.shdr32.sh_offset = cpu_to_le32(type == SHT_NULL ? 0 : elf_foffs); + shdr.shdr32.sh_size = cpu_to_le32(datalen); if (data) elf_foffs += ALIGN(datalen, SEC_FILEALIGN); - fwriteint32_t((int32_t)link, ofile); - fwriteint32_t((int32_t)info, ofile); - fwriteint32_t((int32_t)align, ofile); - fwriteint32_t((int32_t)eltsize, ofile); + shdr.shdr32.sh_link = cpu_to_le32(link); + shdr.shdr32.sh_info = cpu_to_le32(info); + shdr.shdr32.sh_addralign = cpu_to_le32(align); + shdr.shdr32.sh_entsize = cpu_to_le32(eltsize); } else { nasm_assert(is_elf64()); - 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); + + shdr.shdr64.sh_name = cpu_to_le32(name); + shdr.shdr64.sh_type = cpu_to_le32(type); + shdr.shdr64.sh_flags = cpu_to_le64(flags); + shdr.shdr64.sh_addr = 0; + shdr.shdr64.sh_offset = cpu_to_le64(type == SHT_NULL ? 0 : elf_foffs); + shdr.shdr64.sh_size = cpu_to_le32(datalen); if (data) elf_foffs += ALIGN(datalen, SEC_FILEALIGN); - fwriteint32_t((int32_t)link, ofile); - fwriteint32_t((int32_t)info, ofile); - fwriteint64_t((int64_t)align, ofile); - fwriteint64_t((int64_t)eltsize, ofile); + shdr.shdr64.sh_link = cpu_to_le32(link); + shdr.shdr64.sh_info = cpu_to_le32(info); + shdr.shdr64.sh_addralign = cpu_to_le64(align); + shdr.shdr64.sh_entsize = cpu_to_le64(eltsize); } + + nasm_write(&shdr, is_elf64() ? sizeof(shdr.shdr64) : sizeof(shdr.shdr32), ofile); } static void elf_write_sections(void) @@ -2199,12 +2224,6 @@ static int32_t elf_segbase(int32_t segment) return segment; } -static void elf_filename(char *inname, char *outname) -{ - strcpy(elf_module, inname); - standard_extension(inname, outname, ".o"); -} - extern macros_t elf_stdmac[]; /* Claim "elf" as a pragma namespace, for the future */ @@ -2247,6 +2266,7 @@ static const struct dfmt * const elf32_debugs_arr[3] = const struct ofmt of_elf32 = { "ELF32 (i386) object files (e.g. Linux)", "elf32", + ".o", 0, 32, elf32_debugs_arr, @@ -2260,7 +2280,6 @@ const struct ofmt of_elf32 = { elf_sectalign, elf_segbase, elf_directive, - elf_filename, elf_cleanup, elf_pragma_list, }; @@ -2297,6 +2316,7 @@ static const struct dfmt * const elf64_debugs_arr[3] = const struct ofmt of_elf64 = { "ELF64 (x86_64) object files (e.g. Linux)", "elf64", + ".o", 0, 64, elf64_debugs_arr, @@ -2310,7 +2330,6 @@ const struct ofmt of_elf64 = { elf_sectalign, elf_segbase, elf_directive, - elf_filename, elf_cleanup, elf_pragma_list, }; @@ -2347,6 +2366,7 @@ static const struct dfmt * const elfx32_debugs_arr[3] = const struct ofmt of_elfx32 = { "ELFX32 (x86_64) object files (e.g. Linux)", "elfx32", + ".o", 0, 64, elfx32_debugs_arr, @@ -2360,7 +2380,6 @@ const struct ofmt of_elfx32 = { elf_sectalign, elf_segbase, elf_directive, - elf_filename, elf_cleanup, NULL /* pragma list */ }; diff --git a/output/outelf.h b/output/outelf.h index 0f718d9e..8eef73ae 100644 --- a/output/outelf.h +++ b/output/outelf.h @@ -103,10 +103,6 @@ struct stabentry { extern uint8_t elf_osabi; extern uint8_t elf_abiver; -void elf_section_attrib(char *name, char *attr, int pass, - uint32_t *flags_and, uint32_t *flags_or, - uint64_t *align, int *type); - #define WRITE_STAB(p,n_strx,n_type,n_other,n_desc,n_value) \ do { \ WRITELONG(p, n_strx); \ diff --git a/output/outieee.c b/output/outieee.c index e96c723b..114c8151 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -886,15 +886,6 @@ static int32_t ieee_segbase(int32_t segment) return segment; /* no special treatment */ } -/* - * filename - */ -static void ieee_filename(char *inname, char *outname) -{ - strcpy(ieee_infile, inname); - standard_extension(inname, outname, ".o"); -} - static void ieee_write_file(void) { const struct tm * const thetime = &official_compile_time.local; @@ -1507,6 +1498,7 @@ static const struct dfmt * const ladsoft_debug_arr[3] = { const struct ofmt of_ieee = { "IEEE-695 (LADsoft variant) object file format", "ieee", + ".o", OFMT_TEXT, 32, ladsoft_debug_arr, @@ -1520,7 +1512,6 @@ const struct ofmt of_ieee = { ieee_sectalign, ieee_segbase, ieee_directive, - ieee_filename, ieee_cleanup, NULL /* pragma list */ }; diff --git a/output/outmacho.c b/output/outmacho.c index ef13d3bb..742c2948 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -45,6 +45,7 @@ #include "nasm.h" #include "nasmlib.h" +#include "ilog2.h" #include "labels.h" #include "error.h" #include "saa.h" @@ -1105,12 +1106,6 @@ static int32_t macho_segbase(int32_t section) return section; } -static void macho_filename(char *inname, char *outname) -{ - standard_extension(inname, outname, ".o"); - module_name = inname; -} - extern macros_t macho_stdmac[]; /* Comparison function for qsort symbol layout. */ @@ -2292,6 +2287,7 @@ static const struct dfmt * const macho32_df_arr[2] = const struct ofmt of_macho32 = { "NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (i386) object files", "macho32", + ".o", 0, 32, macho32_df_arr, @@ -2305,7 +2301,6 @@ const struct ofmt of_macho32 = { macho_sectalign, macho_segbase, null_directive, - macho_filename, macho_cleanup, macho_pragma_list }; @@ -2357,6 +2352,7 @@ static const struct dfmt * const macho64_df_arr[2] = const struct ofmt of_macho64 = { "NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (x86_64) object files", "macho64", + ".o", 0, 64, macho64_df_arr, @@ -2370,7 +2366,6 @@ const struct ofmt of_macho64 = { macho_sectalign, macho_segbase, null_directive, - macho_filename, macho_cleanup, macho_pragma_list, }; diff --git a/output/outobj.c b/output/outobj.c index db514431..c9418db0 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -1940,12 +1940,6 @@ static int32_t obj_segbase(int32_t segment) return segment; /* no special treatment */ } -static void obj_filename(char *inname, char *outname) -{ - strcpy(obj_infile, inname); - standard_extension(inname, outname, ".obj"); -} - /* Get a file timestamp in MS-DOS format */ static uint32_t obj_file_timestamp(const char *pathname) { @@ -2705,6 +2699,7 @@ static const struct pragma_facility obj_pragma_list[] = { const struct ofmt of_obj = { "MS-DOS 16-bit/32-bit OMF object files", "obj", + ".obj", 0, 32, borland_debug_arr, @@ -2718,7 +2713,6 @@ const struct ofmt of_obj = { obj_sectalign, obj_segbase, obj_directive, - obj_filename, obj_cleanup, obj_pragma_list }; diff --git a/output/outrdf2.c b/output/outrdf2.c index ebc6a1f2..3a218a44 100644 --- a/output/outrdf2.c +++ b/output/outrdf2.c @@ -760,16 +760,12 @@ rdf2_directive(enum directive directive, char *value, int pass) } } -static void rdf2_filename(char *inname, char *outname) -{ - standard_extension(inname, outname, ".rdf"); -} - extern macros_t rdf2_stdmac[]; const struct ofmt of_rdf2 = { "Relocatable Dynamic Object File Format v2.0", "rdf", + ".rdf", 0, 64, null_debug_arr, @@ -783,7 +779,6 @@ const struct ofmt of_rdf2 = { null_sectalign, rdf2_segbase, rdf2_directive, - rdf2_filename, rdf2_cleanup, NULL /* pragma list */ }; diff --git a/output/strtbl.c b/output/strtbl.c new file mode 100644 index 00000000..23b0d118 --- /dev/null +++ b/output/strtbl.c @@ -0,0 +1,117 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2017 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. + * + * ----------------------------------------------------------------------- */ + +/* + * Common string table handling + * + * A number of output formats use a "string table"; a container for + * a number of strings which may be reused at will. This implements + * a string table which eliminates duplicates and returns the index + * into the string table when queried. + */ + +#include "compiler.h" + +#include "nasm.h" +#include "nasmlib.h" +#include "error.h" +#include "strtbl.h" + +struct strtbl_entry { + size_t index; + size_t bytes; + char str[1]; +}; + +void strtbl_init(struct nasm_strtbl *tbl) +{ + tbl->size = 0; + hash_init(&tbl->hash, HASH_LARGE); + strtbl_add(tbl, ""); /* Index 0 is always an empty string */ +} + +void strtbl_free(struct nasm_strtbl *tbl) +{ + hash_free_all(&tbl->hash, false); +} + +size_t strtbl_add(struct nasm_strtbl *tbl, const char *str) +{ + void **sep; + struct strtbl_entry *se; + struct hash_insert hi; + + sep = hash_find(&tbl->hash, str, &hi); + if (sep) { + se = *sep; + } else { + size_t bytes = strlen(str) + 1; + + se = nasm_malloc(sizeof(struct strtbl_entry)-1+bytes); + se->index = tbl->size; + tbl->size += bytes; + se->bytes = bytes; + memcpy(se->str, str, bytes); + + hash_add(&hi, se->str, se); + } + + return se->index; +} + +size_t strtbl_find(struct nasm_strtbl *tbl, const char *str) +{ + void **sep; + struct strtbl_entry *se; + + sep = hash_find(&tbl->hash, str, NULL); + if (sep) { + se = *sep; + return se->index; + } else { + return STRTBL_NONE; + } +} + +/* This create a linearized buffer containing the actual string table */ +void *strtbl_generate(const struct nasm_strtbl *tbl) +{ + char *buf = nasm_malloc(strtbl_size(tbl)); + struct hash_tbl_node *iter = NULL; + struct strtbl_entry *se; + + while ((se = hash_iterate(&tbl->hash, &iter, NULL))) + memcpy(buf + se->index, se->str, se->bytes); + + return buf; +} diff --git a/output/strtbl.h b/output/strtbl.h new file mode 100644 index 00000000..12771e4e --- /dev/null +++ b/output/strtbl.h @@ -0,0 +1,57 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2017 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. + * + * ----------------------------------------------------------------------- */ + +#ifndef NASM_STRTBL_H +#define NASM_STRTBL_H + +#include "compiler.h" +#include "hashtbl.h" + +struct nasm_strtbl { + size_t size; + struct hash_table hash; +}; + +#define STRTBL_NONE ((size_t)-1) + +void strtbl_init(struct nasm_strtbl *tbl); +void strtbl_free(struct nasm_strtbl *tbl); +size_t strtbl_find(struct nasm_strtbl *tbl, const char *str); +size_t strtbl_add(struct nasm_strtbl *tbl, const char *str); +static inline size_t strtbl_size(const struct nasm_strtbl *tbl) +{ + return tbl->size; +} +void * safe_alloc strtbl_generate(const struct nasm_strtbl *tbl); + +#endif /* NASM_STRTBL_H */ diff --git a/stdlib/strrchrnul.c b/stdlib/strrchrnul.c new file mode 100644 index 00000000..d25148eb --- /dev/null +++ b/stdlib/strrchrnul.c @@ -0,0 +1,50 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2017 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 "compiler.h" +#include <string.h> + +#ifndef HAVE_STRRCHRNUL + +char *strrchrnul(const char *s, int c) +{ + char *p; + + p = strrchr(s, c); + if (!p) + p = strchr(s, '\0'); + + return p; +} + +#endif diff --git a/test/objtest.asm b/test/objtest.asm index 03b7f9e2..c68f7cbb 100644 --- a/test/objtest.asm +++ b/test/objtest.asm @@ -35,8 +35,8 @@ common _commvar 2 ; [3] extern _printf ; [6] - group mygroup mybss mydata ; [10] - group mygroup2 mycode mycode2 ; [10] + group mygroup mybss mydata + group mygroup2 mycode mycode2 segment mycode private @@ -67,6 +67,8 @@ _function push bp retf .printf dw _printf, seg _printf ; [2] [4] [16] +.printfd dd _printf, seg _printf ; [2] [4] [16] +.printfq dq _printf, seg _printf ; [2] [4] [16] segment mycode2 private diff --git a/tools/mkdep.pl b/tools/mkdep.pl index cf8bf979..e84cc358 100755 --- a/tools/mkdep.pl +++ b/tools/mkdep.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl ## -------------------------------------------------------------------------- -## -## Copyright 1996-2016 The NASM Authors - All Rights Reserved +## +## Copyright 1996-2017 The NASM Authors - All Rights Reserved ## See the file AUTHORS included with the NASM distribution for ## the specific copyright holders. ## @@ -15,7 +15,7 @@ ## 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 @@ -35,11 +35,15 @@ # # Script to create Makefile-style dependencies. # -# Usage: perl mkdep.pl [-s path-separator] [-o obj-ext] dir... > deps +# Usage: +# perl mkdep.pl [-s path-separator][-o obj-ext] dir... > deps +# perl mkdep.pl [-i][-e][-m makefile]...[-M makefile... --] dir... # use File::Spec; use File::Basename; +use File::Copy; +use File::Temp; use Fcntl; $barrier = "#-- Everything below is generated by mkdep.pl - do not edit --#\n"; @@ -53,8 +57,8 @@ $barrier = "#-- Everything below is generated by mkdep.pl - do not edit --#\n"; sub scandeps($) { my($file) = @_; my $line; - my @xdeps = (); - my @mdeps = (); + my %xdeps; + my %mdeps; open(my $fh, '<', $file) or return; # If not openable, assume generated @@ -69,14 +73,14 @@ sub scandeps($) { die "$0: cannot determine path for dependency: $file -> $nf\n"; } $nf = $dep_path{$nf}; - push(@mdeps, $nf); - push(@xdeps, $nf) unless ( defined($deps{$nf}) ); + $mdeps{$nf}++; + $xdeps{$nf}++ unless ( defined($deps{$nf}) ); } } close($fh); - $deps{$file} = [@mdeps]; + $deps{$file} = [keys(%mdeps)]; - foreach my $xf ( @xdeps ) { + foreach my $xf ( keys(%xdeps) ) { scandeps($xf); } } @@ -100,6 +104,7 @@ sub alldeps($$) { # This almost certainly works only on relative filenames... sub convert_file($$) { my($file,$sep) = @_; + my @fspec = (basename($file)); while ( ($file = dirname($file)) ne File::Spec->curdir() && $file ne File::Spec->rootdir() ) { @@ -119,25 +124,28 @@ sub convert_file($$) { # # Insert dependencies into a Makefile # -sub insert_deps($) { - my($file) = @_; - $nexttemp++; # Unique serial number for each temp file - my $tmp = File::Spec->catfile(dirname($file), 'tmp.'.$nexttemp); +sub _insert_deps($$) { + my($file, $out) = @_; open(my $in, '<', $file) or die "$0: Cannot open input: $file\n"; - open(my $out, '>', $tmp) - or die "$0: Cannot open output: $tmp\n"; - - my($line,$parm,$val); - my($obj) = '.o'; # Defaults - my($sep) = '/'; - my($cont) = "\\"; - my($maxline) = 78; # Seems like a reasonable default + + my $line, $parm, $val; + my $obj = '.o'; # Defaults + my $sep = '/'; + my $cont = "\\"; + my $include_command = undef; + my $selfrule = 0; + my $do_external = 0; + my $maxline = 78; # Seems like a reasonable default my @exclude = (); # Don't exclude anything my @genhdrs = (); + my $external = undef; + my $raw_output = 0; + my @outfile = (); + my $done = 0; - while ( defined($line = <$in>) ) { + while ( defined($line = <$in>) && !$done ) { if ( $line =~ /^([^\s\#\$\:]+\.h):/ ) { # Note: we trust the first Makefile given best my $fpath = $1; @@ -158,35 +166,65 @@ sub insert_deps($) { $cont = $val; } elsif ( $parm eq 'exclude' ) { @exclude = split(/\,/, $val); + } elsif ( $parm eq 'include-command' ) { + $include_command = $val; + } elsif ( $parm eq 'external' ) { + # Keep dependencies in an external file + $external = $val; + } elsif ( $parm eq 'selfrule' ) { + $selfrule = !!$val; } + } elsif ( $line =~ /^(\s*\#?\s*EXTERNAL_DEPENDENCIES\s*=\s*)([01])\s*$/ ) { + $is_external = $externalize ? 1 : $force_inline ? 0 : $2+0; + $line = $1.$is_external."\n"; } elsif ( $line eq $barrier ) { - last; # Stop reading input at barrier line + $done = 1; # Stop reading input at barrier line } - print $out $line; + + push @outfile, $line; } close($in); + $is_external = $is_external && defined($external); + + if ( !$is_external || $externalize ) { + print $out @outfile; + } else { + print $out $barrier; # Start generated file with barrier + } + + if ( $externalize ) { + if ( $is_external && defined($include_command) ) { + print $out "$include_command $external\n"; + } + return undef; + } + my $e; my %do_exclude = (); foreach $e (@exclude) { $do_exclude{$e} = 1; } - my $dfile, $ofile, $str, $sl, $len; - my @deps, $dep; + foreach my $dfile ($external, sort(keys(%deps)) ) { + my $ofile; + my @deps; - print $out $barrier; + if ( $selfrule && $dfile eq $external ) { + $ofile = convert_file($dfile, $sep).':'; + @deps = sort(keys(%deps)); + } elsif ( $dfile =~ /^(.*)\.[Cc]$/ ) { + $ofile = convert_file($1, $sep).$obj.':'; + @deps = ($dfile,alldeps($dfile,1)); + } - foreach $dfile ( sort(keys(%deps)) ) { - if ( $dfile =~ /^(.*)\.[Cc]$/ ) { - $ofile = $1; - $str = convert_file($ofile, $sep).$obj.':'; - $len = length($str); - print $out $str; - foreach $dep ($dfile, alldeps($dfile,1)) { + if (defined($ofile)) { + my $len = length($ofile); + print $out $ofile; + foreach my $dep (@deps) { unless ($do_exclude{$dep}) { - $str = convert_file($dep, $sep); - $sl = length($str)+1; + my $str = convert_file($dep, $sep); + my $sl = length($str)+1; if ( $len+$sl > $maxline-2 ) { print $out ' ', $cont, "\n ", $str; $len = $sl; @@ -199,10 +237,22 @@ sub insert_deps($) { print $out "\n"; } } - close($out); - (unlink($file) && rename($tmp, $file)) - or die "$0: Failed to change $tmp -> $file\n"; + return $external; +} + +sub insert_deps($) +{ + my($mkfile) = @_; + my $tmp = File::Temp->new(DIR => dirname($mkfile)); + my $tmpname = $tmp->filename; + + my $newname = _insert_deps($mkfile, $tmp); + close($tmp); + + $newname = $mkfile unless(defined($newname)); + + move($tmpname, $newname); } # @@ -213,11 +263,20 @@ my %deps = (); my @files = (); my @mkfiles = (); my $mkmode = 0; +$force_inline = 0; +$externalize = 0; +$debug = 0; while ( defined(my $arg = shift(@ARGV)) ) { if ( $arg eq '-m' ) { $arg = shift(@ARGV); push(@mkfiles, $arg); + } elsif ( $arg eq '-i' ) { + $force_inline = 1; + } elsif ( $arg eq '-e' ) { + $externalize = 1; + } elsif ( $arg eq '-d' ) { + $debug++; } elsif ( $arg eq '-M' ) { $mkmode = 1; # Futher filenames are output Makefile names } elsif ( $arg eq '--' && $mkmode ) { @@ -244,7 +303,7 @@ foreach my $dir ( @files ) { if ( $file =~ /\.[Cc]$/ ) { push(@cfiles, $path); } elsif ( $file =~ /\.[Hh]$/ ) { - print STDERR "Filesystem: $file -> $path\n"; + print STDERR "Filesystem: $file -> $path\n" if ( $debug ); $dep_path{$file} = $path; # Allow the blank filename $dep_path{$path} = $path; # Also allow the full pathname } @@ -1 +1 @@ -2.13.04rc0 +2.14rc0 diff --git a/x86/insns.dat b/x86/insns.dat index 28f591b5..1bda0e3c 100644 --- a/x86/insns.dat +++ b/x86/insns.dat @@ -47,7 +47,9 @@ ; subheaders in the NASM documentation. ; -;# Special instructions... +;# Special instructions (pseudo-ops) +; These MUST be first in this file and must maintain the pattern of +; Dx by size, RESx by size, and INCBIN in that order. DB ignore ignore ignore DW ignore ignore ignore DD ignore ignore ignore @@ -64,6 +66,7 @@ REST ignore ignore ignore RESO ignore ignore ignore RESY ignore ignore ignore RESZ ignore ignore ignore +INCBIN ignore ignore ignore ;# Conventional instructions AAA void [ 37] 8086,NOLONG @@ -652,7 +655,6 @@ INC rm8 [m: hle fe /0] 8086,LOCK INC rm16 [m: hle o16 ff /0] 8086,LOCK INC rm32 [m: hle o32 ff /0] 386,LOCK INC rm64 [m: hle o64 ff /0] X64,LOCK -INCBIN ignore ignore ignore INSB void [ 6c] 186 INSD void [ o32 6d] 386 INSW void [ o16 6d] 186 diff --git a/x86/insns.pl b/x86/insns.pl index e6d3eee1..5845ed89 100755 --- a/x86/insns.pl +++ b/x86/insns.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl ## -------------------------------------------------------------------------- ## -## Copyright 1996-2016 The NASM Authors - All Rights Reserved +## Copyright 1996-2017 The NASM Authors - All Rights Reserved ## See the file AUTHORS included with the NASM distribution for ## the specific copyright holders. ## @@ -89,6 +89,7 @@ open(F, '<', $fname) || die "unable to open $fname"; $line = 0; $insns = 0; +$n_opcodes = $n_opcodes_cc = 0; while (<F>) { $line++; chomp; @@ -146,10 +147,14 @@ while (<F>) { } if ( $fields[0] =~ /cc$/ ) { # Conditional instruction - $k_opcodes_cc{$fields[0]}++; + if (!defined($k_opcodes_cc{$fields[0]})) { + $k_opcodes_cc{$fields[0]} = $n_opcodes_cc++; + } } else { # Unconditional instruction - $k_opcodes{$fields[0]}++; + if (!defined($k_opcodes{$fields[0]})) { + $k_opcodes{$fields[0]} = $n_opcodes++; + } } if ($formatted && !$nd) { push @big, $formatted; @@ -189,8 +194,8 @@ foreach $bl (@bytecode_list) { } undef @bytecode_list; -@opcodes = sort keys(%k_opcodes); -@opcodes_cc = sort keys(%k_opcodes_cc); +@opcodes = sort { $k_opcodes{$a} <=> $k_opcodes{$b} } keys(%k_opcodes); +@opcodes_cc = sort { $k_opcodes_cc{$a} <=> $k_opcodes_cc{$b} } keys(%k_opcodes_cc); if ( $output eq 'b') { print STDERR "Writing $oname...\n"; |