Commit graph

221 commits

Author SHA1 Message Date
H. Peter Anvin (Intel)
723ab481a6 warnings: define warning classes at point of use
It is extremely desirable to allow the user fine-grained control of
warnings, but this has been complicated by the fact that a warning
class has had to be defined in no less than three places (error.h,
error.c, nasmdoc.src) before it can be used in source code. Instead,
use a script to define these via magic comments at the point of use.

This hopefully will encourage creating new classes as needed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 21:53:31 -08:00
H. Peter Anvin (Intel)
df2195b6a9 Merge remote-tracking branch 'origin/nasm-2.14.xx'
Resolved Conflicts:
	Makefile.in
	Mkfiles/msvc.mak
	Mkfiles/openwcom.mak
	asm/nasm.c
	nasmlib/alloc.c

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 16:43:43 -08:00
H. Peter Anvin (Intel)
3b91f4c117 malloc: handle potential infinite loop in nasm_alloc_failed()
It is possible on memory exhaustion that nasm_fatal() might cause
another allocation error, thus calling nasm_alloc_failed() again. If
we find us in nasm_alloc_failed() for a second time, try to get a
message out and then call abort().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 13:55:25 -08:00
H. Peter Anvin (Intel)
eb5b3ae0d3 nasmlib: Add nasm_(v)asprintf()
Add a version of (v)asprintf(), which allocates a string on the
heap. Unlike the standard version of (v)asprintf(), we return the
pointer; if one wants the length of the string then one can simply use
the %n pattern.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 14:34:34 -08:00
H. Peter Anvin (Intel)
64471097ca strlist: merge the strtbl and strlist interfaces
The currently-unused strtbl was basically a slightly different version
of strlist, with the find and linearize capabilities. Merge these two
together by augmenting strlist to have the same capabilities.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-11 13:37:32 -08:00
H. Peter Anvin
1aa794527f Move srcfile.c to asm/
srcfile.c is not used by anything outside asm/, so move it there.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-10 23:03:04 -08:00
H. Peter Anvin
1350620bf1 ctype: create our own ctype table
Create our own ctype table where we can do the tests we want to do
cheaply, instead of calling ctype functions and then adding additional
tests all over the code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-11-28 14:55:58 -08:00
H. Peter Anvin
50bbafbffb Makefile.in: fix building RDOFF
Apparently it isn't just NMAKE which is sensitive to the ordering of
.SUFFIXES, it apparently applies just as well to Unix make.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-18 14:02:29 -07:00
H. Peter Anvin
5d8193367e MSVC: fix dependency generation and building RDOFF under MSVC
1. The mkdep.pl program didn't handle excluded dependencies correctly,
   causing it to error out due to config/config.h not existing.
2. NMAKE is sensitive to the order suffixes appear in .SUFFIXES,
   causing it to try to use the builtin rule .c.exe instead of
   .c.obj -> .obj.exe.
3. NMAKE doesn't handle the && operator between commands.
4. The !ifdef jungle around dependency generation was wrong.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-18 13:54:43 -07:00
H. Peter Anvin
675618c5dd Makefile.in: remove duplicated $(ALL_CFLAGS)
We really don't need every C compiler flag repeated twice.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-15 17:41:46 -07:00
H. Peter Anvin
81b62b9f54 Eliminate filename length restrictions, remote ofmt->filename()
Get rid of remaining dependencies on FILENAME_MAX, which ought to have
been removed a long time ago.

Remove ofmt->filename(); all implementations pretty much do the same
thing and there is absolutely no reason to duplicate that
functionality all over the place.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-12-20 13:38:20 -08:00
H. Peter Anvin
4b70b62ba2 Makefile.in: fix typo in pathname
tools/ not qtools/

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 15:27:51 -08:00
H. Peter Anvin
cae5d06184 More autoconf modernizations; upgrade AC_PREREQ to 2.69
Make further autoconf rule improvements and update the required
version of autoconf to 2.69.  That version is now 5+ years old and
although there might be older versions which have the prerequisite
macros they are known to have lots of bugs, and we can't really test
them.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-08 10:22:10 -08:00
H. Peter Anvin
ceeaf11e66 Make dependency generation a bit more robust
Improve the corner cases where we might end up with bogus
dependencies.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-11-06 22:37:37 -08:00
H. Peter Anvin
ad4016952d Makefile: don't store dependency information in git
Make it possible to keep dependency information separate from the
Makefiles, so we don't have to deal with it noisifying the git logs.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-01 14:00:34 -07:00
H. Peter Anvin
77696c7768 make alldeps 2017-11-01 10:51:00 -07:00
H. Peter Anvin
0a126062fb ilog2(): inline functions if practical
For many (most?) targets these will be very small functions, so inline
them.  However, just in case make these external library functions.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 13:34:42 -07:00
Cyrill Gorcunov
20d9c86eb1 build: Merge CPPFLAGS into ALL_CFLAGS
This is a fix for a4f6ca5a33

 - We should not use sole CPPFLAGS when compiling,
   but rather merge it into ALL_CFLAGS

 - nasm.spec.in should use DESTDIR since
   INSTALLROOT now renamed to it

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-06 01:36:06 +03:00
David Seifert
a4f6ca5a33 Make buildsystem respect GNU conventions
* CPPFLAGS is a user variable and should be respected
  when compiling .c files. Think of -D_FORTIFY_SOURCE=2.

