summaryrefslogtreecommitdiff
path: root/src/cmd/8l/span.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-09-12 00:17:44 -0400
committerRuss Cox <rsc@golang.org>2010-09-12 00:17:44 -0400
commit39c59ba49c7193e2fe76598e6470d11f49a8cd8b (patch)
tree66c3580ab7921c1d4935d5cde554b98b6b3b9914 /src/cmd/8l/span.c
parent9d703468861652f59038fb41003a1693a9080975 (diff)
downloadgo-39c59ba49c7193e2fe76598e6470d11f49a8cd8b.tar.gz
6g, 6l, 8g, 8l: move read-only data to text segment
Changing 5g and 5l too, but it doesn't work yet. R=ken2 CC=golang-dev http://codereview.appspot.com/2136047
Diffstat (limited to 'src/cmd/8l/span.c')
-rw-r--r--src/cmd/8l/span.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/cmd/8l/span.c b/src/cmd/8l/span.c
index 99ba279da..3bc18adb6 100644
--- a/src/cmd/8l/span.c
+++ b/src/cmd/8l/span.c
@@ -35,8 +35,9 @@ void
span(void)
{
Prog *p, *q;
- int32 v, c, idat;
+ int32 i, v, c, idat;
int m, n, again;
+ Sym *s;
xdefine("etext", STEXT, 0L);
idat = INITDAT;
@@ -106,6 +107,21 @@ start:
textsize = c;
n++;
}while(again);
+
+ /*
+ * allocate read-only data to the text segment.
+ */
+ c = rnd(c, 8);
+ for(i=0; i<NHASH; i++)
+ for(s = hash[i]; s != S; s = s->link) {
+ if(s->type != SRODATA)
+ continue;
+ v = s->size;
+ while(v & 3)
+ v++;
+ s->value = c;
+ c += v;
+ }
if(INITRND) {
INITDAT = rnd(c+textpad, INITRND);
@@ -114,6 +130,7 @@ start:
goto start;
}
}
+
xdefine("etext", STEXT, c);
if(debug['v'])
Bprint(&bso, "etext = %lux\n", c);
@@ -208,6 +225,7 @@ asmsym(void)
for(s=hash[h]; s!=S; s=s->link)
switch(s->type) {
case SCONST:
+ case SRODATA:
if(!s->reachable)
continue;
putsymb(s->name, 'D', s->value, s->version, s->gotype);
@@ -618,6 +636,7 @@ vaddr(Adr *a)
ckoff(s, v);
case STEXT:
case SCONST:
+ case SRODATA:
if(!s->reachable)
sysfatal("unreachable symbol in vaddr - %s", s->name);
v += s->value;