From da9b38c75c11cc7f18415849b5bf14579ef8317c Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 19 Mar 2017 03:05:24 +0100 Subject: 5l,6l,8l,kl,ql,vl: allow duplicate GLOBAL symbols (from Ori Bernstein) The plan 9 assemblers support the DUPOK flag on text symbols. They parse and ignore it on GLOBL symbols. This patch makes it work in the linkers. The reason I ran into this is because my programming language (Myrddin) uses data symbols to generate type information, and it's useful to avoid duplicating all of the type info in every file that gets generated. --- sys/src/cmd/5l/asm.c | 2 +- sys/src/cmd/5l/l.h | 1 + sys/src/cmd/5l/obj.c | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'sys/src/cmd/5l') diff --git a/sys/src/cmd/5l/asm.c b/sys/src/cmd/5l/asm.c index 81f5e7f55..1d3ecc68b 100644 --- a/sys/src/cmd/5l/asm.c +++ b/sys/src/cmd/5l/asm.c @@ -578,7 +578,7 @@ datblk(long s, long n, int str) } if(l >= n) continue; - if(p->as != AINIT && p->as != ADYNT) { + if(p->as != AINIT && p->as != ADYNT && !p->from.sym->dupok) { for(j=l+(c-i)-1; j>=l; j--) if(buf.dbuf[j]) { print("%P\n", p); diff --git a/sys/src/cmd/5l/l.h b/sys/src/cmd/5l/l.h index 1db0ce9c6..24426e11b 100644 --- a/sys/src/cmd/5l/l.h +++ b/sys/src/cmd/5l/l.h @@ -82,6 +82,7 @@ struct Sym short become; short frame; uchar subtype; + char dupok; ushort file; long value; long sig; diff --git a/sys/src/cmd/5l/obj.c b/sys/src/cmd/5l/obj.c index 218579230..a185919b3 100644 --- a/sys/src/cmd/5l/obj.c +++ b/sys/src/cmd/5l/obj.c @@ -868,6 +868,8 @@ loop: diag("GLOBL must have a name\n%P", p); errorexit(); } + if(p->reg & DUPOK) + s->dupok = 1; if(s->type == 0 || s->type == SXREF) { s->type = SBSS; s->value = 0; @@ -1113,6 +1115,7 @@ lookup(char *symb, int v) s->version = v; s->value = 0; s->sig = 0; + s->dupok = 0; hash[h] = s; return s; } -- cgit v1.2.3