diff --git a/misc/cgo/testshared/src/exe/exe.go b/misc/cgo/testshared/src/exe/exe.go index 31fbedd31c558..f01ad8ab781e9 100644 --- a/misc/cgo/testshared/src/exe/exe.go +++ b/misc/cgo/testshared/src/exe/exe.go @@ -7,6 +7,11 @@ import ( "runtime" ) +// Having a function declared in the main package triggered +// golang.org/issue/18250 +func DeclaredInMain() { +} + func main() { defer depBase.ImplementedInAsm() // This code below causes various go.itab.* symbols to be generated in diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index 98ce3ad79b8f4..dd0e5407e828c 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -602,8 +602,7 @@ func (ctxt *Link) symtab() { adduint(ctxt, moduledata, uint64(nitablinks)) adduint(ctxt, moduledata, uint64(nitablinks)) // The ptab slice - if ptab := ctxt.Syms.ROLookup("go.plugin.tabs", 0); ptab != nil { - ptab.Attr |= AttrReachable + if ptab := ctxt.Syms.ROLookup("go.plugin.tabs", 0); ptab != nil && ptab.Attr.Reachable() { ptab.Attr |= AttrLocal ptab.Type = obj.SRODATA