summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2017-04-23 23:52:32 -0700
committerH. Peter Anvin <hpa@zytor.com>2017-04-23 23:52:32 -0700
commite0172d58706ccbe740bd153c38da42d18f306ade (patch)
tree44c64d97aff1e1a3f7871443f058e1c37068347e
parent28b588b91e8afc7d31e6d7c2560e214f049801a3 (diff)
parent4b177bfb0373e7c8309be5841d9a13664b643d22 (diff)
downloadnasm-e0172d58706ccbe740bd153c38da42d18f306ade.tar.gz
Merge branch 'master' into elf
-rw-r--r--.gitignore3
-rw-r--r--Makefile.in19
-rw-r--r--Mkfiles/msvc.mak6
-rw-r--r--Mkfiles/openwcom.mak6
-rw-r--r--aclocal.m430
-rw-r--r--asm/assemble.c12
-rw-r--r--asm/labels.c8
-rw-r--r--configure.ac5
-rw-r--r--doc/nasmdoc.css19
-rw-r--r--doc/nasmdoc.src58
-rw-r--r--doc/rdsrc.pl5
-rw-r--r--include/nasmlib.h9
-rw-r--r--include/raa.h2
-rw-r--r--include/saa.h5
-rw-r--r--nasm.spec.in58
-rw-r--r--nasm.spec.sed3
-rw-r--r--nasmlib/path.c171
-rw-r--r--nasmlib/saa.c15
-rw-r--r--output/outelf.c20
-rw-r--r--output/outmacho.c63
-rw-r--r--version2
21 files changed, 381 insertions, 138 deletions
diff --git a/.gitignore b/.gitignore
index 267007b7..14eccf95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,11 +14,13 @@
*.pdb
*.rej
*.s
+*.si
*.swp
*.xml
.*swo
*~
\#*
+.\#*
*.bak
*.tmp
.git-ignore
@@ -54,6 +56,7 @@ TAGS
/macros/macros.c
/nasm
/ndisasm
+/nasm.spec
/nsis/arch.nsh
/nsis/version.nsh
/rdoff/Makefile
diff --git a/Makefile.in b/Makefile.in
index f5505a67..71783af4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -100,7 +100,8 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
nasmlib/crc64.$(O) nasmlib/malloc.$(O) \
nasmlib/md5c.$(O) nasmlib/string.$(O) \
nasmlib/file.$(O) nasmlib/mmap.$(O) nasmlib/ilog2.$(O) \
- nasmlib/realpath.$(O) nasmlib/filename.$(O) nasmlib/srcfile.$(O) \
+ nasmlib/realpath.$(O) nasmlib/path.$(O) \
+ nasmlib/filename.$(O) nasmlib/srcfile.$(O) \
nasmlib/zerobuf.$(O) nasmlib/readnum.$(O) nasmlib/bsi.$(O) \
nasmlib/rbtree.$(O) nasmlib/hashtbl.$(O) \
nasmlib/raa.$(O) nasmlib/saa.$(O) \
@@ -348,6 +349,7 @@ clean:
$(RM_F) nasm-*-installer-*.exe
$(RM_F) tags TAGS
$(RM_F) nsis/arch.nsh
+ $(RM_F) perlbreq.si
$(RM_F) $(RDFPROGS) $(RDF2BINLINKS)
distclean: clean
@@ -417,8 +419,16 @@ tar: dist
spec: nasm.spec
-nasm.spec: nasm.spec.in version.sed
- sed -f version.sed < nasm.spec.in > nasm.spec
+ALLPERLSRC := $(shell find $(srcdir) -type f -name '*.p[lh]')
+
+perlbreq.si: $(ALLPERLSRC)
+ sed -n -r -e 's/^use[[:space:]]+([^[:space:];]+).*$$/BuildRequires: perl(\1)/p' $(ALLPERLSRC) | \
+ sed -r -e '/perl\((strict|warnings)\)/d' | \
+ sort | uniq > perlbreq.si || ( rm -f perlbreq.si ; false )
+
+nasm.spec: nasm.spec.in nasm.spec.sed version.sed perlbreq.si
+ sed -f version.sed -f nasm.spec.sed \
+ < nasm.spec.in > nasm.spec || ( rm -f nasm.spec ; false )
splint:
splint -weak *.c
@@ -619,6 +629,9 @@ nasmlib/md5c.$(O): nasmlib/md5c.c config/config.h config/msvc.h \
nasmlib/mmap.$(O): nasmlib/mmap.c config/config.h config/msvc.h \
config/unknown.h config/watcom.h include/compiler.h include/error.h \
include/nasmint.h include/nasmlib.h nasmlib/file.h
+nasmlib/path.$(O): nasmlib/path.c config/config.h config/msvc.h \
+ config/unknown.h config/watcom.h include/compiler.h include/error.h \
+ include/nasmint.h include/nasmlib.h
nasmlib/perfhash.$(O): nasmlib/perfhash.c config/config.h config/msvc.h \
config/unknown.h config/watcom.h include/compiler.h include/hashtbl.h \
include/nasmint.h include/nasmlib.h include/perfhash.h
diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak
index 25915136..b8b6d3ad 100644
--- a/Mkfiles/msvc.mak
+++ b/Mkfiles/msvc.mak
@@ -73,7 +73,8 @@ LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \
nasmlib\crc64.$(O) nasmlib\malloc.$(O) \
nasmlib\md5c.$(O) nasmlib\string.$(O) \
nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) \
- nasmlib\realpath.$(O) nasmlib\filename.$(O) nasmlib\srcfile.$(O) \
+ nasmlib\realpath.$(O) nasmlib\path.$(O) \
+ nasmlib\filename.$(O) nasmlib\srcfile.$(O) \
nasmlib\zerobuf.$(O) nasmlib\readnum.$(O) nasmlib\bsi.$(O) \
nasmlib\rbtree.$(O) nasmlib\hashtbl.$(O) \
nasmlib\raa.$(O) nasmlib\saa.$(O) \
@@ -519,6 +520,9 @@ nasmlib\md5c.$(O): nasmlib\md5c.c config\msvc.h config\unknown.h \
nasmlib\mmap.$(O): nasmlib\mmap.c config\msvc.h config\unknown.h \
config\watcom.h include\compiler.h include\error.h include\nasmint.h \
include\nasmlib.h nasmlib\file.h
+nasmlib\path.$(O): nasmlib\path.c config\msvc.h config\unknown.h \
+ config\watcom.h include\compiler.h include\error.h include\nasmint.h \
+ include\nasmlib.h
nasmlib\perfhash.$(O): nasmlib\perfhash.c config\msvc.h config\unknown.h \
config\watcom.h include\compiler.h include\hashtbl.h include\nasmint.h \
include\nasmlib.h include\perfhash.h
diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak
index 88d4afcc..516c3f03 100644
--- a/Mkfiles/openwcom.mak
+++ b/Mkfiles/openwcom.mak
@@ -59,7 +59,8 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) &
nasmlib/crc64.$(O) nasmlib/malloc.$(O) &
nasmlib/md5c.$(O) nasmlib/string.$(O) &
nasmlib/file.$(O) nasmlib/mmap.$(O) nasmlib/ilog2.$(O) &
- nasmlib/realpath.$(O) nasmlib/filename.$(O) nasmlib/srcfile.$(O) &
+ nasmlib/realpath.$(O) nasmlib/path.$(O) &
+ nasmlib/filename.$(O) nasmlib/srcfile.$(O) &
nasmlib/zerobuf.$(O) nasmlib/readnum.$(O) nasmlib/bsi.$(O) &
nasmlib/rbtree.$(O) nasmlib/hashtbl.$(O) &
nasmlib/raa.$(O) nasmlib/saa.$(O) &
@@ -493,6 +494,9 @@ nasmlib/md5c.$(O): nasmlib/md5c.c config/msvc.h config/unknown.h &
nasmlib/mmap.$(O): nasmlib/mmap.c config/msvc.h config/unknown.h &
config/watcom.h include/compiler.h include/error.h include/nasmint.h &
include/nasmlib.h nasmlib/file.h
+nasmlib/path.$(O): nasmlib/path.c config/msvc.h config/unknown.h &
+ config/watcom.h include/compiler.h include/error.h include/nasmint.h &
+ include/nasmlib.h
nasmlib/perfhash.$(O): nasmlib/perfhash.c config/msvc.h config/unknown.h &
config/watcom.h include/compiler.h include/hashtbl.h include/nasmint.h &
include/nasmlib.h include/perfhash.h
diff --git a/aclocal.m4 b/aclocal.m4
index 5d278448..f216e511 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -9,10 +9,10 @@ AC_DEFUN(PA_ADD_CFLAGS,
CFLAGS="$CFLAGS $1"
AC_TRY_LINK(AC_INCLUDES_DEFAULT,
[printf("Hello, World!\n");],
- AC_MSG_RESULT([yes])
- CFLAGS="$pa_add_cflags__old_cflags ifelse([$2],[],[$1],[$2])",
- AC_MSG_RESULT([no])
- CFLAGS="$pa_add_cflags__old_cflags")])
+ [AC_MSG_RESULT([yes])
+ CFLAGS="$pa_add_cflags__old_cflags ifelse([$2],[],[$1],[$2])"],
+ [AC_MSG_RESULT([no])
+ CFLAGS="$pa_add_cflags__old_cflags"])])
dnl --------------------------------------------------------------------------
dnl PA_ADD_CLDFLAGS()
@@ -28,12 +28,12 @@ AC_DEFUN(PA_ADD_CLDFLAGS,
LDFLAGS="$LDFLAGS $1"
AC_TRY_LINK(AC_INCLUDES_DEFAULT,
[printf("Hello, World!\n");],
- AC_MSG_RESULT([yes])
- CFLAGS="$pa_add_cldflags__old_cflags ifelse([$2],[],[$1],[$2])"
- LDFLAGS="$pa_add_cldflags__old_ldflags ifelse([$2],[],[$1],[$2])",
- AC_MSG_RESULT([no])
- CFLAGS="$pa_add_cldflags__old_cflags"
- LDFLAGS="$pa_add_cldflags__old_ldflags")])
+ [AC_MSG_RESULT([yes])
+ CFLAGS="$pa_add_cldflags__old_cflags ifelse([$2],[],[$1],[$2])"
+ LDFLAGS="$pa_add_cldflags__old_ldflags ifelse([$2],[],[$1],[$2])"],
+ [AC_MSG_RESULT([no])
+ CFLAGS="$pa_add_cldflags__old_cflags"
+ LDFLAGS="$pa_add_cldflags__old_ldflags"])])
dnl --------------------------------------------------------------------------
dnl PA_VAR
@@ -137,15 +137,13 @@ dnl Simpler-to-use versions of AC_ARG_ENABLED, that include the
dnl test for $enableval and the AS_HELP_STRING definition
dnl --------------------------------------------------------------------------
AC_DEFUN(PA_ARG_ENABLED,
-[AC_ARG_ENABLE([$1],
- [AS_HELP_STRING([--enable-$1],[$2])], [], [enableval=no])
- AS_IF([test x"$enableval" != xno], [$3], [$4])
+[AC_ARG_ENABLE([$1], [AS_HELP_STRING([--enable-$1],[$2])], [], [enableval=no])
+ AS_IF([test x"$enableval" != xno], [$3], [$4])
])
AC_DEFUN(PA_ARG_DISABLED,
-[AC_ARG_ENABLE([$1],
- [AS_HELP_STRING([--disable-$1],[$2])], [], [enableval=yes])
- AS_IF([test x"$enableval" = xno], [$3], [$4])
+[AC_ARG_ENABLE([$1],[AS_HELP_STRING([--disable-$1],[$2])], [], [enableval=yes])
+ AS_IF([test x"$enableval" = xno], [$3], [$4])
])
dnl --------------------------------------------------------------------------
diff --git a/asm/assemble.c b/asm/assemble.c
index 9c76b0ea..31db516a 100644
--- a/asm/assemble.c
+++ b/asm/assemble.c
@@ -2426,13 +2426,11 @@ static enum match_result matches(const struct itemplate *itemp,
* - offset can fit in a byte when EVEX is not used
* - offset can be compressed when EVEX is used
*/
-#define IS_MOD_01() (input->eaflags & EAF_BYTEOFFS || \
- (o >= -128 && o <= 127 && \
- seg == NO_SEG && !forw_ref && \
- !(input->eaflags & EAF_WORDOFFS) && \
- !(ins->rex & REX_EV)) || \
- (ins->rex & REX_EV && \
- is_disp8n(input, ins, &output->disp8)))
+#define IS_MOD_01() (!(input->eaflags & EAF_WORDOFFS) && \
+ (ins->rex & REX_EV ? seg == NO_SEG && !forw_ref && \
+ is_disp8n(input, ins, &output->disp8) : \
+ input->eaflags & EAF_BYTEOFFS || (o >= -128 && \
+ o <= 127 && seg == NO_SEG && !forw_ref)))
static enum ea_type process_ea(operand *input, ea *output, int bits,
int rfield, opflags_t rflags, insn *ins,
diff --git a/asm/labels.c b/asm/labels.c
index 8c2223a0..1183151c 100644
--- a/asm/labels.c
+++ b/asm/labels.c
@@ -186,7 +186,7 @@ static union label *find_label(const char *label, int create, int *created)
/*
* must allocate a new block
*/
- lfree->admin.next = (union label *)nasm_malloc(LBLK_SIZE);
+ lfree->admin.next = nasm_malloc(LBLK_SIZE);
lfree = lfree->admin.next;
init_block(lfree);
}
@@ -424,11 +424,11 @@ int init_labels(void)
{
hash_init(&ltab, HASH_LARGE);
- ldata = lfree = (union label *)nasm_malloc(LBLK_SIZE);
+ ldata = lfree = nasm_malloc(LBLK_SIZE);
init_block(lfree);
perm_head = perm_tail =
- (struct permts *)nasm_malloc(sizeof(struct permts));
+ nasm_malloc(sizeof(struct permts));
perm_head->next = NULL;
perm_head->size = PERMTS_SIZE;
@@ -483,7 +483,7 @@ static char *perm_copy(const char *string)
if (perm_tail->size - perm_tail->usage < len) {
perm_tail->next =
- (struct permts *)nasm_malloc(sizeof(struct permts));
+ nasm_malloc(sizeof(struct permts));
perm_tail = perm_tail->next;
perm_tail->next = NULL;
perm_tail->size = PERMTS_SIZE;
diff --git a/configure.ac b/configure.ac
index 1905e8dd..8ee20798 100644
--- a/configure.ac
+++ b/configure.ac
@@ -208,8 +208,9 @@ dnl support function sections
dnl
PA_ARG_ENABLED([sections],
[compile with function/data section support],
- [PA_ADD_CFLAGS([-ffunction-sections]),
- PA_ADD_CFLAGS([-fdata-sections])],
+ [PA_ADD_CLDFLAGS([-ffunction-sections])
+ PA_ADD_CLDFLAGS([-fdata-sections])
+ PA_ADD_CLDFLAGS([-Wl,--gc-sections])],
[])
dnl
dnl support LTO
diff --git a/doc/nasmdoc.css b/doc/nasmdoc.css
index af095273..f989f37b 100644
--- a/doc/nasmdoc.css
+++ b/doc/nasmdoc.css
@@ -61,11 +61,26 @@ ul.index {
color: inherit;
}
}
+@media only screen and (min-width: 90em) {
+ /* For a very wide screen, go to a columnar layout */
+ div.contents {
+ -webkit-column-count: 2;
+ -moz-column-count: 2;
+ column-count: 2;
+ }
+}
+@media only screen and (min-width: 135em) {
+ div.contents {
+ -webkit-column-count: 3;
+ -moz-column-count: 3;
+ column-count: 3;
+ }
+}
@media screen {
/* Setting an explicit margin to keep the navbar from moving */
body {
padding: 0;
- margin: 10px;
+ margin: 8px;
}
/* Link styles */
@@ -94,7 +109,7 @@ ul.index {
ul.navbar {
display: block;
position: sticky;
- top: 10px;
+ top: 8px;
width: 100%;
margin: 0;
padding: 0;
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src
index 79eb59d0..361b8f3b 100644
--- a/doc/nasmdoc.src
+++ b/doc/nasmdoc.src
@@ -791,19 +791,18 @@ disable it by \c{-w-orphan-labels}.
The current \i{warning classes} are:
\b \i\c{other} specifies any warning not otherwise specified in any
-class.
+class. Enabled by default.
\b \i\c{macro-params} covers warnings about \i{multi-line macros}
-being invoked with the wrong number of parameters. This warning
-class is enabled by default; see \k{mlmacover} for an example of why
-you might want to disable it.
+being invoked with the wrong number of parameters. Enabled by default;
+see \k{mlmacover} for an example of why you might want to disable it.
-\b \i\c{macro-selfref} warns if a macro references itself. This
-warning class is disabled by default.
+\b \i\c{macro-selfref} warns if a macro references itself. Disabled by
+default.
-\b\i\c{macro-defaults} warns when a macro has more default
-parameters than optional parameters. This warning class
-is enabled by default; see \k{mlmacdef} for why you might want to disable it.
+\b \i\c{macro-defaults} warns when a macro has more default parameters
+than optional parameters. Enabled by default; see \k{mlmacdef} for why
+you might want to disable it.
\b \i\c{orphan-labels} covers warnings about source lines which
contain no instruction but define a label without a trailing colon.
@@ -811,11 +810,11 @@ NASM warns about this somewhat obscure condition by default;
see \k{syntax} for more information.
\b \i\c{number-overflow} covers warnings about numeric constants which
-don't fit in 64 bits. This warning class is enabled by default.
+don't fit in 64 bits. Enabled by default.
\b \i\c{gnu-elf-extensions} warns if 8-bit or 16-bit relocations
are used in \c{-f elf} format. The GNU extensions allow this.
-This warning class is disabled by default.
+Disabled by default.
\b \i\c{float-overflow} warns about floating point overflow.
Enabled by default.
@@ -844,11 +843,11 @@ form of jmp instruction becomes jmp short form.
Enabled by default.
\b \i\c{zext-reloc} warns that a relocation has been zero-extended due
-to limitations in the output format.
+to limitations in the output format. Enabled by default.
\b \i\c\{ptr} warns about keywords used in other assemblers that might
indicate a mistake in the source code. Currently only the MASM
-\c{PTR} keyword is recognized.
+\c{PTR} keyword is recognized. Enabled by default.
\b \i\c{bad-pragma} warns about a malformed or otherwise unparsable
\c{%pragma} directive. Disabled by default.
@@ -862,22 +861,24 @@ implemented. Disabled by default.
\b \i\c{unknown-warning} warns about a \c{-w} or \c{-W} option or a
\c{[WARNING]} directive that contains an unknown warning name or is
-otherwise not possible to process.
+otherwise not possible to process. Disabled by default.
\b \i\c{all} is an alias for \e{all} suppressible warning classes.
Thus, \c{-w+all} enables all available warnings, and \c{-w-all}
disables warnings entirely (since NASM 2.13).
-Since version 2.00, NASM has also supported the gcc-like syntax
+Since version 2.00, NASM has also supported the \c{gcc}-like syntax
\c{-Wwarning-class} and \c{-Wno-warning-class} instead of
\c{-w+warning-class} and \c{-w-warning-class}, respectively; both
syntaxes work identically.
The option \c{-w+error} or \i\c{-Werror} can be used to treat warnings
as errors. This can be controlled on a per warning class basis
-(\c{-w+error=}\e{warning-class}); if no \e{warning-class} is specified
-NASM treats it as \c{-w+error=all}; the same applies to \c{-w-error}
-or \i\c{-Wno-error}, of course.
+(\c{-w+error=}\e{warning-class} or \c{-Werror=}\e{warning-class});
+if no \e{warning-class} is specified NASM treats it as
+\c{-w+error=all}; the same applies to \c{-w-error} or
+\i\c{-Wno-error},
+of course.
In addition, you can control warnings in the source code itself, using
the \i\c{[WARNING]} directive. See \k{asmdir-warning}.
@@ -4678,9 +4679,15 @@ The \c{[WARNING]} directive can be used to enable or disable classes
of warnings in the same way as the \c{-w} option, see \k{opt-w} for
more details about warning classes.
-Warning classes may be enabled with \c{[warning +]\e{warning-class}\c{]}, disabled
-with \c{[warning -}\e{warning-class}\c{]}, or reset to their original value (as
-specified on the command line) with \c{[warning *}\e{warning-class}{]}.
+\b \c{[warning +}\e{warning-class}\c{]} enables warnings for
+ \e{warning-class}.
+
+\b \c{[warning -}\e{warning-class}\c{]} disables warnings for
+ \e{warning-class}.
+
+\b \c{[warning *}\e{warning-class}\c{]} restores \e{warning-class} to
+ the original value, either the default value or as specified on the
+ command line.
The \c{[WARNING]} directive also accepts the \c{all}, \c{error} and
\c{error=}\e{warning-class} specifiers.
@@ -7754,9 +7761,10 @@ a zero-extended absolute displacement can access from 0 to 4 GB.
\H{unix64} Interfacing to 64-bit C Programs (Unix)
-On Unix, the 64-bit ABI is defined by the document:
+On Unix, the 64-bit ABI as well as the x32 ABI (32-bit ABI with the
+CPU in 64-bit mode) is defined by the documents at:
-\W{http://www.nasm.us/links/unix64abi}\c{http://www.nasm.us/links/unix64abi}
+\W{http://www.nasm.us/abi/unix64}\c{http://www.nasm.us/abi/unix64}
Although written for AT&T-syntax assembly, the concepts apply equally
well for NASM-style assembly. What follows is a simplified summary.
@@ -7786,9 +7794,9 @@ Integer and SSE register arguments are counted separately, so for the case of
\H{win64} Interfacing to 64-bit C Programs (Win64)
-The Win64 ABI is described at:
+The Win64 ABI is described by the document at:
-\W{http://www.nasm.us/links/win64abi}\c{http://www.nasm.us/links/win64abi}
+\W{http://www.nasm.us/abi/win64}\c{http://www.nasm.us/abi/win64}
What follows is a simplified summary.
diff --git a/doc/rdsrc.pl b/doc/rdsrc.pl
index bc066584..129bb085 100644
--- a/doc/rdsrc.pl
+++ b/doc/rdsrc.pl
@@ -971,11 +971,12 @@ sub html_preamble {
print "<h1>", $metadata{'title'}, "</h1>\n";
print '<span class="subtitle">', $metadata{'subtitle'}, "</span>\n";
print "</div>\n";
+ print "<div class=\"contents\"\n>\n";
}
sub html_postamble {
- # Closing tags
- print "</body>\n</html>\n";
+ # Common closing tags
+ print "</div>\n</body>\n</html>\n";
}
sub html_index {
diff --git a/include/nasmlib.h b/include/nasmlib.h
index 16c0c8ca..a71a99ac 100644
--- a/include/nasmlib.h
+++ b/include/nasmlib.h
@@ -426,7 +426,14 @@ char *nasm_opt_val(char *p, char **opt, char **val);
*
* The buffer returned must be freed by the caller
*/
-char *nasm_realpath(const char *rel_path);
+char * safe_alloc nasm_realpath(const char *rel_path);
+
+/*
+ * Path-splitting and merging functions
+ */
+char * safe_alloc nasm_dirname(const char *path);
+char * safe_alloc nasm_basename(const char *path);
+char * safe_alloc nasm_catfile(const char *dir, const char *path);
const char * pure_func prefix_name(int);
diff --git a/include/raa.h b/include/raa.h
index 22c4537b..1ef5cc15 100644
--- a/include/raa.h
+++ b/include/raa.h
@@ -38,7 +38,7 @@
struct RAA;
-struct RAA *raa_init(void);
+struct RAA * never_null raa_init(void);
void raa_free(struct RAA *);
int64_t raa_read(struct RAA *, int32_t);
struct RAA *raa_write(struct RAA *r, int32_t posn, int64_t value);
diff --git a/include/saa.h b/include/saa.h
index 8a8bd075..9d939ef5 100644
--- a/include/saa.h
+++ b/include/saa.h
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2009 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2017 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -66,10 +66,11 @@ struct SAA {
char **blk_ptrs; /* Pointer to pointer blocks */
};
-struct SAA *saa_init(size_t elem_len); /* 1 == byte */
+struct SAA * never_null saa_init(size_t elem_len); /* 1 == byte */
void saa_free(struct SAA *);
void *saa_wstruct(struct SAA *); /* return a structure of elem_len */
void saa_wbytes(struct SAA *, const void *, size_t); /* write arbitrary bytes */
+size_t saa_wcstring(struct SAA *s, const char *str); /* write a C string */
void saa_rewind(struct SAA *); /* for reading from beginning */
void *saa_rstruct(struct SAA *); /* return NULL on EOA */
const void *saa_rbytes(struct SAA *, size_t *); /* return 0 on EOA */
diff --git a/nasm.spec.in b/nasm.spec.in
index 9ca198ea..d6102846 100644
--- a/nasm.spec.in
+++ b/nasm.spec.in
@@ -3,25 +3,29 @@
Summary: The Netwide Assembler, a portable x86 assembler with Intel-like syntax
Name: nasm
Version: @@NASM_MANGLED_VER@@
-Release: 0
+Release: 0%{?dist}
License: BSD
-Group: Development/Languages
Source: http://www.nasm.us/pub/nasm/releasebuilds/%{nasm_version}/nasm-%{nasm_version}.tar.xz
URL: http://www.nasm.us/
BuildRoot: /tmp/rpm-build-nasm
Prefix: %{_prefix}
-BuildRequires: perl, asciidoc, xmlto, ghostscript, perl-Font-TTF
-BuildRequires: adobe-source-sans-pro-fonts, adobe-source-code-pro-fonts
-BuildRequires: fontconfig, xz
+@@PERLBUILDREQS@@
+BuildRequires: autoconf
+BuildRequires: asciidoc
+BuildRequires: xmlto
+BuildRequires: xz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%package doc
-Summary: Extensive documentation for NASM
-Group: Development/Languages
+Summary: Detailed manual for the Netwide Assembler
+BuildArch: noarch
+BuildRequires: ghostscript
+BuildRequires: fontconfig
+BuildRequires: adobe-source-sans-pro-fonts
+BuildRequires: adobe-source-code-pro-fonts
%package rdoff
Summary: Tools for the RDOFF binary format, sometimes used with NASM.
-Group: Development/Tools
%description
NASM is the Netwide Assembler, a free portable assembler for the Intel
@@ -41,26 +45,18 @@ include linker, library manager, loader, and information dump.
%setup -q -n nasm-%{nasm_version}
%build
-%configure --disable-pdf-compression
+autoreconf
+%configure --disable-pdf-compression --enable-sections
make %{?_smp_mflags} everything
+xz -9ef doc/nasmdoc.pdf
%install
-rm -rf "$RPM_BUILD_ROOT"
-mkdir -p "$RPM_BUILD_ROOT"/%{_bindir}
-mkdir -p "$RPM_BUILD_ROOT"/%{_mandir}/man1
-mkdir -p "$RPM_BUILD_ROOT"/usr/tempdoc
-%makeinstall install_everything docdir="$RPM_BUILD_ROOT"/usr/tempdoc
-cp -a $RPM_BUILD_ROOT/usr/tempdoc/html \
- $RPM_BUILD_ROOT/usr/tempdoc/nasmdoc.pdf .
-xz -9ef nasmdoc.pdf
-# remove unpackaged files from the buildroot
-rm -rf $RPM_BUILD_ROOT%{_prefix}/tempdoc
-
-%clean
-rm -rf "$RPM_BUILD_ROOT"
+rm -rf "%{buildroot}"
+mkdir -p "%{buildroot}"/%{_bindir}
+mkdir -p "%{buildroot}"/%{_mandir}/man1
+make INSTALLROOT="%{buildroot}" install install_rdf
%files
-%defattr(-,root,root)
%doc AUTHORS CHANGES README TODO
%{_bindir}/nasm
%{_bindir}/ndisasm
@@ -68,11 +64,9 @@ rm -rf "$RPM_BUILD_ROOT"
%{_mandir}/man1/ndisasm.1*
%files doc
-%defattr(-,root,root)
-%doc html nasmdoc.pdf.xz
+%doc doc/html doc/nasmdoc.pdf.xz
%files rdoff
-%defattr(-,root,root)
%{_bindir}/ldrdf
%{_bindir}/rdf2bin
%{_bindir}/rdf2com
@@ -83,11 +77,7 @@ rm -rf "$RPM_BUILD_ROOT"
%{_bindir}/rdflib
%{_bindir}/rdx
%{_mandir}/man1/ldrdf.1*
-%{_mandir}/man1/rdf2bin.1*
-%{_mandir}/man1/rdf2com.1*
-%{_mandir}/man1/rdf2ihx.1*
-%{_mandir}/man1/rdf2ith.1*
-%{_mandir}/man1/rdf2srec.1*
-%{_mandir}/man1/rdfdump.1*
-%{_mandir}/man1/rdflib.1*
-%{_mandir}/man1/rdx.1*
+%{_mandir}/man1/rd*.1*
+
+# This is the upstream spec file; the change log is in git
+%changelog
diff --git a/nasm.spec.sed b/nasm.spec.sed
new file mode 100644
index 00000000..ae0d039b
--- /dev/null
+++ b/nasm.spec.sed
@@ -0,0 +1,3 @@
+# Replace @@PERLBUILDREQS@@ with the file perlbreq.si
+/@@PERLBUILDREQS@@/{r perlbreq.si
+d}
diff --git a/nasmlib/path.c b/nasmlib/path.c
new file mode 100644
index 00000000..fd7ea132
--- /dev/null
+++ b/nasmlib/path.c
@@ -0,0 +1,171 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2017 The NASM Authors - All Rights Reserved
+ * See the file AUTHORS included with the NASM distribution for
+ * the specific copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * path.c - host operating system specific pathname manipulation functions
+ */
+
+#include "compiler.h"
+#include "nasmlib.h"
+#include "error.h"
+
+#if defined(unix) || defined(__unix) || defined(__unix__)
+# define separators "/"
+# define cleandirend "/"
+# define catsep '/'
+# define leaveonclean 1
+# define curdir "."
+#elif defined(__MSDOS__) || defined(__WINDOWS__) || \
+ defined(__OS2__) || defined(_WIN16) || defined(_WIN32)
+# define separators "/\\:"
+# define cleandirend "/\\"
+# define catsep '\\'
+# define leaveonclean 2 /* Leave \\ at the start alone */
+# define curdir "."
+#elif defined(Macintosh) /* MacOS classic? */
+# define separators ":"
+# define curdir ":"
+# define catsep ':'
+# define cleandirend ":"
+# define leaveonclean 0
+# define leave_leading 1
+#elif defined(__VMS)
+/*
+ * VMS filenames may have ;version at the end. Assume we should count that
+ * as part of the filename anyway.
+ */
+# define separators ":]"
+# define curdir "[]"
+#else
+/* No idea what to do here, do nothing. Feel free to add new ones. */
+# define curdir ""
+#endif
+
+/*
+ * This is an inline, because most compilers can greatly simplify this
+ * for a fixed string, like we have here.
+ */
+static inline bool ismatch(const char *charset, char ch)
+{
+ const char *p;
+
+ for (p = charset; *p; p++) {
+ if (ch == *p)
+ return true;
+ }
+
+ return false;
+}
+
+static const char *first_filename_char(const char *path)
+{
+#ifdef separators
+ const char *p = path + strlen(path);
+
+ while (p > path) {
+ if (!ismatch(separators, p[-1]))
+ return p;
+ p--;
+ }
+
+ return p;
+#else
+ return path;
+#endif
+}
+
+/* Return the filename portion of a PATH as a new string */
+char *nasm_basename(const char *path)
+{
+ return nasm_strdup(first_filename_char(path));
+}
+
+/* Return the directory name portion of a PATH as a new string */
+char *nasm_dirname(const char *path)
+{
+ const char *p = first_filename_char(path);
+ const char *p0 = p;
+ (void)p0; /* Don't warn if unused */
+
+ if (p == path)
+ return nasm_strdup(curdir);
+
+#ifdef cleandirend
+ while (p > path+leaveonclean) {
+ if (ismatch(cleandirend, p[-1]))
+ break;
+ p--;
+ }
+#endif
+
+#ifdef leave_leading
+ /* If the directory contained ONLY separators, leave as-is */
+ if (p == path+leaveonclean)
+ p = p0;
+#endif
+
+ return nasm_strndup(path, p-path);
+}
+
+/*
+ * Concatenate a directory path and a filename. Note that this function
+ * currently does NOT handle the case where file itself contains
+ * directory components (except on Unix platforms, because it is trivial.)
+ */
+char *nasm_catfile(const char *dir, const char *file)
+{
+#ifndef catsep
+ return nasm_strcat(dir, file);
+#else
+ size_t dl = strlen(dir);
+ size_t fl = strlen(file);
+ char *p;
+ bool dosep = true;
+
+ if (!dl || ismatch(separators, dir[dl-1])) {
+ /* No separator necessary */
+ dosep = false;
+ }
+
+ p = nasm_malloc(dl + fl + dosep + 1);
+
+ memcpy(p, dir, dl);
+ p += dl;
+ if (dosep)
+ *p++ = catsep;
+
+ memcpy(p, file, fl+1);
+
+ return p;
+#endif
+}
diff --git a/nasmlib/saa.c b/nasmlib/saa.c
index a0350c10..c4af5aa0 100644
--- a/nasmlib/saa.c
+++ b/nasmlib/saa.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2009 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2017 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -149,6 +149,19 @@ void saa_wbytes(struct SAA *s, const void *data, size_t len)
}
}
+/*
+ * Writes a string, *including* the final null, to the specified SAA,
+ * and return the number of bytes written.
+ */
+size_t saa_wcstring(struct SAA *s, const char *str)
+{
+ size_t bytes = strlen(str) + 1;
+
+ saa_wbytes(s, str, bytes);
+
+ return bytes;
+}
+
void saa_rewind(struct SAA *s)
{
s->rblk = s->blk_ptrs;
diff --git a/output/outelf.c b/output/outelf.c
index 003e7d04..e8d95ea0 100644
--- a/output/outelf.c
+++ b/output/outelf.c
@@ -2493,7 +2493,7 @@ static void stabs_linenum(const char *filename, int32_t linenumber, int32_t segt
{
(void)segto;
if (!stabs_filename) {
- stabs_filename = (char *)nasm_malloc(strlen(filename) + 1);
+ stabs_filename = nasm_malloc(strlen(filename) + 1);
strcpy(stabs_filename, filename);
} else {
if (strcmp(stabs_filename, filename)) {
@@ -2503,7 +2503,7 @@ static void stabs_linenum(const char *filename, int32_t linenumber, int32_t segt
/* why not nasm_free(stabs_filename); we're done with the old one */
- stabs_filename = (char *)nasm_malloc(strlen(filename) + 1);
+ stabs_filename = nasm_malloc(strlen(filename) + 1);
strcpy(stabs_filename, filename);
}
}
@@ -2521,7 +2521,7 @@ static void stabs_output(int type, void *param)
if (!(sects[s->section]->flags & SHF_EXECINSTR))
return; /* line info is only collected for executable sections */
numlinestabs++;
- el = (struct linelist *)nasm_malloc(sizeof(struct linelist));
+ el = nasm_malloc(sizeof(struct linelist));
el->info.offset = s->offset;
el->info.section = s->section;
el->info.name = s->name;
@@ -2553,7 +2553,7 @@ static void stabs_generate(void)
ptr = stabslines;
- allfiles = (char **)nasm_zalloc(numlinestabs * sizeof(char *));
+ allfiles = nasm_zalloc(numlinestabs * sizeof(char *));
numfiles = 0;
while (ptr) {
if (numfiles == 0) {
@@ -2572,7 +2572,7 @@ static void stabs_generate(void)
ptr = ptr->next;
}
strsize = 1;
- fileidx = (int *)nasm_malloc(numfiles * sizeof(int));
+ fileidx = nasm_malloc(numfiles * sizeof(int));
for (i = 0; i < numfiles; i++) {
fileidx[i] = strsize;
strsize += strlen(allfiles[i]) + 1;
@@ -2590,10 +2590,10 @@ static void stabs_generate(void)
* the sourcefiles changes each line, which would mean 1 SOL, 1 SYMLIN per line
* plus one "ending" entry
*/
- sbuf = (uint8_t *)nasm_malloc((numlinestabs * 2 + 4) *
+ sbuf = nasm_malloc((numlinestabs * 2 + 4) *
sizeof(struct stabentry));
- ssbuf = (uint8_t *)nasm_malloc(strsize);
- rbuf = (uint8_t *)nasm_malloc(numlinestabs * (is_elf64() ? 16 : 8) * (2 + 3));
+ ssbuf = nasm_malloc(strsize);
+ rbuf = nasm_malloc(numlinestabs * (is_elf64() ? 16 : 8) * (2 + 3));
rptr = rbuf;
for (i = 0; i < numfiles; i++)
@@ -3318,7 +3318,7 @@ static void dwarf_findfile(const char * fname)
}
/* add file name to end of list */
- dwarf_clist = (struct linelist *)nasm_malloc(sizeof(struct linelist));
+ dwarf_clist = nasm_malloc(sizeof(struct linelist));
dwarf_numfiles++;
dwarf_clist->line = dwarf_numfiles;
dwarf_clist->filename = nasm_malloc(strlen(fname) + 1);
@@ -3357,7 +3357,7 @@ static void dwarf_findsect(const int index)
}
/* add entry to end of list */
- dwarf_csect = (struct sectlist *)nasm_malloc(sizeof(struct sectlist));
+ dwarf_csect = nasm_malloc(sizeof(struct sectlist));
dwarf_nsections++;
dwarf_csect->psaa = plinep = saa_init(1L);
dwarf_csect->line = 1;
diff --git a/output/outmacho.c b/output/outmacho.c
index 173706b9..d10c60c3 100644
--- a/output/outmacho.c
+++ b/output/outmacho.c
@@ -1784,7 +1784,7 @@ static void macho_dbg_generate(void)
size_t saa_len = 0, high_addr = 0, total_len = 0;
struct section *p_section = NULL;
/* calculated at debug_str and referenced at debug_info */
- uint32_t producer_str_offset = 0, module_str_offset = 0;
+ uint32_t producer_str_offset = 0, module_str_offset = 0, path_str_offset = 0;
/* debug section defines */
{
@@ -1797,9 +1797,9 @@ static void macho_dbg_generate(void)
/* dw section walk to find high_addr and total_len */
{
- struct dw_sect_list *p_sect = dw_head_sect;
- uint32_t idx = 0;
- for(; idx < dw_num_sects; idx++) {
+ struct dw_sect_list *p_sect;
+
+ list_for_each(p_sect, dw_head_sect) {
uint64_t offset = get_section_by_index(p_sect->section)->size;
struct SAA *p_linep = p_sect->psaa;
@@ -1811,16 +1811,14 @@ static void macho_dbg_generate(void)
total_len += p_linep->datalen;
high_addr += offset;
- p_sect = p_sect->next;
}
}
/* debug line */
{
- struct file_list *p_file = dw_head_list;
- struct dw_sect_list *p_sect = dw_head_sect;
- size_t linep_off = 0;
- uint32_t idx = 0, buf_size = 0;
+ struct file_list *p_file;
+ struct dw_sect_list *p_sect;
+ size_t linep_off, buf_size;
struct SAA *p_lines = saa_init(1L);
nasm_assert(p_lines != NULL);
@@ -1846,12 +1844,11 @@ static void macho_dbg_generate(void)
saa_write8(p_lines, 1); /* std opcode 12 length */
saa_write8(p_lines, 0); /* end of table */
- for(idx = 0; idx < dw_num_files; idx++) {
- saa_wbytes(p_lines, p_file->file_name, (int32_t)(strlen(p_file->file_name) +1));
+ list_for_each(p_file, dw_head_list) {
+ saa_wcstring(p_lines, p_file->file_name);
saa_write8(p_lines, 0); /* directory */
saa_write8(p_lines, 0); /* time */
saa_write8(p_lines, 0); /* size */
- p_file = p_file->next;
}
saa_write8(p_lines, 0); /* end of table */
@@ -1868,7 +1865,7 @@ static void macho_dbg_generate(void)
p_buf += linep_off;
saa_free(p_lines);
- for(idx = 0; idx < dw_num_sects; idx++) {
+ list_for_each(p_sect, dw_head_sect) {
struct SAA *p_linep = p_sect->psaa;
saa_len = p_linep->datalen;
saa_rnbytes(p_linep, p_buf, saa_len);
@@ -1884,9 +1881,9 @@ static void macho_dbg_generate(void)
/* string section */
{
struct file_list *p_file = dw_head_list;
- uint32_t idx = 0;
struct SAA *p_str = saa_init(1L);
- nasm_assert(p_str != NULL);
+ struct SAA *p_path_str = saa_init(1L);
+ nasm_assert((p_str != NULL) && (p_path_str != NULL));
p_section = get_section_by_name("__DWARF", "__debug_str");
nasm_assert(p_section != NULL);
@@ -1894,19 +1891,33 @@ static void macho_dbg_generate(void)
producer_str_offset = 0;
saa_wbytes(p_str, nasm_signature, strlen(nasm_signature) + 1);
- module_str_offset = producer_str_offset + strlen(nasm_signature) + 1;
- for(; idx < dw_num_files; idx++) {
- saa_wbytes(p_str, p_file->file_name, (int32_t)(strlen(p_file->file_name) + 1));
- p_file = p_file->next;
+ module_str_offset = path_str_offset = producer_str_offset + strlen(nasm_signature) + 1;
+
+ list_for_each(p_file, dw_head_list) {
+ char *cur_path = nasm_realpath(p_file->file_name);
+ char *cur_file = nasm_basename(cur_path);
+ char *cur_dir = nasm_dirname(cur_path);
+
+ saa_wcstring(p_str, cur_file);
+ saa_wcstring(p_path_str, cur_dir);
+
+ nasm_free(cur_path);
+ nasm_free(cur_file);
+ nasm_free(cur_dir);
}
saa_len = p_str->datalen;
-
+ path_str_offset += saa_len;
p_buf = nasm_malloc(saa_len);
saa_rnbytes(p_str, p_buf, saa_len);
macho_output(p_section->index, p_buf, OUT_RAWDATA, saa_len, NO_SEG, 0);
-
saa_free(p_str);
+
+ saa_len = p_path_str->datalen;
+ p_buf = nasm_malloc(saa_len);
+ saa_rnbytes(p_path_str, p_buf, saa_len);
+ macho_output(p_section->index, p_buf, OUT_RAWDATA, saa_len, NO_SEG, 0);
+ saa_free(p_path_str);
}
/* debug info */
@@ -1927,6 +1938,7 @@ static void macho_dbg_generate(void)
saa_write32(p_info, producer_str_offset); /* offset from string table for DW_AT_producer */
saa_write16(p_info, DW_LANG_Mips_Assembler); /* DW_AT_language */
saa_write32(p_info, module_str_offset); /* offset from string table for DW_AT_name */
+ saa_write32(p_info, path_str_offset); /* offset from string table for DW_AT_comp_dir */
saa_write32(p_info, 0); /* DW_AT_stmt_list */
if (ofmt == &of_macho64) {
@@ -1980,6 +1992,9 @@ static void macho_dbg_generate(void)
saa_write8(p_abbrev, DW_AT_name);
saa_write8(p_abbrev, DW_FORM_strp);
+ saa_write8(p_abbrev, DW_AT_comp_dir);
+ saa_write8(p_abbrev, DW_FORM_strp);
+
saa_write8(p_abbrev, DW_AT_stmt_list);
saa_write8(p_abbrev, DW_FORM_data4);
@@ -2026,16 +2041,14 @@ static void macho_dbg_linenum(const char *file_name, int32_t line_num, int32_t s
if(!dw_cur_list || strcmp(file_name, dw_cur_list->file_name)) {
if(dw_head_list) {
- struct file_list *match = dw_head_list;
- uint32_t idx = 0;
+ struct file_list *match;
- for (; idx < dw_num_files; idx++ ) {
+ list_for_each(match, dw_head_list) {
if(!(strcmp(file_name, match->file_name))) {
dw_cur_list = match;
need_new_list = false;
break;
}
- match = match->next;
}
}
diff --git a/version b/version
index 562d30e4..6d4f8e0c 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-2.13rc20
+2.13rc21