diff options
author | Russ Cox <rsc@golang.org> | 2014-11-14 12:10:52 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-11-14 12:10:52 -0500 |
commit | 6b31cfd20257f4d7226d5c4e95c67ed9b48ab58c (patch) | |
tree | fd7941be82dd45f113d8f0668e2c9b6a6ec3c77f /src/liblink/objfile.c | |
parent | 9cabb766eb4acbe2c11ad0084659710919f40c0d (diff) | |
parent | 0fdd42d52b29f44cf6cffa4c881ee8b40f9b3090 (diff) | |
download | go-6b31cfd20257f4d7226d5c4e95c67ed9b48ab58c.tar.gz |
[dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.cc
This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes.
These are the files that had merge conflicts and have been edited by hand:
malloc.go
mem_linux.go
mgc.go
os1_linux.go
proc1.go
panic1.go
runtime1.go
LGTM=austin
R=austin
CC=golang-codereviews
https://codereview.appspot.com/174180043
Diffstat (limited to 'src/liblink/objfile.c')
-rw-r--r-- | src/liblink/objfile.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/liblink/objfile.c b/src/liblink/objfile.c index 6d8694953..aa701f459 100644 --- a/src/liblink/objfile.c +++ b/src/liblink/objfile.c @@ -551,9 +551,10 @@ ldobjfile(Link *ctxt, Biobuf *f, char *pkg, int64 len, char *pn) static void readsym(Link *ctxt, Biobuf *f, char *pkg, char *pn) { - int i, j, c, t, v, n, size, dupok; + int i, j, c, t, v, n, ndata, nreloc, size, dupok; static int ndup; char *name; + uchar *data; Reloc *r; LSym *s, *dup, *typ; Pcln *pc; @@ -569,12 +570,24 @@ readsym(Link *ctxt, Biobuf *f, char *pkg, char *pn) dupok = rdint(f); dupok &= 1; size = rdint(f); + typ = rdsym(ctxt, f, pkg); + rddata(f, &data, &ndata); + nreloc = rdint(f); if(v != 0) v = ctxt->version; s = linklookup(ctxt, name, v); dup = nil; if(s->type != 0 && s->type != SXREF) { + if((t == SDATA || t == SBSS || t == SNOPTRBSS) && ndata == 0 && nreloc == 0) { + if(s->size < size) + s->size = size; + if(typ != nil && s->gotype == nil) + s->gotype = typ; + return; + } + if((s->type == SDATA || s->type == SBSS || s->type == SNOPTRBSS) && s->np == 0 && s->nr == 0) + goto overwrite; if(s->type != SBSS && s->type != SNOPTRBSS && !dupok && !s->dupok) sysfatal("duplicate symbol %s (types %d and %d) in %s and %s", s->name, s->type, t, s->file, pn); if(s->np > 0) { @@ -582,28 +595,30 @@ readsym(Link *ctxt, Biobuf *f, char *pkg, char *pn) s = linknewsym(ctxt, ".dup", ndup++); // scratch } } +overwrite: s->file = pkg; s->dupok = dupok; if(t == SXREF) sysfatal("bad sxref"); if(t == 0) sysfatal("missing type for %s in %s", name, pn); + if(t == SBSS && (s->type == SRODATA || s->type == SNOPTRBSS)) + t = s->type; s->type = t; if(s->size < size) s->size = size; - typ = rdsym(ctxt, f, pkg); if(typ != nil) // if bss sym defined multiple times, take type from any one def s->gotype = typ; if(dup != nil && typ != nil) dup->gotype = typ; - rddata(f, &s->p, &s->np); + s->p = data; + s->np = ndata; s->maxp = s->np; - n = rdint(f); - if(n > 0) { - s->r = emallocz(n * sizeof s->r[0]); - s->nr = n; - s->maxr = n; - for(i=0; i<n; i++) { + if(nreloc > 0) { + s->r = emallocz(nreloc * sizeof s->r[0]); + s->nr = nreloc; + s->maxr = nreloc; + for(i=0; i<nreloc; i++) { r = &s->r[i]; r->off = rdint(f); r->siz = rdint(f); |