Commit Graph

3667 Commits

Author SHA1 Message Date
H. Peter Anvin
8f62246560 Further improve error messages for confused decorators
Try to generate more sensible error messages for bogus combinations
of decorators.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-02 19:02:29 -07:00
H. Peter Anvin
8e37ff4ea1 BR3392392: fix broadcast decorators and improve error messages
Checkin c33d95fde9:
    BR 3392370: {z} decorator allowed on MOVDQ* memory operands

... inadvertently broke broadcast operations, which only apply to
memory operands and therefore were only handled in one of the two
brace-parser implementations.  Fix that.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-02 18:38:58 -07:00
H. Peter Anvin
e886c0e968 Change nasm_zero() to pass an object, not a pointer
Passing an object to nasm_zero() allows us to use it on arrays.
Otherwise the array will decay to a pointer and silently clear only
the first member of the array!

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 14:56:17 -07:00
H. Peter Anvin
1980abfb7a BR 3392363: clear the operands when making an artificial I_RESB
When we make an artificial RESB instructions (due to isolated
prefixes) we need to make sure there isn't any crap left in the
operands structure.  The easiest way to guarantee that is to force it
to zero.

Reported-by: Henrik <henrik@gramner.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 14:53:24 -07:00
H. Peter Anvin
c33d95fde9 BR 3392370: {z} decorator allowed on MOVDQ* memory operands
The spec says very clearly the {z} decorator is allowed on memory
operands for the MOVDQ* instructions.  Remove special cases from the
code to disallow this case, which had the unfortunate effect of
generating a very uninformative error message.

Reported-by: Agner <agner@agner.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 14:37:24 -07:00
sezero
2cd8bab66a Mkfiles: remove useless/broken owlinux.mak, update README for openwcom.mak
To build with OpenWatcom and a standard Unix/GNU Make, use the owcc
wrapper.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 14:01:26 -07:00
H. Peter Anvin
17df43c8f2 outdbg: add %pragma for maximum size of a raw data dump
A raw data dump can potentially be very large, especially when
incbin is used.  Allow a %pragma for setting the maximum dump
size (defaults to 128 bytes.)

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 12:03:57 -07:00
H. Peter Anvin
ac06133ed2 output: remove the completely unused set_info method
Every single backend has this method set to NULL.  It is also a
rather strange interface.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 11:41:16 -07:00
H. Peter Anvin
31a14699fb outdbg: update to dump new backend interface data
Update the debug output format to dump (most of) the information that
is available via the new backend format, as well as the legacy backend
format -- probably the only backend ever which will ever want both!

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-31 11:32:53 -07:00
H. Peter Anvin
60ada96294 NASM 2.13rc9 2017-03-28 16:15:06 -07:00
H. Peter Anvin
cac0b19977 nasm.c: get rid of private copy of bitness
There is no reason to keep a private copy of the value of
"globalbits", which needs to be kept in sync anyway.  With the move of
directive processing to a separate file, this variable wasn't kept up
to date, resulting in failures.

This resolves BR 3392390.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-28 16:12:30 -07:00
H. Peter Anvin
d9bc244f8a assemble.c: if a displacement is large enough, we may wrap
If a displacement is as large as the address size currently in use
(which is the norm except for 64-bit code), then we should use
OUT_WRAP rather than OUT_UNSIGNED; the sign doesn't matter at all.

This resolves BR 3392391.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-28 15:54:15 -07:00
H. Peter Anvin
37d01d1a89 changes.src: document no_dead_strip
Document Mach-O support for no_dead_strip.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-28 15:51:45 -07:00
H. Peter Anvin
002532d323 Document new Mach-O flags
Add documentation for recent Mach-O enhancements.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-28 15:36:26 -07:00
Cyrill Gorcunov
5fe4eff8c4 output: elf -- Make elf_section_attrib static
After elf files have been merged into one
no need to keep it global.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-25 22:15:04 +03:00
Cyrill Gorcunov
ee1fc45ee1 dwarf: Update dwarf_line_number_extended
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-25 22:15:04 +03:00
Cyrill Gorcunov
de03b2b831 dwarf: Update dwarf_calling_conversion
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-25 22:15:04 +03:00
Cyrill Gorcunov
c95c2536b4 dwarf: Update dwarf_language
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-25 20:55:48 +03:00
Cyrill Gorcunov
495b6352d8 output: elf,dwarf -- Fix lookup over existing files
We are missing @next access here so in result we
might allocate same name several times.

