diff options
| author | Elias Naur <mail@eliasnaur.com> | 2019-11-10 08:42:54 +0100 |
|---|---|---|
| committer | Elias Naur <mail@eliasnaur.com> | 2019-11-15 21:02:07 +0000 |
| commit | d856e05d64591d3dec6411e3d86fe325e85eecc5 (patch) | |
| tree | 7bffc8c2a8651bdf67db00f2a0deef7ab17d93ba /src | |
| parent | 4160a71d4206e11d2122d1d9520c55a5b95c2085 (diff) | |
| download | go-d856e05d64591d3dec6411e3d86fe325e85eecc5.tar.xz | |
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: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/link/internal/ld/macho.go | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go index 8756da4fd8..e50eddd96c 100644 --- a/src/cmd/link/internal/ld/macho.go +++ b/src/cmd/link/internal/ld/macho.go @@ -404,21 +404,26 @@ func (ctxt *Link) domacho() { } } if machoPlatform == 0 { - machoPlatform = PLATFORM_MACOS - if ctxt.LinkMode == LinkInternal { - // For lldb, must say LC_VERSION_MIN_MACOSX or else - // it won't know that this Mach-O binary is from OS X - // (could be iOS or WatchOS instead). - // Go on iOS uses linkmode=external, and linkmode=external - // adds this itself. So we only need this code for linkmode=internal - // and we can assume OS X. - // - // See golang.org/issues/12941. - // - // The version must be at least 10.9; see golang.org/issues/30488. - 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 + switch ctxt.Arch.Family { + default: + machoPlatform = PLATFORM_MACOS + if ctxt.LinkMode == LinkInternal { + // For lldb, must say LC_VERSION_MIN_MACOSX or else + // it won't know that this Mach-O binary is from OS X + // (could be iOS or WatchOS instead). + // Go on iOS uses linkmode=external, and linkmode=external + // adds this itself. So we only need this code for linkmode=internal + // and we can assume OS X. + // + // See golang.org/issues/12941. + // + // The version must be at least 10.9; see golang.org/issues/30488. + 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 } } |
