]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: fix syms that are both cgo_import_static & cgo_import_dynamic
authorIan Lance Taylor <iant@golang.org>
Wed, 1 May 2013 21:30:19 +0000 (14:30 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 1 May 2013 21:30:19 +0000 (14:30 -0700)
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

src/cmd/ld/go.c
src/cmd/ld/lib.c

index fa2ec4e28da5c2fda2561bb9809f7ee9914a8edb..47fdbe9442b846e509c8b3efbf95ddb2ff961598 100644 (file)
@@ -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;
index 6b95ae2aeab7ce511a60a42b4a14e1d2579d9308..47a52b553c943daed12846105820da069130f2c0 100644 (file)
@@ -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.