summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2017-05-01 15:10:47 -0700
committerH. Peter Anvin <hpa@zytor.com>2017-05-01 15:10:47 -0700
commit217e714e6bfae501cdceeb9ca13b9339502a4f0e (patch)
treefa72b3d52dd00678447dc4c000421b6f4ca0ce4b
parent08e71e7dc47027d6e9ef4f85189e8421f632fb13 (diff)
downloadnasm-217e714e6bfae501cdceeb9ca13b9339502a4f0e.tar.gz
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>
-rw-r--r--asm/assemble.c2
-rw-r--r--output/legacy.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/asm/assemble.c b/asm/assemble.c
index 31db516a..d88d889c 100644
--- a/asm/assemble.c
+++ b/asm/assemble.c
@@ -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);
diff --git a/output/legacy.c b/output/legacy.c
index 3fc95ee8..38d6d7e0 100644
--- a/output/legacy.c
+++ b/output/legacy.c
@@ -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;