cmd/link/internal/ld: consolidate macho platform setup

Determine the macho platform once and use that the two places that
need it. This makes it easier to add a third platform check for a
follow-up change.

Updates #31447

Change-Id: I522a5fface647ab8e608f816c5832d531534df7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/174198
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Elias Naur 2019-04-27 11:28:49 +02:00
parent a28a942768
commit a74e01204e
2 changed files with 33 additions and 31 deletions

View file

@ -1482,12 +1482,8 @@ func (ctxt *Link) hostlink() {
if err != nil {
Exitf("%s: parsing Mach-O header failed: %v", os.Args[0], err)
}
load, err := peekMachoPlatform(exem)
if err != nil {
Exitf("%s: failed to parse Mach-O load commands: %v", os.Args[0], err)
}
// Only macOS supports unmapped segments such as our __DWARF segment.
if load == nil || load.platform == PLATFORM_MACOS {
if machoPlatform == PLATFORM_MACOS {
if err := machoCombineDwarf(ctxt, exef, exem, dsym, combinedOutput); err != nil {
Exitf("%s: combining dwarf failed: %v", os.Args[0], err)
}