* Pass ALL_CFLAGS when linking too. This is recommended
  for certain edge cases (-flto)

* Use DESTDIR instead of INSTALLROOT for staging dir
  Every other build system (Automake, CMake, Meson) uses
  DESTDIR. This integrates better into distro and other
  build systems that have standard hooks for DESTDIR.

* $(MAKE) -C <dir> is better than cd'ing into a <dir>

* Use Autoconf's ${docdir} and ${htmldir} for installing
  the documentation. This makes handling documentation
  easier and respects user choice.

Signed-off-by: David Seifert <soap@gentoo.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-06 01:28:57 +03:00
H. Peter Anvin
97408d67dd Merge remote-tracking branch 'origin/elf' 2017-04-29 13:28:12 -07:00
H. Peter Anvin
4aa13c9e81 Makefile.in: better filter for Perl dependencies
Be a bit smarter about what to require and what to ignore.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-26 00:21:40 -07:00
H. Peter Anvin
d3e22572b3 Clean up byteorder functions
Move byte order handling functions to their own header file, and try
to be more specific about how exactly to handle things.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 13:01:08 -07:00
H. Peter Anvin
bf0bcef3d4 output: generic string table implementation
Several output formats use "string tables", which is a collection of
null-terminated (C) strings which are referenced by a byte offset into
the string table.  A single string can be referenced an arbitrary
number of times.

As this is quite simple to implement with a hash table, we do exactly
that.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 00:23:03 -07:00
H. Peter Anvin
0979957e19 nasmlib: add path-splitting functions
Some debugging formats may need to be able to split paths into
directory name and filename, at least.  This is kind of iffy, at least
across platforms, but that isn't really expected to be an issue in
practice... we hope.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 22:39:53 -07:00
H. Peter Anvin
3e019c9197 nasm.spec: s/Build-Requires/BuildRequires/
Fix incorrectly spelled tag.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 18:58:53 -07:00
H. Peter Anvin
16ffec1864 nasm.spec: use a sed file to insert perl dependencies
There are just too many ways that an inline sed script can screw up.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 18:54:23 -07:00
H. Peter Anvin
cf96845bf6 nasm.spec: sync with Fedora spec file, auto-generate Perl depends
Sync up with how the Fedora spec file has evolved.
Auto-generate the Perl build dependencies.
Add --enable-lto: it makes especally the rdoff files much smaller.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 18:33:53 -07:00
H. Peter Anvin
8dc965347d rdoff: use nasm-provided safe memory allocation and I/O
We already have abort-on-error memory allocation and I/O operations in
nasmlib, so use them for rdoff as well.

Delete long-since-obsolete rdoff Mkfiles directory.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 13:56:50 -07:00
H. Peter Anvin
717695f440 Makefile.in: add $(X) to the list of suffixes
If $(X) is not empty, it needs to be added as a suffix, otherwise the
rule .$(O)$(X) won't do anything at all.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 23:33:42 -07:00
H. Peter Anvin
910ae64b31 Makefile.in: more fixes to rdoff commands
The rdoff command links are cantankeous.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 23:18:36 -07:00
H. Peter Anvin
28b9f7a9c2 Makefile.in: fix install_rdf some more...
Apparently I have a hard time getting this right today.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 22:48:42 -07:00
H. Peter Anvin
3a864c1670 Makefile.in: missing \ broke "make install_rdf"
A missing backslash broke "make install_rdf", and therefore broke the
build robot.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 22:42:44 -07:00
H. Peter Anvin
dd26697412 Makefile.in: fix dumb mistakes
Fix a few dumb but serious mistables in Makefile.in that prevented
anything from actually getting linked.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 18:42:39 -07:00
H. Peter Anvin
070508a5ae Makefile.in: make rules for rdoff only define dependencies
MSVC command-line syntax doesn't allow us to share these rules if
explicit.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 18:08:43 -07:00
H. Peter Anvin
9a714c98a2 rdoff: move rdoff build into main Makefile to make it build on Windows
NSIS packages rdoff, and we really want to be able to build the full
NSIS package on an MSVC platform.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-06 17:24:03 -07:00
H. Peter Anvin
90cc4154ae BR 3392397: WMAKE uses a nonstandard syntax for phony targets
The standard syntax for a phony target in Make is:

