diff options
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/plugin.go | 9 | ||||
| -rw-r--r-- | src/runtime/symtab.go | 12 |
2 files changed, 18 insertions, 3 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]. diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index bba3ccfc20..686af08ef0 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -202,7 +202,9 @@ type moduledata struct { ptab []ptabEntry - pluginpath string + pluginpath string + pkghashes []modulehash + modulename string modulehashes []modulehash @@ -213,10 +215,18 @@ type moduledata struct { next *moduledata } +// A modulehash is used to compare the ABI of a new module or a +// package in a new module with the loaded program. +// // For each shared library a module links against, the linker creates an entry in the // moduledata.modulehashes slice containing the name of the module, the abi hash seen // at link time and a pointer to the runtime abi hash. These are checked in // moduledataverify1 below. +// +// For each loaded plugin, the the pkghashes slice has a modulehash of the +// newly loaded package that can be used to check the plugin's version of +// a package against any previously loaded version of the package. +// This is done in plugin.lastmoduleinit. type modulehash struct { modulename string linktimehash string |
