aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2013-05-01 14:30:19 -0700
committerIan Lance Taylor <iant@golang.org>2013-05-01 14:30:19 -0700
commita555758909530b36d5b7fc5b2897698924222d14 (patch)
treec7dfb3a7696f07e816f7f9d801419cbf226713e0
parent3bd076991bcb619f076dab99a17cdd620dada037 (diff)
downloadgo-a555758909530b36d5b7fc5b2897698924222d14.tar.gz
go-a555758909530b36d5b7fc5b2897698924222d14.zip
cmd/ld: fix syms that are both cgo_import_static & cgo_import_dynamic
This is needed for SWIG when linking in internal mode. In internal mode if a symbol was cgo_import_static we used to forget that it was also cgo_import_dynamic. R=rsc, r CC=golang-dev https://golang.org/cl/9080043
-rw-r--r--src/cmd/ld/go.c5
-rw-r--r--src/cmd/ld/lib.c12
2 files changed, 13 insertions, 4 deletions
diff --git a/src/cmd/ld/go.c b/src/cmd/ld/go.c
index fa2ec4e28d..47fdbe9442 100644
--- a/src/cmd/ld/go.c
+++ b/src/cmd/ld/go.c
@@ -463,11 +463,12 @@ loadcgo(char *file, char *pkg, char *p, int n)
s = lookup(local, 0);
if(local != f[1])
free(local);
- if(s->type == 0 || s->type == SXREF) {
+ if(s->type == 0 || s->type == SXREF || s->type == SHOSTOBJ) {
s->dynimplib = lib;
s->extname = remote;
s->dynimpvers = q;
- s->type = SDYNIMPORT;
+ if(s->type != SHOSTOBJ)
+ s->type = SDYNIMPORT;
havedynamic = 1;
}
continue;
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c
index 6b95ae2aea..47a52b553c 100644
--- a/src/cmd/ld/lib.c
+++ b/src/cmd/ld/lib.c
@@ -331,8 +331,16 @@ loadlib(void)
// Drop all the cgo_import_static declarations.
// Turns out we won't be needing them.
for(s = allsym; s != S; s = s->allsym)
- if(s->type == SHOSTOBJ)
- s->type = 0;
+ if(s->type == SHOSTOBJ) {
+ // If a symbol was marked both
+ // cgo_import_static and cgo_import_dynamic,
+ // then we want to make it cgo_import_dynamic
+ // now.
+ if(s->extname != nil && s->cgoexport == 0) {
+ s->type = SDYNIMPORT;
+ } else
+ s->type = 0;
+ }
}
// Now that we know the link mode, trim the dynexp list.