From af5f918a9235ec8a4ce72553141c06b9631fb550 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 14 Jun 2018 19:53:45 -0700 Subject: [PATCH 1/3] Don't keep assigning segment numbers to EXTERN or COMMON If a symbol is EXTERN or COMMON, then we should not keep assigning it new segment numbers over and over. Instead, change the label code so that it assignes a new segment value if and only if one has not been assigned before. Signed-off-by: H. Peter Anvin --- asm/directiv.c | 2 +- asm/labels.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/asm/directiv.c b/asm/directiv.c index 53c1917c..68a74a12 100644 --- a/asm/directiv.c +++ b/asm/directiv.c @@ -369,7 +369,7 @@ bool process_directives(char *directive) break; if (type == LBL_COMMON || type == LBL_EXTERN) - define_label(value, seg_alloc(), size, false); + define_label(value, 0, size, false); break; } diff --git a/asm/labels.c b/asm/labels.c index eec5a844..ccdedace 100644 --- a/asm/labels.c +++ b/asm/labels.c @@ -77,7 +77,6 @@ static bool ismagic(const char *l) #define END_LIST -3 /* don't clash with NO_SEG! */ #define END_BLOCK -2 -#define BOGUS_VALUE -4 #define PERMTS_SIZE 16384 /* size of text blocks */ #if (PERMTS_SIZE < IDLEN_MAX) @@ -230,7 +229,6 @@ static union label *find_label(const char *label, bool create, bool *created) *created = true; nasm_zero(*lfree); - lfree->admin.movingon = BOGUS_VALUE; lfree->defn.label = perm_copy(label); lfree->defn.subsection = NO_SEG; if (label_str) @@ -426,6 +424,12 @@ void define_label(const char *label, int32_t segment, nasm_error(ERR_WARNING, "label `%s' defined on pass two", label); } + if (!segment) { + segment = lptr->defn.segment; + if (!segment) + segment = lptr->defn.segment = seg_alloc(); + } + if (lptr->defn.defined || lptr->defn.type == LBL_BACKEND) { /* We have seen this on at least one previous pass */ mangle_label_name(lptr); From 46c839a03ddb07dd7266e9b826a24eafa242dfbf Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 14 Jun 2018 20:00:07 -0700 Subject: [PATCH 2/3] labels: allocation of a segment number counts as a change If we allocate a new segment number, that has to cause global_offset_changed to be incremented. Thus, we should not update lptr->defn.segment until that would ordinarily be done. Signed-off-by: H. Peter Anvin --- asm/labels.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/asm/labels.c b/asm/labels.c index ccdedace..88edc9ed 100644 --- a/asm/labels.c +++ b/asm/labels.c @@ -424,11 +424,8 @@ void define_label(const char *label, int32_t segment, nasm_error(ERR_WARNING, "label `%s' defined on pass two", label); } - if (!segment) { - segment = lptr->defn.segment; - if (!segment) - segment = lptr->defn.segment = seg_alloc(); - } + if (!segment) + segment = lptr->defn.segment ? lptr->defn.segment : seg_alloc(); if (lptr->defn.defined || lptr->defn.type == LBL_BACKEND) { /* We have seen this on at least one previous pass */ From 430d41ede82babfbcc0d576cb0a83b09a9d62f7b Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 14 Jun 2018 20:01:22 -0700 Subject: [PATCH 3/3] NASM 2.14rc4 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 86db947a..c4a380cc 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.14rc3 +2.14rc4