OLD | NEW |
1 /* | 1 /* |
2 * Bytecode utility functions | 2 * Bytecode utility functions |
3 * | 3 * |
4 * Copyright (C) 2001-2007 Peter Johnson | 4 * Copyright (C) 2001-2007 Peter Johnson |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
14 * | 14 * |
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' | 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' |
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE | 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE |
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 * POSSIBILITY OF SUCH DAMAGE. | 25 * POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 #include "util.h" | 27 #include "util.h" |
28 /*@unused@*/ RCSID("$Id: bytecode.c 2130 2008-10-07 05:38:11Z peter $"); | 28 /*@unused@*/ RCSID("$Id: bytecode.c 2233 2009-10-31 21:45:55Z peter $"); |
29 | 29 |
30 #include "libyasm-stdint.h" | 30 #include "libyasm-stdint.h" |
31 #include "coretype.h" | 31 #include "coretype.h" |
32 | 32 |
33 #include "errwarn.h" | 33 #include "errwarn.h" |
34 #include "intnum.h" | 34 #include "intnum.h" |
35 #include "expr.h" | 35 #include "expr.h" |
36 #include "value.h" | 36 #include "value.h" |
37 #include "symrec.h" | 37 #include "symrec.h" |
38 | 38 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 /*@out@*/ int *gap, void *d, | 302 /*@out@*/ int *gap, void *d, |
303 yasm_output_value_func output_value, | 303 yasm_output_value_func output_value, |
304 /*@null@*/ yasm_output_reloc_func output_reloc) | 304 /*@null@*/ yasm_output_reloc_func output_reloc) |
305 /*@sets *buf@*/ | 305 /*@sets *buf@*/ |
306 { | 306 { |
307 /*@only@*/ /*@null@*/ unsigned char *mybuf = NULL; | 307 /*@only@*/ /*@null@*/ unsigned char *mybuf = NULL; |
308 unsigned char *origbuf, *destbuf; | 308 unsigned char *origbuf, *destbuf; |
309 long i; | 309 long i; |
310 int error = 0; | 310 int error = 0; |
311 | 311 |
312 if (yasm_bc_get_multiple(bc, &bc->mult_int, 1) || bc->mult_int == 0) { | 312 long mult; |
| 313 if (yasm_bc_get_multiple(bc, &mult, 1) || mult == 0) { |
313 *bufsize = 0; | 314 *bufsize = 0; |
314 return NULL; | 315 return NULL; |
315 } | 316 } |
| 317 bc->mult_int = mult; |
316 | 318 |
317 /* special case for reserve bytecodes */ | 319 /* special case for reserve bytecodes */ |
318 if (bc->callback->special == YASM_BC_SPECIAL_RESERVE) { | 320 if (bc->callback->special == YASM_BC_SPECIAL_RESERVE) { |
319 *bufsize = bc->len*bc->mult_int; | 321 *bufsize = bc->len*bc->mult_int; |
320 *gap = 1; | 322 *gap = 1; |
321 return NULL; /* we didn't allocate a buffer */ | 323 return NULL; /* we didn't allocate a buffer */ |
322 } | 324 } |
323 *gap = 0; | 325 *gap = 0; |
324 | 326 |
325 if (*bufsize < bc->len*bc->mult_int) { | 327 if (*bufsize < bc->len*bc->mult_int) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 return bc->multiple; | 375 return bc->multiple; |
374 } | 376 } |
375 | 377 |
376 yasm_insn * | 378 yasm_insn * |
377 yasm_bc_get_insn(yasm_bytecode *bc) | 379 yasm_bc_get_insn(yasm_bytecode *bc) |
378 { | 380 { |
379 if (bc->callback->special != YASM_BC_SPECIAL_INSN) | 381 if (bc->callback->special != YASM_BC_SPECIAL_INSN) |
380 return NULL; | 382 return NULL; |
381 return (yasm_insn *)bc->contents; | 383 return (yasm_insn *)bc->contents; |
382 } | 384 } |
OLD | NEW |