Merge remote-tracking branch 'origin/nasm-2.12.xx'

Resolved Conflicts:
	.gitignore
	Makefile.in
	Mkfiles/msvc.mak
	Mkfiles/netware.mak
	Mkfiles/openwcom.mak
	Mkfiles/owlinux.mak
	preproc-nop.c
	preproc.c
	version

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2016-05-16 21:24:26 -07:00
commit a87c5e4c87
35 changed files with 456 additions and 252 deletions

5
.gitignore vendored
View file

@ -3,6 +3,7 @@
*.dbg
*.exe
*.lib
*.i
*.lst
*.o
*.o64
@ -12,8 +13,9 @@
*.out
*.pdb
*.rej
*.xml
*.s
*.swp
*.xml
.*swo
*~
\#*
@ -40,6 +42,7 @@ TAGS
/doc/*.txt
/doc/Makefile
/doc/inslist.src
/doc/version.src
/doc/html
/doc/info
/insnsa.c

View file

@ -10,6 +10,7 @@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
objdir = @builddir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
@ -30,7 +31,7 @@ RANLIB = @RANLIB@
STRIP = @STRIP@
PERL = perl
PERLFLAGS = -I$(srcdir)/perllib
PERLFLAGS = -I$(srcdir)/perllib -I$(srcdir)
RUNPERL = $(PERL) $(PERLFLAGS)
INSTALL = @INSTALL@
@ -105,7 +106,8 @@ NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) \
LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
nasmlib/nasmlib.$(O) nasmlib/ver.$(O) \
nasmlib/file.$(O) nasmlib/realpath.$(O) \
nasmlib/ilog2.$(O) nasmlib/md5c.$(O) nasmlib/crc64.$(O)
nasmlib/ilog2.$(O) nasmlib/md5c.$(O) nasmlib/crc64.$(O) \
nasmlib/srcfile.$(O)
#-- End File Lists --#
all: nasm$(X) ndisasm$(X) rdf
@ -127,7 +129,7 @@ ndisasm$(X): $(NDISASM) $(NASMLIB)
# instruction-table file by a Perl script. They're distributed,
# though, so it isn't necessary to have Perl just to recompile NASM
# from the distribution.
INSDEP = insns.dat insns.pl insns-iflags.pl
INSDEP = insns.dat insns.pl
iflag.c: $(INSDEP)
$(RUNPERL) $(srcdir)/insns.pl -fc $(srcdir)/insns.dat
@ -219,9 +221,11 @@ perlreq: $(PERLREQ)
nsis/arch.nsh: nsis/getpearch.pl nasm$(X)
$(PERL) $(srcdir)/nsis/getpearch.pl nasm$(X) > nsis/arch.nsh
# Should only be done after "make everything"
# Should only be done after "make everything".
# The use of redirection here keeps makensis from moving the cwd to the
# source directory.
nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh
$(MAKENSIS) nsis/nasm.nsi
$(MAKENSIS) -Dsrcdir="$(srcdir)" -Dobjdir="$(objdir)" - < "$<"
# Generated manpages, also pregenerated for distribution
manpages: nasm.1 ndisasm.1
@ -382,6 +386,8 @@ nasmlib/nasmlib.$(O): nasmlib/nasmlib.c compiler.h config.h directiv.h \
pptok.h preproc.h regs.h tables.h tokens.h
nasmlib/realpath.$(O): nasmlib/realpath.c compiler.h config.h nasmint.h \
nasmlib.h
nasmlib/srcfile.$(O): nasmlib/srcfile.c compiler.h config.h hashtbl.h \
nasmint.h nasmlib.h
nasmlib/ver.$(O): nasmlib/ver.c ver.h version.h
ndisasm.$(O): ndisasm.c compiler.h config.h directiv.h disasm.h iflag.h \
iflaggen.h insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h \
@ -411,11 +417,10 @@ output/outcoff.$(O): output/outcoff.c compiler.h config.h directiv.h eval.h \
output/outdbg.$(O): output/outdbg.c compiler.h config.h directiv.h insnsi.h \
nasm.h nasmint.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h \
regs.h tables.h
output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h \
eval.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h \
output/elf.h output/outelf.h output/outform.h output/outlib.h \
output/stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h \
tables.h ver.h
output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h eval.h \
insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \
preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h
output/outform.$(O): output/outform.c compiler.h config.h directiv.h \
insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/outform.h pptok.h \
preproc.h regs.h tables.h

View file

@ -35,7 +35,7 @@ INTERNAL_CFLAGS = /I$(srcdir) /I. \
ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /RELEASE
LIBS =
PERL = perl -I$(srcdir)/perllib
PERL = perl -I$(srcdir)/perllib -I$(srcdir)
# Binary suffixes
O = obj
@ -75,7 +75,8 @@ NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) \
LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
nasmlib/nasmlib.$(O) nasmlib/ver.$(O) \
nasmlib/file.$(O) nasmlib/realpath.$(O) \
nasmlib/ilog2.$(O) nasmlib/md5c.$(O) nasmlib/crc64.$(O)
nasmlib/ilog2.$(O) nasmlib/md5c.$(O) nasmlib/crc64.$(O) \
nasmlib/srcfile.$(O)
#-- End File Lists --#
all: nasm$(X) ndisasm$(X)
@ -296,6 +297,8 @@ nasmlib/nasmlib.$(O): nasmlib/nasmlib.c compiler.h directiv.h iflag.h \
iflaggen.h insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h \
preproc.h regs.h tables.h tokens.h
nasmlib/realpath.$(O): nasmlib/realpath.c compiler.h nasmint.h nasmlib.h
nasmlib/srcfile.$(O): nasmlib/srcfile.c compiler.h hashtbl.h nasmint.h \
nasmlib.h
nasmlib/ver.$(O): nasmlib/ver.c ver.h version.h
ndisasm.$(O): ndisasm.c compiler.h directiv.h disasm.h iflag.h iflaggen.h \
insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h \
@ -324,8 +327,8 @@ output/outcoff.$(O): output/outcoff.c compiler.h directiv.h eval.h insnsi.h \
output/outdbg.$(O): output/outdbg.c compiler.h directiv.h insnsi.h nasm.h \
nasmint.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h \
tables.h
output/outelf.$(O): output/outelf.c compiler.h directiv.h eval.h \
insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
output/outelf.$(O): output/outelf.c compiler.h directiv.h eval.h insnsi.h \
nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \
preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h
output/outform.$(O): output/outform.c compiler.h directiv.h insnsi.h nasm.h \

View file

@ -56,7 +56,8 @@ NDISASM = ndisasm.o disasm.o sync.o \
LIBOBJ = snprintf.o vsnprintf.o strlcpy.o \
nasmlib.o ver.o \
file.o realpath.o \
ilog2.o md5c.o crc64.o
ilog2.o md5c.o crc64.o \
srcfile.o
#-- End File Lists --#
NASM_OBJ = $(addprefix $(OBJDIR)/,$(notdir $(NASM))) $(EOLIST)
@ -183,6 +184,7 @@ nasmlib.o: nasmlib.c compiler.h config.h directiv.h iflag.h iflaggen.h \
insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h \
regs.h tables.h tokens.h
realpath.o: realpath.c compiler.h config.h nasmint.h nasmlib.h
srcfile.o: srcfile.c compiler.h config.h hashtbl.h nasmint.h nasmlib.h
ver.o: ver.c ver.h version.h
ndisasm.o: ndisasm.c compiler.h config.h directiv.h disasm.h iflag.h \
iflaggen.h insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h \

View file

@ -22,7 +22,7 @@ LD = *wlink
LDEBUG =
LDFLAGS = op quiet $(%TARGET_LFLAGS) $(LDEBUG)
LIBS =
PERL = perl -I$(srcdir)/perllib
PERL = perl -I$(srcdir)/perllib -I$(srcdir)
STRIP = wstrip
@ -72,7 +72,8 @@ NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) &
LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) &
nasmlib/nasmlib.$(O) nasmlib/ver.$(O) &
nasmlib/file.$(O) nasmlib/realpath.$(O) &
nasmlib/ilog2.$(O) nasmlib/md5c.$(O) nasmlib/crc64.$(O)
nasmlib/ilog2.$(O) nasmlib/md5c.$(O) nasmlib/crc64.$(O) &
nasmlib/srcfile.$(O)
#-- End File Lists --#
what: .SYMBOLIC
@ -323,6 +324,8 @@ nasmlib/nasmlib.$(O): nasmlib/nasmlib.c compiler.h config.h directiv.h &
pptok.h preproc.h regs.h tables.h tokens.h
nasmlib/realpath.$(O): nasmlib/realpath.c compiler.h config.h nasmint.h &
nasmlib.h
nasmlib/srcfile.$(O): nasmlib/srcfile.c compiler.h config.h hashtbl.h &
nasmint.h nasmlib.h
nasmlib/ver.$(O): nasmlib/ver.c ver.h version.h
ndisasm.$(O): ndisasm.c compiler.h config.h directiv.h disasm.h iflag.h &
iflaggen.h insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h &
@ -352,11 +355,10 @@ output/outcoff.$(O): output/outcoff.c compiler.h config.h directiv.h eval.h &
output/outdbg.$(O): output/outdbg.c compiler.h config.h directiv.h insnsi.h &
nasm.h nasmint.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h &
regs.h tables.h
output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h &
eval.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h &
output/elf.h output/outelf.h output/outform.h output/outlib.h &
output/stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h &
tables.h ver.h
output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h eval.h &
insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h &
output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h &
preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h
output/outform.$(O): output/outform.c compiler.h config.h directiv.h &
insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/outform.h pptok.h &
preproc.h regs.h tables.h

View file

@ -37,7 +37,7 @@ ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
LD = $(CC)
LDFLAGS = $(ALL_CFLAGS)
LIBS =
PERL = perl -I$(srcdir)/perllib
PERL = perl -I$(srcdir)/perllib -I$(srcdir)
STRIP = wstrip
@ -83,7 +83,8 @@ NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) \
LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
nasmlib/nasmlib.$(O) nasmlib/ver.$(O) \
nasmlib/file.$(O) nasmlib/realpath.$(O) \
nasmlib/ilog2.$(O) nasmlib/md5c.$(O) nasmlib/crc64.$(O)
nasmlib/ilog2.$(O) nasmlib/md5c.$(O) nasmlib/crc64.$(O) \
nasmlib/srcfile.$(O)
#-- End File Lists --#
what:
@ -288,6 +289,8 @@ nasmlib/nasmlib.$(O): nasmlib/nasmlib.c compiler.h directiv.h iflag.h \
iflaggen.h insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h \
preproc.h regs.h tables.h tokens.h
nasmlib/realpath.$(O): nasmlib/realpath.c compiler.h nasmint.h nasmlib.h
nasmlib/srcfile.$(O): nasmlib/srcfile.c compiler.h hashtbl.h nasmint.h \
nasmlib.h
nasmlib/ver.$(O): nasmlib/ver.c ver.h version.h
ndisasm.$(O): ndisasm.c compiler.h directiv.h disasm.h iflag.h iflaggen.h \
insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h \
@ -316,8 +319,8 @@ output/outcoff.$(O): output/outcoff.c compiler.h directiv.h eval.h insnsi.h \
output/outdbg.$(O): output/outdbg.c compiler.h directiv.h insnsi.h nasm.h \
nasmint.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h \
tables.h
output/outelf.$(O): output/outelf.c compiler.h directiv.h eval.h \
insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
output/outelf.$(O): output/outelf.c compiler.h directiv.h eval.h insnsi.h \
nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \
preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h
output/outform.$(O): output/outform.c compiler.h directiv.h insnsi.h nasm.h \

View file

@ -334,7 +334,7 @@ static void out(int64_t offset, int32_t segto, const void *data,
int32_t segment, int32_t wrt)
{
static int32_t lineno = 0; /* static!!! */
static char *lnfname = NULL;
static const char *lnfname = NULL;
uint8_t p[8];
int asize = addrsize(type, size); /* Address size in bytes */
const int amax = ofmt->maxbits >> 3; /* Maximum address size in bytes */

