Commit Graph

3880 Commits

Author SHA1 Message Date
H. Peter Anvin
af9fe8f597 Don't sort opcodes; move all pseudo-ops to the beginning
We don't need to sort opcodes anymore, since we are using an O(1) hash
and not binary search.  Instead, sort them in the order they first
appear in insns.dat; this lets us move all the pseudo-ops to a
contiguous range at the start of the file, for more efficient
handling.

Change the functions that process pseudo-ops accordingly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:44:24 -07:00
H. Peter Anvin
d23066906c incbin: remove pointless call to lfmt->set_offset()
We already have the correct offset; otherwise the times == 1 case
would not work.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:29:05 -07:00
H. Peter Anvin
20f6c253cd Merge remote-tracking branch 'origin/nasm-2.13.xx' 2017-05-01 21:25:14 -07:00
H. Peter Anvin
4892f95bb5 doc/changes.src: update with the latest changes
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:16:21 -07:00
H. Peter Anvin
3e458a89d8 a) Fix handling of DZ/ZWORD; b) don't crash on TIMES JMP
a) Fix a number of missing instances of DZ and ZWORD.

b) NASM would crash if TIMES was used on an instruction which varies
   in size, e.g. JMP.  Fix this by moving the handling of TIMES at a
   higher level, so we generate the instruction "de novo" for each
   iteration.  The exception is INCBIN, so we can avoid reading the
   included file over and over.

c) When using the RESx instructions, just fold TIMES into the reserved
   space size; there is absolutely no point to iterate over it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 21:13:15 -07:00
H. Peter Anvin
5810c594c9 listing: fix base address for TIMES
A simpler, and actually correct fix for the listing address for
TIMES.  The listing interface is quite frankly insane, but it probably
is better to fix it in 2.14+ and not in the maintenance branch.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 19:51:09 -07:00
H. Peter Anvin
5f93c9597d Revert "asm/assemble.c: correct the listing address for TIMES"
This reverts commit 440ba7e13e.

The fix is wrong; it causes the listing file to *only* show <rept>,
without showing the first iteration.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 19:44:34 -07:00
H. Peter Anvin
3301ee8a9e doc/changes.src: document the changes to the 2.13 maint branch so far
Current changes scheduled for 2.13.01.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:41:30 -07:00
H. Peter Anvin
440ba7e13e asm/assemble.c: correct the listing address for TIMES
We need to set the listing offset before calling LIST_TIMES, but we
had already advanced data.offset by calling out().  Move the call to
lfmt->set_offset() and lfmt->uplevel() to the top and out of the loop;
there is no reason for it to be in the loop in the first place.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:39:15 -07:00
H. Peter Anvin
571592ea63 listing.c: show [ssss] for a segment instead of a bogus address
There is no point in showing a number of a relative segment, so just
show [ssss]; even if there is a possible segment offset it is
linker-dependent and output format dependent.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:32:37 -07:00
H. Peter Anvin
217e714e6b output/legacy.c: OUT_SEGMENT -> OUT_ADDRESS with a zero addend
The legacy output doesn't distinguish between segments and other
addresses, so we need to force the offset to zero before passing it
down to the output layer.

This addresses BR 3392406.

