Commit Graph

3090 Commits

Author SHA1 Message Date
H. Peter Anvin
6a5b3ecb16 codeview: use nasm_free() instead of plain free()
We want to consistently use our allocator wrapper functions whereever
possible.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-10 15:40:24 -07:00
Cyrill Gorcunov
771d04e263 preproc: Don't dereference nil @istk
If not input was specified istk = NULL, so don't dereference it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-05-10 23:27:03 +03:00
H. Peter Anvin
acb48602fc srcfile.c: remove unnecessary #include's
Remove #include's inherited from nasmlib.c which aren't needed in this
file.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-10 09:01:10 -07:00
H. Peter Anvin
cfbdc3c6fa NASM 2.12.02rc4 2016-05-10 03:12:28 -07:00
H. Peter Anvin
02f49f2c1e stdscan: put some error message strings in quotes
Put some error message strings inside `...' quotes to match existing
usage.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-10 03:08:09 -07:00
H. Peter Anvin
274cda81f8 Use a hash to keep exactly one copy of each filename around
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>
2016-05-10 03:01:58 -07:00
H. Peter Anvin
b157701b17 quote: make the input argument to nasm_quote() const
Whereas nasm_unquote() unquotes the argument in place, nasm_quote()
has to allocate a new string (since the new string will *always* be
longer than the old string!)  Make the old string const since we're
making a copy anyway.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-10 02:59:04 -07:00
Fabian Giesen
c74a709885 codeview: Call register_file only when producing line numbers
Previously, debug info would refer to the first file seen, even
when it did not actually generate line numbers (e.g. segto=-1).

Fix it so we only lock in the file name the first time we actually
produce a line number record. Not as good as proper support for
debug info referencing multiple source files but much more useful
than the current behavior.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-05-10 12:01:32 +03:00
Fabian Giesen
142285ddd8 codeview: Make md5sum calc read file in 'binary' mode
When assembling on Windows machines with CRLF line endings, computing
the MD5 hash from the file read in "text" mode (transforms CRLF->LF)
gives incorrect results.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-05-10 12:01:22 +03:00
Fabian Giesen
86d8756f0c codeview: Look up %include path when determining files to hash.
The hash calculation in calc_md5 tries to open the source file via
"filename" again. For %includes, this is the file name that was
specified in the %include directive, not the actual name of the file
that was opened by the preprocessor. In other words, this fails if the
include file is not in the current working directory.

Add pp_input_fopen that uses the preprocessor include path lookup
code to resolve a file name and open it, and use that in codeview.c.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-05-10 12:01:08 +03:00
H. Peter Anvin
31c97fb89e NASM 2.12.02rc3 2016-05-09 14:37:39 -07:00
H. Peter Anvin
77511e32a7 doc: document warning improvements
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 14:36:59 -07:00
H. Peter Anvin
f43aedac23 .gitignore: add .s and .i files
.s and .i files can be generated during debugging.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 14:14:11 -07:00
H. Peter Anvin
3736895c07 Fix and clean up listing of macro expansion
Fix the printing of the macro stack: we need to follow the
mstk->next_active list, not mstk->next, and we need to reverse the
order so that the highest-level inclusion comes first.

Since this should be a rare or at least performance-insensitive
operation, do it using simple function recursion.

Finally, add an ellipsis before the "from macro" message; it greatly
enhances readability.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 14:10:32 -07:00
H. Peter Anvin
4def1a8db4 Show the expanded macro stack when displaying diagnostics
It can be hard to find errors inside potentially nested macros.
Show the mmacro expansion stack when printing diagnostics.
Note that a list file doesn't help for errors that are detected
before the code-generation pass.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 13:59:44 -07:00
H. Peter Anvin
b4f734fb84 Ignore unrecognized warning names
If we get an invalid warning name passed to the -w/-W option or the
[warning] directive, ignore it.  This may be a warning name enabled in
a future version of NASM, and it is rather pointless to error out on
it.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 12:13:08 -07:00
H. Peter Anvin
19bc9de9d0 doc/changes.src: document PTR warning
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 12:09:04 -07:00
H. Peter Anvin
69550eac55 Specifically if we encounter the PTR keyword
Issue a specific suppressible warning if we encounter the PTR keyword.
This usually indicates someone mistakenly using MASM syntax in NASM.

This introduces a generic infrastructure for issuing warnings for such
keywords.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 12:05:56 -07:00
H. Peter Anvin
934f0478d4 Fix the handling of pass1 warnings, display control option for warnings
Fix pass1 warnings so they actually display.

When issuing suppressible warnings, display the option that controls
them, as gcc has been doing for a while.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 12:00:19 -07:00
H. Peter Anvin
3d72e45a13 outmacho: Fix missing brace
Fix a missing brace introduced in checkin
84f6860ed5. This was a transcription
error of mine; Zenith432's original patch was correct.

Cc: Zenith432 <zenith432@users.sourceforge.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 11:36:55 -07:00
H. Peter Anvin
3c27bdcaee NASM 2.12.02rc2 2016-05-09 11:21:04 -07:00
H. Peter Anvin
ff7ff12b1c changes.src: update as of the current time
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 11:19:58 -07:00
Zenith432
84f6860ed5 outmacho: Fix relative relocations for 32-bit Mach-O
IP-relative relocations were broken for 32-bit Mach-O when referencing
external symbols after the Mach-O backends were merged.

This fixes bug reports 3392348, 3392352, and 3392346.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-05-09 11:16:10 -07:00
H. Peter Anvin
ccb16787d5 NASM 2.12.02rc1 2016-04-05 13:25:50 -07:00
H. Peter Anvin
8494cc82c5 changes.src: document %if error fix
Document the fix for errors inside live %if branches.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-04-05 13:06:14 -07:00
H. Peter Anvin
eb6653f9e4 preproc: correct the logic in the suppression of preproc errors
The logic for suppressing preprocessor errors was missing an !, which
was present before checkin 215186fe82.

Reported-by: Knut St. Osmundsen <bird-nasm@anduin.net>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-04-05 13:03:10 -07:00
H. Peter Anvin
d2238e2286 changes.src: fix old typo
arror -> error

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-04-05 12:49:07 -07:00
Cyrill Gorcunov
138e3f6699 insns.dat: Bring back rax for 64 bit mode of MONITORX
Previously in d3be338017 i ripped off @rax but this
is due to misinterpretation of

https://sourceware.org/ml/binutils/2015-06/msg00041/mwaitx.patch

so move it back.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-03-27 13:19:13 +03:00
Cyrill Gorcunov
d3be338017 insns.dat: Fix monitorx instruction
It accepts rax|ax registers instead of rax.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-03-27 13:06:58 +03:00
Cyrill Gorcunov
b7636a8a56 insns.dat: Allow MONITORX, MWAITX and CLZERO in 32bit mode as well
Reported-by: Paul Blinzer <apblinzer@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-03-23 00:07:55 +03:00
H. Peter Anvin
86d4acea57 NASM 2.12.01 2016-03-17 17:15:36 -07:00
H. Peter Anvin
4bef68a84e msvc.mak: /Ox and /Oy are redundant with /O2
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>
2016-03-08 00:50:13 -08:00
H. Peter Anvin
134874848c nasmdoc.src: remove unimplemented %comment directive
%comment..%endcomment were never implemented, remove from the
documentation.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 23:58:11 -08:00
H. Peter Anvin
8da30d0266 Makefiles: run "make alldeps"
Automatic update of dependencies.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 23:23:19 -08:00
H. Peter Anvin
283b3fb15a Defer debug format search until after command line parsing
Avoid funnies with ordering of debug format selection by deferring
debug format search until after command line processing.  Also permit
the -gformat syntax used by many C compilers.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 23:20:00 -08:00
H. Peter Anvin
477ae4419c ofmt: get rid of the debuginfo parameter to ofmt->cleanup()
Get rid of the completely pointless "debuginfo" parameter to
ofmt->cleanup().  Most backends completely ignore it, and the two that
care (obj, ieee) can simply test dfmt instead.

Also, dfmt is never NULL, so any test for a NULL dfmt is bogus.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 22:55:43 -08:00
H. Peter Anvin
3ab8c5f9c6 NASM 2.12.01rc2 2016-03-07 22:18:29 -08:00
H. Peter Anvin
2a74d84d1c doc: document fix to the codeview output format
Document the label fix; although a global error, it was user-visible
in the Codeview backend so document it as such.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:17:10 -08:00
H. Peter Anvin
c941a35e58 outelf*: remove null debug functions
Instead of duplicating empty functions, use the corresponding
null_debug_* functions.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-03-07 22:12:19 -08:00
H. Peter Anvin
bc42cbe363 codeview: remove hack for handling local labels
Now when labels are properly concatenated in common code, there is no
reason for the debugging backend to need to be aware of local
symbols.  We don't have to consider ..[^@] special symbols either, as
they are now filtered in labels.c.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Debugged-by: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:06:16 -08:00
H. Peter Anvin
3def9fcb59 outieee: no need to filter .. symbols in the debug format anymore
labels.c now filter ..[^@] special symbols from the debug backend,
so we don't have to open-code that everywhere.

In the actual output format, don't treat ..@ symbols as special.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:04:54 -08:00
H. Peter Anvin
5686a65fe9 outobj: no need to filter .. symbols in the debug format anymore
labels.c now filter ..[^@] special symbols from the debug backend, so
we don't have to open-code that everywhere.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:03:50 -08:00
H. Peter Anvin
fc0ff223b2 labels: emit the same label name to the output and debug backends!!
When a local label was seen, the debug backend would not receive the
full label name!  In order to both simplify the code and avoid this
kind of discrepancy again, make both the output and debug format calls
from a common static function.

However, none of the current debug format backends want to see NASM
special symbols (that start with .. but not ..@) so filter those from
the debug backend.

Finally, fix an incorrect comment in nasm.h: the debug format is
called *after* the output format.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Jim Kukunas <james.t.kukunas@linux.intel.com>
2016-03-07 22:00:01 -08:00
H. Peter Anvin
172b840aa3 Change nasmlist/ListGen to lfmt/struct lfmt
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>
2016-03-07 12:08:48 -08:00
H. Peter Anvin
335c4857ce Remove ofmt->current_dfmt indirection
Move ofmt->current_dfmt into a separate global variable.  This
should allow us to make ofmt readonly and removes some additional
gratuitious differences between backends.

From master branch checkin a7bc15dd0a

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-03-07 12:07:50 -08:00
H. Peter Anvin
ccab91f826 Merge branch 'nasm-2.12.xx' of ssh://repo.or.cz/srv/git/nasm into nasm-2.12.xx 2016-03-07 11:37:16 -08:00
H. Peter Anvin
3c6300738c NASM 2.12.01rc1 2016-03-07 11:36:46 -08:00
Cyrill Gorcunov
6832acb6e3 doc: changes -- Don't forget to mention MONITORX and MWAITX
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-03-07 22:36:18 +03:00
Cyrill Gorcunov
f34cf39459 doc: changes -- Add CLZERO into the list
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-03-07 22:32:31 +03:00
Cyrill Gorcunov
b854be2772 insns.dat: Add CLZERO AMD instruction
https://sourceware.org/ml/binutils/2015-03/msg00078.html
http://bugzilla.nasm.us/show_bug.cgi?id=3392337

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-03-05 12:39:06 +03:00