output/legacy.c: OUT_SEGMENT -> OUT_ADDRESS with a zero addend

The legacy output doesn't distinguish between segments and other
addresses, so we need to force the offset to zero before passing it
down to the output layer.

This addresses BR 3392406.

Reported-by: <rugxulo@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2017-05-01 15:10:47 -07:00
parent 08e71e7dc4
commit 217e714e6b
2 changed files with 4 additions and 2 deletions

View File

@ -495,7 +495,7 @@ static inline void out_segment(struct out_data *data,
data->type = OUT_SEGMENT;
data->sign = OUT_UNSIGNED;
data->size = 2;
data->toffset = opx->offset;
data->toffset = opx->offset; /* Is this really needed/wanted? */
data->tsegment = ofmt->segbase(opx->segment + 1);
data->twrt = opx->wrt;
out(data);

View File

@ -89,7 +89,9 @@ void nasm_do_legacy_output(const struct out_data *data)
case OUT_SEGMENT:
type = OUT_ADDRESS;
/* fall through */
dptr = &zero_buffer;
size = (data->sign == OUT_SIGNED) ? -data->size : data->size;
break;
case OUT_ADDRESS:
dptr = &data->toffset;