Repository: go
Issue: x/mobile: building 2 independent xcframeworks for iOS Simulator, but crash when app start up
Labels: NeedsInvestigation,mobile

<!--
Please answer these questions before submitting your issue. Thanks!
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.17.6 darwin/amd64
</pre>

### Does this issue reproduce with the latest release?

yes

### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/x/Library/Caches/go-build"
GOENV="/Users/x/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/x/.gvm/pkgsets/go1.17.6/global/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/x/.gvm/pkgsets/go1.17.6/global"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/Users/x/.gvm/gos/go1.17.6"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/x/.gvm/gos/go1.17.6/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/private/tmp/golang-crash-test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vd/lrhd0qbn1t56jjs5ml_81_w00000gp/T/go-build4026723300=/tmp/go-build -gno-record-gcc-switches -fno-common"

</pre></details>

### What did you do?

Building 2 independent xcframeworks for iOS App to use.

```shell
gomobile bind -tags test1 -target=ios -o build/golang_crash_test1.xcframework ./crash
gomobile bind -tags test2 -target=ios -o build/golang_crash_test2.xcframework ./crash
```

And then use the xcframeworks in the [Xcode project](https://github.com/pipi32167/golang-sdk-crash-test/tree/main/example/golang-sdk-crash-test)

<!--
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on go.dev/play is best.
-->



### What did you expect to see?

The iOS program is able to run properly.

### What did you see instead?

The iOS program running crash with the callstack: 

```
#0	0x000000010e814d55 in debugCall65536 ()
#1	0x000000010ed76899 in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const ()
#2	0x000000010ed92941 in invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const ()
#3	0x000000010ed8be09 in invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const ()
#4	0x000000010ed8af5f in dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const ()
#5	0x000000010ed8bb93 in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const ()
#6	0x000000010ed923a2 in dyld3::MachOAnalyzer::forEachInitializerPointerSection(Diagnostics&, void (unsigned int, unsigned int, unsigned char const*, bool&) block_pointer) const ()
#7	0x000000010ed925e4 in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const ()
#8	0x000000010ed767cc in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const ()
#9	0x000000010ed76958 in dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const ()
#10	0x000000010ed769f6 in dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const ()
#11	0x000000010ed852d8 in dyld4::APIs::runAllInitializersForMain() ()
#12	0x000000010ed69920 in dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) ()
#13	0x000000010ed69d3f in _dyld_sim_prepare ()
#14	0x00000001145fcb24 in dyld4::prepareSim(dyld4::RuntimeState&, char const*) ()
#15	0x00000001145fb6de in dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) ()
#16	0x00000001145fb4b4 in start ()
```