aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/plugin.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2016-11-12 06:24:36 -0500
committerDavid Crawshaw <crawshaw@golang.org>2016-11-15 16:14:27 +0000
commit03da2690c9fefdbaff613f9ccc224b5f0abfbe16 (patch)
tree548d28619823ab21f19ea6be1b35f979ce879396 /src/runtime/plugin.go
parenta145890059e9c7aae870e1b9e74b204b6c8bc8d5 (diff)
downloadgo-03da2690c9fefdbaff613f9ccc224b5f0abfbe16.tar.xz
cmd/link, runtime, plugin: versioning
In plugins and every program that opens a plugin, include a hash of every imported package. There are two versions of each hash: one local and one exported. As the program starts and plugins are loaded, the first exported symbol for each package becomes the canonical version. Any subsequent plugin's local package hash symbol has to match the canonical version. Fixes #17832 Change-Id: I4e62c8e1729d322e14b1673bada40fa7a74ea8bc Reviewed-on: https://go-review.googlesource.com/33161 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/plugin.go')
-rw-r--r--src/runtime/plugin.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/runtime/plugin.go b/src/runtime/plugin.go
index 7907936e14..845bf76e92 100644
--- a/src/runtime/plugin.go
+++ b/src/runtime/plugin.go
@@ -7,7 +7,7 @@ package runtime
import "unsafe"
//go:linkname plugin_lastmoduleinit plugin.lastmoduleinit
-func plugin_lastmoduleinit() (path string, syms map[string]interface{}) {
+func plugin_lastmoduleinit() (path string, syms map[string]interface{}, mismatchpkg string) {
md := firstmoduledata.next
if md == nil {
throw("runtime: no plugin module data")
@@ -41,6 +41,11 @@ func plugin_lastmoduleinit() (path string, syms map[string]interface{}) {
throw("plugin: new module data overlaps with previous moduledata")
}
}
+ for _, pkghash := range md.pkghashes {
+ if pkghash.linktimehash != *pkghash.runtimehash {
+ return "", nil, pkghash.modulename
+ }
+ }
// Initialize the freshly loaded module.
modulesinit()
@@ -74,7 +79,7 @@ func plugin_lastmoduleinit() (path string, syms map[string]interface{}) {
}
syms[name] = val
}
- return md.pluginpath, syms
+ return md.pluginpath, syms, ""
}
// inRange reports whether v0 or v1 are in the range [r0, r1].