]> granicus.if.org Git - yasm/commitdiff
Add sanity check for computed section size.
authorPeter Johnson <peter@tortall.net>
Sat, 12 Jul 2003 02:07:08 +0000 (02:07 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 12 Jul 2003 02:07:08 +0000 (02:07 -0000)
svn path=/trunk/yasm/; revision=1002

modules/objfmts/coff/coff-objfmt.c

index 06cc426f1f8fd8044bdac05b79f4648a5824cb3e..0d58988ef52806d0ca6eb36448e2e864f438084b 100644 (file)
@@ -463,6 +463,9 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d)
        if (last)
            csd->size = last->offset + last->len;
     } else {
+       /*@null@*/ yasm_bytecode *last =
+           yasm_bcs_last(yasm_section_get_bytecodes(sect));
+
        pos = ftell(info->f);
        if (pos == -1) {
            yasm_fatal(N_("could not get file position on output file"));
@@ -474,6 +477,11 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d)
        info->csd = csd;
        yasm_bcs_traverse(yasm_section_get_bytecodes(sect), info,
                          coff_objfmt_output_bytecode);
+
+       /* Sanity check final section size */
+       if (csd->size != (last->offset + last->len))
+           yasm_internal_error(
+               N_("coff: section computed size did not match actual size"));
     }
 
     /* Empty?  Go on to next section */