Reported-by: <rugxulo@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:10:47 -07:00
H. Peter Anvin
08e71e7dc4 test/Makefile: add a rule to run omfdump on an .obj file
omfdump is really useful while debugging obj output, so add an
explicit rule to generate omfdump output.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-05-01 15:09:44 -07:00
H. Peter Anvin
b3dd17b0b6 Merge branch 'nasm-2.13.xx' 2017-04-29 13:35:16 -07:00
H. Peter Anvin
91ac58dc65 changes.src: we managed to implement a few %pragmas before 2.13...
Minor change to the release notes for 2.13: we did end up with a few
actually implemented %pragmas.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-29 13:34:19 -07:00
H. Peter Anvin
9516cf3fda NASM 2.14rc0
Tag the development branch as NASM 2.14rc0 so there is no confusion
about ordering versus the 2.13.xx branch.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-29 13:29:53 -07:00
H. Peter Anvin
97408d67dd Merge remote-tracking branch 'origin/elf' 2017-04-29 13:28:12 -07:00
H. Peter Anvin
b84ac82249 NASM 2.13 2017-04-29 13:25:21 -07:00
H. Peter Anvin
65ce38a819 nasmlib/ilog2.c: force the shift in ROUND() to be an uint32_t
Some compilers apparently warn on 1 << w for w == 31; fix it by
explicitly making it UINT32_C(1).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-29 13:13:59 -07:00
H. Peter Anvin
0624296834 changes.src: definitely making 2.13 next
About to release 2.13 for real.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-29 13:13:59 -07:00
H. Peter Anvin
d6b9227565 NASM 2.13rc23 2017-04-27 20:04:34 -07:00
Chang S. Bae
375f452813 outmacho: fix dwarf line number information (debug_line section)
Create directory table in prologue and file name indicates index
of the table for its directory

Now bring back included file names

Signedoff-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-27 20:04:15 -07:00
Chang S. Bae
961d8670bf outmacho: add dir list
Separate dir info from the file list to align with dwarf format
in debug_line section

Signedoff-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-27 20:03:53 -07:00
H. Peter Anvin
0e37f02bad Mkfiles/README: add a blank line
Trivial formatting fix: add a blank line for readability.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-26 00:22:42 -07:00
H. Peter Anvin
4aa13c9e81 Makefile.in: better filter for Perl dependencies
Be a bit smarter about what to require and what to ignore.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-26 00:21:40 -07:00
H. Peter Anvin
752781f2af doc/pspdf.pl: fix spacing
Fix whitespace alignment, no functional change.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-26 00:16:57 -07:00
H. Peter Anvin
e6eb87edc4 win32, doc: fix PDF generation scripts for Windows
Win32::Registry is obsolete, we need to use Win32::TieRegistry on
current platforms.

GhostScript uses # rather than = on Windows, it seems.

Try to find GhostScript in the registry and add it to the PATH.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-26 00:05:12 -07:00
H. Peter Anvin
409da5b561 Windows portability: fix construct in findfont.ph, README update
Fix a construct in doc/findfont.ph which crashes Perl on Windows
unconditionally.

Improve the README for building the full package with MSVC.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-25 20:32:39 -07:00
H. Peter Anvin
35915aec7f NASM 2.13rc22 2017-04-25 13:19:49 -07:00
H. Peter Anvin
c26a7d4cbe nasmlib/path.c: a few more detection macros
Add a few more operating system detection macros, including BeOS.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-25 13:18:36 -07:00
Chang S. Bae
1d73d14eb0 outmatch: fix file info and cleanup in dwarf generation
In debug info and line, only main source is showed up. Header files
will be laid out via TAG_subprogram

Included missing memory cleanups

Removed unnecessary null assertions

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-25 12:54:25 -07:00
Chang S. Bae
64dd380f1e nasmlib: include macro for Mach system and fix on filename extraction
Add __MACH__ as a Unix-like system (e.g. MacOS X defines __MACH__ but
no variant of __unix__.)

Fix a reversed test in first_filename_char().

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-25 12:53:52 -07:00
H. Peter Anvin
53cd7c7bf0 bytesex: more endianness detection hacks
A few more tricks for sussing out endinanness, and add an ultimate
fallback option.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-25 12:51:17 -07:00
H. Peter Anvin
c6bbfaa70d doc: formatting consistency for %!
Consistent formatting for the %! environment variable reference.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-25 12:39:11 -07:00
H. Peter Anvin
3ddaa86ba2 doc: make the %! (environment variable) construct a little clearer
Make the %! construct a little more clear.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 14:21:43 -07:00
H. Peter Anvin
f268b97a8e doc: add (deprecated) to context fall-through lookup heading
Context fall-through lookup is deprecated, make it as clear as
possible.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 14:18:59 -07:00
H. Peter Anvin
573112ee86 endian.h: can be called sys/endian.h or machine/endian.h
On some platforms, endian.h may exist but be called sys/endian.h or
machine/endian.h.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 13:28:14 -07:00
H. Peter Anvin
d3e22572b3 Clean up byteorder functions
Move byte order handling functions to their own header file, and try
to be more specific about how exactly to handle things.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 13:01:08 -07:00
H. Peter Anvin
bbb39579ec hashtbl, strtbl: add hash_free_all(), split strtbl_find()
Add hash_free_all() to factor common code of iterating over all
members of a hash to free them with a single nasm_free().