target: <dependencies>

.PHONY: target

... however, Watcom WMAKE seems to use

target: <dependencies> .SYMBOLIC

and furthermore, seems to *require* it.  Therefore, remove the
"perlreq" target from the automatically distributed region and move it
into the specific region; it should not need to change anyway since
the PERLREQ list itself is still synced.

If it was only a matter of the .SYMBOLIC versus .PHONY token it would
be easy enough to change that in syncfiles.pl, but this syntax change
is big enough that it doesn't make enough sense to worry about.

Reported-by: sezero <sezero@users.sourceforge.net>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-05 21:24:55 -07:00
H. Peter Anvin
14858d7343 Makefiles: distribute file generation rules via syncfiles.pl
Distribute the file generation rules to auxiliary Makefiles via
syncfiles.pl.  These rules are OS- and Make-dialect-generic enough
that our mangling script handles them well enough.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-03 11:13:29 -07:00
H. Peter Anvin
526a6c7390 Rename insns-iflags.pl -> insns-iflags.ph, add missing dependency
insns-iflags.ph is included from another Perl script, so rename it .ph
(Perl header).  Add missing dependency to the main Makefile.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-03 10:33:12 -07:00
H. Peter Anvin
5253f58c36 Add generic perfect string hashes, use for directives
Add a generic facility for generating perfect string hashes, where all
that is needed is an enum and a string table.  The existing mechanism
using a custom Perl script wrapped around a module continues to be
available for any use case where this particular approach isn't
sophisticated enough.

Much of this patch comes from renaming "enum directives" to "enum
directive" as a result of the string hash generator expecting a set of
uniform naming conventions.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-03 00:27:07 -07:00
H. Peter Anvin
ea33e83081 Run "make alldeps"
Missing dependencies strike again :(

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-08 01:31:10 -08:00
H. Peter Anvin
a6e26d9cca Add a generic pragma-handling infrastructure
Add infrastructure for handling %pragmas with a variety of namespaces,
etc., etc...

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 21:32:37 -08:00
H. Peter Anvin
b20bc733c9 asm/*: Move directive processing to its own file, refactor error handling
Move directive processing to its own file, and move nasmlib/error.c to
asm/error.c (it was not used by the disassembler); remove some extern
declarations from .c files, and do some general code cleanups.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 19:31:04 -08:00
H. Peter Anvin
ed40e2528d Rename directiv.c to directbl.c to free up the name directiv.c
We want to move the directive handling to a separate file, so change
the filename of the directive table handler to something a bit more
specific.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 18:08:03 -08:00
H. Peter Anvin
6980985eb9 make clean: clean up more things that ought to be
Cleaning up hasn't really kept up to date with source code changes.
Try make it better for now; this also ought to make it easier to do
the corresponding cleaning in the *.mak files.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-01 01:23:00 -08:00
H. Peter Anvin
2d6a3101f9 Run make alldeps 2017-02-28 18:14:35 -08:00
H. Peter Anvin
a5a56bd117 exprlib: move dumping code to a separate C file
Most of the time we don't need the dumping code, so move it to a
separate C file to the linker can exclude it.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 18:13:43 -08:00
H. Peter Anvin
4d58a8fef5 Makefile: move all non-main objects into libnasm.a
There is no fundamental reason for all objects that don't contain a
main() function to not be part of libnasm.a; this allows the linker to
do its job optimally, especially in the presence of debugging code
which may not be needed under normal conditions.

If we do end up with function name conflicts the library might have to
be split, but it would be better to simply avoid that case.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-02-28 18:08:21 -08:00
H. Peter Anvin
9222364607 nasmlib/file: move memory-mapping functions out of file.c
Move memory-mapping functions from file.c into a separate mmap.c.
This will be cleaner especially once (if) we end up doing a Windows
implementation, which is likely to look entirely different.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-02-23 18:39:00 -08:00
H. Peter Anvin
f5287231c1 Move canned OpenWatcom config to config/watcom.h.
Move the canned OpenWatcom configuration file to config/watcom.h.
Also exclude config/config.h from being a dependency for MSVC.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-19 13:23:04 -07:00
H. Peter Anvin
1fe546cf35 Run make alldeps
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-14 15:09:52 -07:00