View file

@ -5,3 +5,4 @@
autoheader
autoconf
rm -rf autom4te.cache config.log config.status
rm -f Makefile rdoff/Makefile doc/Makefile config.h

View file

@ -191,5 +191,5 @@ PA_ADD_CFLAGS([-Werror=missing-declarations])
PA_ADD_CFLAGS([-Werror=comment])
PA_ADD_CFLAGS([-Werror=vla])])
AC_OUTPUT_COMMANDS([mkdir -p output])
AC_OUTPUT_COMMANDS([mkdir -p nasmlib nsis output stdlib])
AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)

View file

@ -2,6 +2,7 @@
# UNIX Makefile for NASM documentation
#
top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
prefix = @prefix@
@ -16,7 +17,7 @@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
PERL = perl
PERL = perl -I$(srcdir)
MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
TEXI2IPF = texi2ipf
@ -26,7 +27,7 @@ ACRODIST = @ACRODIST@ # Acrobat Distiller
PSTOPDF = @PSTOPDF@ # BSD/MacOS X utility
PS2PDF = @PS2PDF@ # Part of GhostScript
SRCS = nasmdoc.src inslist.src changes.src
SRCS = nasmdoc.src inslist.src changes.src version.src
OUT = info html nasmdoc.txt nasmdoc.ps nasmdoc.pdf
# exports
@ -38,28 +39,35 @@ all: $(OUT)
os2: nasm.inf
inslist.src: inslist.pl ../insns.dat
$(PERL) $(srcdir)/inslist.pl
$(PERL) $(srcdir)/inslist.pl $(srcdir)/../insns.dat
.PHONY: html
html: html/nasmdoc0.html
RDSRC = $(PERL) $(srcdir)/rdsrc.pl -I$(srcdir)/
html/nasmdoc0.html: $(SRCS) rdsrc.pl
mkdir -p html
$(PERL) $(srcdir)/rdsrc.pl html < $<
$(RDSRC) html "$<"
mv -f *.html html
nasmdoc.dip: $(SRCS) rdsrc.pl
$(PERL) $(srcdir)/rdsrc.pl dip < $<
$(RDSRC) dip "$<"
nasmdoc.texi: $(SRCS) rdsrc.pl
$(PERL) $(srcdir)/rdsrc.pl texi < $<
$(RDSRC) texi "$<"
nasmdoc.txt: $(SRCS) rdsrc.pl
$(PERL) $(srcdir)/rdsrc.pl txt < $<
$(RDSRC) txt "$<"
nasmdoc.ps: nasmdoc.dip nasmlogo.eps $(srcdir)/../version genpsdriver.pl \
version.src: $(top_srcdir)/version.pl $(top_srcdir)/version
$(PERL) $(top_srcdir)/version.pl docsrc \
< $(top_srcdir)/version > version.src
nasmdoc.ps: nasmdoc.dip nasmlogo.eps \
genps.pl psfonts.ph pswidth.ph head.ps
$(PERL) $(srcdir)/genpsdriver.pl > nasmdoc.ps
$(PERL) $(srcdir)/genps.pl -headps $(srcdir)/head.ps nasmdoc.dip \
> nasmdoc.ps
nasmdoc.pdf: nasmdoc.ps
$(ACRODIST) -n -q --nosecurity -o $@ $< || \
@ -88,7 +96,7 @@ nasm.inf: nasmdoc.ipf
clean:
-rm -f *.rtf *.hpj *.texi *.gid *.ipf *.dip
-rm -f *.aux *.cp *.fn *.ky *.pg *.log *.toc *.tp *.vr
-rm -f inslist.src
-rm -f inslist.src version.src
spotless: clean
-rm -rf html info

