1
0
mirror of https://github.com/golang/go synced 2024-11-22 02:44:39 -07:00

6l, 8l: make etext accurate; introduce rodata, erodata.

Makes binaries work with 6cov again.

R=ken2
CC=golang-dev
https://golang.org/cl/2192041
This commit is contained in:
Russ Cox 2010-09-14 11:13:04 -04:00
parent caf3b4a749
commit b7e9e9188a
2 changed files with 12 additions and 2 deletions

View File

@ -45,6 +45,9 @@ span(void)
Sym *s; Sym *s;
xdefine("etext", STEXT, 0L); xdefine("etext", STEXT, 0L);
xdefine("rodata", SRODATA, 0L);
xdefine("erodata", SRODATA, 0L);
idat = INITDAT; idat = INITDAT;
for(p = firstp; p != P; p = p->link) { for(p = firstp; p != P; p = p->link) {
if(p->as == ATEXT) if(p->as == ATEXT)
@ -122,11 +125,13 @@ loop:
textsize = c; textsize = c;
goto loop; goto loop;
} }
xdefine("etext", STEXT, c);
/* /*
* allocate read-only data to the text segment. * allocate read-only data to the text segment.
*/ */
c = rnd(c, 8); c = rnd(c, 8);
xdefine("rodata", SRODATA, c);
for(i=0; i<NHASH; i++) for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) { for(s = hash[i]; s != S; s = s->link) {
if(s->type != SRODATA) if(s->type != SRODATA)
@ -137,6 +142,7 @@ loop:
s->value = c; s->value = c;
c += v; c += v;
} }
xdefine("erodata", SRODATA, c);
if(INITRND) { if(INITRND) {
INITDAT = rnd(c, INITRND); INITDAT = rnd(c, INITRND);
@ -146,7 +152,6 @@ loop:
} }
} }
xdefine("etext", STEXT, c);
if(debug['v']) if(debug['v'])
Bprint(&bso, "etext = %llux\n", c); Bprint(&bso, "etext = %llux\n", c);
Bflush(&bso); Bflush(&bso);

View File

@ -40,6 +40,9 @@ span(void)
Sym *s; Sym *s;
xdefine("etext", STEXT, 0L); xdefine("etext", STEXT, 0L);
xdefine("rodata", SRODATA, 0L);
xdefine("erodata", SRODATA, 0L);
idat = INITDAT; idat = INITDAT;
for(p = firstp; p != P; p = p->link) { for(p = firstp; p != P; p = p->link) {
if(p->as == ATEXT) if(p->as == ATEXT)
@ -107,11 +110,13 @@ start:
textsize = c; textsize = c;
n++; n++;
}while(again); }while(again);
xdefine("etext", STEXT, c);
/* /*
* allocate read-only data to the text segment. * allocate read-only data to the text segment.
*/ */
c = rnd(c, 8); c = rnd(c, 8);
xdefine("rodata", SRODATA, c);
for(i=0; i<NHASH; i++) for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) { for(s = hash[i]; s != S; s = s->link) {
if(s->type != SRODATA) if(s->type != SRODATA)
@ -122,6 +127,7 @@ start:
s->value = c; s->value = c;
c += v; c += v;
} }
xdefine("erodata", SRODATA, c);
if(INITRND) { if(INITRND) {
INITDAT = rnd(c+textpad, INITRND); INITDAT = rnd(c+textpad, INITRND);
@ -131,7 +137,6 @@ start:
} }
} }
xdefine("etext", STEXT, c);
if(debug['v']) if(debug['v'])
Bprint(&bso, "etext = %lux\n", c); Bprint(&bso, "etext = %lux\n", c);
Bflush(&bso); Bflush(&bso);