aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2018-12-13 16:43:43 -0800
committerH. Peter Anvin (Intel) <hpa@zytor.com>2018-12-13 16:43:43 -0800
commitdf2195b6a978448f640cae552858740d214886a4 (patch)
treead9a7198f2b89ad36e6d06fc7bfb560b3fc0ce74
parentfef75c265a2dafb6482ffd4078f74f2a66fa2535 (diff)
parent3b91f4c117003a9f42717fe88257b6025790169e (diff)
downloadnasm-df2195b6a978448f640cae552858740d214886a4.tar.gz
nasm-df2195b6a978448f640cae552858740d214886a4.tar.xz
nasm-df2195b6a978448f640cae552858740d214886a4.zip
Merge remote-tracking branch 'origin/nasm-2.14.xx'
Resolved Conflicts: Makefile.in Mkfiles/msvc.mak Mkfiles/openwcom.mak asm/nasm.c nasmlib/alloc.c Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--Makefile.in5
-rw-r--r--Mkfiles/msvc.mak5
-rw-r--r--Mkfiles/openwcom.mak5
-rw-r--r--asm/nasm.c6
-rw-r--r--include/error.h5
-rw-r--r--nasmlib/alloc.c18
-rw-r--r--nasmlib/errfile.c5
-rw-r--r--rdoff/ldrdf.c3
8 files changed, 39 insertions, 13 deletions
diff --git a/Makefile.in b/Makefile.in
index 8e55e83e..78eaffe2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -96,8 +96,9 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \
\
nasmlib/ver.$(O) \
- nasmlib/crc64.$(O) nasmlib/alloc.$(O) nasmlib/asprintf.$(O) \
- nasmlib/md5c.$(O) nasmlib/string.$(O) nasmlib/nctype.$(O) \
+ nasmlib/alloc.$(O) nasmlib/asprintf.$(O) nasmlib/errfile.$(O) \
+ nasmlib/crc64.$(O) nasmlib/md5c.$(O) \
+ nasmlib/string.$(O) nasmlib/nctype.$(O) \
nasmlib/file.$(O) nasmlib/mmap.$(O) nasmlib/ilog2.$(O) \
nasmlib/realpath.$(O) nasmlib/path.$(O) \
nasmlib/filename.$(O) \
diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak
index 89e392d9..9c7d60e0 100644
--- a/Mkfiles/msvc.mak
+++ b/Mkfiles/msvc.mak
@@ -68,8 +68,9 @@ LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \
stdlib\strnlen.$(O) stdlib\strrchrnul.$(O) \
\
nasmlib\ver.$(O) \
- nasmlib\crc64.$(O) nasmlib\alloc.$(O) nasmlib\asprintf.$(O) \
- nasmlib\md5c.$(O) nasmlib\string.$(O) nasmlib\nctype.$(O) \
+ nasmlib\alloc.$(O) nasmlib\asprintf.$(O) nasmlib\errfile.$(O) \
+ nasmlib\crc64.$(O) nasmlib\md5c.$(O) \
+ nasmlib\string.$(O) nasmlib\nctype.$(O) \
nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) \
nasmlib\realpath.$(O) nasmlib\path.$(O) \
nasmlib\filename.$(O) \
diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak
index 1c407dea..2babe5dc 100644
--- a/Mkfiles/openwcom.mak
+++ b/Mkfiles/openwcom.mak
@@ -57,8 +57,9 @@ LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) &
stdlib\strnlen.$(O) stdlib\strrchrnul.$(O) &
&
nasmlib\ver.$(O) &
- nasmlib\crc64.$(O) nasmlib\alloc.$(O) nasmlib\asprintf.$(O) &
- nasmlib\md5c.$(O) nasmlib\string.$(O) nasmlib\nctype.$(O) &
+ nasmlib\alloc.$(O) nasmlib\asprintf.$(O) nasmlib\errfile.$(O) &
+ nasmlib\crc64.$(O) nasmlib\md5c.$(O) &
+ nasmlib\string.$(O) nasmlib\nctype.$(O) &
nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) &
nasmlib\realpath.$(O) nasmlib\path.$(O) &
nasmlib\filename.$(O) &
diff --git a/asm/nasm.c b/asm/nasm.c
index 48217455..149e1042 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -121,7 +121,7 @@ const struct ofmt *ofmt = &OF_DEFAULT;
const struct ofmt_alias *ofmt_alias = NULL;
const struct dfmt *dfmt;
-static FILE *error_file; /* Where to write error messages */
+FILE *error_file; /* Where to write error messages */
FILE *ofile = NULL;
struct optimization optimizing =
@@ -451,6 +451,8 @@ int main(int argc, char **argv)
{
timestamp();
+ error_file = stderr;
+
iflag_set_default_cpu(&cpu);
iflag_set_default_cpu(&cmd_cpu);
@@ -460,8 +462,6 @@ int main(int argc, char **argv)
want_usage = terminate_after_phase = false;
nasm_set_verror(nasm_verror_asm);
- error_file = stderr;
-
nasm_ctype_init();
src_init();
diff --git a/include/error.h b/include/error.h
index 8d5084c8..a2146e97 100644
--- a/include/error.h
+++ b/include/error.h
@@ -41,6 +41,11 @@
#include "compiler.h"
/*
+ * File pointer for error messages
+ */
+extern FILE *error_file; /* Error file descriptor */
+
+/*
* An error reporting function should look like this.
*/
void printf_func(2, 3) nasm_error(int severity, const char *fmt, ...);
diff --git a/nasmlib/alloc.c b/nasmlib/alloc.c
index 2f3f9519..ad2cff3d 100644
--- a/nasmlib/alloc.c
+++ b/nasmlib/alloc.c
@@ -42,7 +42,23 @@
no_return nasm_alloc_failed(void)
{
- nasm_fatal("out of memory");
+ /* If nasm_fatal() gets us back here, then croak hard */
+ static bool already_here = false;
+ FILE *errfile;
+
+ if (likely(!already_here)) {
+ already_here = true;
+ nasm_fatal("out of memory!");
+ }
+
+ errfile = error_file;
+ if (!errfile)
+ error_file = stderr;
+
+ fprintf(error_file, "nasm: out of memory!\n");
+ fflush(error_file);
+ fflush(NULL);
+ abort();
}
void *nasm_malloc(size_t size)
diff --git a/nasmlib/errfile.c b/nasmlib/errfile.c
new file mode 100644
index 00000000..ee4bae8e
--- /dev/null
+++ b/nasmlib/errfile.c
@@ -0,0 +1,5 @@
+#include "compiler.h"
+#include <stdio.h>
+
+FILE *error_file;
+
diff --git a/rdoff/ldrdf.c b/rdoff/ldrdf.c
index dd80d70e..49729b4f 100644
--- a/rdoff/ldrdf.c
+++ b/rdoff/ldrdf.c
@@ -126,9 +126,6 @@ char *generic_rec_file = NULL;
/* module name to be added at the beginning of output file */
char *modname_specified = NULL;
-/* error file */
-static FILE *error_file;
-
/* the header of the output file, built up stage by stage */
rdf_headerbuf *newheader = NULL;