]> granicus.if.org Git - yasm/commitdiff
Merge a number of revisions from trunk:
authorPeter Johnson <peter@tortall.net>
Sat, 10 Mar 2007 08:38:23 +0000 (08:38 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 10 Mar 2007 08:38:23 +0000 (08:38 -0000)
 [1804]: -E and -s command line options (feature)
 [1805]: Fix uninit warning
 [1806]: -Wsize-override option (feature)
 [1807]: Change prefix order
 [1808], [1809], [1810]: Bugfixes
 [1811]: Mach-O section and segment name zeroing bugfix
 [1814]: HAMT portability fix

svn path=/branches/yasm-0.6.x/; revision=1818

23 files changed:
frontends/yasm/yasm.c
libyasm/arch.h
libyasm/errwarn.h
libyasm/hamt.c
libyasm/symrec.c
libyasm/tests/expr-wide-ident.hex
modules/arch/x86/tests/addrop.hex
modules/arch/x86/tests/genopcode.hex
modules/arch/x86/tests/rep.hex
modules/arch/x86/tests/sse-prefix.hex
modules/arch/x86/tests/sse4.hex
modules/arch/x86/x86bc.c
modules/objfmts/elf/elf-objfmt.c
modules/objfmts/macho/macho-objfmt.c
modules/objfmts/macho/tests/gas32/gas-macho32.hex
modules/objfmts/macho/tests/gas64/gas-macho64.hex
modules/objfmts/macho/tests/nasm32/macho-reloc.hex
modules/objfmts/macho/tests/nasm32/machotest.hex
modules/objfmts/macho/tests/nasm64/machotest64.hex
modules/parsers/gas/gas-parse.c
modules/parsers/gas/gas-token.re
modules/parsers/nasm/nasm-parse.c
modules/parsers/nasm/tests/long.hex

index b213415bff623e66d856d96e5b4632adf869b95d..d49fce04214e62bf02d038222599925b0df6ac9c 100644 (file)
@@ -69,6 +69,8 @@ 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 FILE *errfile;
+/*@null@*/ /*@only@*/ static char *error_filename = NULL;
 static enum {
     EWSTYLE_GNU = 0,
     EWSTYLE_VC
@@ -93,6 +95,8 @@ 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 opt_error_file(char *cmd, /*@null@*/ char *param, int extra);
+static int opt_error_stdout(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);
 static int opt_preproc_option(char *cmd, /*@null@*/ char *param, int extra);
@@ -160,6 +164,10 @@ static opt_option options[] =
       N_("enables/disables warning"), NULL },
     { 'M', NULL, 0, opt_makedep_handler, 0,
       N_("generate Makefile dependencies on stdout"), NULL },
+    { 'E', NULL, 1, opt_error_file, 0,
+      N_("redirect error messages to file"), N_("file") },
+    { 's', NULL, 0, opt_error_stdout, 0,
+      N_("redirect error messages to stdout"), NULL },
     { 'e', "preproc-only", 0, preproc_only_handler, 0,
       N_("preprocess only (writes output to stdout by default)"), NULL },
     { 'i', NULL, 1, opt_include_option, 0,
@@ -548,6 +556,8 @@ main(int argc, char *argv[])
     /*@null@*/ FILE *in = NULL;
     size_t i;
 
+    errfile = stderr;
+
 #if defined(HAVE_SETLOCALE) && defined(HAVE_LC_MESSAGES)
     setlocale(LC_MESSAGES, "");
 #endif
@@ -586,6 +596,13 @@ main(int argc, char *argv[])
            return EXIT_SUCCESS;
     }
 
+    /* Open error file if specified. */
+    if (error_filename) {
+       errfile = open_file(error_filename, "wt");
+       if (!errfile)
+           return EXIT_FAILURE;
+    }
+
     /* Initialize BitVector (needed for intnum/floatnum). */
     if (BitVector_Boot() != ErrCode_Ok) {
        print_error(_("%s: could not initialize BitVector"), _("FATAL"));
@@ -773,6 +790,9 @@ cleanup(yasm_object *object)
        if (objfmt_keyword)
            yasm_xfree(objfmt_keyword);
     }
+
+    if (errfile != stderr && errfile != stdout)
+       fclose(errfile);
 }
 
 /*
@@ -1024,12 +1044,42 @@ opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
        action(YASM_WARN_ORPHAN_LABEL);
     else if (strcmp(cmd, "uninit-contents") == 0)
        action(YASM_WARN_UNINIT_CONTENTS);
+    else if (strcmp(cmd, "size-override") == 0)
+       action(YASM_WARN_SIZE_OVERRIDE);
     else
        return 1;
 
     return 0;
 }
 
+static int
+opt_error_file(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra)
+{
+    if (error_filename) {
+       print_error(
+           _("warning: can output to only one error file, last specified used"));
+       yasm_xfree(error_filename);
+    }
+
+    assert(param != NULL);
+    error_filename = yasm__xstrdup(param);
+
+    return 0;
+}
+
+static int
+opt_error_stdout(/*@unused@*/ char *cmd, /*@unused@*/ char *param,
+                /*@unused@*/ int extra)
+{
+    /* Clear any specified error filename */
+    if (error_filename) {
+       yasm_xfree(error_filename);
+       error_filename = NULL;
+    }
+    errfile = stdout;
+    return 0;
+}
+
 static int
 preproc_only_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param,
                     /*@unused@*/ int extra)
