From: Peter Johnson Date: Tue, 7 Nov 2006 06:40:05 +0000 (-0000) Subject: Allow overriding of strict-ness requirement with command line option X-Git-Tag: v0.6.0~101 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9fde4e16570b9c32491f621d302573906419f771;p=yasm Allow overriding of strict-ness requirement with command line option "--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 svn path=/trunk/yasm/; revision=1681 --- diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 85b38f95..44ac9e33 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -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) { diff --git a/modules/arch/x86/x86arch.c b/modules/arch/x86/x86arch.c index 39223855..ba294e87 100644 --- a/modules/arch/x86/x86arch.c +++ b/modules/arch/x86/x86arch.c @@ -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; diff --git a/modules/arch/x86/x86arch.h b/modules/arch/x86/x86arch.h index a2639c47..a2487d09 100644 --- a/modules/arch/x86/x86arch.h +++ b/modules/arch/x86/x86arch.h @@ -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. diff --git a/modules/arch/x86/x86id.c b/modules/arch/x86/x86id.c index 73b690b2..349bd82d 100644 --- a/modules/arch/x86/x86id.c +++ b/modules/arch/x86/x86id.c @@ -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] =