]> granicus.if.org Git - yasm/commitdiff
Fix writing of PC-relative values (broken in rev. 1.9).
authorPeter Johnson <peter@tortall.net>
Mon, 12 Aug 2002 03:58:01 +0000 (03:58 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 12 Aug 2002 03:58:01 +0000 (03:58 -0000)
svn path=/trunk/yasm/; revision=688

modules/objfmts/bin/bin-objfmt.c
src/objfmts/bin/bin-objfmt.c

index cae3f1ca0e675e87ca919d32c15d967be97a7e9d..4bd045b1dabc5fe4b12d3248b81faa7cfe34ece0 100644 (file)
@@ -248,11 +248,22 @@ bin_objfmt_output_expr(expr **ep, unsigned char **bufp, unsigned long valsize,
                InternalError(_("tried to do PC-relative offset from invalid sized value"));
            val = intnum_get_uint(num);
            val = (unsigned long)((long)(val - (bc->offset + bc->len)));
+           switch (valsize) {
+               case 1:
+                   WRITE_BYTE(*bufp, val);
+                   break;
+               case 2:
+                   WRITE_SHORT(*bufp, val);
+                   break;
+               case 4:
+                   WRITE_LONG(*bufp, val);
+                   break;
+           }
+       } else {
+           /* Write value out. */
+           intnum_get_sized(num, *bufp, (size_t)valsize);
+           *bufp += valsize;
        }
-
-       /* Write value out. */
-       intnum_get_sized(num, *bufp, (size_t)valsize);
-       *bufp += valsize;
        return 0;
     }
 
index cae3f1ca0e675e87ca919d32c15d967be97a7e9d..4bd045b1dabc5fe4b12d3248b81faa7cfe34ece0 100644 (file)
@@ -248,11 +248,22 @@ bin_objfmt_output_expr(expr **ep, unsigned char **bufp, unsigned long valsize,
                InternalError(_("tried to do PC-relative offset from invalid sized value"));
            val = intnum_get_uint(num);
            val = (unsigned long)((long)(val - (bc->offset + bc->len)));
+           switch (valsize) {
+               case 1:
+                   WRITE_BYTE(*bufp, val);
+                   break;
+               case 2:
+                   WRITE_SHORT(*bufp, val);
+                   break;
+               case 4:
+                   WRITE_LONG(*bufp, val);
+                   break;
+           }
+       } else {
+           /* Write value out. */
+           intnum_get_sized(num, *bufp, (size_t)valsize);
+           *bufp += valsize;
        }
-
-       /* Write value out. */
-       intnum_get_sized(num, *bufp, (size_t)valsize);
-       *bufp += valsize;
        return 0;
     }