@@ -1184,11 +1234,11 @@ static void
 print_error(const char *fmt, ...)
 {
     va_list va;
-    fprintf(stderr, "yasm: ");
+    fprintf(errfile, "yasm: ");
     va_start(va, fmt);
-    vfprintf(stderr, fmt, va);
+    vfprintf(errfile, fmt, va);
     va_end(va);
-    fputc('\n', stderr);
+    fputc('\n', errfile);
 }
 
 static /*@exits@*/ void
@@ -1206,9 +1256,9 @@ handle_yasm_int_error(const char *file, unsigned int line, const char *message)
 static /*@exits@*/ void
 handle_yasm_fatal(const char *fmt, va_list va)
 {
-    fprintf(stderr, "yasm: %s: ", _("FATAL"));
-    vfprintf(stderr, gettext(fmt), va);
-    fputc('\n', stderr);
+    fprintf(errfile, "yasm: %s: ", _("FATAL"));
+    vfprintf(errfile, gettext(fmt), va);
+    fputc('\n', errfile);
     exit(EXIT_FAILURE);
 }
 
@@ -1234,15 +1284,16 @@ print_yasm_error(const char *filename, unsigned long line, const char *msg,
                 const char *xref_msg)
 {
     if (line)
-       fprintf(stderr, fmt[ewmsg_style], filename, line, "", msg);
+       fprintf(errfile, fmt[ewmsg_style], filename, line, "", msg);
     else
-       fprintf(stderr, fmt_noline[ewmsg_style], filename, "", msg);
+       fprintf(errfile, fmt_noline[ewmsg_style], filename, "", msg);
 
     if (xref_fn && xref_msg) {
        if (xref_line)
-           fprintf(stderr, fmt[ewmsg_style], xref_fn, xref_line, "", xref_msg);
+           fprintf(errfile, fmt[ewmsg_style], xref_fn, xref_line, "",
+                   xref_msg);
        else
-           fprintf(stderr, fmt_noline[ewmsg_style], xref_fn, "", xref_msg);
+           fprintf(errfile, fmt_noline[ewmsg_style], xref_fn, "", xref_msg);
     }
 }
 
@@ -1250,7 +1301,9 @@ static void
 print_yasm_warning(const char *filename, unsigned long line, const char *msg)
 {
     if (line)
-       fprintf(stderr, fmt[ewmsg_style], filename, line, _("warning: "), msg);
+       fprintf(errfile, fmt[ewmsg_style], filename, line, _("warning: "),
+               msg);
     else
-       fprintf(stderr, fmt_noline[ewmsg_style], filename, _("warning: "), msg);
+       fprintf(errfile, fmt_noline[ewmsg_style], filename, _("warning: "),
+               msg);
 }
