From aea4222f673ee9189ba81548978b091004afe994 Mon Sep 17 00:00:00 2001 From: Aaron Zinman Date: Wed, 3 Feb 2016 17:36:15 -0800 Subject: [PATCH] =?utf8?q?darwin/amd64:=20fix=20text-relocation=20issues?= =?utf8?q?=20for=20c-archive=20libraries=E2=80=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Run-TryBot: David Crawshaw TryBot-Result: Gobot Gobot --- src/cmd/link/internal/ld/macho.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go index 5842e1ce20..d60203fb91 100644 --- a/src/cmd/link/internal/ld/macho.go +++ b/src/cmd/link/internal/ld/macho.go @@ -356,8 +356,9 @@ func machoshbits(mseg *MachoSeg, sect *Section, segname string) { buf := "__" + strings.Replace(sect.Name[1:], ".", "_", -1) var msect *MachoSect - if sect.Rwx&1 == 0 && (Thearch.Thechar == '7' || (Thearch.Thechar == '6' && Buildmode == BuildmodeCShared)) { - // Darwin external linker on arm64 and on amd64 in c-shared buildmode + if sect.Rwx&1 == 0 && (Thearch.Thechar == '7' || // arm64 + (Thearch.Thechar == '6' && (Buildmode == BuildmodeCShared || Buildmode == BuildmodeCArchive))) { // amd64 + // Darwin external linker on arm64 and on amd64 in c-shared/c-archive buildmode // complains about absolute relocs in __TEXT, so if the section is not // executable, put it in __DATA segment. msect = newMachoSect(mseg, buf, "__DATA") -- 2.48.1