]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: allow for stdcall decorated dynimport names
authorJames Gray <james@james4k.com>
Wed, 30 Jan 2013 16:29:33 +0000 (08:29 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 30 Jan 2013 16:29:33 +0000 (08:29 -0800)
To allow for stdcall decorated names on Windows, two changes were needed:
1. Change the symbol versioning delimiter '@' in cgo's dynimport output to a '#', and in cmd/ld when it parses dynimports.
2. Remove the "@N" decorator from the first argument of cgo's dynimport output (PE only).

Fixes #4607.

R=minux.ma, adg, rsc
CC=golang-dev
https://golang.org/cl/7047043

src/cmd/cgo/out.go
src/cmd/ld/go.c

index ef1d06978c5c6d442ac30d705a3ad1027d813ebd..2b48ce2b4a86307a4db51d2f3af5c9d207a26233 100644 (file)
@@ -176,7 +176,7 @@ func dynimport(obj string) {
                for _, s := range sym {
                        targ := s.Name
                        if s.Version != "" {
-                               targ += "@" + s.Version
+                               targ += "#" + s.Version
                        }
                        fmt.Fprintf(stdout, "#pragma dynimport %s %s %q\n", s.Name, targ, s.Library)
                }
@@ -218,7 +218,8 @@ func dynimport(obj string) {
                }
                for _, s := range sym {
                        ss := strings.Split(s, ":")
-                       fmt.Fprintf(stdout, "#pragma dynimport %s %s %q\n", ss[0], ss[0], strings.ToLower(ss[1]))
+                       name := strings.Split(ss[0], "@")[0]
+                       fmt.Fprintf(stdout, "#pragma dynimport %s %s %q\n", name, ss[0], strings.ToLower(ss[1]))
                }
                return
        }
index ab19d7c0094dd6744857096d323ed01074396850..b2c5243dfd211bae57071166dd36559ea3fa80fb 100644 (file)
@@ -506,7 +506,7 @@ loaddynimport(char *file, char *pkg, char *p, int n)
                }
 
                name = expandpkg(name, pkg);
-               q = strchr(def, '@');
+               q = strchr(def, '#');
                if(q)
                        *q++ = '\0';
                s = lookup(name, 0);