index 7646dc715b6537b62f50121f0e1117c49bf36881..4a12884d78902458ffe0da2e2101980605962b11 100644 (file)
@@ -264,7 +264,7 @@ struct yasm_insn_operand {
 
     uintptr_t targetmod;       /**< Arch target modifier, 0 if none. */
 
-    /** Specified size of the operand, in bytes.  0 if not user-specified. */
+    /** Specified size of the operand, in bits.  0 if not user-specified. */
     unsigned int size:8;
 
     /** Nonzero if dereference.  Used for "*foo" in GAS.
index d609b9ce2e32ba4f060749f31ebb436cd323cc5d..64b73b59930a57a596b3f8ab32ca2f23da14b479 100644 (file)
@@ -41,7 +41,8 @@ typedef enum yasm_warn_class {
     YASM_WARN_UNREC_CHAR,   /**< Unrecognized characters (while tokenizing) */
     YASM_WARN_PREPROC,     /**< Preprocessor warnings */
     YASM_WARN_ORPHAN_LABEL, /**< Label alone on a line without a colon */
-    YASM_WARN_UNINIT_CONTENTS /**< Uninitialized space in code/data section */
+    YASM_WARN_UNINIT_CONTENTS, /**< Uninitialized space in code/data section */
+    YASM_WARN_SIZE_OVERRIDE /**< Double size override */
 } yasm_warn_class;
 
 /** Error classes.  Bitmask-based to support limited subclassing. */
