/* Preprocess-only buffer size */
#define PREPROC_BUF_SIZE 16384
+/* Check the module version */
+#define check_module_version(d, TYPE, desc) \
+do { \
+ if (d && d->version != YASM_##TYPE##_VERSION) { \
+ print_error( \
+ _("%s: module version mismatch: %s `%s' (need %d, module %d)"), \
+ _("FATAL"), _(desc), d->keyword, YASM_##TYPE##_VERSION, \
+ d->version); \
+ exit(EXIT_FAILURE); \
+ } \
+} while (0)
+
/*@null@*/ /*@only@*/ static char *obj_filename = NULL, *in_filename = NULL;
/*@null@*/ /*@only@*/ static char *machine_name = NULL;
static int special_options = 0;
cleanup(NULL);
return EXIT_FAILURE;
}
+ check_module_version(cur_preproc, PREPROC, "preproc");
apply_preproc_saved_options();
return EXIT_FAILURE;
}
}
+ check_module_version(cur_arch, ARCH, "arch");
/* Set up architecture using the selected (or default) machine */
if (!machine_name)
_("optimizer"));
return EXIT_FAILURE;
}
+ check_module_version(cur_optimizer, OPTIMIZER, "optimizer");
yasm_arch_common_initialize(cur_arch);
yasm_expr_initialize(cur_arch);
_("object format"));
return EXIT_FAILURE;
}
+ check_module_version(cur_objfmt, OBJFMT, "objfmt");
/* If not already specified, default to null as the debug format. */
if (!cur_dbgfmt)
_("debug format"));
return EXIT_FAILURE;
}
+ check_module_version(cur_dbgfmt, DBGFMT, "dbgfmt");
/* determine the object filename if not specified */
if (!obj_filename) {
return EXIT_FAILURE;
}
}
+ check_module_version(cur_parser, PARSER, "parser");
/* If not already specified, default to the parser's default preproc. */
if (!cur_preproc)
cleanup(NULL);
return EXIT_FAILURE;
}
+ check_module_version(cur_preproc, PREPROC, "preproc");
apply_preproc_saved_options();
const char *keyword;
} yasm_arch_machine;
+/** Version number of #yasm_arch interface. Any functional change to the
+ * #yasm_arch interface should simultaneously increment this number. This
+ * version should be checked by #yasm_arch loaders to verify that the
+ * expected version (the version defined by its libyasm header files) matches
+ * the loaded module version (the version defined by the module's libyasm
+ * header files). Doing this will ensure that the module version's function
+ * definitions match the module loader's function definitions. The version
+ * number must never be decreased.
+ */
+#define YASM_ARCH_VERSION 0
+
/** YASM architecture interface.
* \note All "data" in parser-related functions (parse_*) needs to start the
* parse initialized to 0 to make it okay for a parser-related function
* on the same piece of data.
*/
struct yasm_arch {
+ /** Version (see #YASM_ARCH_VERSION). Should always be set to
+ * #YASM_ARCH_VERSION by the module source and checked against
+ * #YASM_ARCH_VERSION by the module loader.
+ */
+ unsigned int version;
+
/** One-line description of the architecture. */
const char *name;
#ifndef YASM_DBGFMT_H
#define YASM_DBGFMT_H
+/** Version number of #yasm_dbgfmt interface. Any functional change to the
+ * #yasm_dbgfmt interface should simultaneously increment this number. This
+ * version should be checked by #yasm_dbgfmt loaders to verify that the
+ * expected version (the version defined by its libyasm header files) matches
+ * the loaded module version (the version defined by the module's libyasm
+ * header files). Doing this will ensure that the module version's function
+ * definitions match the module loader's function definitions. The version
+ * number must never be decreased.
+ */
+#define YASM_DBGFMT_VERSION 0
+
/** YASM debug format interface. */
struct yasm_dbgfmt {
+ /** Version (see #YASM_DBGFMT_VERSION). Should always be set to
+ * #YASM_DBGFMT_VERSION by the module source and checked against
+ * #YASM_DBGFMT_VERSION by the module loader.
+ */
+ unsigned int version;
+
/** One-line description of the debug format. */
const char *name;
#ifndef YASM_OBJFMT_H
#define YASM_OBJFMT_H
+/** Version number of #yasm_objfmt interface. Any functional change to the
+ * #yasm_objfmt interface should simultaneously increment this number. This
+ * version should be checked by #yasm_objfmt loaders to verify that the
+ * expected version (the version defined by its libyasm header files) matches
+ * the loaded module version (the version defined by the module's libyasm
+ * header files). Doing this will ensure that the module version's function
+ * definitions match the module loader's function definitions. The version
+ * number must never be decreased.
+ */
+#define YASM_OBJFMT_VERSION 0
+
/** YASM object format interface. */
struct yasm_objfmt {
+ /** Version (see #YASM_OBJFMT_VERSION). Should always be set to
+ * #YASM_OBJFMT_VERSION by the module source and checked against
+ * #YASM_OBJFMT_VERSION by the module loader.
+ */
+ unsigned int version;
+
/** One-line description of the object format. */
const char *name;
#ifndef YASM_OPTIMIZER_H
#define YASM_OPTIMIZER_H
+/** Version number of #yasm_optimizer interface. Any functional change to the
+ * #yasm_optimizer interface should simultaneously increment this number. This
+ * version should be checked by #yasm_optimizer loaders to verify that the
+ * expected version (the version defined by its libyasm header files) matches
+ * the loaded module version (the version defined by the module's libyasm
+ * header files). Doing this will ensure that the module version's function
+ * definitions match the module loader's function definitions. The version
+ * number must never be decreased.
+ */
+#define YASM_OPTIMIZER_VERSION 0
+
/* Interface to the optimizer module(s) */
struct yasm_optimizer {
+ /** Version (see #YASM_OPTIMIZER_VERSION). Should always be set to
+ * #YASM_OPTIMIZER_VERSION by the module source and checked against
+ * #YASM_OPTIMIZER_VERSION by the module loader.
+ */
+ unsigned int version;
+
/* one-line description of the optimizer */
const char *name;
-/* $IdPath: yasm/libyasm/parser.h,v 1.21 2003/03/13 06:54:19 peter Exp $
+/* $IdPath$
* Parser module interface header file
*
* Copyright (C) 2001 Peter Johnson
#ifndef YASM_PARSER_H
#define YASM_PARSER_H
+/** Version number of #yasm_parser interface. Any functional change to the
+ * #yasm_parser interface should simultaneously increment this number. This
+ * version should be checked by #yasm_parser loaders to verify that the
+ * expected version (the version defined by its libyasm header files) matches
+ * the loaded module version (the version defined by the module's libyasm
+ * header files). Doing this will ensure that the module version's function
+ * definitions match the module loader's function definitions. The version
+ * number must never be decreased.
+ */
+#define YASM_PARSER_VERSION 0
+
/* Interface to the parser module(s) -- the "front end" of the assembler */
struct yasm_parser {
+ /** Version (see #YASM_PARSER_VERSION). Should always be set to
+ * #YASM_PARSER_VERSION by the module source and checked against
+ * #YASM_PARSER_VERSION by the module loader.
+ */
+ unsigned int version;
+
/* one-line description of the parser */
const char *name;
#ifndef YASM_PREPROC_H
#define YASM_PREPROC_H
+/** Version number of #yasm_preproc interface. Any functional change to the
+ * #yasm_preproc interface should simultaneously increment this number. This
+ * version should be checked by #yasm_preproc loaders to verify that the
+ * expected version (the version defined by its libyasm header files) matches
+ * the loaded module version (the version defined by the module's libyasm
+ * header files). Doing this will ensure that the module version's function
+ * definitions match the module loader's function definitions. The version
+ * number must never be decreased.
+ */
+#define YASM_PREPROC_VERSION 0
+
/* Interface to the preprocesor module(s) */
struct yasm_preproc {
+ /** Version (see #YASM_PREPROC_VERSION). Should always be set to
+ * #YASM_PREPROC_VERSION by the module source and checked against
+ * #YASM_PREPROC_VERSION by the module loader.
+ */
+ unsigned int version;
+
/* one-line description of the preprocessor */
const char *name;
/* Define arch structure -- see arch.h for details */
yasm_arch yasm_lc3b_LTX_arch = {
+ YASM_ARCH_VERSION,
"LC-3b",
"lc3b",
lc3b_initialize,
/* Define arch structure -- see arch.h for details */
yasm_arch yasm_x86_LTX_arch = {
+ YASM_ARCH_VERSION,
"x86 (IA-32 and derivatives), AMD64",
"x86",
x86_initialize,
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <util.h>
-/*@unused@*/ RCSID("$IdPath: yasm/modules/dbgfmts/null/null-dbgfmt.c,v 1.8 2003/03/26 05:07:56 peter Exp $");
+/*@unused@*/ RCSID("$IdPath$");
#define YASM_LIB_INTERNAL
#include <libyasm.h>
/* Define dbgfmt structure -- see dbgfmt.h for details */
yasm_dbgfmt yasm_null_LTX_dbgfmt = {
+ YASM_DBGFMT_VERSION,
"No debugging info",
"null",
NULL, /*null_dbgfmt_initialize*/
/* Define objfmt structure -- see objfmt.h for details */
yasm_objfmt yasm_bin_LTX_objfmt = {
+ YASM_OBJFMT_VERSION,
"Flat format binary",
"bin",
NULL,
/* Define objfmt structure -- see objfmt.h for details */
yasm_objfmt yasm_coff_LTX_objfmt = {
+ YASM_OBJFMT_VERSION,
"COFF (DJGPP)",
"coff",
"o",
/* Define objfmt structure -- see objfmt.h for details */
yasm_objfmt yasm_win32_LTX_objfmt = {
+ YASM_OBJFMT_VERSION,
"Win32",
"win32",
"obj",
/* Define objfmt structure -- see objfmt.h for details */
yasm_objfmt yasm_dbg_LTX_objfmt = {
+ YASM_OBJFMT_VERSION,
"Trace of all info passed to object format module",
"dbg",
"dbg",
/* Define objfmt structure -- see objfmt.h for details */
yasm_objfmt yasm_elf_LTX_objfmt = {
+ YASM_OBJFMT_VERSION,
"ELF",
"elf",
"o",
/* Define optimizer structure -- see optimizer.h for details */
yasm_optimizer yasm_basic_LTX_optimizer = {
+ YASM_OPTIMIZER_VERSION,
"Only the most basic optimizations",
"basic",
basic_optimize
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <util.h>
-/*@unused@*/ RCSID("$IdPath: yasm/modules/parsers/nasm/nasm-parser.c,v 1.34 2003/05/04 22:15:09 peter Exp $");
+/*@unused@*/ RCSID("$IdPath$");
#define YASM_LIB_INTERNAL
#include <libyasm.h>
/* Define parser structure -- see parser.h for details */
yasm_parser yasm_nasm_LTX_parser = {
+ YASM_PARSER_VERSION,
"NASM-compatible parser",
"nasm",
nasm_parser_preproc_keywords,
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <util.h>
-/*@unused@*/ RCSID("$IdPath: yasm/modules/preprocs/nasm/nasm-preproc.c,v 1.8 2003/04/01 04:06:47 mu Exp $");
+/*@unused@*/ RCSID("$IdPath$");
#define YASM_LIB_INTERNAL
#include <libyasm.h>
/* Define preproc structure -- see preproc.h for details */
yasm_preproc yasm_nasm_LTX_preproc = {
+ YASM_PREPROC_VERSION,
"Real NASM Preprocessor",
"nasm",
nasm_preproc_initialize,
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <util.h>
-/*@unused@*/ RCSID("$IdPath: yasm/modules/preprocs/raw/raw-preproc.c,v 1.23 2003/04/01 04:06:47 mu Exp $");
+/*@unused@*/ RCSID("$IdPath$");
#define YASM_LIB_INTERNAL
#include <libyasm.h>
/* Define preproc structure -- see preproc.h for details */
yasm_preproc yasm_raw_LTX_preproc = {
+ YASM_PREPROC_VERSION,
"Disable preprocessing",
"raw",
raw_preproc_initialize,