aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/symtab.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2017-10-09 16:04:44 -0400
committerDavid Crawshaw <crawshaw@golang.org>2017-10-13 01:13:33 +0000
commitc58b98b2d617ab2dfe839c4e5ef1e2008c9b60cf (patch)
treec81802d52b2d633d7e416b32fc2a3c5f409626bc /src/runtime/symtab.go
parentd06815ba3f0a196adeacfbf5cc963fe2b7d42f46 (diff)
downloadgo-c58b98b2d617ab2dfe839c4e5ef1e2008c9b60cf.tar.xz
cmd/link, runtime: put hasmain bit in moduledata
Currently we look to see if the main.main symbol address is in the module data text range. This requires access to the main.main symbol, which usually the runtime has, but does not when building a plugin. To avoid a dynamic relocation to main.main (which I haven't worked out how to have the linker generate on darwin), stop using the symbol. Instead record a boolean in the moduledata if the module has the main function. Fixes #22175 Change-Id: If313a118f17ab499d0a760bbc2519771ed654530 Reviewed-on: https://go-review.googlesource.com/69370 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/symtab.go')
-rw-r--r--src/runtime/symtab.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
index 542c29ecd6..2f426c7bf1 100644
--- a/src/runtime/symtab.go
+++ b/src/runtime/symtab.go
@@ -375,6 +375,8 @@ type moduledata struct {
modulename string
modulehashes []modulehash
+ hasmain uint8 // 1 if module contains the main function, 0 otherwise
+
gcdatamask, gcbssmask bitvector
typemap map[typeOff]*_type // offset to *_rtype in previous module
@@ -472,9 +474,8 @@ func modulesinit() {
// contains the main function.
//
// See Issue #18729.
- mainText := funcPC(main_main)
for i, md := range *modules {
- if md.text <= mainText && mainText <= md.etext {
+ if md.hasmain != 0 {
(*modules)[0] = md
(*modules)[i] = &firstmoduledata
break