diff options
| author | Keith Randall <khr@golang.org> | 2023-03-09 16:31:41 +0000 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2023-03-09 19:19:41 +0000 |
| commit | 642542cb3c4b672cb34cde44a415c05bf1560a5e (patch) | |
| tree | 8de0ffba0445a8220cb01ac191f44d8c1048c107 /src/plugin/plugin_dlopen.go | |
| parent | aafc734c7807bafeb8aa69c019494f69965154b0 (diff) | |
| download | go-642542cb3c4b672cb34cde44a415c05bf1560a5e.tar.xz | |
Revert "cmd/link: establish dependable package initialization order"
This reverts commit ce2a609909d9de3391a99a00fe140506f724f933.
aka CL 462035
Reason for revert: this CL is causing some problems in some internal Google programs.
Change-Id: I4476b8d8d2c3d7b5703d1d85c93baebb4b4e5d26
Reviewed-on: https://go-review.googlesource.com/c/go/+/474976
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/plugin/plugin_dlopen.go')
| -rw-r--r-- | src/plugin/plugin_dlopen.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/plugin/plugin_dlopen.go b/src/plugin/plugin_dlopen.go index f6ae219d95..b4c4e4061c 100644 --- a/src/plugin/plugin_dlopen.go +++ b/src/plugin/plugin_dlopen.go @@ -74,7 +74,7 @@ func open(name string) (*Plugin, error) { if plugins == nil { plugins = make(map[string]*Plugin) } - pluginpath, syms, initTasks, errstr := lastmoduleinit() + pluginpath, syms, errstr := lastmoduleinit() if errstr != "" { plugins[filepath] = &Plugin{ pluginpath: pluginpath, @@ -92,7 +92,14 @@ func open(name string) (*Plugin, error) { plugins[filepath] = p pluginsMu.Unlock() - doInit(initTasks) + initStr := make([]byte, len(pluginpath)+len("..inittask")+1) // +1 for terminating NUL + copy(initStr, pluginpath) + copy(initStr[len(pluginpath):], "..inittask") + + initTask := C.pluginLookup(h, (*C.char)(unsafe.Pointer(&initStr[0])), &cErr) + if initTask != nil { + doInit(initTask) + } // Fill out the value of each plugin symbol. updatedSyms := map[string]any{} @@ -140,14 +147,9 @@ var ( ) // lastmoduleinit is defined in package runtime. -func lastmoduleinit() (pluginpath string, syms map[string]any, inittasks []*initTask, errstr string) +func lastmoduleinit() (pluginpath string, syms map[string]any, errstr string) // doInit is defined in package runtime. // //go:linkname doInit runtime.doInit -func doInit(t []*initTask) - -type initTask struct { - // fields defined in runtime.initTask. We only handle pointers to an initTask - // in this package, so the contents are irrelevant. -} +func doInit(t unsafe.Pointer) // t should be a *runtime.initTask |
