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>
This commit is contained in:
H. Peter Anvin, Intel 2018-06-25 13:16:53 -07:00
parent 4fb2acc0d3
commit c5e45f6b70

View File

@ -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 */