Commit cdb77652 authored by Elias Naur's avatar Elias Naur Committed by Brad Fitzpatrick

[release-branch.go1.12] cmd/link/internal/ld: bump macOS and macOS SDK version to 10.9

Satisfies the Apple Notary.

Fixes #30526

Change-Id: I91cf2d706a3ebe79bafdb759a0d32266ed6b9096
Reviewed-on: https://go-review.googlesource.com/c/go/+/175918
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/175919Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 3a1b4e75
......@@ -662,9 +662,11 @@ func Asmbmacho(ctxt *Link) {
// 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 | 7<<8 | 0<<0 // OS X version 10.7.0
ml.data[1] = 10<<16 | 7<<8 | 0<<0 // SDK 10.7.0
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
}
a := machowrite(ctxt.Arch, ctxt.Out, ctxt.LinkMode)
......
package main
import (
"debug/macho"
"internal/testenv"
"io/ioutil"
"os"
......@@ -171,3 +172,67 @@ main.x: relocation target main.zero not defined
t.Fatalf("want:\n%sgot:\n%s", want, got)
}
}
var testMacOSVersionSrc = `
package main
func main() { }
`
func TestMacOSVersion(t *testing.T) {
testenv.MustHaveGoBuild(t)
tmpdir, err := ioutil.TempDir("", "TestMacOSVersion")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpdir)
src := filepath.Join(tmpdir, "main.go")
err = ioutil.WriteFile(src, []byte(testMacOSVersionSrc), 0666)
if err != nil {
t.Fatal(err)
}
exe := filepath.Join(tmpdir, "main")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-ldflags=-linkmode=internal", "-o", exe, src)
cmd.Env = append(os.Environ(),
"CGO_ENABLED=0",
"GOOS=darwin",
"GOARCH=amd64",
)
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("%v: %v:\n%s", cmd.Args, err, out)
}
exef, err := os.Open(exe)
if err != nil {
t.Fatal(err)
}
exem, err := macho.NewFile(exef)
if err != nil {
t.Fatal(err)
}
found := false
const LC_VERSION_MIN_MACOSX = 0x24
checkMin := func(ver uint32) {
major, minor := (ver>>16)&0xff, (ver>>8)&0xff
if major != 10 || minor < 9 {
t.Errorf("LC_VERSION_MIN_MACOSX version %d.%d < 10.9", major, minor)
}
}
for _, cmd := range exem.Loads {
raw := cmd.Raw()
type_ := exem.ByteOrder.Uint32(raw)
if type_ != LC_VERSION_MIN_MACOSX {
continue
}
osVer := exem.ByteOrder.Uint32(raw[8:])
checkMin(osVer)
sdkVer := exem.ByteOrder.Uint32(raw[12:])
checkMin(sdkVer)
found = true
break
}
if !found {
t.Errorf("no LC_VERSION_MIN_MACOSX load command found")
}
}
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