1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Issue 53989: the use of jump table caused a function 6 // from the plugin jumps in the middle of the function 7 // to the function with the same name in the main 8 // executable. As these two functions may be compiled 9 // differently as plugin needs to be PIC, this causes 10 // crash. 11 12 package main 13 14 import ( 15 "plugin" 16 17 "testplugin/issue53989/p" 18 ) 19 20 func main() { 21 p.Square(7) // call the function in main executable 22 23 p, err := plugin.Open("issue53989.so") 24 if err != nil { 25 panic(err) 26 } 27 f, err := p.Lookup("Square") 28 if err != nil { 29 panic(err) 30 } 31 f.(func(int))(7) // call the plugin one 32 } 33