Reported-by: "Bae, Chang Seok" <chang.seok.bae@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-23 19:19:38 +03:00
Cyrill Gorcunov
8f1d6b0ed8 output: elf -- Use Elf64_Ehdr into section offset
Same as we do in e_shoff.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-18 16:25:49 +03:00
Cyrill Gorcunov
b074501887 output: elf -- Use ElfX_Relx in elf_build_reltab
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-18 15:16:10 +03:00
Cyrill Gorcunov
a95a8e6d7f output: elf -- Add ELF32_R_INFO, ELF64_R_INFO helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-18 15:16:10 +03:00
Cyrill Gorcunov
bb6daa408e output: elf -- Start using ElfX_Sym in elf_build_symtab
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-18 15:16:10 +03:00
Cyrill Gorcunov
c2df71b3ae elf: Switch writting sections with Elf structs
The target of all this code rework is to
start using general backend engine with
native Elf types behind.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-18 15:16:10 +03:00
Cyrill Gorcunov
3a994a92cc output: Elf -- Start using ElfX_Ehdr instead of opencoded writes
This should be more convenient. At least both headers
are well documented in specifications so we simply
follow them.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-18 15:16:10 +03:00
Cyrill Gorcunov
2f038e9d5d nasmlib: Add _le helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-18 15:16:10 +03:00
H. Peter Anvin
e74fd4b7b8 outelf: claim %pragma elf as our namespace
We don't have any elf pragmas yet, but we want to be able to do
"%pragma elf" and have it work for any of the elf formats.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-14 18:58:35 -07:00
H. Peter Anvin
6e4ceb7ba1 Merge remote-tracking branch 'origin/master' 2017-03-14 18:48:21 -07:00
H. Peter Anvin
9f16cfde4c macho: implement do_dead_strip, make subsections_by_symbols a pragma
Implement the MachO do_dead_strip directive, which sets a flag on the
corresponding section.  This as well as subsections_by_symbols are
reimplemented as pragmas; if someone uses the predefined macro they
still get the expected behavior.

However, this allows someone to write:

%pragma macho subsections_by_symbols

... and have it ignored if compiling for, say, ELF.

Also, implement the following section attributes:

      zerofill, no_dead_strip, live_support, strip_static_syms

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-14 18:46:31 -07:00
H. Peter Anvin
b852d351f6 nasmlib.h: explicitly include <ctype.h>
There are macros in this file which depend on <ctype.h>, so treat them
that way.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-14 18:42:25 -07:00
H. Peter Anvin
785ffb95da labels: make lookup_labels and is_extern take a const char *
Whenever we can, we should constipate our arguments...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-14 18:41:25 -07:00
Cyrill Gorcunov
fa38564c49 output: elf -- Fix typo in ELF32_ST_INFO
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-12 11:40:52 +03:00
Cyrill Gorcunov
bcf0389481 elf: Drop code duplication in elf_section_header
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-12 11:37:41 +03:00
Cyrill Gorcunov
660101a02e elf: Align members for file format defs
For readability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-12 11:37:23 +03:00
Cyrill Gorcunov
37034f1cc8 elf: Add EI_ constants
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-12 11:37:15 +03:00
H. Peter Anvin
8753425472 asm/pragma.c: if the handler is NULL, treat it as DIRR_UNKNOWN
If the handler is NULL, then all pragmas are by definition unknown, so
treat them exactly as if we had received DIRR_UNKNOWN from the
handler.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-08 20:28:13 -08:00
H. Peter Anvin
d9493fa440 pragma: use the directives hash to look up directive names
Very few things have any desire to do its own string parsing, and the
directives hash is already a plain string-to-numbers O(1) hash.  The
namespace is small enough that even if it makes some switch statements
compile a bit larger there is no real reason to have separate hashes,
even if the actual code as opposed to the data structure was shared.

So, for right now, just throw them together in one big happy pot.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-03-08 20:10:46 -08:00
H. Peter Anvin
d49a3bf6db changes.src: some minor textual improvements
Document the new -Werror= options a little bit better.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-08 01:50:08 -08:00
H. Peter Anvin
024d0e0fd0 NASM 2.13rc8 2017-03-08 01:32:56 -08: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
e345e3d640 Merge remote-tracking branch 'origin/master' 2017-03-08 01:30:20 -08:00
H. Peter Anvin
b2047cbb98 Make -Werror controllable on a per-warning-class basis
Make -Werror possible to control on a per-warning-class basis.  While
I was fixing up that code anyway, merge the handling of the -w, -W and
[warning] argument and directives.

Furthermore, make *all* warnings suppressible; any warning that isn't
categorized now belong to category "other".  However, for cleanliness
sake an "other" option does not get listed in the warning messages.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-08 01:26:40 -08:00
Cyrill Gorcunov
485413344b asm/pragma: Add missing "assemble.h" inclusion
| asm/pragma.c:131:6: error: no previous prototype for ‘process_pragma’ [-Werror=missing-prototypes]
| void process_pragma(char *str)
|      ^~~~~~~~~~~~~~

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-08 11:39:42 +03:00
H. Peter Anvin
38373e8f1c NASM 2.13rc7 2017-03-07 23:04:15 -08:00
H. Peter Anvin
7fcd9898f4 doc: document subsections_via_symbols
Document the subsections_via_symbols directive.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 23:03:11 -08:00
H. Peter Anvin
fc7c5c3967 outmacho.mac: fix typo in subsections_via_symbols
subsections_via_symbols is plural for both nouns.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 23:02:31 -08:00
H. Peter Anvin
b786f66c2e output: output format macros should be case insensitive
Use %imacro instead of %macro for ELF "osabi" and Mach-O
"subsections_by_symbols".

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 22:53:48 -08:00
H. Peter Anvin
8e1cb8e594 outmacho: support the "subsections_via_symbols" directive
The "subsection_via_symbols" directive simply sets a flag in the
Mach-O file header.

Requested in BR 3392367.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 22:43:00 -08:00
H. Peter Anvin
e562b70cea output: make the return value from the directives method more meaningful
The directives code is already trying to do a bit more unified error
handling, so give ourselves a bit richer interface.  At this point,
the conversion was pretty automatic so we probably return DIRR_OK
instead of DIRR_ERROR in a fair number of places, but that's okay.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 22:42:39 -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