summaryrefslogtreecommitdiff
path: root/sys/src/cmd/vl
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/vl
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/vl')
-rw-r--r--sys/src/cmd/vl/asm.c2
-rw-r--r--sys/src/cmd/vl/l.h1
-rw-r--r--sys/src/cmd/vl/obj.c3
3 files changed, 5 insertions, 1 deletions
diff --git a/sys/src/cmd/vl/asm.c b/sys/src/cmd/vl/asm.c
index c18c5b408..20e9c0c28 100644
--- a/sys/src/cmd/vl/asm.c
+++ b/sys/src/cmd/vl/asm.c
@@ -708,7 +708,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/vl/l.h b/sys/src/cmd/vl/l.h
index e8c6577b5..1ea12b15b 100644
--- a/sys/src/cmd/vl/l.h
+++ b/sys/src/cmd/vl/l.h
@@ -74,6 +74,7 @@ struct Sym
short version;
short become;
short frame;
+ char dupok;
long value;
Sym* link;
};
diff --git a/sys/src/cmd/vl/obj.c b/sys/src/cmd/vl/obj.c
index 6002b7417..5f6e7200c 100644
--- a/sys/src/cmd/vl/obj.c
+++ b/sys/src/cmd/vl/obj.c
@@ -803,6 +803,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;
@@ -1036,6 +1038,7 @@ lookup(char *symb, int v)
s->type = 0;
s->version = v;
s->value = 0;
+ s->dupok = 0;
hash[h] = s;
return s;
}