Split strtbl_find() into strtbl_find() and strtbl_add().  It is very
unlikely that the same call site will want to have both of these
functionalities, and in the end the code for the two functions are
surprisingly different.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 00:54:51 -07:00
H. Peter Anvin
bf0bcef3d4 output: generic string table implementation
Several output formats use "string tables", which is a collection of
null-terminated (C) strings which are referenced by a byte offset into
the string table.  A single string can be referenced an arbitrary
number of times.

As this is quite simple to implement with a hash table, we do exactly
that.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 00:23:03 -07:00
H. Peter Anvin
e0172d5870 Merge branch 'master' into elf 2017-04-23 23:52:32 -07:00
H. Peter Anvin
4b177bfb03 outmacho: clean up list walks, use nasm_basename/nasm_dirname
Use the new nasm_basename() and nasm_dirname() functions to split a
pathname.

Use nasm_wcstring() to write a C string to an SAA.

Use list_for_each() to walk linked lists.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 23:46:41 -07:00
H. Peter Anvin
6e11b2cc54 saa, raa: saa_init() and raa_init() will never return NULL
Like other NASM allocation functions, these will abort rather than
ever return NULL.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 23:37:11 -07:00
H. Peter Anvin
40f0a7495a SAA: add saa_wcstring()
Add saa_wcstring() to write a C string (a string including final NUL)
to an SAA, and return the number of bytes written.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 23:20:54 -07:00
H. Peter Anvin
d00d8c6ac3 nasmlib: fix MacOS classic catsep definition
Correct the definition for MacOS classic "catsep" in nasm_catfile().
Also put in a stern comment that this function doesn't handle
filenames with path components.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 23:11:12 -07:00
H. Peter Anvin
11a07a7319 nasmlib: add function to splice pathnames
Add a function to splice a pathname consisting of a directory and a
filename.  It is worth noting that this function is limited to that
particular use case: in particular, it does NOT currently support
concatenating a filename which itself contains directory components to
a non-null directory.

Combining directory names is extremely system-dependent and probably
needs more than just parameterized code in many cases, for example,
on VMS combining "foo:[bar]" with "[baz]quux" should produce
"foo:[bar.baz]quux" whereas combining "foo:[bar]" and baz:quux" is an
outright error.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 23:01:00 -07:00
H. Peter Anvin
0979957e19 nasmlib: add path-splitting functions
Some debugging formats may need to be able to split paths into
directory name and filename, at least.  This is kind of iffy, at least
across platforms, but that isn't really expected to be an issue in
practice... we hope.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 22:39:53 -07:00
H. Peter Anvin
26fad144de configure.ac: fix --enable-sections
The --enable-sections option isn't too useful without
-Wl,--gc-sections.  It's unclear if gcc will provide that option by
default.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 21:42:31 -07:00
H. Peter Anvin
d2b7aa8edf aclocal.m4: fix underquoted strings
Some strings were underquoted, causing failures.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 21:42:08 -07:00
H. Peter Anvin
7aae842810 nasm.spec: LTO breaks debug info, fall back to --enable-sections
--enable-lto seems to completely break RPM debug information, so fall
back on --enable-sections, which at least allows the linker to do
better dead code removal.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 21:19:09 -07:00
H. Peter Anvin
b8b77e4452 nasm.spec: more cleanups, doc is noarch
The doc file is noarch, and do some other cleanups.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 21:15:05 -07:00