Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: illegal text-relocation for c-archive darwin/amd64 #14217
When compiling using buildmode c-archive on darwin/amd64 (targeting the iOS simulator), I run into this error when trying to link the resulting archive to my Swift code:
ld: illegal text-relocation to 'type..eq.encoding/xml.Attr' in .../lib.a(go.o) from 'runtime.rodata' in .../lib.a(go.o) for architecture x86_64
Looking at the cmd/link/internal/ld/macho.go, it seems that it currently is only checking for shared archives on amd64 when it chooses to use the DATA segment over TEXT.
The existing implementation deals with absolute relocations in __TEXT for darwin/amd64 in build-mode c-shared, but it ignores c-archive. This results in issues when trying to use a c-archive in an iOS app on the 64-bit simulator. This patch adds c-archive to the handling of this issue. Fixes #14217 Change-Id: I2e4d5193caa531171ad22fd0cd420a8bfb4646a6 Reviewed-on: https://go-review.googlesource.com/19206 Reviewed-by: David Crawshaw <email@example.com> Run-TryBot: David Crawshaw <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-on: https://go-review.googlesource.com/22046