Commit d856e05d authored by Elias Naur's avatar Elias Naur

cmd/link/internal/ld: set MachO platform to PLATFORM_IOS on iOS

CL 205340 changed the linker to skip certain flags when linking
for iOS. However, for host linking on iOS (such as on the Corellium
darwin/arm64 builders) the MachO platform defaults to PLATFORM_MACOS,
and the flags are not skipped.

Avoids warnings such as

    ld: warning: -no_pie ignored for arm64

Updates #32963

Change-Id: Ib6b4c2375fd14cf89410bf5ff1537b692b7a1c15
Reviewed-on: https://go-review.googlesource.com/c/go/+/206337
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 4160a71d
...@@ -404,21 +404,26 @@ func (ctxt *Link) domacho() { ...@@ -404,21 +404,26 @@ func (ctxt *Link) domacho() {
} }
} }
if machoPlatform == 0 { if machoPlatform == 0 {
machoPlatform = PLATFORM_MACOS switch ctxt.Arch.Family {
if ctxt.LinkMode == LinkInternal { default:
// For lldb, must say LC_VERSION_MIN_MACOSX or else machoPlatform = PLATFORM_MACOS
// it won't know that this Mach-O binary is from OS X if ctxt.LinkMode == LinkInternal {
// (could be iOS or WatchOS instead). // For lldb, must say LC_VERSION_MIN_MACOSX or else
// Go on iOS uses linkmode=external, and linkmode=external // it won't know that this Mach-O binary is from OS X
// adds this itself. So we only need this code for linkmode=internal // (could be iOS or WatchOS instead).
// and we can assume OS X. // Go on iOS uses linkmode=external, and linkmode=external
// // adds this itself. So we only need this code for linkmode=internal
// See golang.org/issues/12941. // and we can assume OS X.
// //
// The version must be at least 10.9; see golang.org/issues/30488. // See golang.org/issues/12941.
ml := newMachoLoad(ctxt.Arch, LC_VERSION_MIN_MACOSX, 2) //
ml.data[0] = 10<<16 | 9<<8 | 0<<0 // OS X version 10.9.0 // The version must be at least 10.9; see golang.org/issues/30488.
ml.data[1] = 10<<16 | 9<<8 | 0<<0 // SDK 10.9.0 ml := newMachoLoad(ctxt.Arch, LC_VERSION_MIN_MACOSX, 2)
ml.data[0] = 10<<16 | 9<<8 | 0<<0 // OS X version 10.9.0
ml.data[1] = 10<<16 | 9<<8 | 0<<0 // SDK 10.9.0
}
case sys.ARM, sys.ARM64:
machoPlatform = PLATFORM_IOS
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment