Fix #97: Support right-shifted symbols in binary output (the root cause).

Also fix the symptom by checking for non-NULL value->rel.

svn path=/trunk/yasm/; revision=1744
0.6.0
Peter Johnson 18 years ago
parent 763687f8bd
commit 9bbc4a4926
  1. 16
      modules/objfmts/bin/bin-objfmt.c
  2. 2
      modules/objfmts/bin/tests/Makefile.inc
  3. 3
      modules/objfmts/bin/tests/shr.asm
  4. 260
      modules/objfmts/bin/tests/shr.hex

@ -143,14 +143,22 @@ bin_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
if (value->rel && !value->curpos_rel
&& yasm_symrec_get_label(value->rel, &precbc)
&& (sect = yasm_bc_get_section(precbc))) {
unsigned int rshift = (unsigned int)value->rshift;
yasm_expr *syme;
if (value->rshift > 0)
syme = yasm_expr_create(YASM_EXPR_SHR, yasm_expr_sym(value->rel),
yasm_expr_int(yasm_intnum_create_uint(rshift)), bc->line);
else
syme = yasm_expr_create_ident(yasm_expr_sym(value->rel), bc->line);
if (!value->abs)
value->abs = yasm_expr_create_ident(yasm_expr_sym(value->rel),
bc->line);
value->abs = syme;
else
value->abs =
yasm_expr_create(YASM_EXPR_ADD, yasm_expr_expr(value->abs),
yasm_expr_sym(value->rel), bc->line);
yasm_expr_expr(syme), bc->line);
value->rel = NULL;
value->rshift = 0;
}
/* Simplify absolute portion of value, transforming symrecs */
@ -170,7 +178,7 @@ bin_objfmt_output_value(yasm_value *value, unsigned char *buf, size_t destsize,
}
/* Absolute value; handle it here as output_basic won't understand it */
if (yasm_symrec_is_abs(value->rel)) {
if (value->rel && yasm_symrec_is_abs(value->rel)) {
if (value->curpos_rel) {
/* Calculate value relative to current assembly position */
/*@only@*/ yasm_intnum *outval;

@ -28,3 +28,5 @@ EXTRA_DIST += modules/objfmts/bin/tests/reserve.hex
EXTRA_DIST += modules/objfmts/bin/tests/reserve.errwarn
EXTRA_DIST += modules/objfmts/bin/tests/reserve-err.asm
EXTRA_DIST += modules/objfmts/bin/tests/reserve-err.errwarn
EXTRA_DIST += modules/objfmts/bin/tests/shr.asm
EXTRA_DIST += modules/objfmts/bin/tests/shr.hex

@ -0,0 +1,3 @@
x: mov al, x>>8
times 256 db 0
y: mov ah, y>>8

@ -0,0 +1,260 @@
b0
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
b4
01
Loading…
Cancel
Save