Commit 5bcad92f authored by Russ Cox's avatar Russ Cox

ld: add NOPTRBSS for large, pointer-free uninitialized data

cc: add #pragma textflag to set it
runtime: mark mheap to go into noptr-bss.
        remove special case in garbage collector

Remove the ARM from.flag field created by CL 5687044.
The DUPOK flag was already in p->reg, so keep using that.

Otherwise test/nilptr.go creates a very large binary.
Should fix the arm build.
Diagnosed by minux.ma; replacement for CL 5690044.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/5686060
parent 9c08d650
...@@ -491,7 +491,6 @@ zaddr(Gen *a, int s) ...@@ -491,7 +491,6 @@ zaddr(Gen *a, int s)
Bputc(&obuf, a->type); Bputc(&obuf, a->type);
Bputc(&obuf, a->reg); Bputc(&obuf, a->reg);
Bputc(&obuf, 0); // flag
Bputc(&obuf, s); Bputc(&obuf, s);
Bputc(&obuf, a->name); Bputc(&obuf, a->name);
switch(a->type) { switch(a->type) {
......
...@@ -564,10 +564,9 @@ zaddr(char *bp, Adr *a, int s) ...@@ -564,10 +564,9 @@ zaddr(char *bp, Adr *a, int s)
bp[0] = a->type; bp[0] = a->type;
bp[1] = a->reg; bp[1] = a->reg;
bp[2] = 0; // flag bp[2] = s;
bp[3] = s; bp[3] = a->name;
bp[4] = a->name; bp += 4;
bp += 5;
switch(a->type) { switch(a->type) {
default: default:
diag(Z, "unknown type %d in zaddr", a->type); diag(Z, "unknown type %d in zaddr", a->type);
......
...@@ -139,7 +139,9 @@ gclean(void) ...@@ -139,7 +139,9 @@ gclean(void)
continue; continue;
if(s->type == types[TENUM]) if(s->type == types[TENUM])
continue; continue;
textflag = s->dataflag;
gpseudo(AGLOBL, s, nodconst(s->type->width)); gpseudo(AGLOBL, s, nodconst(s->type->width));
textflag = 0;
} }
nextpc(); nextpc();
p->as = AEND; p->as = AEND;
......
...@@ -27,7 +27,6 @@ struct Addr ...@@ -27,7 +27,6 @@ struct Addr
uchar reg; uchar reg;
char pun; char pun;
uchar etype; uchar etype;
char flag;
}; };
#define A ((Addr*)0) #define A ((Addr*)0)
......
...@@ -93,7 +93,6 @@ zaddr(Biobuf *b, Addr *a, int s) ...@@ -93,7 +93,6 @@ zaddr(Biobuf *b, Addr *a, int s)
default: default:
Bputc(b, a->type); Bputc(b, a->type);
Bputc(b, a->reg); Bputc(b, a->reg);
Bputc(b, a->flag);
Bputc(b, s); Bputc(b, s);
Bputc(b, a->name); Bputc(b, a->name);
} }
......
...@@ -254,9 +254,9 @@ ggloblnod(Node *nam, int32 width) ...@@ -254,9 +254,9 @@ ggloblnod(Node *nam, int32 width)
p->to.type = D_CONST; p->to.type = D_CONST;
p->to.offset = width; p->to.offset = width;
if(nam->readonly) if(nam->readonly)
p->from.flag = RODATA; p->reg = RODATA;
if(nam->type != T && !haspointers(nam->type)) if(nam->type != T && !haspointers(nam->type))
p->from.flag |= NOPTR; p->reg |= NOPTR;
} }
void void
...@@ -273,7 +273,7 @@ ggloblsym(Sym *s, int32 width, int dupok) ...@@ -273,7 +273,7 @@ ggloblsym(Sym *s, int32 width, int dupok)
p->to.offset = width; p->to.offset = width;
if(dupok) if(dupok)
p->reg = DUPOK; p->reg = DUPOK;
p->from.flag |= RODATA; p->reg |= RODATA;
} }
int int
......
...@@ -75,6 +75,7 @@ enum { ...@@ -75,6 +75,7 @@ enum {
ElfStrPlt, ElfStrPlt,
ElfStrNoteNetbsdIdent, ElfStrNoteNetbsdIdent,
ElfStrNoPtrData, ElfStrNoPtrData,
ElfStrNoPtrBss,
NElfStr NElfStr
}; };
...@@ -168,6 +169,7 @@ doelf(void) ...@@ -168,6 +169,7 @@ doelf(void)
elfstr[ElfStrNoPtrData] = addstring(shstrtab, ".noptrdata"); elfstr[ElfStrNoPtrData] = addstring(shstrtab, ".noptrdata");
elfstr[ElfStrData] = addstring(shstrtab, ".data"); elfstr[ElfStrData] = addstring(shstrtab, ".data");
elfstr[ElfStrBss] = addstring(shstrtab, ".bss"); elfstr[ElfStrBss] = addstring(shstrtab, ".bss");
elfstr[ElfStrNoPtrBss] = addstring(shstrtab, ".noptrbss");
if(HEADTYPE == Hnetbsd) if(HEADTYPE == Hnetbsd)
elfstr[ElfStrNoteNetbsdIdent] = addstring(shstrtab, ".note.netbsd.ident"); elfstr[ElfStrNoteNetbsdIdent] = addstring(shstrtab, ".note.netbsd.ident");
addstring(shstrtab, ".rodata"); addstring(shstrtab, ".rodata");
...@@ -1847,12 +1849,14 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*)) ...@@ -1847,12 +1849,14 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*))
case STYPE: case STYPE:
case SSTRING: case SSTRING:
case SGOSTRING: case SGOSTRING:
case SNOPTRDATA:
if(!s->reachable) if(!s->reachable)
continue; continue;
put(s, s->name, 'D', s->value, s->size, s->version, s->gotype); put(s, s->name, 'D', s->value, s->size, s->version, s->gotype);
continue; continue;
case SBSS: case SBSS:
case SNOPTRBSS:
if(!s->reachable) if(!s->reachable)
continue; continue;
put(s, s->name, 'B', s->value, s->size, s->version, s->gotype); put(s, s->name, 'B', s->value, s->size, s->version, s->gotype);
......
...@@ -76,7 +76,6 @@ struct Adr ...@@ -76,7 +76,6 @@ struct Adr
uchar index; // not used on arm, required by ld/go.c uchar index; // not used on arm, required by ld/go.c
char reg; char reg;
char name; char name;
char flag;
int32 offset2; // argsize int32 offset2; // argsize
char class; char class;
Sym* gotype; Sym* gotype;
......
...@@ -301,7 +301,6 @@ zaddr(Biobuf *f, Adr *a, Sym *h[]) ...@@ -301,7 +301,6 @@ zaddr(Biobuf *f, Adr *a, Sym *h[])
a->type = Bgetc(f); a->type = Bgetc(f);
a->reg = Bgetc(f); a->reg = Bgetc(f);
a->flag = Bgetc(f);
c = Bgetc(f); c = Bgetc(f);
if(c < 0 || c > NSYM){ if(c < 0 || c > NSYM){
print("sym out of range: %d\n", c); print("sym out of range: %d\n", c);
...@@ -541,7 +540,7 @@ loop: ...@@ -541,7 +540,7 @@ loop:
s->type = SBSS; s->type = SBSS;
s->value = 0; s->value = 0;
} }
if(s->type != SBSS && s->type != SNOPTRDATA && !s->dupok) { if(s->type != SBSS && s->type != SNOPTRBSS && !s->dupok) {
diag("redefinition: %s\n%P", s->name, p); diag("redefinition: %s\n%P", s->name, p);
s->type = SBSS; s->type = SBSS;
s->value = 0; s->value = 0;
...@@ -550,10 +549,14 @@ loop: ...@@ -550,10 +549,14 @@ loop:
s->size = p->to.offset; s->size = p->to.offset;
if(p->reg & DUPOK) if(p->reg & DUPOK)
s->dupok = 1; s->dupok = 1;
if(p->from.flag & RODATA) if(p->reg & RODATA)
s->type = SRODATA; s->type = SRODATA;
else if(p->from.flag & NOPTR) else if(p->reg & NOPTR) {
s->type = SNOPTRDATA; if(s->np > 0)
s->type = SNOPTRDATA;
else
s->type = SNOPTRBSS;
}
break; break;
case ADATA: case ADATA:
......
...@@ -421,6 +421,8 @@ symaddr(Sym *s) ...@@ -421,6 +421,8 @@ symaddr(Sym *s)
case SDATA: case SDATA:
case SBSS: case SBSS:
case SCONST: case SCONST:
case SNOPTRDATA:
case SNOPTRBSS:
break; break;
} }
return v; return v;
......
...@@ -158,7 +158,9 @@ gclean(void) ...@@ -158,7 +158,9 @@ gclean(void)
continue; continue;
if(s->type == types[TENUM]) if(s->type == types[TENUM])
continue; continue;
textflag = s->dataflag;
gpseudo(AGLOBL, s, nodconst(s->type->width)); gpseudo(AGLOBL, s, nodconst(s->type->width));
textflag = 0;
} }
nextpc(); nextpc();
p->as = AEND; p->as = AEND;
......
...@@ -96,6 +96,7 @@ enum { ...@@ -96,6 +96,7 @@ enum {
ElfStrGnuVersionR, ElfStrGnuVersionR,
ElfStrNoteNetbsdIdent, ElfStrNoteNetbsdIdent,
ElfStrNoPtrData, ElfStrNoPtrData,
ElfStrNoPtrBss,
NElfStr NElfStr
}; };
...@@ -573,6 +574,7 @@ doelf(void) ...@@ -573,6 +574,7 @@ doelf(void)
elfstr[ElfStrNoPtrData] = addstring(shstrtab, ".noptrdata"); elfstr[ElfStrNoPtrData] = addstring(shstrtab, ".noptrdata");
elfstr[ElfStrData] = addstring(shstrtab, ".data"); elfstr[ElfStrData] = addstring(shstrtab, ".data");
elfstr[ElfStrBss] = addstring(shstrtab, ".bss"); elfstr[ElfStrBss] = addstring(shstrtab, ".bss");
elfstr[ElfStrNoPtrBss] = addstring(shstrtab, ".noptrbss");
if(HEADTYPE == Hnetbsd) if(HEADTYPE == Hnetbsd)
elfstr[ElfStrNoteNetbsdIdent] = addstring(shstrtab, ".note.netbsd.ident"); elfstr[ElfStrNoteNetbsdIdent] = addstring(shstrtab, ".note.netbsd.ident");
addstring(shstrtab, ".elfdata"); addstring(shstrtab, ".elfdata");
...@@ -1169,6 +1171,7 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*)) ...@@ -1169,6 +1171,7 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*))
case SCONST: case SCONST:
case SRODATA: case SRODATA:
case SDATA: case SDATA:
case SNOPTRDATA:
case SELFROSECT: case SELFROSECT:
case SMACHOGOT: case SMACHOGOT:
case STYPE: case STYPE:
...@@ -1181,6 +1184,7 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*)) ...@@ -1181,6 +1184,7 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*))
continue; continue;
case SBSS: case SBSS:
case SNOPTRBSS:
if(!s->reachable) if(!s->reachable)
continue; continue;
put(s, s->name, 'B', symaddr(s), s->size, s->version, s->gotype); put(s, s->name, 'B', symaddr(s), s->size, s->version, s->gotype);
......
...@@ -555,7 +555,7 @@ loop: ...@@ -555,7 +555,7 @@ loop:
s->type = SBSS; s->type = SBSS;
s->size = 0; s->size = 0;
} }
if(s->type != SBSS && s->type != SNOPTRDATA && !s->dupok) { if(s->type != SBSS && s->type != SNOPTRBSS && !s->dupok) {
diag("%s: redefinition: %s in %s", diag("%s: redefinition: %s in %s",
pn, s->name, TNAME); pn, s->name, TNAME);
s->type = SBSS; s->type = SBSS;
...@@ -567,8 +567,12 @@ loop: ...@@ -567,8 +567,12 @@ loop:
s->dupok = 1; s->dupok = 1;
if(p->from.scale & RODATA) if(p->from.scale & RODATA)
s->type = SRODATA; s->type = SRODATA;
else if(p->from.scale & NOPTR) else if(p->from.scale & NOPTR) {
s->type = SNOPTRDATA; if(s->np > 0)
s->type = SNOPTRDATA;
else
s->type = SNOPTRBSS;
}
goto loop; goto loop;
case ADATA: case ADATA:
......
...@@ -146,7 +146,9 @@ gclean(void) ...@@ -146,7 +146,9 @@ gclean(void)
continue; continue;
if(s->type == types[TENUM]) if(s->type == types[TENUM])
continue; continue;
textflag = s->dataflag;
gpseudo(AGLOBL, s, nodconst(s->type->width)); gpseudo(AGLOBL, s, nodconst(s->type->width));
textflag = 0;
} }
nextpc(); nextpc();
p->as = AEND; p->as = AEND;
......
...@@ -92,6 +92,7 @@ enum { ...@@ -92,6 +92,7 @@ enum {
ElfStrGnuVersionR, ElfStrGnuVersionR,
ElfStrNoteNetbsdIdent, ElfStrNoteNetbsdIdent,
ElfStrNoPtrData, ElfStrNoPtrData,
ElfStrNoPtrBss,
NElfStr NElfStr
}; };
...@@ -530,6 +531,7 @@ doelf(void) ...@@ -530,6 +531,7 @@ doelf(void)
elfstr[ElfStrNoPtrData] = addstring(shstrtab, ".noptrdata"); elfstr[ElfStrNoPtrData] = addstring(shstrtab, ".noptrdata");
elfstr[ElfStrData] = addstring(shstrtab, ".data"); elfstr[ElfStrData] = addstring(shstrtab, ".data");
elfstr[ElfStrBss] = addstring(shstrtab, ".bss"); elfstr[ElfStrBss] = addstring(shstrtab, ".bss");
elfstr[ElfStrNoPtrBss] = addstring(shstrtab, ".noptrbss");
if(HEADTYPE == Hnetbsd) if(HEADTYPE == Hnetbsd)
elfstr[ElfStrNoteNetbsdIdent] = addstring(shstrtab, ".note.netbsd.ident"); elfstr[ElfStrNoteNetbsdIdent] = addstring(shstrtab, ".note.netbsd.ident");
addstring(shstrtab, ".elfdata"); addstring(shstrtab, ".elfdata");
...@@ -1256,12 +1258,14 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*)) ...@@ -1256,12 +1258,14 @@ genasmsym(void (*put)(Sym*, char*, int, vlong, vlong, int, Sym*))
case SSTRING: case SSTRING:
case SGOSTRING: case SGOSTRING:
case SWINDOWS: case SWINDOWS:
case SNOPTRDATA:
if(!s->reachable) if(!s->reachable)
continue; continue;
put(s, s->name, 'D', symaddr(s), s->size, s->version, s->gotype); put(s, s->name, 'D', symaddr(s), s->size, s->version, s->gotype);
continue; continue;
case SBSS: case SBSS:
case SNOPTRBSS:
if(!s->reachable) if(!s->reachable)
continue; continue;
put(s, s->name, 'B', symaddr(s), s->size, s->version, s->gotype); put(s, s->name, 'B', symaddr(s), s->size, s->version, s->gotype);
......
...@@ -122,6 +122,7 @@ struct Sym ...@@ -122,6 +122,7 @@ struct Sym
uchar sym; uchar sym;
uchar aused; uchar aused;
uchar sig; uchar sig;
uchar dataflag;
}; };
#define S ((Sym*)0) #define S ((Sym*)0)
...@@ -524,6 +525,7 @@ EXTERN int nterm; ...@@ -524,6 +525,7 @@ EXTERN int nterm;
EXTERN int packflg; EXTERN int packflg;
EXTERN int fproundflg; EXTERN int fproundflg;
EXTERN int textflag; EXTERN int textflag;
EXTERN int dataflag;
EXTERN int ncontin; EXTERN int ncontin;
EXTERN int canreach; EXTERN int canreach;
EXTERN int warnreach; EXTERN int warnreach;
...@@ -766,6 +768,7 @@ void arginit(void); ...@@ -766,6 +768,7 @@ void arginit(void);
void pragvararg(void); void pragvararg(void);
void pragpack(void); void pragpack(void);
void pragfpround(void); void pragfpround(void);
void pragdataflag(void);
void pragtextflag(void); void pragtextflag(void);
void pragincomplete(void); void pragincomplete(void);
void pragdynimport(void); void pragdynimport(void);
......
...@@ -120,6 +120,10 @@ loop: ...@@ -120,6 +120,10 @@ loop:
(*f)(c, t, s); (*f)(c, t, s);
if(s->class == CLOCAL) if(s->class == CLOCAL)
s = mkstatic(s); s = mkstatic(s);
if(dataflag) {
s->dataflag = dataflag;
dataflag = 0;
}
firstbit = 0; firstbit = 0;
n->sym = s; n->sym = s;
n->type = s->type; n->type = s->type;
......
...@@ -567,19 +567,23 @@ pragfpround(void) ...@@ -567,19 +567,23 @@ pragfpround(void)
void void
pragtextflag(void) pragtextflag(void)
{ {
Sym *s; textflag = getnsn();
textflag = 0;
s = getsym();
textflag = 7;
if(s)
textflag = atoi(s->name+1);
while(getnsc() != '\n') while(getnsc() != '\n')
; ;
if(debug['f']) if(debug['f'])
print("%4d: textflag %d\n", lineno, textflag); print("%4d: textflag %d\n", lineno, textflag);
} }
void
pragdataflag(void)
{
dataflag = getnsn();
while(getnsc() != '\n')
;
if(debug['f'])
print("%4d: dataflag %d\n", lineno, dataflag);
}
void void
pragincomplete(void) pragincomplete(void)
{ {
......
...@@ -74,6 +74,13 @@ pragtextflag(void) ...@@ -74,6 +74,13 @@ pragtextflag(void)
; ;
} }
void
pragdataflag(void)
{
while(getnsc() != '\n')
;
}
void void
pragprofile(void) pragprofile(void)
{ {
......
...@@ -731,6 +731,10 @@ macprag(void) ...@@ -731,6 +731,10 @@ macprag(void)
pragtextflag(); pragtextflag();
return; return;
} }
if(s && strcmp(s->name, "dataflag") == 0) {
pragdataflag();
return;
}
if(s && strcmp(s->name, "varargck") == 0) { if(s && strcmp(s->name, "varargck") == 0) {
pragvararg(); pragvararg();
return; return;
......
...@@ -806,8 +806,12 @@ dodata(void) ...@@ -806,8 +806,12 @@ dodata(void)
} }
for(s = datap; s != nil; s = s->next) { for(s = datap; s != nil; s = s->next) {
if(s->np > 0 && s->type == SBSS) if(s->np > 0) {
s->type = SDATA; if(s->type == SBSS)
s->type = SDATA;
if(s->type == SNOPTRBSS)
s->type = SNOPTRDATA;
}
if(s->np > s->size) if(s->np > s->size)
diag("%s: initialize bounds (%lld < %d)", diag("%s: initialize bounds (%lld < %d)",
s->name, (vlong)s->size, s->np); s->name, (vlong)s->size, s->np);
...@@ -935,11 +939,24 @@ dodata(void) ...@@ -935,11 +939,24 @@ dodata(void)
datsize += t; datsize += t;
} }
/* bss */ /* bss, then pointer-free bss */
noptr = nil;
sect = addsection(&segdata, ".bss", 06); sect = addsection(&segdata, ".bss", 06);
sect->vaddr = datsize; sect->vaddr = datsize;
for(; s != nil; s = s->next) { for(; ; s = s->next) {
if(s->type != SBSS) { if((s == nil || s->type >= SNOPTRBSS) && noptr == nil) {
// finish bss, start noptrbss
datsize = rnd(datsize, 8);
sect->len = datsize - sect->vaddr;
sect = addsection(&segdata, ".noptrbss", 06);
sect->vaddr = datsize;
noptr = sect;
}
if(s == nil) {
sect->len = datsize - sect->vaddr;
break;
}
if(s->type > SNOPTRBSS) {
cursym = s; cursym = s;
diag("unexpected symbol type %d", s->type); diag("unexpected symbol type %d", s->type);
} }
...@@ -961,7 +978,6 @@ dodata(void) ...@@ -961,7 +978,6 @@ dodata(void)
s->value = datsize; s->value = datsize;
datsize += t; datsize += t;
} }
sect->len = datsize - sect->vaddr;
} }
// assign addresses to text // assign addresses to text
...@@ -1004,7 +1020,7 @@ textaddress(void) ...@@ -1004,7 +1020,7 @@ textaddress(void)
void void
address(void) address(void)
{ {
Section *s, *text, *data, *rodata, *symtab, *pclntab, *noptr; Section *s, *text, *data, *rodata, *symtab, *pclntab, *noptr, *bss, *noptrbss;
Sym *sym, *sub; Sym *sym, *sub;
uvlong va; uvlong va;
...@@ -1031,6 +1047,8 @@ address(void) ...@@ -1031,6 +1047,8 @@ address(void)
segdata.fileoff = segtext.fileoff + segtext.filelen; segdata.fileoff = segtext.fileoff + segtext.filelen;
data = nil; data = nil;
noptr = nil; noptr = nil;
bss = nil;
noptrbss = nil;
for(s=segdata.sect; s != nil; s=s->next) { for(s=segdata.sect; s != nil; s=s->next) {
s->vaddr = va; s->vaddr = va;
va += s->len; va += s->len;
...@@ -1040,8 +1058,12 @@ address(void) ...@@ -1040,8 +1058,12 @@ address(void)
data = s; data = s;
if(strcmp(s->name, ".noptrdata") == 0) if(strcmp(s->name, ".noptrdata") == 0)
noptr = s; noptr = s;
if(strcmp(s->name, ".bss") == 0)
bss = s;
if(strcmp(s->name, ".noptrbss") == 0)
noptrbss = s;
} }
segdata.filelen -= data->next->len; // deduct .bss segdata.filelen -= bss->len + noptrbss->len; // deduct .bss
text = segtext.sect; text = segtext.sect;
rodata = text->next; rodata = text->next;
...@@ -1068,7 +1090,11 @@ address(void) ...@@ -1068,7 +1090,11 @@ address(void)
xdefine("epclntab", SRODATA, pclntab->vaddr + pclntab->len); xdefine("epclntab", SRODATA, pclntab->vaddr + pclntab->len);
xdefine("noptrdata", SBSS, noptr->vaddr); xdefine("noptrdata", SBSS, noptr->vaddr);
xdefine("enoptrdata", SBSS, noptr->vaddr + noptr->len); xdefine("enoptrdata", SBSS, noptr->vaddr + noptr->len);
xdefine("bss", SBSS, bss->vaddr);
xdefine("ebss", SBSS, bss->vaddr + bss->len);
xdefine("data", SBSS, data->vaddr); xdefine("data", SBSS, data->vaddr);
xdefine("edata", SBSS, data->vaddr + data->len); xdefine("edata", SBSS, data->vaddr + data->len);
xdefine("noptrbss", SBSS, noptrbss->vaddr);
xdefine("enoptrbss", SBSS, noptrbss->vaddr + noptrbss->len);
xdefine("end", SBSS, segdata.vaddr + segdata.len); xdefine("end", SBSS, segdata.vaddr + segdata.len);
} }
...@@ -49,6 +49,7 @@ enum ...@@ -49,6 +49,7 @@ enum
SMACHOGOT, SMACHOGOT,
SWINDOWS, SWINDOWS,
SBSS, SBSS,
SNOPTRBSS,
SXREF, SXREF,
SMACHODYNSTR, SMACHODYNSTR,
......
...@@ -334,6 +334,10 @@ symtab(void) ...@@ -334,6 +334,10 @@ symtab(void)
xdefine("enoptrdata", SBSS, 0); xdefine("enoptrdata", SBSS, 0);
xdefine("data", SBSS, 0); xdefine("data", SBSS, 0);
xdefine("edata", SBSS, 0); xdefine("edata", SBSS, 0);
xdefine("bss", SBSS, 0);
xdefine("ebss", SBSS, 0);
xdefine("noptrbss", SBSS, 0);
xdefine("enoptrbss", SBSS, 0);
xdefine("end", SBSS, 0); xdefine("end", SBSS, 0);
xdefine("epclntab", SRODATA, 0); xdefine("epclntab", SRODATA, 0);
xdefine("esymtab", SRODATA, 0); xdefine("esymtab", SRODATA, 0);
......
...@@ -112,7 +112,7 @@ addr(Biobuf *bp) ...@@ -112,7 +112,7 @@ addr(Biobuf *bp)
long off; long off;
a.type = Bgetc(bp); /* a.type */ a.type = Bgetc(bp); /* a.type */
skip(bp,2); /* reg, flag */ skip(bp,1); /* reg */
a.sym = Bgetc(bp); /* sym index */ a.sym = Bgetc(bp); /* sym index */
a.name = Bgetc(bp); /* sym type */ a.name = Bgetc(bp); /* sym type */
switch(a.type){ switch(a.type){
......
...@@ -14,7 +14,9 @@ package runtime ...@@ -14,7 +14,9 @@ package runtime
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "type.h" #include "type.h"
#pragma dataflag 16 /* mark mheap as 'no pointers', hiding from garbage collector */
MHeap runtime·mheap; MHeap runtime·mheap;
extern MStats mstats; // defined in extern.go extern MStats mstats; // defined in extern.go
extern volatile int32 runtime·MemProfileRate; extern volatile int32 runtime·MemProfileRate;
......
...@@ -85,7 +85,7 @@ struct FinBlock ...@@ -85,7 +85,7 @@ struct FinBlock
extern byte data[]; extern byte data[];
extern byte etext[]; extern byte etext[];
extern byte end[]; extern byte ebss[];
static G *fing; static G *fing;
static FinBlock *finq; // list of finalizers that are to be executed static FinBlock *finq; // list of finalizers that are to be executed
...@@ -630,10 +630,7 @@ mark(void (*scan)(byte*, int64)) ...@@ -630,10 +630,7 @@ mark(void (*scan)(byte*, int64))
FinBlock *fb; FinBlock *fb;
// mark data+bss. // mark data+bss.
// skip runtime·mheap itself, which has no interesting pointers scan(data, ebss - data);
// and is mostly zeroed and would not otherwise be paged in.
scan(data, (byte*)&runtime·mheap - data);
scan((byte*)(&runtime·mheap+1), end - (byte*)(&runtime·mheap+1));
// mark stacks // mark stacks
for(gp=runtime·allg; gp!=nil; gp=gp->alllink) { for(gp=runtime·allg; gp!=nil; gp=gp->alllink) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment