aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ver.h10
-rw-r--r--nasmlib/ver.c44
-rw-r--r--output/outelf.c6
-rw-r--r--output/outieee.c2
-rw-r--r--output/outmacho.c2
-rw-r--r--output/outobj.c2
6 files changed, 56 insertions, 10 deletions
diff --git a/include/ver.h b/include/ver.h
index 62d9c52d..dfc4c6ad 100644
--- a/include/ver.h
+++ b/include/ver.h
@@ -41,7 +41,13 @@
extern const char nasm_version[];
extern const char nasm_date[];
extern const char nasm_compile_options[];
-extern const char nasm_comment[];
-extern const char nasm_signature[];
+
+extern const char *nasm_comment(void);
+extern size_t nasm_comment_len(void);
+
+extern const char *nasm_signature(void);
+extern size_t nasm_signature_len(void);
+
+extern int nasm_test_run(void);
#endif /* NASM_VER_H */
diff --git a/nasmlib/ver.c b/nasmlib/ver.c
index 98362e35..b1638b7d 100644
--- a/nasmlib/ver.c
+++ b/nasmlib/ver.c
@@ -31,6 +31,9 @@
*
* ----------------------------------------------------------------------- */
+#include <stdlib.h>
+#include <string.h>
+
#include "ver.h"
#include "version.h"
@@ -44,8 +47,45 @@ const char nasm_compile_options[] = ""
;
/* These are used by some backends. */
-const char nasm_comment[] =
+static const char __nasm_comment[] =
"The Netwide Assembler " NASM_VER;
-const char nasm_signature[] =
+static const char __nasm_signature[] =
"NASM " NASM_VER;
+
+/* These are constant so we could pass regression tests */
+static const char __nasm_comment_const[] ="The Netwide Assembler CONST";
+static const char __nasm_signature_const[] = "NASM CONST";
+
+int nasm_test_run(void)
+{
+ return getenv("NASM_TEST_RUN") ? 1 : 0;
+}
+
+const char *nasm_comment(void)
+{
+ if (!nasm_test_run())
+ return __nasm_comment;
+ return __nasm_comment_const;
+}
+
+size_t nasm_comment_len(void)
+{
+ if (!nasm_test_run())
+ return strlen(__nasm_comment);
+ return strlen(__nasm_comment_const);
+}
+
+const char *nasm_signature(void)
+{
+ if (!nasm_test_run())
+ return __nasm_signature;
+ return __nasm_signature_const;
+}
+
+size_t nasm_signature_len(void)
+{
+ if (!nasm_test_run())
+ return strlen(__nasm_signature);
+ return strlen(__nasm_signature_const);
+}
diff --git a/output/outelf.c b/output/outelf.c
index d8a55416..e3e3a686 100644
--- a/output/outelf.c
+++ b/output/outelf.c
@@ -2996,7 +2996,7 @@ static void dwarf_generate(void)
saa_write32(pinforel, 0);
saa_write32(pinfo,0); /* DW_AT_stmt_list */
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1);
- saa_wbytes(pinfo, nasm_signature, strlen(nasm_signature)+1);
+ saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1);
saa_write16(pinfo,DW_LANG_Mips_Assembler);
saa_write8(pinfo,2); /* abbrviation number LEB128u */
saa_write32(pinforel, pinfo->datalen + 4);
@@ -3035,7 +3035,7 @@ static void dwarf_generate(void)
saa_write32(pinforel, 0);
saa_write32(pinfo,0); /* DW_AT_stmt_list */
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1);
- saa_wbytes(pinfo, nasm_signature, strlen(nasm_signature)+1);
+ saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1);
saa_write16(pinfo,DW_LANG_Mips_Assembler);
saa_write8(pinfo,2); /* abbrviation number LEB128u */
saa_write32(pinforel, pinfo->datalen + 4);
@@ -3075,7 +3075,7 @@ static void dwarf_generate(void)
saa_write64(pinforel, 0);
saa_write32(pinfo,0); /* DW_AT_stmt_list */
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1);
- saa_wbytes(pinfo, nasm_signature, strlen(nasm_signature)+1);
+ saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1);
saa_write16(pinfo,DW_LANG_Mips_Assembler);
saa_write8(pinfo,2); /* abbrviation number LEB128u */
saa_write64(pinforel, pinfo->datalen + 4);
diff --git a/output/outieee.c b/output/outieee.c
index 211cdaba..ce4830da 100644
--- a/output/outieee.c
+++ b/output/outieee.c
@@ -893,7 +893,7 @@ static void ieee_write_file(void)
/*
* Write the NASM boast comment.
*/
- ieee_putascii("CO0,%02X%s.\n", strlen(nasm_comment), nasm_comment);
+ ieee_putascii("CO0,%02X%s.\n", nasm_comment_len(), nasm_comment());
/*
* write processor-specific information
diff --git a/output/outmacho.c b/output/outmacho.c
index 769aac02..14aec076 100644
--- a/output/outmacho.c
+++ b/output/outmacho.c
@@ -1950,7 +1950,7 @@ static void macho_dbg_generate(void)
nasm_assert(p_section != NULL);
producer_str_offset = 0;
- module_str_offset = dir_str_offset = saa_wcstring(p_str, nasm_signature);
+ module_str_offset = dir_str_offset = saa_wcstring(p_str, nasm_signature());
dir_str_offset += saa_wcstring(p_str, cur_file);
saa_wcstring(p_str, cur_dir);
diff --git a/output/outobj.c b/output/outobj.c
index b766c54c..1caaf200 100644
--- a/output/outobj.c
+++ b/output/outobj.c
@@ -1981,7 +1981,7 @@ static void obj_write_file(void)
*/
orp->type = COMENT;
obj_rword(orp, dTRANSL);
- obj_name(orp, nasm_comment);
+ obj_name(orp, nasm_comment());
obj_emit2(orp);
/*