View file

@ -8,6 +8,26 @@ The NASM 2 series supports x86-64, and is the production version of NASM
since 2007.
\S{cl-2.12.02} Version 2.12.02
\b Fix preprocessor errors, especially \c{%error} and \c{%warning},
inside \c{%if} statements.
\b Fix relative relocations in 32-bit Mach-O.
\b More Codeview debug format fixes.
\b If the MASM PTR keyword is encountered, issue a warning. This is
much more likely to indicate a MASM-ism encountered in NASM than it
is a valid label. This warning can be suppressed with \c{-w-ptr},
the \c{[warning]} directive (see \k{opt-w}) or by the macro
definition \c{%idefine ptr %??}.
\b When an error or a warning comes from the expansion of a multi-line
macro, display the file and line numbers for the expanded macros.
Macros defined with \c{.nolist} do not get displayed.
\S{cl-2.12.01} Version 2.12.01
\b Portability fixes for some platforms.
@ -48,7 +68,7 @@ since 2007.
\b Allow 64-bit outputs in 16/32-bit only backends. Unsigned 64-bit
relocations are zero-extended from 32-bits with a warning
(suppressible via \c{-w-zext-reloc}); signed 64-bit relocations are
an arror.
an error.
\b Line numbers in list files now correspond to the lines in the source
files, instead of simply being sequential.

View file

