Commit Graph

3695 Commits

Author SHA1 Message Date
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
H. Peter Anvin
3e019c9197 nasm.spec: s/Build-Requires/BuildRequires/
Fix incorrectly spelled tag.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 18:58:53 -07:00
H. Peter Anvin
16ffec1864 nasm.spec: use a sed file to insert perl dependencies
There are just too many ways that an inline sed script can screw up.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 18:54:23 -07:00
H. Peter Anvin
cf96845bf6 nasm.spec: sync with Fedora spec file, auto-generate Perl depends
Sync up with how the Fedora spec file has evolved.
Auto-generate the Perl build dependencies.
Add --enable-lto: it makes especally the rdoff files much smaller.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 18:33:53 -07:00
H. Peter Anvin
3e555483b3 labels, outelf: remove casts for allocations
Remove casts from allocations.  This is simply Not How To Do Things:
every cast carries a potential risk of being a toxic type misuse
(e.g. pointer as integer) and so any unnecessary cast is actively
harmful.

Note that a lot of allocations here are completely unnecessary: the
core code now guarantees that all filenames are permanently allocated
for the duration of the assembly, and so should be turned into const
char * without any further allocation.  Any remaining malloc+strcpy
should be turned into nasm_strdup(), and nasm_new[n]() used whereever
possible.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-23 17:02:46 -07:00
Chang S. Bae
4dfbd9aec5 macho: add file path to the dwarf debugging output
Apple's linker requires file path along with file name to produce
debug notes.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-23 16:46:45 -07:00
H. Peter Anvin
9f94136c33 NASM 2.13rc21 2017-04-20 18:04:42 -07:00
H. Peter Anvin
57e08284a6 doc, html: switch to a columnar layout for a very wide window
If we open in a very wide window, split the text into columns so it
can actually be conveniently read.

Also, change the body margin to 8px, as that seems to be the more
common browser default.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-20 18:03:10 -07:00
Henrik Gramner
16d4db3aab Fix ModR/M.mod for EVEX instructions
It was incorrectly set to 01b in some cases when where it should be 10b.

Fixes BR 3392402.

Signed-off-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-20 17:48:44 -07:00
H. Peter Anvin
32b9824f5c doc: formatting fixes to the warnings documentation
Formatting and language consistency cleanups to the sections about
disabling and enabling warning classes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-20 02:03:59 -07:00
H. Peter Anvin
c2f371c0b9 Merge branch 'master' of ssh://repo.or.cz/nasm 2017-04-20 01:39:42 -07:00
H. Peter Anvin
4d993a1c03 doc: update links to ABI documents
We have a separate namespace for ABI documents.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-20 01:36:57 -07:00
H. Peter Anvin
28b588b91e Run make alldeps 2017-04-18 16:10:03 -07:00
H. Peter Anvin
c4d75ddcbf Merge branch 'master' into elf
Resolved Conflicts:
	aclocal.m4
	output/outelf.c

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 16:08:54 -07:00
H. Peter Anvin
e558dfd249 configure, ilog2: add some MSVC intrinsics
Add MSVC intrinsics for byte swapping and for BSF (ilog2).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 16:05:22 -07:00
H. Peter Anvin
5eb528b6c5 configure.ac: test for common byte-swapping functions
Test for a variety of common byte-swapping functions.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 15:49:25 -07:00
H. Peter Anvin
96b2895ac0 aclocal.m4: make it possible to request a header file to be further used
Make it possible to request testing for a header file, which if found,
will be always included for futher tests.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 15:48:31 -07:00
H. Peter Anvin
b68edcac72 tools/release: make doesn't like MAKE in the environment, so call it makej
make really doesn't like something called MAKE in the environment, so
call it makej like buildall.sh on the server.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 10:52:05 -07:00
H. Peter Anvin
5f46eea191 tools/release: don't double-quote $MAKE
We actually want it broken down into words... (e.g. make -jX).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 10:39:07 -07:00
H. Peter Anvin
ab8c1d2ee5 tools/release: allow invoking make as a parallel build
If the variable MAKE is set in the environment, use it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-18 10:35:15 -07:00
H. Peter Anvin
7e9d4fdf8d nasmdoc.pdf: always begin a chapter on an odd page
If we want to print the document, we really want each chapter to start
on an odd (right-facing) page; otherwise it gets rather strange.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 16:01:31 -07:00
H. Peter Anvin
84deac219d rdoff.c: one more unsafe use of fread()
Use the same error pattern as the rest of the calls in this function.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:25:13 -07:00
H. Peter Anvin
6edeb335f0 rdflib.c: fix(?) one more unsafe use of fread()
It isn't 100% clear what is the right thing to do in this particular
case, so this is my best attempt...

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:22:32 -07:00
H. Peter Anvin
f20f1878f5 NASM 2.13rc20 2017-04-17 14:15:51 -07:00
H. Peter Anvin
3d6d7331ab rdoff: add back rdfutils.h missing from previous checkin
Checkin 8dc965347d was missing this
file, causing obvious failures.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:14:26 -07:00
H. Peter Anvin
cea308b3dc changes.src: document DWARF support for Mach-O
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:05:51 -07:00
H. Peter Anvin
3e66fcd8f8 NASM 2.13rc19 2017-04-17 14:02:38 -07:00
Chang S. Bae
5431732560 Fix errors uncovered by clang warnings
1. One incorrect variable use(!)
2. One possibly uninitialized variable.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:01:33 -07:00
Chang S. Bae
d685bdd65c outmacho: dwarf debug (4/4)
line information added in dwarf output

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:00:20 -07:00
Chang S. Bae
2c2272a86d outmacho: dwarf debug (3/4)
debug information sections now generated.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:00:20 -07:00
Chang S. Bae
6d14596476 outmacho: dwarf debug (2/4)
file and section list added for managing debug line info
also, now macho parts get to call debug interfaces

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:00:18 -07:00
Chang S. Bae
6a912a3c90 outmacho: dwarf debug (1/4)
skeletion interfaces

MachO Dwarf is basically porting of ELF's DWARF implementations
and it includes debug line information and some debug meta data

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:00:16 -07:00
Chang S. Bae
3b26c45e7f outmacho: align filesize together with vmsize
According to the Mach-O spec this should not be necessary for .o
files, but it seems that we get problems with extracted dsyms if this
is not done, so do this for now -- we might be able to troubleshoot
this later.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 14:00:07 -07:00
H. Peter Anvin
ef1ea87c3c Merge branch 'master' of ssh://repo.or.cz/nasm 2017-04-17 13:57:59 -07:00
H. Peter Anvin
8dc965347d rdoff: use nasm-provided safe memory allocation and I/O
We already have abort-on-error memory allocation and I/O operations in
nasmlib, so use them for rdoff as well.

Delete long-since-obsolete rdoff Mkfiles directory.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-04-17 13:56:50 -07:00
H. Peter Anvin
aa319b93e9 doc: add the version number to the HTML output
Add the subtitle (e.g. "version XXXX...") to the HTML output.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-17 02:18:50 -07:00