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>
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>
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>
Sometimes we really want to use an extended pathname for an include
file, for documentation purposes; e.g. "config/config.h". This makes
alldeps handle that case correctly (and also adds the config/
directory to directories scanned by alldeps).
It is unclear if this will work correctly if there are include files
with the same name in different directories, but we currently do not
have any case like that.
Reported-by: anonymous coward <nasm64developer@users.sf.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Instead of trying to do hacks in the Makefiles, define header files
for specific compilers if they can't use autoconf. Currently defined
for Microsoft Visual Studio, based on MSDN documentation. It is
currently untested.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
nasmlib.c had basically turned into a garbage bin of various functions
with very little in common. Break it up into logical components for
isolation and manageability.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The old code for keeping track of source file name and line was
confused as hell about ownership of the strings, and it is pretty
clear we leaked that information all over the place.
Instead, use a hash table to keep a copy of each string as necessary,
and simply make references to a string pool that we keep until the end
of the assembly session.
This pool probably should be unified with the list of dependency
files, and so on, but that is for the development branch.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
There is a bunch of common code here so merge them all into one file.
Unmergable parts are wrapped with is_elf() helpers.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Added missing rules for creating a library out of LIBOBJ
and using it when linking.
* Updated the clean rule and PRELREQ list.
* Always build with debug info as it ends up in external PDB files
anyway and doesn't really impact binary size.
* Added /RELEASE to the LDFLAGS so the linker checksums the headers and
the binary can be signed.
Signed-off-by: Knut St. Osmundsen<bird-nasm@anduin.net>
Reviewed-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Split lib/ into nasmlib/ (for nasm-specific functions) and stdlib/
(for replacements for C library functions which may be missing.)
Rename the ersatz inttypes.h to nasmint.h so we can use a simple test
in compiler.h instead of dealing with include path magic.
Remove tests in configure.in for ancient missing functions (which will
break the build anyway.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Move version strings to a separate header, instead of needing to
include nasm.h in places where it probably really doesn't belong.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
There is no reason to not use an archive manager to build our
executables. If there really are systems which don't have any kind of
archive manager, we can simply link all the objects.
This also drops any use of configure to detect library objects.
Instead just use HAVE_* and let the archive manager delete them.
A lot of additional functions could be declared library functions and
reorganized.
***FIX*** Mkfiles/*.mak have not yet been updated.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
nasmlib.[ch] desperately need to be broken up into smaller chunks.
Break file I/O related functions out into file.c, so at least we can
avoid the problem with P_WAIT being defined in <io.h> on Windows but
is also used as a prefix constant in "nasm.h".
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Per the MSVC++ docs, /Ox and /Oy are redundant with /O2, and the docs
recommend that they do not be used together.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
For consistency with ofmt/dfmt, change the listing structure
to "struct lfmt" and "lfmt" and move it to listing.h.
From master branch commit 8ac25aa020
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
For consistency with ofmt/dfmt, change the listing structure
to "struct lfmt" and "lfmt" and move it to listing.h.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Merge the two Mach-O backends for cleanliness and maintainability.
This should also make the recent fixes to MachO-64 available in
MachO-32.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The previous commit contained unnecessary dependencies for realpath.c
so run make alldeps to remove those.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Try harder to nasm_realpath() to be as portable as possible. Move it
to a separate file since it has gotten complex enough that it is
cleaner that way.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Codeview is a debug format for win32/win64 PE/COFF files. It adds two sections,
.debug$S (symbols) and .debug$T (types), to the generated object file. These
sections are then used by the linker to generate a PDB file which can be used
by various debuggers (WinDbg, Visual Studio, etc).
Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This implementation was written by Colin Plumb and
is in the public domain.
I've updated it to use stdint.h and the standard C types rather than
sys/types.h for portability.
Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Adds a new Makefile variable DEBUG that controls whether a symbol file (.PDB)
is created for the executables, e. g., nmake -f Mkfiles\msvc.mak DEBUG=1
Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
45a22d9a61 changes the arguments of insns.pl
and adds a new autogenerated header iflaggen.h. Update the nmake Makefile
accordingly.
Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
Apparently some people still care about compiling native on MS-DOS,
and we don't have a significant number of files which need adjustment.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Add ilog2_{32,64}() and alignlog2_{32,64}() ... the latter is intended
for alignment statements and return -1 for non-power-of-2 other than 0
(which returns 0).
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>