From 1021b089d5d05240ad8dd32da16329764b952de0 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Fri, 29 Nov 2024 11:20:51 +0900 Subject: [PATCH 1/2] outobj: allow for segments in the group FLAT to belong to the other group It's possible that segments belong to both the group FLAT and the other group because the group FLAT is a pseudo group. Signed-off-by: KO Myung-Hun --- output/outobj.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/output/outobj.c b/output/outobj.c index 281839d0..3f2315f9 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -1536,7 +1536,12 @@ static int32_t obj_segment(char *name, int *bits) nasm_free(grp->segs[i].name); grp->segs[i] = grp->segs[grp->nindices]; grp->segs[grp->nindices++].index = seg->obj_index; - if (seg->grp) + /* + * The group FLAT is a pseudo group. Therefore, it is + * allowed to redefine a segment in the group FLAT as + * other group. + */ + if (seg->grp && strcmp(seg->grp->name, "FLAT")) nasm_warn(WARN_OTHER, "segment `%s' is already part of" " a group: first one takes precedence", seg->name); @@ -1651,7 +1656,12 @@ obj_directive(enum directive directive, char *value) */ grp->segs[grp->nentries++] = grp->segs[grp->nindices]; grp->segs[grp->nindices++].index = seg->obj_index; - if (seg->grp) + /* + * The group FLAT is a pseudo group. Therefore, it is + * allowed to redefine a segment in the group FLAT as + * other group. + */ + if (seg->grp && strcmp(seg->grp->name, "FLAT")) nasm_warn(WARN_OTHER, "segment `%s' is already part of" " a group: first one takes precedence", seg->name); From 3924c48c0facf83a2f02269af5243f246faaa7dc Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Fri, 29 Nov 2024 11:29:35 +0900 Subject: [PATCH 2/2] outobj: disallow the combination of USE16(16-bit segment) and FLAT FLAT should be used only with USE32(32-bit segment). Signed-off-by: KO Myung-Hun --- output/outobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/output/outobj.c b/output/outobj.c index 3f2315f9..48dcf450 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -1517,6 +1517,9 @@ static int32_t obj_segment(char *name, int *bits) } } + if (!seg->use32 && seg->grp && !strcmp(seg->grp->name, "FLAT")) + nasm_panic("wrong combination of USE16(16-bit segment) and FLAT"); + /* We need to know whenever we have at least one 32-bit segment */ obj_use32 |= seg->use32;