aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld/data.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2014-09-28 08:27:05 -0700
committerIan Lance Taylor <iant@golang.org>2014-09-28 08:27:05 -0700
commitf6fc14094a476d2e23722f124cfcd8204c2659b0 (patch)
tree875f21415f04acde2038d270833b43b5574725e3 /src/cmd/ld/data.c
parent56c4d0a5c63a81de4a0d935337b226d229a44c07 (diff)
downloadgo-f6fc14094a476d2e23722f124cfcd8204c2659b0.tar.xz
cmd/ld: don't automatically mark symbols created by -X as reachable
This fixes the bug in which the linker reports "missing Go type information" when a -X option refers to a symbol that is not used. Fixes #8821. LGTM=rsc R=rsc, r CC=golang-codereviews https://golang.org/cl/151000043
Diffstat (limited to 'src/cmd/ld/data.c')
-rw-r--r--src/cmd/ld/data.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/ld/data.c b/src/cmd/ld/data.c
index 89226bfe28..9983a9281c 100644
--- a/src/cmd/ld/data.c
+++ b/src/cmd/ld/data.c
@@ -620,6 +620,7 @@ addstrdata(char *name, char *value)
{
LSym *s, *sp;
char *p;
+ uchar reachable;
p = smprint("%s.str", name);
sp = linklookup(ctxt, p, 0);
@@ -630,13 +631,17 @@ addstrdata(char *name, char *value)
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