]> granicus.if.org Git - yasm/commitdiff
x86arch.c, x86id.c: Explicitly cast to unsigned char.
authorPeter Johnson <peter@tortall.net>
Sun, 7 Jan 2007 22:00:53 +0000 (22:00 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 7 Jan 2007 22:00:53 +0000 (22:00 -0000)
stabs-dbgfmt.c: Check for overflow, cast to unsigned short.

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

modules/arch/x86/x86arch.c
modules/arch/x86/x86id.c
modules/dbgfmts/stabs/stabs-dbgfmt.c

index ba294e87dab5e5ed441339c9bc723cc3e083ce3a..ded908407aea7836ba6d43b9a1fd7930f9079684 100644 (file)
@@ -109,9 +109,9 @@ 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;
+       arch_x86->mode_bits = (unsigned char)val;
     else if (yasm__strcasecmp(var, "force_strict") == 0)
-       arch_x86->force_strict = val;
+       arch_x86->force_strict = (unsigned char)val;
     else
        return 1;
     return 0;
index 6f332d4507a7271a9bbc0233383f3ad6ddcb5409..cde34831855b30b623d3b64ad2dfbee745d21220 100644 (file)
@@ -2998,7 +2998,7 @@ yasm_x86__finalize_insn(yasm_arch *arch, yasm_bytecode *bc,
        if (num_segregs > 1)
            yasm_warn_set(YASM_WARN_GENERAL,
                          N_("multiple segment overrides, using leftmost"));
-       insn->special_prefix = segregs[num_segregs-1]>>8;
+       insn->special_prefix = (unsigned char)(segregs[num_segregs-1]>>8);
     } else if (num_segregs > 0)
        yasm_internal_error(N_("unhandled segment prefix"));
 
index 2274a0d7bd384238589ce86071da29c75efe58f8..9e2fe271966359be6b2de72750eec0bca1698b15 100644 (file)
@@ -372,8 +372,6 @@ stabs_dbgfmt_generate(yasm_dbgfmt *dbgfmt, yasm_errwarns *errwarns)
        }
     }
 
-
-
     /* initial pseudo-stab */
     stab = yasm_xmalloc(sizeof(stabs_stab));
     dbgbc = yasm_bc_create_common(&stabs_bc_stab_callback, stab, 0);
@@ -407,7 +405,12 @@ stabs_dbgfmt_generate(yasm_dbgfmt *dbgfmt, yasm_errwarns *errwarns)
     stab->bcstr = filebc;
     stab->type = N_UNDF;
     stab->other = 0;
-    stab->desc = info.stabcount;
+    if (info.stabcount > 0xffff) {
+       yasm_warn_set(YASM_WARN_GENERAL, N_("over 65535 stabs"));
+       yasm_errwarn_propagate(errwarns, 0);
+       stab->desc = 0xffff;
+    } else
+       stab->desc = (unsigned short)info.stabcount;
 }
 
 static int