index 746fb904da2a6e1d66a9fe4d491e95872a7f936a..6eee0586dba610625d583440e9f2d17a592d2b4e 100644 (file)
@@ -45,7 +45,7 @@ struct HAMTEntry {
 
 typedef struct HAMTNode {
     unsigned long BitMapKey;           /* 32 bits, bitmap or hash key */
-    void *BaseValue;                   /* Base of HAMTNode list or value */
+    uintptr_t BaseValue;               /* Base of HAMTNode list or value */
 } HAMTNode;
 
 struct HAMT {
@@ -59,14 +59,20 @@ struct HAMT {
  * 4 or 2-byte aligned (as it uses the LSB of the pointer variable to store
  * the subtrie flag!
  */
-#define IsSubTrie(n)           ((uintptr_t)((n)->BaseValue) & 1)
+#define IsSubTrie(n)           ((n)->BaseValue & 1)
 #define SetSubTrie(h, n, v)    do {                            \
-       if ((uintptr_t)(v) & 1)                         \
+       if ((uintptr_t)(v) & 1)                                 \
            h->error_func(__FILE__, __LINE__,                   \
                          N_("Subtrie is seen as subtrie before flag is set (misaligned?)"));   \
-       (n)->BaseValue = (void *)((uintptr_t)(v) | 1);  \
+       (n)->BaseValue = (uintptr_t)(v) | 1;    \
     } while (0)
-#define GetSubTrie(n)          (HAMTNode *)((uintptr_t)((n)->BaseValue)&~1UL)
+#define SetValue(h, n, v)      do {                            \
+       if ((uintptr_t)(v) & 1)                                 \
+           h->error_func(__FILE__, __LINE__,                   \
+                         N_("Value is seen as subtrie (misaligned?)")); \
+       (n)->BaseValue = (uintptr_t)(v);        \
+    } while (0)
+#define GetSubTrie(n)          (HAMTNode *)(((n)->BaseValue | 1) ^ 1)
 
 static unsigned long
 HashKey(const char *key)
@@ -98,7 +104,7 @@ HAMT_create(/*@exits@*/ void (*error_func)
 
     for (i=0; i<32; i++) {
        hamt->root[i].BitMapKey = 0;
-       hamt->root[i].BaseValue = NULL;
+       hamt->root[i].BaseValue = 0;
     }
 
     hamt->error_func = error_func;
@@ -199,7 +205,7 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
        entry->str = str;
        entry->data = data;
        STAILQ_INSERT_TAIL(&hamt->entries, entry, next);
-       node->BaseValue = entry;
+       SetValue(hamt, node, entry);
        if (IsSubTrie(node))
            hamt->error_func(__FILE__, __LINE__,
                             N_("Data is seen as subtrie (misaligned?)"));
@@ -261,10 +267,10 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
                        if (keypart2 < keypart) {
                            newnodes[0] = *node;    /* structure copy */
                            newnodes[1].BitMapKey = key;
-                           newnodes[1].BaseValue = entry;
+                           SetValue(hamt, &newnodes[1], entry);
                        } else {
                            newnodes[0].BitMapKey = key;
-                           newnodes[0].BaseValue = entry;
+                           SetValue(hamt, &newnodes[0], entry);
                            newnodes[1] = *node;    /* structure copy */
                        }
 
@@ -315,7 +321,7 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace,
            entry->str = str;
            entry->data = data;
            STAILQ_INSERT_TAIL(&hamt->entries, entry, next);
-           newnodes[Map].BaseValue = entry;
+           SetValue(hamt, &newnodes[Map], entry);
            SetSubTrie(hamt, node, newnodes);
 
            *replace = 1;
index 2147a5c6a63421f9ad7fee33fe015d5f74b64ef5..76ef09ad5e2128baba4f748a8ddb17008e411732 100644 (file)
@@ -104,7 +104,7 @@ symrec_destroy_one(/*@only@*/ void *d)
 {
     yasm_symrec *sym = d;
     yasm_xfree(sym->name);
-    if (sym->type == SYM_EQU)
+    if (sym->type == SYM_EQU && (sym->status & YASM_SYM_VALUED))
        yasm_expr_destroy(sym->value.expn);
     yasm__assoc_data_destroy(sym->assoc_data);
     yasm_xfree(sym);
@@ -242,6 +242,8 @@ yasm_symtab_define_equ(yasm_symtab *symtab, const char *name, yasm_expr *e,
                       unsigned long line)
 {
     yasm_symrec *rec = symtab_define(symtab, name, SYM_EQU, 1, line);
+    if (yasm_error_occurred())
+       return rec;
     rec->value.expn = e;
     rec->status |= YASM_SYM_VALUED;
     return rec;
@@ -252,8 +254,9 @@ yasm_symtab_define_label(yasm_symtab *symtab, const char *name,
                         yasm_bytecode *precbc, int in_table,
                         unsigned long line)
 {
-    yasm_symrec *rec;
-    rec = symtab_define(symtab, name, SYM_LABEL, in_table, line);
+    yasm_symrec *rec = symtab_define(symtab, name, SYM_LABEL, in_table, line);
+    if (yasm_error_occurred())
+       return rec;
     rec->value.precbc = precbc;
     if (in_table && precbc)
        yasm_bc__add_symrec(precbc, rec);
@@ -264,8 +267,9 @@ yasm_symrec *
 yasm_symtab_define_curpos(yasm_symtab *symtab, const char *name,
                          yasm_bytecode *precbc, unsigned long line)
 {
-    yasm_symrec *rec;
-    rec = symtab_define(symtab, name, SYM_CURPOS, 0, line);
+    yasm_symrec *rec = symtab_define(symtab, name, SYM_CURPOS, 0, line);
+    if (yasm_error_occurred())
+       return rec;
     rec->value.precbc = precbc;
     return rec;
 }
@@ -275,6 +279,8 @@ yasm_symtab_define_special(yasm_symtab *symtab, const char *name,
                           yasm_sym_vis vis)
 {
     yasm_symrec *rec = symtab_define(symtab, name, SYM_SPECIAL, 1, 0);
+    if (yasm_error_occurred())
+       return rec;
     rec->status |= YASM_SYM_VALUED;
     rec->visibility = vis;
     return rec;
@@ -359,6 +365,7 @@ symtab_parser_finalize_checksym(yasm_symrec *sym, /*@null@*/ void *d)
            YASM_EXPR_ADD,
            yasm_expr_copy(yasm_section_get_start(sect)),
            sym->line);
+       sym->status |= YASM_SYM_VALUED;
     }
 
     return 0;
@@ -449,7 +456,7 @@ yasm_symrec_get_line(const yasm_symrec *sym)
 const yasm_expr *
 yasm_symrec_get_equ(const yasm_symrec *sym)
 {
-    if (sym->type == SYM_EQU)
+    if (sym->type == SYM_EQU && (sym->status & YASM_SYM_VALUED))
        return sym->value.expn;
     return (const yasm_expr *)NULL;
 }
@@ -509,7 +516,10 @@ yasm_symrec_print(const yasm_symrec *sym, FILE *f, int indent_level)
        case SYM_EQU:
            fprintf(f, "%*s_EQU_\n", indent_level, "");
            fprintf(f, "%*sExpn=", indent_level, "");
-           yasm_expr_print(sym->value.expn, f);
+           if (sym->status & YASM_SYM_VALUED)
+               yasm_expr_print(sym->value.expn, f);
+           else
+               fprintf(f, "***UNVALUED***");
            fprintf(f, "\n");
            break;
        case SYM_LABEL:
index f5a9ca482ee59164dc15b4b35a9492f2b8828f81..f8d54ff38e7755c509982daee4daf182ae95ef4d 100644 (file)
@@ -1,5 +1,5 @@
-66 
 67 
+66 
 8d 
 94 
 0a 
index da61c8737bb162b2ab14a6a7b1af94b399bd3b4b..34e3ff70bd3e63b1947c0e255aee9ab19fe05a0c 100644 (file)
@@ -63,8 +63,8 @@ f6
 00 
 00 
 26 
-66 
 67 
+66 
 f7 
 3d 
 05 
index 4814eb28d0e72d2c03e7f0aa4e2f80c0997b0762..d6a562d24bf8fb9d65619f6bb64d4e12b274e137 100644 (file)
@@ -92,13 +92,13 @@ d1
 0f 
 be 
 01 
-66 
 67 
+66 
 0f 
 b7 
 18 
-66 
 67 
+66 
 0f 
 b6 
 0b 
index 84f347670dcf18f6c004915746268c1d3afdc167..9d95dcc6be24cb42ebaca3386717eedd7eed39be 100644 (file)
@@ -1,7 +1,7 @@
 f2 
 ad 
-f2 
 66 
+f2 
 ad 
 f3 
 aa 
index d7c781300424cebe2ab5a797d4f6bfff6dd5fb0d..968c69f0841c4453426e5fa3b136f424ef1c9359 100644 (file)
@@ -3,15 +3,15 @@ a5
 66 
 26 
 a5 
-f3 
 66 
-a5 
 f3 
+a5 
 66 
+f3 
 64 
 a5 
-f3 
 66 
+f3 
 64 
 a5 
 a5 
@@ -58,8 +58,8 @@ c2
 00 
 66 
 a5 
-f3 
 66 
+f3 
 a5 
 a5 
 f3 
index 43699ffa348a5ff39bdc35743d24362c6c03bbb0..2366d2fda2a33e01fe1c3c924bc69c56c2ac1e44 100644 (file)
@@ -1,11 +1,11 @@
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -27,14 +27,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -56,14 +56,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -85,14 +85,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -118,14 +118,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -151,14 +151,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -184,14 +184,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -213,14 +213,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -242,14 +242,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -271,14 +271,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -304,14 +304,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -337,14 +337,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -370,14 +370,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -399,14 +399,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -428,14 +428,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -457,14 +457,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -490,14 +490,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -523,14 +523,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -556,14 +556,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -585,14 +585,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -614,14 +614,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -643,14 +643,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -676,14 +676,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -709,14 +709,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -742,14 +742,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -771,14 +771,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -804,14 +804,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -833,14 +833,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -866,14 +866,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -895,14 +895,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -928,14 +928,14 @@ f3
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
@@ -958,14 +958,14 @@ c1
 7f 
 02 
 c3 
-66 
 67 
+66 
 8b 
 54 
 24 
 04 
-66 
 67 
+66 
 8b 
 44 
 24 
index a4326d3220393cf5f97c9522dbd8a43f49452a50..88fa21c950fc3bd1ef9350bb0aef3e441eddf91c 100644 (file)
@@ -761,16 +761,16 @@ static void
 x86_common_tobytes(const x86_common *common, unsigned char **bufp,
                   unsigned int segreg)
 {
-    if (common->lockrep_pre != 0)
-       YASM_WRITE_8(*bufp, common->lockrep_pre);
     if (segreg != 0)
        YASM_WRITE_8(*bufp, (unsigned char)segreg);
+    if (common->addrsize != 0 && common->addrsize != common->mode_bits)
+       YASM_WRITE_8(*bufp, 0x67);
     if (common->opersize != 0 &&
        ((common->mode_bits != 64 && common->opersize != common->mode_bits) ||
         (common->mode_bits == 64 && common->opersize == 16)))
        YASM_WRITE_8(*bufp, 0x66);
-    if (common->addrsize != 0 && common->addrsize != common->mode_bits)
-       YASM_WRITE_8(*bufp, 0x67);
+    if (common->lockrep_pre != 0)
+       YASM_WRITE_8(*bufp, common->lockrep_pre);
 }
 
 static void
index c0ae84164c382d31cb8e19d322f271cfe01cdac1..d239f0578a56853544e0b4884ec490f11a5d9a86 100644 (file)
@@ -1118,7 +1118,7 @@ dir_type(yasm_objfmt_elf *objfmt_elf, yasm_valparam *vp, unsigned long line)
 
     /* Pull new type from val */
     vp = yasm_vps_next(vp);
-    if (vp->val) {
+    if (vp && vp->val) {
        if (yasm__strcasecmp(vp->val, "function") == 0)
            elf_sym_set_type(entry, STT_FUNC);
        else if (yasm__strcasecmp(vp->val, "object") == 0)
@@ -1147,10 +1147,10 @@ dir_size(yasm_objfmt_elf *objfmt_elf, yasm_valparam *vp, unsigned long line)
 
     /* Pull new size from either param (expr) or val */
     vp = yasm_vps_next(vp);
-    if (vp->param) {
+    if (vp && vp->param) {
        elf_sym_set_size(entry, vp->param);
        vp->param = NULL;
-    } else if (vp->val)
+    } else if (vp && vp->val)
        elf_sym_set_size(entry, yasm_expr_create_ident(yasm_expr_sym(
            yasm_symtab_use(objfmt_elf->symtab, vp->val, line)), line));
     else
index b0c79bc3dcf29aaeded890522396a8d684f86245..68db6adb18ff2571140f6fe0b91a2c419fe5ce86 100644 (file)
@@ -761,8 +761,12 @@ macho_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d)
 
     localbuf = info->buf;
 
-    fwrite(msd->sectname, 16, 1, info->f);
-    fwrite(msd->segname, 16, 1, info->f);
+    memset(localbuf, 0, 16);
+    strncpy((char *)localbuf, msd->sectname, 16);
+    localbuf += 16;
+    memset(localbuf, 0, 16);
+    strncpy((char *)localbuf, msd->segname, 16);
+    localbuf += 16;
     /* section address, size depend on 32/64 bit mode */
     YASM_WRITE_32_L(localbuf, msd->vmoff);     /* address in memory */
     if (info->is_64)
@@ -800,9 +804,9 @@ macho_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d)
     YASM_WRITE_32_L(localbuf, 0);      /* reserved 2 */
 
     if (info->is_64)
-       fwrite(info->buf, MACHO_SECTCMD64_SIZE - 32, 1, info->f);       /* 2*16 byte strings already written */
+       fwrite(info->buf, MACHO_SECTCMD64_SIZE, 1, info->f);
     else
-       fwrite(info->buf, MACHO_SECTCMD_SIZE - 32, 1, info->f); /* 2*16 byte strings already written */
+       fwrite(info->buf, MACHO_SECTCMD_SIZE, 1, info->f);
 
     return 0;
 }
index 5ab90a5adb3b4a4d516080149b51155fedbe4189..72cdabdeb36ce46083cd0e03bed83457afca101d 100644 (file)
@@ -89,15 +89,15 @@ fe
 78 
 74 
 00 
-2e 
-63 
-6f 
-6e 
-73 
-74 
 00 
-5f 
-5f 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 54 
@@ -105,15 +105,15 @@ fe
 58 
 54 
 00 
-5f 
-5f 
-74 
-65 
-78 
-74 
 00 
-2e 
-63 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 00 
 00 
 00 
@@ -157,15 +157,15 @@ bc
 74 
 61 
 00 
-2e 
-73 
-74 
-61 
-74 
-69 
-63 
-5f 
-64 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 44 
@@ -173,15 +173,15 @@ bc
 54 
 41 
 00 
-5f 
-5f 
-6d 
-6f 
-64 
-5f 
-69 
-6e 
-69 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 41 
 00 
 00 
@@ -224,16 +224,16 @@ f4
 73 
 73 
 00 
-2e 
-6f 
-62 
-6a 
-63 
-5f 
-63 
-6c 
-61 
-73 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 44 
@@ -241,15 +241,15 @@ f4
 54 
 41 
 00 
-5f 
-5f 
-6d 
-6f 
-64 
-5f 
-69 
-6e 
-69 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 81 
 00 
 00 
index 09f1e8db08fc2e7c250e608ec9dc8a8d2ea55b23..e4fa4882abccbb0eeb1abbebf1016045f1b83c7e 100644 (file)
@@ -109,15 +109,15 @@ c5
 78 
 74 
 00 
-2e 
-63 
-6f 
-6e 
-73 
-74 
 00 
-5f 
-5f 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 54 
@@ -125,15 +125,15 @@ c5
 58 
 54 
 00 
-5f 
-5f 
-74 
-65 
-78 
-74 
 00 
-2e 
-63 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 00 
 00 
 00 
@@ -189,15 +189,15 @@ e8
 74 
 61 
 00 
-2e 
-73 
-74 
-61 
-74 
-69 
-63 
-5f 
-64 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 44 
@@ -205,15 +205,15 @@ e8
 54 
 41 
 00 
-5f 
-5f 
-6d 
-6f 
-64 
-5f 
-69 
-6e 
-69 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5d 
 00 
 00 
index 65406c5d27434ef647571a0c2aeee6ccb5f3ec0f..7ef6e8a17ac92a3378af18fdac2154b7f93482f5 100644 (file)
@@ -89,15 +89,15 @@ f4
 78 
 74 
 00 
-2e 
-63 
-6f 
-6e 
-73 
-74 
 00 
-5f 
-5f 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 54 
@@ -105,15 +105,15 @@ f4
 58 
 54 
 00 
-5f 
-5f 
-74 
-65 
-78 
-74 
 00 
-2e 
-63 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 00 
 00 
 00 
@@ -157,15 +157,15 @@ f4
 74 
 61 
 00 
-2e 
-73 
-74 
-61 
-74 
-69 
-63 
-5f 
-64 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 44 
@@ -173,15 +173,15 @@ f4
 54 
 41 
 00 
-5f 
-5f 
-6d 
-6f 
-64 
-5f 
-69 
-6e 
-69 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 28 
 00 
 00 
index d1e36c5b08f9f97e0e6088708ce29f1ab70bfa4f..e6791e4e3702d94436c630be63375ceaf3cd2c52 100644 (file)
@@ -89,15 +89,15 @@ fe
 78 
 74 
 00 
-2e 
-63 
-6f 
-6e 
-73 
-74 
 00 
-5f 
-5f 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 54 
@@ -105,15 +105,15 @@ fe
 58 
 54 
 00 
-5f 
-5f 
-74 
-65 
-78 
-74 
 00 
-2e 
-63 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 00 
 00 
 00 
@@ -157,15 +157,15 @@ c0
 74 
 61 
 00 
-2e 
-73 
-74 
-61 
-74 
-69 
-63 
-5f 
-64 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 44 
@@ -173,15 +173,15 @@ c0
 54 
 41 
 00 
-5f 
-5f 
-6d 
-6f 
-64 
-5f 
-69 
-6e 
-69 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 47 
 00 
 00 
@@ -224,16 +224,16 @@ f8
 73 
 73 
 00 
-2e 
-6f 
-62 
-6a 
-63 
-5f 
-63 
-6c 
-61 
-73 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 44 
@@ -241,15 +241,15 @@ f8
 54 
 41 
 00 
-5f 
-5f 
-6d 
-6f 
-64 
-5f 
-69 
-6e 
-69 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 87 
 00 
 00 
index 46ecbc5888890be9239fdfdf0c373b82f6789e49..213951869c9117174c0642f4024a42dcb1ed5635 100644 (file)
@@ -109,15 +109,15 @@ c6
 78 
 74 
 00 
-2e 
-63 
-6f 
-6e 
-73 
-74 
 00 
-5f 
-5f 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 54 
@@ -125,15 +125,15 @@ c6
 58 
 54 
 00 
-5f 
-5f 
-74 
-65 
-78 
-74 
 00 
-2e 
-63 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 00 
 00 
 00 
@@ -189,15 +189,15 @@ c6
 74 
 61 
 00 
-2e 
-73 
-74 
-61 
-74 
-69 
-63 
-5f 
-64 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 44 
@@ -205,15 +205,15 @@ c6
 54 
 41 
 00 
-5f 
-5f 
-6d 
-6f 
-64 
-5f 
-69 
-6e 
-69 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 7a 
 00 
 00 
@@ -268,16 +268,16 @@ ea
 73 
 73 
 00 
-2e 
-6f 
-62 
-6a 
-63 
-5f 
-63 
-6c 
-61 
-73 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 5f 
 5f 
 44 
@@ -285,15 +285,15 @@ ea
 54 
 41 
 00 
-5f 
-5f 
-6d 
-6f 
-64 
-5f 
-69 
-6e 
-69 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
 c6 
 00 
 00 
index 2f0cbb07e31202e80299aff4208a1dceee5c54a6..a119938c0b228e4d439c4c1926e6037406859db3 100644 (file)
@@ -1001,7 +1001,7 @@ parse_memaddr(yasm_parser_gas *parser_gas)
 
     if (curtok == '(') {
        int havereg = 0;
-       uintptr_t reg;
+       uintptr_t reg = 0;
        yasm_intnum *scale = NULL;
 
        get_next_token(); /* '(' */
index 4f4e21844426a0ce8cd01a4f01b3ddf7059d697d..eca535bd1508dcbdd9a6cba9203f30a969d5b1fe 100644 (file)
@@ -214,10 +214,6 @@ static size_t strbuf_size = 0;
 static void
 strbuf_append(size_t count, YYCTYPE *cursor, yasm_scanner *s, int ch)
 {
-    if (cursor == s->eof)
-       yasm_error_set(YASM_ERROR_SYNTAX,
-                      N_("unexpected end of file in string"));
-
     if (count >= strbuf_size) {
        strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE);
        strbuf_size += STRBUF_ALLOC_SIZE;
@@ -677,6 +673,13 @@ stringconst_scan:
     /*!re2c
        /* Handle escaped double-quote by copying and continuing */
        "\\\""      {
+           if (cursor == s->eof) {
+               yasm_error_set(YASM_ERROR_SYNTAX,
+                              N_("unexpected end of file in string"));
+               lvalp->str.contents = (char *)strbuf;
+               lvalp->str.len = count;
+               RETURN(STRING);
+           }
            strbuf_append(count++, cursor, s, '"');
            goto stringconst_scan;
        }
@@ -690,6 +693,13 @@ stringconst_scan:
        }
 
        any     {
+           if (cursor == s->eof) {
+               yasm_error_set(YASM_ERROR_SYNTAX,
+                              N_("unexpected end of file in string"));
+               lvalp->str.contents = (char *)strbuf;
+               lvalp->str.len = count;
+               RETURN(STRING);
+           }
            strbuf_append(count++, cursor, s, s->tok[0]);
            goto stringconst_scan;
        }
index 0f6fba44c0ba1601e64a2fac56d02cabf120311b..c2687e910b5ae04659eb4112c05421c5913d7ed8 100644 (file)
@@ -680,8 +680,25 @@ parse_operand(yasm_parser_nasm *parser_nasm)
                yasm_arch_get_reg_size(parser_nasm->arch, op->data.reg) != size)
                yasm_error_set(YASM_ERROR_TYPE,
                               N_("cannot override register size"));
-           else
+           else {
+               /* Silently override others unless a warning is turned on.
+                * This is to allow overrides such as:
+                *   %define arg1 dword [bp+4]
+                *   cmp word arg1, 2
+                * Which expands to:
+                *   cmp word dword [bp+4], 2
+                */
+               if (op->size != 0) {
+                   if (op->size != size)
+                       yasm_warn_set(YASM_WARN_SIZE_OVERRIDE,
+                           N_("overriding operand size from %u-bit to %u-bit"),
+                           op->size, size);
+                   else
+                       yasm_warn_set(YASM_WARN_SIZE_OVERRIDE,
+                                     N_("double operand size override"));
+               }
                op->size = size;
+           }
            return op;
        }
        case TARGETMOD:
index 2ae8e5bb4e3b569a1f8a10ca89b97c4df4a7ee26..72e9cc5ddacdf44389a867ba7e74f58a942ded06 100644 (file)
@@ -1,5 +1,5 @@
-66 
 67 
+66 
 c7 
 00 
 00