mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link, plugin: use full plugin path for symbols
Plumb the import path of a plugin package through to the linker, and use it as the prefix on the exported symbol names. Before this we used the basename of the plugin file as the prefix, which could conflict and result in multiple loaded plugins sharing symbols that are distinct. Fixes #17155 Fixes #17579 Change-Id: I7ce966ca82d04e8507c0bcb8ea4ad946809b1ef5 Reviewed-on: https://go-review.googlesource.com/32355 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
590fce4884
commit
9da7058466
12 changed files with 119 additions and 40 deletions
|
|
@ -37,7 +37,6 @@ import (
|
|||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"strings"
|
||||
|
|
@ -59,6 +58,7 @@ var (
|
|||
flagBuildid = flag.String("buildid", "", "record `id` as Go toolchain build id")
|
||||
|
||||
flagOutfile = flag.String("o", "", "write output to `file`")
|
||||
flagPluginPath = flag.String("pluginpath", "", "full path name for plugin")
|
||||
FlagLinkshared = flag.Bool("linkshared", false, "link against installed Go shared libraries")
|
||||
|
||||
flagInstallSuffix = flag.String("installsuffix", "", "set package directory `suffix`")
|
||||
|
|
@ -175,8 +175,7 @@ func Main() {
|
|||
addlibpath(ctxt, "command line", "command line", file, pkgpath, "")
|
||||
}
|
||||
case BuildmodePlugin:
|
||||
pluginName := strings.TrimSuffix(filepath.Base(flag.Arg(0)), ".a")
|
||||
addlibpath(ctxt, "command line", "command line", flag.Arg(0), pluginName, "")
|
||||
addlibpath(ctxt, "command line", "command line", flag.Arg(0), *flagPluginPath, "")
|
||||
default:
|
||||
addlibpath(ctxt, "command line", "command line", flag.Arg(0), "main", "")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue