Commit graph

3257 commits

Author SHA1 Message Date
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
Fabian Giesen
6503051dcc 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-04-30 16:01:30 +03:00
Fabian Giesen
5b838ef981 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-04-30 16:00:59 +03:00
Fabian Giesen
0bbc38dbd5 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-04-30 16:00:38 +03:00
Cyrill Gorcunov
3421a3f3f3 out: Elf -- Fix typo in section name
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:57:52 +03:00
Cyrill Gorcunov
4670887c4d out: Elf -- Merge Elf32, Elfx32 and Elf64 into single file
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>
2016-04-24 20:02:41 +03:00
Cyrill Gorcunov
855ec5aa2c out: Elf32, Elfx32, Elf64 -- Rename unmergable routines
Keep them separate for a while, and merge later.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:41 +03:00
Cyrill Gorcunov
6dfc0b2214 out: Elfx32 -- Unify dwarf_ types
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:41 +03:00
Cyrill Gorcunov
8348af4caf output: Elf32, Elfx32 -- Use 64 bit address
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:41 +03:00
Cyrill Gorcunov
239dfaa5b3 output: Elf32 -- Shuffle few lines to make it close to other code
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:41 +03:00
Cyrill Gorcunov
bff511937f output: Elf32, Elfx32 -- Unify elf_add_gsym_reloc
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:41 +03:00
Cyrill Gorcunov
b89fb8015c out: Elf32 -- A few more constants usage
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:41 +03:00
Cyrill Gorcunov
232788c549 output: Elf32, Elfx32, Elf64 -- Declare ofmt for all
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:41 +03:00
Cyrill Gorcunov
171af38cbc out: Elf64, Elfx32 -- Drop useless DEBUG
We rather need a trace engine.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
a087d49f70 out: Elf32, Elfx32, Elf64 -- Unify elf_init and elf_deflabel
Note FIXMEs for address later.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
8ba28bc20b out: Elf32 -- Unify dwarf_ nums
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
d3ec4be590 out: Elf32, Elfx32, Elf64 -- more unifications
Some elf_ section numbers may be unused.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
784d10cb9a out: Elf32, Elfx32 -- Unify elf_sect_write, elf_section_header and add elf_sect_writeaddr
elf_sect_writeaddr is unused by now.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
6285d72efb out: Elf64, Elfx32 -- Style fix
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
a541094beb out: Elf32, Elfx32 -- Unify struct ELF_SECTDATA and @elf_foffs
Use int64_t.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
caa18da230 out: Elf32 -- Reuse TY_DEBUGSYMLIN
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
fbbe8fe9e2 out: Elf32 -- Unify struct symlininfo
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
583f505155 out: Elf64, Elf32, Elfx32 -- Style merge
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
2bb791956e out: Elf32, Elfx32, Elf64 -- Use ofmt->maxbits
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
e03bac6dbf out: Elf32 -- Add missing comment
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
a65e0481c2 out: Elfx32, Elf32 -- Unify elf_add_reloc
Make offset being int64_t and use 0 for Elf32.
Thus it gonna be the same for all Elfs.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
H. Peter Anvin
6a83cb93b3 msvc.mak: change $(L) to $(A)
Change $(L) to $(A) for consistency with Makefile.in.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-04-21 18:10:10 -07:00
Knut St. Osmundsen
6fd298418b msvc.mak: Build fixes, updates and improvements.
* 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>
2016-04-21 09:13:32 +03: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