-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Milestone
@wdvxdr1123
Description
package main import ( _ "unsafe" ) //go:linkname addmoduledata runtime.addmoduledata func addmoduledata() func main() { addmoduledata() }
This program can compile ok. However, comment said do NOT call from Go.
Lines 427 to 428 in ebc763f
// Called from linker-generated .initarray; declared for go vet; do NOT call from Go.
func addmoduledata()
And using linkname on this function will cause a linker crash when building with buildmode=plugin.
package main import ( _ "unsafe" ) //go:linkname addmoduledata runtime.addmoduledata func addmoduledata() func FOO() { addmoduledata() }
go build -buildmode=plugin a.go
# command-line-arguments
runtime.gcWriteBarrier1: phase error: addr=0x63750 but val=0x5dc00 sym=runtime.gcWriteBarrier1 type=STEXT sect=.text sect.addr=0x0 prev=runtime.addmoduledata