From 2449909d816de46bc43065e6e93fe801c7770055 Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Tue, 4 Jun 2013 15:18:02 -0700 Subject: [PATCH] cmd/5c, cmd/6c, cmd/8c: isolate textflag and dataflag Fixes #5419. R=golang-dev, dave, minux.ma, rsc CC=golang-dev https://golang.org/cl/9241044 --- src/cmd/5c/txt.c | 11 ++++++++--- src/cmd/6c/txt.c | 14 ++++++++++---- src/cmd/8c/txt.c | 14 ++++++++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/cmd/5c/txt.c b/src/cmd/5c/txt.c index b8675fe60f..8dfd586fd4 100644 --- a/src/cmd/5c/txt.c +++ b/src/cmd/5c/txt.c @@ -139,9 +139,7 @@ gclean(void) continue; if(s->type == types[TENUM]) continue; - textflag = s->dataflag; gpseudo(AGLOBL, s, nodconst(s->type->width)); - textflag = 0; } nextpc(); p->as = AEND; @@ -1181,10 +1179,17 @@ gpseudo(int a, Sym *s, Node *n) p->from.type = D_OREG; p->from.sym = s; p->from.name = D_EXTERN; - if(a == ATEXT || a == AGLOBL) { + + switch(a) { + case ATEXT: p->reg = textflag; textflag = 0; + break; + case AGLOBL: + p->reg = s->dataflag; + break; } + if(s->class == CSTATIC) p->from.name = D_STATIC; naddr(n, &p->to); diff --git a/src/cmd/6c/txt.c b/src/cmd/6c/txt.c index 364b189f27..54b1cf54cb 100644 --- a/src/cmd/6c/txt.c +++ b/src/cmd/6c/txt.c @@ -158,9 +158,7 @@ gclean(void) continue; if(s->type == types[TENUM]) continue; - textflag = s->dataflag; gpseudo(AGLOBL, s, nodconst(s->type->width)); - textflag = 0; } nextpc(); p->as = AEND; @@ -1502,8 +1500,16 @@ gpseudo(int a, Sym *s, Node *n) p->as = a; p->from.type = D_EXTERN; p->from.sym = s; - p->from.scale = textflag; - textflag = 0; + + switch(a) { + case ATEXT: + p->from.scale = textflag; + textflag = 0; + break; + case AGLOBL: + p->from.scale = s->dataflag; + break; + } if(s->class == CSTATIC) p->from.type = D_STATIC; diff --git a/src/cmd/8c/txt.c b/src/cmd/8c/txt.c index 1b7617bc52..7f95387955 100644 --- a/src/cmd/8c/txt.c +++ b/src/cmd/8c/txt.c @@ -146,9 +146,7 @@ gclean(void) continue; if(s->type == types[TENUM]) continue; - textflag = s->dataflag; gpseudo(AGLOBL, s, nodconst(s->type->width)); - textflag = 0; } nextpc(); p->as = AEND; @@ -1381,8 +1379,16 @@ gpseudo(int a, Sym *s, Node *n) p->as = a; p->from.type = D_EXTERN; p->from.sym = s; - p->from.scale = textflag; - textflag = 0; + + switch(a) { + case ATEXT: + p->from.scale = textflag; + textflag = 0; + break; + case AGLOBL: + p->from.scale = s->dataflag; + break; + } if(s->class == CSTATIC) p->from.type = D_STATIC; -- 2.48.1