aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld/data.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-03 12:22:19 -0400
committerRuss Cox <rsc@golang.org>2014-10-03 12:22:19 -0400
commit904ec0098137f742e0dd96da3bc033d6a0b615d1 (patch)
tree6a05a91443927524fcb78ac82df0142d8e6ae71f /src/cmd/ld/data.c
parentd42328c9f749140adf947833e0381fc639c32737 (diff)
parentc65a47f890e33eeed6ee9d8b6d965a5534fb6e0e (diff)
downloadgo-904ec0098137f742e0dd96da3bc033d6a0b615d1.tar.xz
[dev.garbage] merge default into dev.garbage
Diffstat (limited to 'src/cmd/ld/data.c')
-rw-r--r--src/cmd/ld/data.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/cmd/ld/data.c b/src/cmd/ld/data.c
index 71624c3304..9983a9281c 100644
--- a/src/cmd/ld/data.c
+++ b/src/cmd/ld/data.c
@@ -620,22 +620,28 @@ addstrdata(char *name, char *value)
{
LSym *s, *sp;
char *p;
+ uchar reachable;
p = smprint("%s.str", name);
sp = linklookup(ctxt, p, 0);
free(p);
addstring(sp, value);
+ sp->type = SRODATA;
s = linklookup(ctxt, name, 0);
s->size = 0;
s->dupok = 1;
+ reachable = s->reachable;
addaddr(ctxt, s, sp);
adduint32(ctxt, s, strlen(value));
if(PtrSize == 8)
adduint32(ctxt, s, 0); // round struct to pointer width
- // in case reachability has already been computed
- sp->reachable = s->reachable;
+ // addstring, addaddr, etc., mark the symbols as reachable.
+ // In this case that is not necessarily true, so stick to what
+ // we know before entering this function.
+ s->reachable = reachable;
+ sp->reachable = reachable;
}
vlong
@@ -816,8 +822,15 @@ proggenaddsym(ProgGen *g, LSym *s)
proggenskip(g, g->pos, s->value - g->pos);
g->pos += s->value - g->pos;
- if(s->gotype == nil && s->size >= PtrSize) {
+ // The test for names beginning with . here is meant
+ // to keep .dynamic and .dynsym from turning up as
+ // conservative symbols. They should be marked SELFSECT
+ // and not SDATA, but sometimes that doesn't happen.
+ // Leave debugging the SDATA issue for the Go rewrite.
+
+ if(s->gotype == nil && s->size >= PtrSize && s->name[0] != '.') {
// conservative scan
+ diag("missing Go type information for global symbol: %s size %d", s->name, (int)s->size);
if((s->size%PtrSize) || (g->pos%PtrSize))
diag("proggenaddsym: unaligned conservative symbol %s: size=%lld pos=%lld",
s->name, s->size, g->pos);
@@ -833,7 +846,7 @@ proggenaddsym(ProgGen *g, LSym *s)
proggenarrayend(g);
}
g->pos = s->value + size;
- } else if(s->gotype == nil || decodetype_noptr(s->gotype) || s->size < PtrSize) {
+ } else if(s->gotype == nil || decodetype_noptr(s->gotype) || s->size < PtrSize || s->name[0] == '.') {
// no scan
if(s->size < 32*PtrSize) {
// Emit small symbols as data.