]> granicus.if.org Git - yasm/commitdiff
Allow overriding of strict-ness requirement with command line option
authorPeter Johnson <peter@tortall.net>
Tue, 7 Nov 2006 06:40:05 +0000 (06:40 -0000)
committerPeter Johnson <peter@tortall.net>
Tue, 7 Nov 2006 06:40:05 +0000 (06:40 -0000)
"--force-strict", which switches Yasm back to the old behavior of treating
any sized operand as "strict" (forcing the actual size).

Requested by: Michael Urman <mu@tortall.net>

svn path=/trunk/yasm/; revision=1681

frontends/yasm/yasm.c
modules/arch/x86/x86arch.c
modules/arch/x86/x86arch.h
modules/arch/x86/x86id.c

index 85b38f955df7e5d06178497935d517e1603c93f4..44ac9e33b4c0c1cdcf61e5d417cff5dbcf077f52 100644 (file)
@@ -68,6 +68,7 @@ static int special_options = 0;
 /*@null@*/ /*@dependent@*/ static const yasm_listfmt_module *
     cur_listfmt_module = NULL;
 static int preproc_only = 0;
+static unsigned int force_strict = 0;
 static int generate_make_dependencies = 0;
 static int warning_error = 0;  /* warnings being treated as errors */
 static enum {
@@ -92,6 +93,7 @@ static int opt_listfmt_handler(char *cmd, /*@null@*/ char *param, int extra);
 static int opt_listfile_handler(char *cmd, /*@null@*/ char *param, int extra);
 static int opt_objfile_handler(char *cmd, /*@null@*/ char *param, int extra);
 static int opt_machine_handler(char *cmd, /*@null@*/ char *param, int extra);
+static int opt_strict_handler(char *cmd, /*@null@*/ char *param, int extra);
 static int opt_warning_handler(char *cmd, /*@null@*/ char *param, int extra);
 static int preproc_only_handler(char *cmd, /*@null@*/ char *param, int extra);
 static int opt_include_option(char *cmd, /*@null@*/ char *param, int extra);
@@ -152,6 +154,8 @@ static opt_option options[] =
       N_("name of object-file output"), N_("filename") },
     { 'm', "machine", 1, opt_machine_handler, 0,
       N_("select machine (list with -m help)"), N_("machine") },
+    { 0, "force-strict", 0, opt_strict_handler, 0,
+      N_("treat all sized operands as if `strict' was used"), NULL },
     { 'w', NULL, 0, opt_warning_handler, 1,
       N_("inhibits warning messages"), NULL },
     { 'W', NULL, 0, opt_warning_handler, 0,
@@ -606,6 +610,8 @@ main(int argc, char *argv[])
                          cur_objfmt_module->default_x86_mode_bits);
     }
 
+    yasm_arch_set_var(cur_arch, "force_strict", force_strict);
+
     /* Parse! */
     cur_parser_module->do_parse(object, cur_preproc, cur_arch, cur_objfmt,
                                cur_dbgfmt, in, in_filename,
@@ -963,6 +969,15 @@ opt_machine_handler(/*@unused@*/ char *cmd, char *param,
     return 0;
 }
 
+static int
+opt_strict_handler(/*@unused@*/ char *cmd,
+                  /*@unused@*/ /*@null@*/ char *param,
+                  /*@unused@*/ int extra)
+{
+    force_strict = 1;
+    return 0;
+}
+
 static int
 opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
 {
index 392238556b296014974c0f51f4982cc0590dda64..ba294e87dab5e5ed441339c9bc723cc3e083ce3a 100644 (file)
@@ -61,6 +61,7 @@ x86_create(const char *machine, const char *parser,
     arch_x86->cpu_enabled = ~CPU_Any;
     arch_x86->amd64_machine = amd64_machine;
     arch_x86->mode_bits = 0;
+    arch_x86->force_strict = 0;
 
     if (yasm__strcasecmp(parser, "nasm") == 0)
        arch_x86->parser = X86_PARSER_NASM;
@@ -109,6 +110,8 @@ x86_set_var(yasm_arch *arch, const char *var, unsigned long val)
     yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch;
     if (yasm__strcasecmp(var, "mode_bits") == 0)
        arch_x86->mode_bits = val;
+    else if (yasm__strcasecmp(var, "force_strict") == 0)
+       arch_x86->force_strict = val;
     else
        return 1;
     return 0;
index a2639c47a33be98b4de99b7b5b6b161ebd271ba2..a2487d09faf884c699223d9d34f9e0cb1be772d0 100644 (file)
@@ -77,6 +77,7 @@ typedef struct yasm_arch_x86 {
        X86_PARSER_GAS
     } parser;
     unsigned char mode_bits;
+    unsigned char force_strict;
 } yasm_arch_x86;
 
 /* 0-15 (low 4 bits) used for register number, stored in same data area.
index 73b690b24a5854ceb9a06a443cc039aa960b110c..349bd82d6f4387daf1b05a533785ab4ab0179f5f 100644 (file)
@@ -2914,7 +2914,8 @@ yasm_x86__finalize_insn(yasm_arch *arch, yasm_bytecode *bc,
                     * pre-emptively expand to full size.
                     * For unspecified size case, still optimize.
                     */
-                   if (!op->strict || op->size == 0)
+                   if (!(arch_x86->force_strict || op->strict)
+                       || op->size == 0)
                        insn->postop = X86_POSTOP_SIGNEXT_IMM8;
                    else if (op->size != 8) {
                        insn->opcode.opcode[0] =