From 21c977e717d7ecea03275810dcc11c082d4f20f0 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 16 Oct 2023 17:12:25 -0700 Subject: [PATCH] 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 Reported-by: Vladimir Chebotarev Signed-off-by: H. Peter Anvin --- output/legacy.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/output/legacy.c b/output/legacy.c index 15d22e9e..f75291f5 100644 --- a/output/legacy.c +++ b/output/legacy.c @@ -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;