aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin, Intel <h.peter.anvin@intel.com>2018-06-25 13:16:53 -0700
committerH. Peter Anvin, Intel <h.peter.anvin@intel.com>2018-06-25 13:16:53 -0700
commitc5e45f6b7081c6dd5959d48327c2a9828b65315d (patch)
treeb62a9a5f89a309fd137b54ce8305afc13fa6961c
parent4fb2acc0d3ff6bdb0d5dbcb6368ac1a524186ced (diff)
downloadnasm-c5e45f6b7081c6dd5959d48327c2a9828b65315d.tar.gz
nasm-c5e45f6b7081c6dd5959d48327c2a9828b65315d.tar.xz
nasm-c5e45f6b7081c6dd5959d48327c2a9828b65315d.zip
labels: auto-promote EXTERN labels to GLOBAL if defined
If we define a label which was previously declared EXTERN, then automatically treat is as GLOBAL. Previously, we would fail to converge and loop forever, which is obviously not what we want. This is more user-friendly anyway. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--asm/labels.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/asm/labels.c b/asm/labels.c
index 1b93348c..93a687ea 100644
--- a/asm/labels.c
+++ b/asm/labels.c
@@ -434,8 +434,14 @@ void define_label(const char *label, int32_t segment,
*/
lptr = find_label(label, true, &created);
- if (!segment)
+ if (segment) {
+ /* We are actually defining this label */
+ if (lptr->defn.type == LBL_EXTERN) /* auto-promote EXTERN to GLOBAL */
+ lptr->defn.type = LBL_GLOBAL;
+ } else {
+ /* It's a pseudo-segment (extern, common) */
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 */