summaryrefslogtreecommitdiff
path: root/sys/src/cmd/8l
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2017-03-19 03:05:24 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2017-03-19 03:05:24 +0100
commitda9b38c75c11cc7f18415849b5bf14579ef8317c (patch)
tree427a69021fef7444f35b9880677c6bdce63e68d9 /sys/src/cmd/8l
parentbd178b6dc6a6d6a81be05c0a1f7c03b352f833c1 (diff)
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.
Diffstat (limited to 'sys/src/cmd/8l')
-rw-r--r--sys/src/cmd/8l/asm.c2
-rw-r--r--sys/src/cmd/8l/l.h1
-rw-r--r--sys/src/cmd/8l/list.c1
-rw-r--r--sys/src/cmd/8l/obj.c3
4 files changed, 6 insertions, 1 deletions
diff --git a/sys/src/cmd/8l/asm.c b/sys/src/cmd/8l/asm.c
index a1bb36ba6..129b3cd71 100644
--- a/sys/src/cmd/8l/asm.c
+++ b/sys/src/cmd/8l/asm.c
@@ -421,7 +421,7 @@ datblk(long s, long n)
}
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/8l/l.h b/sys/src/cmd/8l/l.h
index fbb0a191b..2ca800342 100644
--- a/sys/src/cmd/8l/l.h
+++ b/sys/src/cmd/8l/l.h
@@ -80,6 +80,7 @@ struct Sym
short become;
short frame;
uchar subtype;
+ char dupok;
ushort file;
long value;
long sig;
diff --git a/sys/src/cmd/8l/list.c b/sys/src/cmd/8l/list.c
index 212b8ad3c..f6b1eda2e 100644
--- a/sys/src/cmd/8l/list.c
+++ b/sys/src/cmd/8l/list.c
@@ -23,6 +23,7 @@ Pconv(Fmt *fp)
bigP = p;
switch(p->as) {
case ATEXT:
+ case AGLOBL:
if(p->from.scale) {
snprint(str, sizeof(str), "(%ld) %A %D,%d,%D",
p->line, p->as, &p->from, p->from.scale, &p->to);
diff --git a/sys/src/cmd/8l/obj.c b/sys/src/cmd/8l/obj.c
index 2aeee6811..ba4571468 100644
--- a/sys/src/cmd/8l/obj.c
+++ b/sys/src/cmd/8l/obj.c
@@ -885,6 +885,8 @@ loop:
case AGLOBL:
s = p->from.sym;
+ if(p->from.scale & DUPOK)
+ s->dupok = 1;
if(s->type == 0 || s->type == SXREF) {
s->type = SBSS;
s->value = 0;
@@ -1134,6 +1136,7 @@ lookup(char *symb, int v)
s->version = v;
s->value = 0;
s->sig = 0;
+ s->dupok = 0;
hash[h] = s;
nsymbol++;
return s;