diff options
author | Russ Cox <rsc@golang.org> | 2016-01-13 09:59:16 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2016-01-13 19:06:40 +0000 |
commit | 4a0eee2faa3c54dd267c76fe8d8c332cb6badc80 (patch) | |
tree | 6c007b13559151a2a982a12fac941ec851f9f769 | |
parent | dd6753a6f28ade7b7d24d082b438de3c7dd48557 (diff) | |
download | go-4a0eee2faa3c54dd267c76fe8d8c332cb6badc80.tar.gz go-4a0eee2faa3c54dd267c76fe8d8c332cb6badc80.zip |
cmd/link: add LC_VERSION_MIN_MACOSX to linkmode=internal OS X binaries
This makes lldb willing to debug them.
The minimum version is hard-coded at OS X 10.7,
because that is the minimum that Go requires.
For more control over the version, users can
use linkmode=external and pass the relevant flags to the host linker.
Fixes #12941.
Change-Id: I20027be8aa034d07dd2a3326828f75170afe905f
Reviewed-on: https://go-review.googlesource.com/18588
Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/cmd/link/internal/ld/macho.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go index af93361000..1c7f3a0d82 100644 --- a/src/cmd/link/internal/ld/macho.go +++ b/src/cmd/link/internal/ld/macho.go @@ -566,6 +566,25 @@ func Asmbmacho() { } } + if 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 intead). + // 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. + const ( + LC_VERSION_MIN_MACOSX = 0x24 + LC_VERSION_MIN_IPHONEOS = 0x25 + LC_VERSION_MIN_WATCHOS = 0x30 + ) + ml := newMachoLoad(LC_VERSION_MIN_MACOSX, 2) + ml.data[0] = 10<<16 | 7<<8 | 0<<0 // OS X version 10.7.0 + ml.data[1] = 10<<16 | 7<<8 | 0<<0 // SDK 10.7.0 + } + // TODO: dwarf headers go in ms too if Debug['s'] == 0 { dwarfaddmachoheaders(ms) |