Commit graph

3447 commits

Author SHA1 Message Date
Martin Lindhe
8cc93f5232 assemble_file: Get rid of global variable @sb
fixes pvs-studio error 'V707 Giving short names to global variables
is considered to be bad practice. It is suggested to rename 'sb' variable.

gorcunov@: Use local non-static variable.

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
58f37c1736 parser: Get rid of global variable
fixes pvs-studio error 'V707 Giving short names to global variables
is considered to be bad practice. It is suggested to rename 'i' variable.

gorcunov@: Simply define it as local variable.

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
ec8b2081d3 macho: Improve macho_calculate_sizes
pvs-studio error 'V629 Consider inspecting the '1 << s->align' expression.
Bit shifting of the 32-bit value with a subsequent expansion to the 64-bit type.'

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
d551b431a1 Move @debugid declaration to same level as @q
fixes pvs-studio error 'V507 Pointer to local array 'debugid' is
stored outside the scope of this array. Such a pointer will become invalid.'

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
058782948d nasmlib: md5c -- Use size of struct ctx for memset
fixes pvs-studio 'V512 A call of the 'memset' function will lead to
underflow of the buffer 'ctx'.'

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
3478078c5f disasm: matches -- fix operator priority error with parenthesis
fixes pvs-studio error 'V502 Perhaps the '?:' operator works in a different way
than it was expected. The '?:' operator has a lower priority than the '!=' operator.'

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
f172526697 outas86: Shrink as86_section_names
fix pvs-studio error 'V581 The conditional expressions of the 'if'
operators situated alongside each other are identical.
Check lines: 170, 173.'

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
5b85276196 outcoff: Shrink coff_section_names
fix pvs-studio error 'V581 The conditional expressions of the 'if'
operators situated alongside each other are identical. Check lines: 304, 311.'

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
42aa10c985 output,aout: Improve aout_section_names
fix pvs-studio error 'V581 The conditional expressions of the 'if'
operators situated alongside each other are identical.
Check lines: 246, 249.'

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
b150e386ae Drop redundant test with isnumchar
Fix pvs-studio error 'V501 There are identical sub-expressions
'(c) == '_'' to the left and to the right of the '||' operator.'. isnumchar()
is a macro defined as (nasm_isalnum(c) || (c) == '_')

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
9b5aa2e6d0 Drop redundant test with isnumchar
fix pvs-studio error 'V501 There are identical sub-expressions '(c) == '_'' to
the left and to the right of the '||' operator.'. isnumchar() is a macro
defined as (nasm_isalnum(c) || (c) == '_')

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
Martin Lindhe
e29e321e62 Dont set @mod twice
pvs-studio: V519 The 'mod' variable is assigned values twice successively.
Perhaps this is a mistake. Check lines: 398, 405.

Signed-off-by: Martin Lindhe <martin-commit@ubique.se>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-01-05 22:38:41 +03:00
H. Peter Anvin
abd28c9ab9 If we have new features introduced by C11, use them
Instead of using hacks or compiler-specific features, if we have
standard features as defined in ISO C11, use them.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-12-20 02:29:58 -08:00
Cyrill Gorcunov
fd610f27d6 asm/parser.c -- Fix typo in testing for register
It should be EXPR_REG_END referred when testing
for register present.

A typo in 472a7c1d17

https://bugzilla.nasm.us/show_bug.cgi?id=3392375

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-11-29 01:17:33 +03:00
H. Peter Anvin
7294d62040 compiler.h: use the correct symbol to test for __builtin_expect()
__builtin_expect() has leading underscores, they need to be reflected
in the symbol.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 15:53:38 -08:00
H. Peter Anvin
8d4fb26ad4 Various fixes to the ilog2 functions
Fix several bugs in the ilog2 functions.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 14:23:54 -08:00
H. Peter Anvin
069ad5fc18 nasmlib: we need the exact size for the clz functions
We need to use the exact size for the clz functions, otherwise we will
generate the wrong result.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 14:05:53 -08:00
H. Peter Anvin
8b19083483 Better support for function attributes, autoconf cleanups
Use autoconf to detect function attributes; some compilers like Sun CC
do support some gcc-style attributes, but don't define __GNUC__.  Also
-U__STRICT_ANSI__ already in configure.ac so our tests match what we
might eventually encounter.

Add const_func and pure_func attributes.

Decorate functions in nasmlib.h with const_func and pure_func.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 14:01:37 -08:00
H. Peter Anvin
70d0458050 Merge remote-tracking branch 'origin/nasm-2.12.xx'
Resolved Conflicts:
	output/outelf32.c
	output/outelf64.c

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 12:00:23 -08:00
H. Peter Anvin
456b1c46f8 doc/changes.src: document the RDPID instruction
Add RDPID to changes.src.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 11:56:42 -08:00
H. Peter Anvin
c7ea29b247 Add rdpid instruction
Add the RDPID instruction, documented in the Intel SDM October 2016.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-11-15 11:55:14 -08:00
Cyrill Gorcunov
48fe2eea27 output: outelf,dwarf -- Add missing DW_LNS_copy
Backport of master commit ed347369ae

https://bugzilla.nasm.us/show_bug.cgi?id=3392325

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-11-06 18:38:34 +03:00
Cyrill Gorcunov
4d79eed7b7 x86/insns.dat -- Fix typo in VMOVDQA instruction
https://bugzilla.nasm.us/show_bug.cgi?id=3392369

Reported-by: Agner <agner@agner.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-11-05 16:39:27 +03:00
Hilmar Ackermann
ed347369ae output: outelf,dwarf -- Add missing DW_LNS_copy
https://bugzilla.nasm.us/show_bug.cgi?id=3392325

