Commit 65e2b6f8 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

cmd/ld: mark hostobj sections as containing no pointers

Currently they are scanned conservatively.
But there is no reason to scan them. C world must not contain
pointers into Go heap. Moreover, we don't have enough information
to emit write barriers nor update pointers there in future.
The immediate need is that it breaks the new GC because
these are weird symbols as if with pointers but not necessary
pointer aligned.

LGTM=rsc
R=golang-codereviews, rlh, rsc
CC=golang-codereviews, iant, khr
https://golang.org/cl/117000043
parent 722764b7
...@@ -539,7 +539,7 @@ ldelf(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -539,7 +539,7 @@ ldelf(Biobuf *f, char *pkg, int64 len, char *pn)
s->type = SRODATA; s->type = SRODATA;
break; break;
case ElfSectFlagAlloc + ElfSectFlagWrite: case ElfSectFlagAlloc + ElfSectFlagWrite:
s->type = SDATA; s->type = SNOPTRDATA;
break; break;
case ElfSectFlagAlloc + ElfSectFlagExec: case ElfSectFlagAlloc + ElfSectFlagExec:
s->type = STEXT; s->type = STEXT;
...@@ -572,7 +572,7 @@ ldelf(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -572,7 +572,7 @@ ldelf(Biobuf *f, char *pkg, int64 len, char *pn)
if(s->size < sym.size) if(s->size < sym.size)
s->size = sym.size; s->size = sym.size;
if(s->type == 0 || s->type == SXREF) if(s->type == 0 || s->type == SXREF)
s->type = SBSS; s->type = SNOPTRBSS;
continue; continue;
} }
if(sym.shndx >= obj->nsect || sym.shndx == 0) if(sym.shndx >= obj->nsect || sym.shndx == 0)
......
...@@ -589,10 +589,10 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -589,10 +589,10 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn)
s->type = SRODATA; s->type = SRODATA;
} else { } else {
if (strcmp(sect->name, "__bss") == 0) { if (strcmp(sect->name, "__bss") == 0) {
s->type = SBSS; s->type = SNOPTRBSS;
s->np = 0; s->np = 0;
} else } else
s->type = SDATA; s->type = SNOPTRDATA;
} }
sect->sym = s; sect->sym = s;
} }
......
...@@ -230,10 +230,10 @@ ldpe(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -230,10 +230,10 @@ ldpe(Biobuf *f, char *pkg, int64 len, char *pn)
s->type = SRODATA; s->type = SRODATA;
break; break;
case IMAGE_SCN_CNT_UNINITIALIZED_DATA|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE: //.bss case IMAGE_SCN_CNT_UNINITIALIZED_DATA|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE: //.bss
s->type = SBSS; s->type = SNOPTRBSS;
break; break;
case IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE: //.data case IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE: //.data
s->type = SDATA; s->type = SNOPTRDATA;
break; break;
case IMAGE_SCN_CNT_CODE|IMAGE_SCN_MEM_EXECUTE|IMAGE_SCN_MEM_READ: //.text case IMAGE_SCN_CNT_CODE|IMAGE_SCN_MEM_EXECUTE|IMAGE_SCN_MEM_READ: //.text
s->type = STEXT; s->type = STEXT;
...@@ -338,7 +338,7 @@ ldpe(Biobuf *f, char *pkg, int64 len, char *pn) ...@@ -338,7 +338,7 @@ ldpe(Biobuf *f, char *pkg, int64 len, char *pn)
if(s->type == SDYNIMPORT) if(s->type == SDYNIMPORT)
s->plt = -2; // flag for dynimport in PE object files. s->plt = -2; // flag for dynimport in PE object files.
if (s->type == SXREF && sym->value > 0) {// global data if (s->type == SXREF && sym->value > 0) {// global data
s->type = SDATA; s->type = SNOPTRDATA;
s->size = sym->value; s->size = sym->value;
} }
continue; continue;
......
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