output/legacy: when converting OUT_SEGMENT, clear the offset

Legacy backends like obj/omf may depend on the offset being zero if
not in use.

Reported-by: Bernd Boeckmann <bernd-freedos@boeckmann.io>
Reported-by: Vladimir Chebotarev <vladimir.chebotarev@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2023-10-16 17:12:25 -07:00
parent 7d5e549d63
commit 21c977e717

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2016-2022 The NASM Authors - All Rights Reserved
* Copyright 2016-2023 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@ -89,8 +89,11 @@ void nasm_do_legacy_output(const struct out_data *data)
case OUT_SEGMENT:
type = OUT_ADDRESS;
tsegment |= 1;
/* fall through */
if (tsegment != NO_SEG && tsegment < SEG_ABS)
tsegment |= 1;
dptr = zero_buffer;
size = data->size;
break;
case OUT_ADDRESS:
dptr = &data->toffset;