@ -1,7 +1,7 @@
#!/usr/bin/perl
## --------------------------------------------------------------------------
##
## Copyright 1996-2012 The NASM Authors - All Rights Reserved
## Copyright 1996-2016 The NASM Authors - All Rights Reserved
## See the file AUTHORS included with the NASM distribution for
## the specific copyright holders.
##
@ -36,9 +36,6 @@
# Format the documentation as PostScript
#
use Env;
use lib $srcdir;
require 'psfonts.ph'; # The fonts we want to use
require 'pswidth.ph'; # PostScript string width
@ -87,6 +84,9 @@ use Fcntl;
'11x17' => [792,1224], # US double paper size
);
# Canned header file
$headps = 'head.ps';
#
# Parse the command line
#
@ -104,6 +104,8 @@ while ( $arg = shift(@ARGV) ) {
$psconf{$parm} = shift(@ARGV);
} elsif ( $parm =~ /^(title|subtitle|year|author|license)$/ ) {
$metadata{$parm} = shift(@ARGV);
} elsif ( $parm eq 'headps' ) {
$headps = shift(@ARGV);
} else {
die "$0: Unknown option: $arg\n";
}
@ -1028,7 +1030,8 @@ foreach $fset ( @AllFonts ) {
print "/bullet [",ps_string($charcode{'bullet'}),"] def\n";
# Emit the canned PostScript prologue
open(PSHEAD, "< head.ps");
open(PSHEAD, '<', $headps)
or die "$0: cannot open: $headps: $!\n";
while ( defined($line = <PSHEAD>) ) {
print $line;
}

View file

@ -1,64 +0,0 @@
#!/usr/bin/perl
## --------------------------------------------------------------------------
##
## Copyright 1996-2009 The NASM Authors - All Rights Reserved
## See the file AUTHORS included with the NASM distribution for
## the specific copyright holders.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following
## conditions are met:
##
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above
## copyright notice, this list of conditions and the following
## disclaimer in the documentation and/or other materials provided
## with the distribution.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## --------------------------------------------------------------------------
#
# Runs the equivalent of the following command line:
#
# $(PERL) $(srcdir)/genps.pl -subtitle "version `cat ../version`" \
# nasmdoc.dip
#
# This is implemented as a Perl script since `cat ...` doesn't
# necessarily work on non-Unix systems.
#
use File::Spec;
use Fcntl;
use Env;
$perl = $ENV{PERL} || 'perl';
$srcdir = $ENV{srcdir} || File::Spec->curdir();
$versionfile = File::Spec->catfile($srcdir, File::Spec->updir(), 'version');
$genps = File::Spec->catfile($srcdir, 'genps.pl');
sysopen(VERSION, $versionfile, O_RDONLY)
or die "$0: cannot open $versionfile\n";
$version = <VERSION>;
chomp $version;
close(VERSION);
# \240 = no-break space, see @NASMEncoding in genps.pl.
# If we use a normal space, it breaks on 'doze platforms...
system($perl, $genps, '-subtitle', "version\240".$version,
@ARGV, 'nasmdoc.dip');

View file

@ -33,6 +33,7 @@
\#
\# Source code to NASM documentation
\#
\M{category}{Programming}
\M{title}{NASM - The Netwide Assembler}
\M{year}{1996-2016}
@ -45,6 +46,9 @@
\M{infotitle}{The Netwide Assembler for x86}
\M{epslogo}{nasmlogo.eps}
\M{logoyadj}{-72}
\& version.src
\IR{-D} \c{-D} option
\IR{-E} \c{-E} option
\IR{-F} \c{-F} option
@ -382,11 +386,6 @@ google for us!
development}\i{daily development snapshots} of NASM are available from
the official web site.
Announcements are posted to
\W{news:comp.lang.asm.x86}\i\c{comp.lang.asm.x86},
and to the web site
\W{http://www.freshmeat.net/}\c{http://www.freshmeat.net/}.
If you want information about the current development status, please
subscribe to the \i\c{nasm-devel} email list; see link from the
website.
@ -963,13 +962,21 @@ Enabled by default.
form of jmp instruction becomes jmp short form.
Enabled by default.
\b \i\c{zext-reloc} warns that a relocation has been zero-extended due
to limitations in the output format.
\b \i\c\{ptr} warns about keywords used in other assemblers that might
indicate a mistake in the source code. Currently only the MASM
\c{PTR} keyword is recognized.
\b \i\c{error} causes warnings to be treated as errors. Disabled by
default.
\b \i\c{all} is an alias for \e{all} suppressible warning classes (not
including \c{error}). Thus, \c{-w+all} enables all available warnings.
In addition, you can set warning classes across sections.
In addition, you can control warnings in the source code itself, using
the \i\c{[warning]} directive.
Warning classes may be enabled with \i\c{[warning +warning-name]},
disabled with \i\c{[warning -warning-name]} or reset to their
original value with \i\c{[warning *warning-name]}. No "user form"
@ -8246,4 +8253,3 @@ column shows the processor type in which the instruction was introduced and,
\A{changelog} \i{NASM Version History}
\& changes.src

View file

@ -117,11 +117,19 @@
# Includes filename. Recursion is allowed.
#
use IO::File;
use File::Spec;
@include_path = ();
$diag = 1, shift @ARGV if $ARGV[0] eq "-d";
while ($ARGV[0] =~ /^\-[Ii](.*)$/) {
push(@include_path, $1);
shift;
}
($out_format) = @ARGV;
$out_format = shift(@ARGV);
@files = @ARGV;
@files = ('-') unless(scalar(@files));
$| = 1;
@ -136,9 +144,8 @@ print "Reading input...";
$pname = "para000000";
@pnames = @pflags = ();
$para = undef;
while (defined($_ = <STDIN>)) {
$_ = &untabify($_);
&check_include($_);
foreach $file (@files) {
&include($file);
}
&got_para($para);
print "done.\n";
@ -205,8 +212,9 @@ sub untabify($) {
}
return $o;
}
sub check_include {
sub read_line {
local $_ = shift;
$_ = &untabify($_);
if (/\\& (\S+)/) {
&include($1);
} else {
@ -226,11 +234,25 @@ sub get_para($_) {
}
sub include {
my $name = shift;
my $F = IO::File->new($name)
or die "Cannot open $name: $!";
while (<$F>) {
&check_include($_);
my $F;
if ($name eq '-') {
open($F, '<-'); # stdin
} else {
my $found = 0;
foreach my $idir ( File::Spec->curdir, @include_path ) {
my $fpath = File::Spec->catfile($idir, $name);
if (open($F, '<', $fpath)) {
$found = 1;
last;
}
}
die "Cannot open $name: $!\n" unless ($found);
}
while (defined($_ = <$F>)) {
&read_line($_);
}
close($F);
}
sub got_para {
local ($_) = @_;
@ -1493,7 +1515,7 @@ sub add_item {
#
sub write_dip {
open(PARAS, "> nasmdoc.dip");
foreach $k (keys(%metadata)) {
foreach $k (sort(keys(%metadata))) {
print PARAS 'meta :', $k, "\n";
print PARAS $metadata{$k},"\n";
}

View file

@ -799,8 +799,10 @@ MFENCE void [ np 0f ae f0] X64,AMD
MONITOR void [ 0f 01 c8] PRESCOTT
MONITOR reg_eax,reg_ecx,reg_edx [---: 0f 01 c8] PRESCOTT,NOLONG,ND
MONITOR reg_rax,reg_ecx,reg_edx [---: 0f 01 c8] X64,ND
MONITORX void [ 0f 01 fa] X64,AMD
MONITORX void [ 0f 01 fa] AMD
MONITORX reg_rax,reg_ecx,reg_edx [---: 0f 01 fa] X64,AMD,ND
MONITORX reg_eax,reg_ecx,reg_edx [---: 0f 01 fa] AMD,ND
MONITORX reg_ax,reg_ecx,reg_edx [---: 0f 01 fa] AMD,ND
MOV mem,reg_sreg [mr: 8c /r] 8086,SW
MOV reg16,reg_sreg [mr: o16 8c /r] 8086
MOV reg32,reg_sreg [mr: o32 8c /r] 386
@ -893,8 +895,8 @@ MUL rm32 [m: o32 f7 /4] 386
MUL rm64 [m: o64 f7 /4] X64
MWAIT void [ 0f 01 c9] PRESCOTT
MWAIT reg_eax,reg_ecx [--: 0f 01 c9] PRESCOTT,ND
MWAITX void [ 0f 01 fb] X64,AMD
MWAITX reg_eax,reg_ecx [--: 0f 01 fb] X64,AMD,ND
MWAITX void [ 0f 01 fb] AMD
MWAITX reg_eax,reg_ecx [--: 0f 01 fb] AMD,ND
NEG rm8 [m: hle f6 /3] 8086,LOCK
NEG rm16 [m: hle o16 f7 /3] 8086,LOCK
NEG rm32 [m: hle o32 f7 /3] 386,LOCK
@ -5116,7 +5118,7 @@ WRPKRU void [ 0f 01 ef] X64,FUTURE
CLFLUSHOPT mem [m: 66 0f ae /7] FUTURE
; AMD Zen v1
CLZERO void [ 0f 01 fc] X64,FUTURE,AMD
CLZERO void [ 0f 01 fc] FUTURE,AMD
;# Systematic names for the hinting nop instructions
; These should be last in the file

54
nasm.c
View file

@ -171,6 +171,7 @@ static const struct warning {
{"hle", "invalid hle prefixes", true},
{"bnd", "invalid bnd prefixes", true},
{"zext-reloc", "relocation zero-extended to match output format", true},
{"ptr", "non-NASM keyword used in other assemblers", true},
};
static bool want_usage;
@ -339,6 +340,7 @@ int main(int argc, char **argv)
error_file = stderr;
tolower_init();
src_init();
offsets = raa_init();
forwrefs = saa_init((int32_t)sizeof(struct forwrefinfo));
@ -399,7 +401,7 @@ int main(int argc, char **argv)
preproc->cleanup(0);
} else if (operating_mode & OP_PREPROCESS) {
char *line;
char *file_name = NULL;
const char *file_name = NULL;
int32_t prior_linnum = 0;
int lineinc = 0;
@ -439,7 +441,6 @@ int main(int argc, char **argv)
nasm_fputs(line, ofile);
nasm_free(line);
}
nasm_free(file_name);
preproc->cleanup(0);
if (ofile)
fclose(ofile);
@ -479,9 +480,11 @@ int main(int argc, char **argv)
ofmt->cleanup();
cleanup_labels();
fflush(ofile);
if (ferror(ofile))
if (ferror(ofile)) {
nasm_error(ERR_NONFATAL|ERR_NOFILE,
"write error on output file `%s'", outname);
terminate_after_phase = true;
}
}
if (ofile) {
@ -502,6 +505,7 @@ int main(int argc, char **argv)
saa_free(forwrefs);
eval_cleanup();
stdscan_cleanup();
src_free();
return terminate_after_phase;
}
@ -890,8 +894,7 @@ set_warning:
for (i = 1; i <= ERR_WARN_MAX; i++)
warning_on_global[i] = !do_warn;
} else {
nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
"invalid warning `%s'", param);
/* Ignore invalid warning names; forward compatibility */
}
break;
@ -1515,9 +1518,7 @@ static void assemble_file(char *fname, StrList **depend_ptr)
warning_on[i] = warning_on_global[i];
break;
}
} else
nasm_error(ERR_NONFATAL,
"invalid warning id in WARNING directive");
}
break;
case D_CPU: /* [CPU] */
cpu = get_cpu(value);
@ -1869,19 +1870,18 @@ static enum directives getkw(char **directive, char **value)
*/
static void nasm_verror_gnu(int severity, const char *fmt, va_list ap)
{
char *currentfile = NULL;
const char *currentfile = NULL;
int32_t lineno = 0;
if (is_suppressed_warning(severity))
return;
if (!(severity & ERR_NOFILE))
src_get(&lineno, &currentfile);
src_get(&lineno, &currentfile);
if (!skip_this_pass(severity)) {
if (currentfile) {
fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno);
nasm_free(currentfile);
} else {
fputs("nasm: ", error_file);
}
@ -1907,7 +1907,7 @@ static void nasm_verror_gnu(int severity, const char *fmt, va_list ap)
*/
static void nasm_verror_vc(int severity, const char *fmt, va_list ap)
{
char *currentfile = NULL;
const char *currentfile = NULL;
int32_t lineno = 0;
if (is_suppressed_warning(severity))
@ -1919,7 +1919,6 @@ static void nasm_verror_vc(int severity, const char *fmt, va_list ap)
if (!skip_this_pass(severity)) {
if (currentfile) {
fprintf(error_file, "%s(%"PRId32") : ", currentfile, lineno);
nasm_free(currentfile);
} else {
fputs("nasm: ", error_file);
}
@ -1951,15 +1950,18 @@ static bool is_suppressed_warning(int severity)
static bool skip_this_pass(int severity)
{
/* See if it's a pass-one only warning and we're not in pass one. */
/* See if it's a pass-specific warning which should be skipped. */
if ((severity & ERR_MASK) > ERR_WARNING)
return false;
if (((severity & ERR_PASS1) && pass0 != 1) ||
((severity & ERR_PASS2) && pass0 != 2))
return true;
return false;
/*
* passn is 1 on the very first pass only.
* pass0 is 2 on the code-generation (final) pass only.
* These are the passes we care about in this case.
*/
return (((severity & ERR_PASS1) && passn != 1) ||
((severity & ERR_PASS2) && pass0 != 2));
}
/**
@ -1998,14 +2000,22 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args)
break;
}
vsnprintf(msg, sizeof msg, fmt, args);
vsnprintf(msg, sizeof msg - 64, fmt, args);
if ((severity & (ERR_WARN_MASK|ERR_PP_LISTMACRO)) == ERR_WARN_MASK) {
char *p = strchr(msg, '\0');
snprintf(p, 64, " [-w+%s]", warnings[WARN_IDX(severity)].name);
}
if (!skip_this_pass(severity))
fprintf(error_file, "%s%s\n", pfx, msg);
/* Are we recursing from error_list_macros? */
if (severity & ERR_PP_LISTMACRO)
return;
/*
* Don't suppress this with skip_this_pass(), or we don't get
* preprocessor warnings in the list file
* pass1 or preprocessor warnings in the list file
*/
if ((severity & ERR_MASK) >= ERR_WARNING)
lfmt->error(severity, pfx, msg);
@ -2013,6 +2023,8 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args)
if (severity & ERR_USAGE)
want_usage = true;
preproc->error_list_macros(severity);
switch (severity & ERR_MASK) {
case ERR_DEBUG:
/* no further action, by definition */

4
nasm.h
View file

@ -342,6 +342,9 @@ struct preproc_ops {
/* Include path from command line */
void (*include_path)(char *path);
/* Unwind the macro stack when printing an error message */
void (*error_list_macros)(int severity);
};
extern const struct preproc_ops nasmpp;
@ -421,6 +424,7 @@ enum ccode { /* condition code names */
#define TFLAG_BRC_OPT (1 << 1) /* may or may not have braces. opmasks {k1} */
#define TFLAG_BRC_ANY (TFLAG_BRC | TFLAG_BRC_OPT)
#define TFLAG_BRDCAST (1 << 2) /* broadcasting decorator */
#define TFLAG_WARN (1 << 3) /* warning only, treat as ID */
static inline uint8_t get_cond_opcode(enum ccode c)
{

View file

@ -106,6 +106,7 @@ static inline vefunc nasm_set_verror(vefunc ve)
#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() */
/*
* These codes define specific types of suppressible warning.
@ -134,7 +135,8 @@ static inline vefunc nasm_set_verror(vefunc ve)
#define ERR_WARN_HLE WARN(13) /* bad HLE prefixes */
#define ERR_WARN_BND WARN(14) /* bad BND prefixes */
#define ERR_WARN_ZEXTRELOC WARN(15) /* relocation zero-extended */
#define ERR_WARN_MAX 15 /* the highest numbered one */
#define ERR_WARN_PTR WARN(16) /* not a NASM keyword */
#define ERR_WARN_MAX 16 /* the highest numbered one */
/*
* Wrappers around malloc, realloc and free. nasm_malloc will
@ -389,16 +391,24 @@ void fwriteaddr(uint64_t data, int size, FILE * fp);
int bsi(const char *string, const char **array, int size);
int bsii(const char *string, const char **array, int size);
char *src_set_fname(char *newname);
/*
* These functions are used to keep track of the source code file and name.
*/
void src_init(void);
void src_free(void);
const char *src_set_fname(const char *newname);
const char *src_get_fname(void);
int32_t src_set_linnum(int32_t newline);
int32_t src_get_linnum(void);
/* Can be used when there is no need for the old information */
void src_set(int32_t line, const char *filename);
/*
* src_get may be used if you simply want to know the source file and line.
* src_get gets both the source file name and line.
* It is also used if you maintain private status about the source location
* It return 0 if the information was the same as the last time you
* checked, -1 if the name changed and (new-old) if just the line changed.
* checked, -2 if the name changed and (new-old) if just the line changed.
*/
int src_get(int32_t *xline, char **xname);
int32_t src_get(int32_t *xline, const char **xname);
char *nasm_strcat(const char *one, const char *two);

View file

@ -479,44 +479,6 @@ int bsii(const char *string, const char **array, int size)
return -1; /* we haven't got it :( */
}
static char *file_name = NULL;
static int32_t line_number = 0;
char *src_set_fname(char *newname)
{
char *oldname = file_name;
file_name = newname;
return oldname;
}
int32_t src_set_linnum(int32_t newline)
{
int32_t oldline = line_number;
line_number = newline;
return oldline;
}
int32_t src_get_linnum(void)
{
return line_number;
}
int src_get(int32_t *xline, char **xname)
{
if (!file_name || !*xname || strcmp(*xname, file_name)) {
nasm_free(*xname);
*xname = file_name ? nasm_strdup(file_name) : NULL;
*xline = line_number;
return -2;
}
if (*xline != line_number) {
int32_t tmp = line_number - *xline;
*xline = line_number;
return tmp;
}
return 0;
}
char *nasm_strcat(const char *one, const char *two)
{
char *rslt;

128
nasmlib/srcfile.c Normal file
View file

@ -0,0 +1,128 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 1996-2016 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.
*
* ----------------------------------------------------------------------- */
/*
* srcfile.c - keep track of the current position in the input stream
*/
#include "compiler.h"
#include <string.h>
#include <inttypes.h>
#include "nasmlib.h"
#include "hashtbl.h"
static const char *file_name = NULL;
static int32_t line_number = 0;
static struct hash_table filename_hash;
void src_init(void)
{
hash_init(&filename_hash, HASH_MEDIUM);
}
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);
}
/*
* Set the current filename, returning the old one. The input
* filename is duplicated if needed.
*/
const char *src_set_fname(const char *newname)
{
struct hash_insert hi;
const char *oldname;
void **dp;
if (newname) {
dp = hash_find(&filename_hash, newname, &hi);
if (dp) {
newname = (const char *)(*dp);
} else {
newname = nasm_strdup(newname);
hash_add(&hi, newname, (void *)newname);
}
}
oldname = file_name;
file_name = newname;
return oldname;
}
int32_t src_set_linnum(int32_t newline)
{
int32_t oldline = line_number;
line_number = newline;
return oldline;
}
void src_set(int32_t line, const char *fname)
{
src_set_fname(fname);
src_set_linnum(line);
}
const char *src_get_fname(void)
{
return file_name;
}
int32_t src_get_linnum(void)
{
return line_number;
}
int32_t src_get(int32_t *xline, const char **xname)
{
const char *xn = *xname;
int32_t xl = *xline;
*xline = line_number;
*xname = file_name;
/* XXX: Is the strcmp() really needed here? */
if (!file_name || !xn || (xn != file_name && strcmp(xn, file_name)))
return -2;
else
return line_number - xl;
}

View file

@ -26,6 +26,8 @@
# 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.
!addincludedir "${objdir}/nsis"
!addincludedir "${srcdir}/nsis"
!include "version.nsh"
!include /nonfatal "arch.nsh"
@ -50,7 +52,7 @@ SetCompressor lzma
;Name and file
Name "${PACKAGE_NAME}"
OutFile "../${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe"
OutFile "${objdir}/${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" ""
@ -67,8 +69,8 @@ Var CmdFailed
;--------------------------------
;Interface Settings
Caption "${PACKAGE_SHORT_NAME} installation"
Icon "nasm.ico"
UninstallIcon "nasm-un.ico"
Icon "${srcdir}/nsis/nasm.ico"
UninstallIcon "${srcdir}/nsis/nasm-un.ico"
!define MUI_ABORTWARNING
@ -98,10 +100,10 @@ UninstallIcon "nasm-un.ico"
Section "NASM" SecNasm
Sectionin RO
SetOutPath "$INSTDIR"
File "../LICENSE"
File "../nasm.exe"
File "../ndisasm.exe"
File "nasm.ico"
File "${srcdir}/LICENSE"
File "${objdir}/nasm.exe"
File "${objdir}/ndisasm.exe"
File "${srcdir}/nsis/nasm.ico"
;Store installation folder
WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR
@ -137,27 +139,27 @@ skip:
SectionEnd
Section "RDOFF" SecRdoff
File "../rdoff/ldrdf.exe"
File "../rdoff/rdf2bin.exe"
File "../rdoff/rdf2com.exe"
File "../rdoff/rdf2ith.exe"
File "../rdoff/rdf2ihx.exe"
File "../rdoff/rdf2srec.exe"
File "../rdoff/rdfdump.exe"
File "../rdoff/rdflib.exe"
File "${objdir}/rdoff/ldrdf.exe"
File "${objdir}/rdoff/rdf2bin.exe"
File "${objdir}/rdoff/rdf2com.exe"
File "${objdir}/rdoff/rdf2ith.exe"
File "${objdir}/rdoff/rdf2ihx.exe"
File "${objdir}/rdoff/rdf2srec.exe"
File "${objdir}/rdoff/rdfdump.exe"
File "${objdir}/rdoff/rdflib.exe"
SectionEnd
Section "Manual" SecManual
SetOutPath "$INSTDIR"
File "../doc/nasmdoc.pdf"
File "${objdir}/doc/nasmdoc.pdf"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\nasmdoc.pdf"
SectionEnd
Section "VS8 integration" SecVS8
CreateDirectory "$INSTDIR\VSrules"
SetOutPath "$INSTDIR\VSrules"
File "../contrib/VSrules/nasm.README"
File "../contrib/VSrules/nasm.rules"
File "${srcdir}/contrib/VSrules/nasm.README"
File "${srcdir}/contrib/VSrules/nasm.rules"
SectionEnd
;--------------------------------

View file

@ -285,16 +285,16 @@ static void cv8_cleanup(void)
build_type_table(type_sect);
if (cv8_state.source_file.name != NULL)
free(cv8_state.source_file.name);
nasm_free(cv8_state.source_file.name);
if (cv8_state.cwd != NULL)
free(cv8_state.cwd);
nasm_free(cv8_state.cwd);
saa_free(cv8_state.lines);
saa_rewind(cv8_state.symbols);
while ((sym = saa_rstruct(cv8_state.symbols)))
free(sym->name);
nasm_free(sym->name);
saa_free(cv8_state.symbols);
}

View file

@ -464,6 +464,8 @@ static int64_t add_reloc(struct section *sect, int32_t section,
r->snum = raa_read(extsyms, section);
if (reltype == RL_BRANCH)
r->type = X86_64_RELOC_BRANCH;
else if (reltype == GENERIC_RELOC_VANILLA)
adjust = -sect->size;
} else {
/* local */
r->ext = 0;
@ -1320,6 +1322,8 @@ static void macho_write_section (void)
l += sectstab[r->snum]->addr;
if (r->pcrel)
l -= s->addr;
} else if (r->pcrel && r->type == GENERIC_RELOC_VANILLA) {
l -= s->addr;
}
/* write new offset back */

View file

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 1996-2012 The NASM Authors - All Rights Reserved
* Copyright 1996-2016 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@ -59,8 +59,7 @@ static int32_t nop_lineinc;
static void nop_reset(char *file, int pass, StrList **deplist)
{
src_set_fname(nasm_strdup(file));
src_set_linnum(0);
src_set(0, file);
nop_lineinc = 1;
nop_fp = fopen(file, "r");
@ -120,9 +119,9 @@ static char *nop_getline(void)
int li;
char *nm = nasm_malloc(strlen(buffer));
if (sscanf(buffer + 5, "%"PRId32"+%d %s", &ln, &li, nm) == 3) {
nasm_free(src_set_fname(nm));
src_set_linnum(ln);
src_set(ln, nm);
nop_lineinc = li;
nasm_free(nm);
continue;
}
nasm_free(nm);
@ -169,6 +168,11 @@ static void nop_include_path(char *path)
(void)path;
}
static void nop_error_list_macros(int severity)
{
(void)severity;
}
const struct preproc_ops preproc_nop = {
nop_reset,
nop_getline,
@ -177,5 +181,6 @@ const struct preproc_ops preproc_nop = {
nop_pre_define,
nop_pre_undefine,
nop_pre_include,
nop_include_path
nop_include_path,
nop_error_list_macros,
};

View file

@ -154,6 +154,9 @@ struct MMacro {
uint64_t unique;
int lineno; /* Current line number on expansion */
uint64_t condcnt; /* number of if blocks... */
const char *fname; /* File where defined */
int32_t xline; /* First line in macro */
};
@ -267,7 +270,7 @@ struct Include {
FILE *fp;
Cond *conds;
Line *expansion;
char *fname;
const char *fname;
int lineno, lineinc;
MMacro *mstk; /* stack of active macros/reps */
};
@ -2517,7 +2520,7 @@ static int do_directive(Token * tline)
/* -MG given but file not found */
nasm_free(inc);
} else {
inc->fname = src_set_fname(nasm_strdup(p));
inc->fname = src_set_fname(p);
inc->lineno = src_set_linnum(0);
inc->lineinc = 1;
inc->expansion = NULL;
@ -2754,7 +2757,7 @@ issue_error:
pp_directives[i]);
return DIRECTIVE_FOUND;
}
defining = nasm_malloc(sizeof(MMacro));
defining = nasm_zalloc(sizeof(MMacro));
defining->max_depth =
(i == PP_RMACRO) || (i == PP_IRMACRO) ? DEADMAN_LIMIT : 0;
defining->casesense = (i == PP_MACRO) || (i == PP_RMACRO);
@ -2764,6 +2767,8 @@ issue_error:
return DIRECTIVE_FOUND;
}
src_get(&defining->xline, &defining->fname);
mmac = (MMacro *) hash_findix(&mmacros, defining->name);
while (mmac) {
if (!strcmp(mmac->name, defining->name) &&
@ -3571,7 +3576,9 @@ issue_error:
src_set_linnum(k);
istk->lineinc = m;
if (tline) {
nasm_free(src_set_fname(detoken(tline, false)));
char *fname = detoken(tline, false);
src_set_fname(fname);
nasm_free(fname);
}
free_tlist(origline);
return DIRECTIVE_FOUND;
@ -4128,12 +4135,10 @@ again:
*/
if (!m->expansion) {
if (!strcmp("__FILE__", m->name)) {
int32_t num = 0;
char *file = NULL;
src_get(&num, &file);
const char *file = src_get_fname();
/* nasm_free(tline->text); here? */
tline->text = nasm_quote(file, strlen(file));
tline->type = TOK_STRING;
nasm_free(file);
continue;
}
if (!strcmp("__LINE__", m->name)) {
@ -4812,7 +4817,7 @@ static void pp_verror(int severity, const char *fmt, va_list arg)
istk && istk->conds &&
((severity & ERR_PP_PRECOND) ?
istk->conds->state == COND_NEVER :
emitting(istk->conds->state)))
!emitting(istk->conds->state)))
return;
/* get %macro name */
@ -4848,8 +4853,7 @@ pp_reset(char *file, int apass, StrList **deplist)
istk->mstk = NULL;
istk->fp = fopen(file, "r");
istk->fname = NULL;
src_set_fname(nasm_strdup(file));
src_set_linnum(0);
src_set(0, file);
istk->lineinc = 1;
if (!istk->fp)
nasm_fatal(ERR_NOFILE, "unable to open input file `%s'", file);
@ -5025,10 +5029,8 @@ static char *pp_getline(void)
"expected `%%endif' before end of file");
}
/* only set line and file name if there's a next node */
if (i->next) {
src_set_linnum(i->lineno);
nasm_free(src_set_fname(nasm_strdup(i->fname)));
}
if (i->next)
src_set(i->lineno, i->fname);
istk = i->next;
lfmt->downlevel(LIST_INCLUDE);
nasm_free(i);
@ -5139,12 +5141,11 @@ static void pp_cleanup(int pass)
Include *i = istk;
istk = istk->next;
fclose(i->fp);
nasm_free(i->fname);
nasm_free(i);
}
while (cstk)
ctx_pop();
nasm_free(src_set_fname(NULL));
src_set_fname(NULL);
if (pass == 0) {
IncPath *i;
free_llist(predef);
@ -5253,6 +5254,34 @@ static void make_tok_num(Token * tok, int64_t val)
tok->type = TOK_NUMBER;
}
static void pp_list_one_macro(MMacro *m, int severity)
{
if (!m)
return;
/* We need to print the next_active list in reverse order */
pp_list_one_macro(m->next_active, severity);
if (m->name && !m->nolist) {
src_set(m->xline + m->lineno, m->fname);
nasm_error(severity, "... from macro `%s' defined here", m->name);
}
}
static void pp_error_list_macros(int severity)
{
int32_t saved_line;
const char *saved_fname = NULL;
severity |= ERR_PP_LISTMACRO | ERR_NO_SEVERITY;
src_get(&saved_line, &saved_fname);
if (istk)
pp_list_one_macro(istk->mstk, severity);
src_set(saved_line, saved_fname);
}
const struct preproc_ops nasmpp = {
pp_reset,
pp_getline,
@ -5261,5 +5290,6 @@ const struct preproc_ops nasmpp = {
pp_pre_define,
pp_pre_undefine,
pp_pre_include,
pp_include_path
pp_include_path,
pp_error_list_macros,
};

View file

@ -42,9 +42,10 @@
#include "nasmlib.h"
#include "quote.h"
char *nasm_quote(char *str, size_t len)
char *nasm_quote(const char *str, size_t len)
{
char c, c1, *p, *q, *nstr, *ep;
const char *p, *ep;
char c, c1, *q, *nstr;
unsigned char uc;
bool sq_ok, dq_ok;
size_t qlen;

View file

@ -36,7 +36,7 @@
#include "compiler.h"
char *nasm_quote(char *str, size_t len);
char *nasm_quote(const char *str, size_t len);
size_t nasm_unquote(char *str, char **endptr);
char *nasm_skip_string(char *str);

View file

@ -19,7 +19,7 @@ datarootdir = @datarootdir@
CC = @CC@
CFLAGS = @CFLAGS@
BUILD_CFLAGS = $(CFLAGS) @DEFS@
INTERNAL_CFLAGS = -I$(srcdir) -I$(top_srcdir)
INTERNAL_CFLAGS = -I$(srcdir) -I$(top_srcdir) -I..
ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

View file

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 1996-2009 The NASM Authors - All Rights Reserved
* Copyright 1996-2016 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@ -113,7 +113,7 @@ static int stdscan_handle_brace(struct tokenval *tv)
if (!(tv->t_flag & TFLAG_BRC_ANY)) {
/* invalid token is put inside braces */
nasm_error(ERR_NONFATAL,
"%s is not a valid decorator with braces", tv->t_charptr);
"`%s' is not a valid decorator with braces", tv->t_charptr);
tv->t_type = TOKEN_INVALID;
} else if (tv->t_flag & TFLAG_BRC_OPT) {
if (is_reg_class(OPMASKREG, tv->t_integer)) {
@ -166,6 +166,11 @@ int stdscan(void *private_data, struct tokenval *tv)
* is it actually a register or instruction name, or what? */
token_type = nasm_token_hash(ourcopy, tv);
if (unlikely(tv->t_flag & TFLAG_WARN)) {
nasm_error(ERR_WARNING|ERR_PASS1|ERR_WARN_PTR,
"`%s' is not a NASM keyword", tv->t_charptr);
}
if (likely(!(tv->t_flag & TFLAG_BRC))) {
/* most of the tokens fall into this case */
return token_type;

12
test/macroerr.asm Normal file
View file

@ -0,0 +1,12 @@
%include "macroerr.inc"
%macro bluttan 1
mov eax,%1
blej %1
%endmacro
bluttan ptr
blej ptr
dd ptr, ptr
ptr:

3
test/macroerr.inc Normal file
View file

@ -0,0 +1,3 @@
%macro blej 1
mov eax,%1
%endmacro

4
test/ptr.asm Normal file
View file

@ -0,0 +1,4 @@
;; This should warn but still assemble, as the code is correct
mov eax,dword ptr
ptr:

View file

@ -1,6 +1,6 @@
## --------------------------------------------------------------------------
##
## Copyright 1996-2013 The NASM Authors - All Rights Reserved
## Copyright 1996-2016 The NASM Authors - All Rights Reserved
## See the file AUTHORS included with the NASM distribution for
## the specific copyright holders.
##
@ -76,6 +76,9 @@ word
yword
zword
% TOKEN_ID, 0, TFLAG_WARN, 0
ptr
% TOKEN_FLOAT, 0, 0, 0
__infinity__
__nan__

View file

@ -1,7 +1,7 @@
#!/usr/bin/perl
## --------------------------------------------------------------------------
##
## Copyright 1996-2009 The NASM Authors - All Rights Reserved
## Copyright 1996-2016 The NASM Authors - All Rights Reserved
## See the file AUTHORS included with the NASM distribution for
## the specific copyright holders.
##
@ -178,6 +178,9 @@ if ( $what eq 'h' ) {
print $nasm_id, "\n"; # Print ID in decimal
} elsif ( $what eq 'xid' ) {
printf "0x%08x\n", $nasm_id; # Print ID in hexadecimal
} elsif ( $what eq 'docsrc' ) {
printf "\\M{version}{%s}\n", $line;
printf "\\M{subtitle}{version %s}\n", $line;
} else {
die "$0: Unknown output: $what\n";
}