Signed-off-by: Hilmar Ackermann <hilmar.ackermann@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-11-05 15:12:45 +03:00
H. Peter Anvin
472a7c1d17 Allow relative references to external symbols in data
Allow constructs like:

      dd foo - $

... where foo is an external symbol.  Currently this is only
implemented for extops, i.e. dx opcodes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-31 08:44:25 -07:00
Cyrill Gorcunov
6600eb1188 x86/insns.dat -- Fix typo in VMOVDQA instruction
https://bugzilla.nasm.us/show_bug.cgi?id=3392369

Reported-by: Agner <agner@agner.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-10-23 18:13:25 +03:00
Cyrill Gorcunov
a1461a5a89 nsis: Use Program Files (x86) directory for nasm installation on x86-64
https://bugzilla.nasm.us/show_bug.cgi?id=3392365

Reported-by: Mat <mberchtold@gmail.com>
Based-on-patch-by: Mat <mberchtold@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-10-23 16:27:48 +03:00
Cyrill Gorcunov
9e8c2466a4 nsis: Import x64.nsh
From NSIS-3.0 source code (Include/x64.nsh).
Hopefully it will be enough for nsis-v2.5
to support Win64.

https://sourceforge.net/p/nsis/code/HEAD/tree/NSIS/trunk/Include/x64.nsh

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-10-23 16:27:44 +03: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
4c9132e3a0 compiler.h: include <sys/types.h>
Apparently, at least on some OS/2 compilers, <sys/types.h> needs to be
included for off_t to be defined.  This seems like a generically good
idea to include this header whenever it is available.

Remove reference to <types.h>.  This was supposedly for MSVC, but
there is no actual evidence that it is useful beyond <sys/types.h>.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-19 13:13:38 -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
H. Peter Anvin
44e3a11087 compiler.h: fix typo in the non-gcc case
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-14 15:05:28 -07:00
H. Peter Anvin
9b733a5845 compiler.h: for newer gcc attributes, we can use __has_attribute()
For newer gcc attributes, we can use __has_attribute() to test for
attribute presence.  This improves compatibility both with older gcc
and with clang, at least with -Werror enabled.

Reported-by: Daniel Lundqvist <daniel@malarhojden.nu>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-14 15:01:06 -07:00
H. Peter Anvin
9df6b4c8c2 output/legacy.c: include outlib.h
Add outlib.h for the prototype of nasm_do_legacy_output().

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-06 14:19:02 -07:00
H. Peter Anvin
8220533cda rdoff/rdlar.h: include "compiler.h" not "config.h"
We should not include config.h "naked"; include "compiler.h".

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-06 14:18:21 -07:00
H. Peter Anvin
c58b4c3c76 distclean: clean up config/config.h
When doing "make distclean", clean config/config.h as config.h has
moved.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-06 14:17:38 -07:00
H. Peter Anvin
93c93b0a2e alldeps: handle uses of full pathnames, e.g. "config/config.h"
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>
2016-10-06 14:12:39 -07:00
H. Peter Anvin
194751404b nasmint.h: change header guards to NASM_NASMINT_H
Change the header guards for nasmint.h to NASM_NASMINT_H instead of
INTTYPES_H.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 18:11:57 -07:00
H. Peter Anvin
4b189f89d0 nasmint.h: add support for the MSVS < 2005 __int64 type
MSVS < 2005 doesn't have "long long", so use the MSVC-specific
__int64, I64, and ...[u]i64 constructs.  nasmint.h makes this easy
enough that it is worth doing.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 18:09:01 -07:00
H. Peter Anvin
2024ae60d6 config/msvc.h: inttypes.h and stdbool.h introduced in MSVS 2013
<inttypes.h> and <stdbool.h> were introduced in MS Visual Studio 2013,
not 2015.  See:

https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 17:50:53 -07:00
H. Peter Anvin
276785a8ff config: add configuration file for unknown compilers
Add a config header file for the most conservative case of a totally
unknown compiler.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 17:13:50 -07:00
H. Peter Anvin
397c169736 Move config.h to a subdirectory, add MSVC-specific config file
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>
2016-10-04 17:01:59 -07:00
H. Peter Anvin
9255b51369 test: simple pragma preprocessor test
Simple test to examine the preprocessor output from %pragma.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 15:01:34 -07:00
H. Peter Anvin
bc7f4fe275 preproc: add plumbing for the %pragma directive
Plumb the %pragma directive through the preprocessor and make it
generate an assembly directive unless given as %pragma preproc.  So
far no actual pragmas are actually defined.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 14:57:17 -07:00
H. Peter Anvin
76c49379b7 test/Makefile: add rule to generate preprocessor output
Add a rule in the test directory to run the preprocessor.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 14:56:37 -07:00
H. Peter Anvin
e93572e6be Merge remote-tracking branch 'origin/nasm-2.12.xx' 2016-10-04 14:09:07 -07:00
H. Peter Anvin
3f87a2ac50 preproc: add dummy %pragma directive
In future versions of NASM we will presumably have "real" pragmas; add
dummy support for the %pragma directive for forward compatibility.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-10-04 14:07:19 -07:00
Daniel Lundqvist
439875c1d9 ldrdf: Remove output file if there are any errors
If there are any errors while linking, we should not create an
output file.

Signed-off-by: Daniel Lundqvist <daniel@malarhojden.nu>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 03:36:27 -07:00
H. Peter Anvin
436e367874 Factor out common string list handling code
Simplify the preprocessor code by factoring out the common string list
handling code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 01:12:28 -07:00
H. Peter Anvin
9924d1ea85 preproc: clean up handing of the dependency lists
We search the dependency list anyway (ouch...) so we might as well
use that instead of keeping track of a tail pointer.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-10-04 00:59:39 -07:00