1
0
mirror of https://github.com/golang/go synced 2024-11-26 05:37:57 -07:00

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
This commit is contained in:
Ian Lance Taylor 2013-05-01 14:30:19 -07:00
parent 3bd076991b
commit a555758909
2 changed files with 13 additions and 4 deletions

View File

@ -463,11 +463,12 @@ loadcgo(char *file, char *pkg, char *p, int n)
s = lookup(local, 0); s = lookup(local, 0);
if(local != f[1]) if(local != f[1])
free(local); free(local);
if(s->type == 0 || s->type == SXREF) { if(s->type == 0 || s->type == SXREF || s->type == SHOSTOBJ) {
s->dynimplib = lib; s->dynimplib = lib;
s->extname = remote; s->extname = remote;
s->dynimpvers = q; s->dynimpvers = q;
s->type = SDYNIMPORT; if(s->type != SHOSTOBJ)
s->type = SDYNIMPORT;
havedynamic = 1; havedynamic = 1;
} }
continue; continue;

View File

@ -331,8 +331,16 @@ loadlib(void)
// Drop all the cgo_import_static declarations. // Drop all the cgo_import_static declarations.
// Turns out we won't be needing them. // Turns out we won't be needing them.
for(s = allsym; s != S; s = s->allsym) for(s = allsym; s != S; s = s->allsym)
if(s->type == SHOSTOBJ) if(s->type == SHOSTOBJ) {
s->type = 0; // 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. // Now that we know the link mode, trim the dynexp list.