UPDATE: lang/go 1.22.4 -> 1.22.5
This commit is contained in:
parent
8c1115799e
commit
e02eba8cae
@ -1,13 +1,13 @@
|
||||
ONLY_FOR_ARCHS = ${GO_ARCHS}
|
||||
|
||||
BIN_BOOTSTRAP_GOARCHS = 386 amd64 arm arm64 mips64 riscv64
|
||||
BIN_BOOTSTRAP_GOARCHS = 386 amd64 arm arm64 riscv64
|
||||
BIN_BOOTSTRAP_VERSION = 1.20.4
|
||||
|
||||
COMMENT = Go programming language
|
||||
|
||||
# increment _MODGO_SYSTEM_VERSION in go.port.mk after updating to a new
|
||||
# version, to trigger updates of go-compiled ports
|
||||
VERSION = 1.22.4
|
||||
VERSION = 1.22.5
|
||||
DISTNAME = go${VERSION}.src
|
||||
PKGNAME = go-${VERSION}
|
||||
PKGSPEC = ${FULLPKGNAME:S/go-/go-=/}
|
||||
@ -45,16 +45,14 @@ GOROOT = ${PREFIX}/go
|
||||
GOROOT_BOOTSTRAP =
|
||||
|
||||
# sync with go.port.mk
|
||||
.if ${MACHINE_ARCH} == "amd64"
|
||||
.if ${MACHINE_ARCH} == "aarch64"
|
||||
GOARCH = arm64
|
||||
.elif ${MACHINE_ARCH} == "amd64"
|
||||
GOARCH = amd64
|
||||
.elif ${MACHINE_ARCH} == "arm"
|
||||
GOARCH = arm
|
||||
.elif ${MACHINE_ARCH} == "aarch64"
|
||||
GOARCH = arm64
|
||||
.elif ${MACHINE_ARCH} == "i386"
|
||||
GOARCH = 386
|
||||
.elif ${MACHINE_ARCH} == "mips64"
|
||||
GOARCH = mips64
|
||||
.elif ${MACHINE_ARCH} == "riscv64"
|
||||
GOARCH = riscv64
|
||||
.endif
|
||||
|
@ -2,13 +2,11 @@ SHA256 (go-openbsd-386-bootstrap-1.20.4.tar.gz) = TnujxhLC6RBpp+Yq6G7jkz7dM+znj0
|
||||
SHA256 (go-openbsd-amd64-bootstrap-1.20.4.tar.gz) = 8WlSsDZ/ZLtSJ6I8s0FKX6CChU8ULsxaA1PEQZw2nWQ=
|
||||
SHA256 (go-openbsd-arm-bootstrap-1.20.4.tar.gz) = MFK9DdbKJSqyYFLANhKbD6KWT1x+wX8+w9NTJ21o1/4=
|
||||
SHA256 (go-openbsd-arm64-bootstrap-1.20.4.tar.gz) = G3sZhx63D+QLEgbwU1+d3ECiVJjVrFD5RqD2/qutXmI=
|
||||
SHA256 (go-openbsd-mips64-bootstrap-1.20.4.tar.gz) = CaZYJ+pIQp+lp721Ox45Y8uqkbsygcfyDFxQsqabPIs=
|
||||
SHA256 (go-openbsd-riscv64-bootstrap-1.20.4.tar.gz) = lQv/8KPWi8U3yLG+k3xVDNRVzxa5rmPIIpJUDrwVo0o=
|
||||
SHA256 (go1.22.4.src.tar.gz) = /tcgZ45yinyjC6jR3tHKr+J9FgKPqwIyuLqOIgCPt4Q=
|
||||
SHA256 (go1.22.5.src.tar.gz) = rJxyPyJJaa7mJLw0/TTJ4T8qIS11xxyAfeZEu0bhEvY=
|
||||
SIZE (go-openbsd-386-bootstrap-1.20.4.tar.gz) = 100681343
|
||||
SIZE (go-openbsd-amd64-bootstrap-1.20.4.tar.gz) = 107075675
|
||||
SIZE (go-openbsd-arm-bootstrap-1.20.4.tar.gz) = 104680775
|
||||
SIZE (go-openbsd-arm64-bootstrap-1.20.4.tar.gz) = 102706601
|
||||
SIZE (go-openbsd-mips64-bootstrap-1.20.4.tar.gz) = 105352848
|
||||
SIZE (go-openbsd-riscv64-bootstrap-1.20.4.tar.gz) = 106167229
|
||||
SIZE (go1.22.4.src.tar.gz) = 27555503
|
||||
SIZE (go1.22.5.src.tar.gz) = 27559458
|
||||
|
@ -1,10 +1,6 @@
|
||||
# increment after a go compiler update to trigger updates of
|
||||
# compiled go packages (see arch-defines.mk)
|
||||
_MODGO_SYSTEM_VERSION = 14
|
||||
|
||||
# not using the normal ports mechanism, but setting USE_NOBTCFI for
|
||||
# documentation in sqlports
|
||||
USE_NOBTCFI = Yes
|
||||
_MODGO_SYSTEM_VERSION = 16
|
||||
|
||||
ONLY_FOR_ARCHS ?= ${GO_ARCHS}
|
||||
|
||||
@ -27,14 +23,16 @@ _subst := ${_subst}:S/${l:U}/!$l/g
|
||||
BUILD_DEPENDS += ${MODGO_BUILD_DEPENDS}
|
||||
.endif
|
||||
|
||||
.if ${MACHINE_ARCH} == "amd64"
|
||||
.if ${MACHINE_ARCH} == "aarch64"
|
||||
_GOARCH = arm64
|
||||
.elif ${MACHINE_ARCH} == "amd64"
|
||||
_GOARCH = amd64
|
||||
.elif ${MACHINE_ARCH} == "arm"
|
||||
_GOARCH = arm
|
||||
.elif ${MACHINE_ARCH} == "aarch64"
|
||||
_GOARCH = arm64
|
||||
.elif ${MACHINE_ARCH} == "i386"
|
||||
_GOARCH = 386
|
||||
.elif ${MACHINE_ARCH} == "riscv64"
|
||||
_GOARCH = riscv64
|
||||
.endif
|
||||
|
||||
MODGO_PACKAGE_PATH = ${PREFIX}/go-pkg
|
||||
|
@ -0,0 +1,11 @@
|
||||
Index: src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
|
||||
--- src/cmd/asm/internal/asm/testdata/amd64enc_extra.s.orig
|
||||
+++ src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
|
||||
@@ -1059,5 +1059,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
|
||||
RDPID DX // f30fc7fa
|
||||
RDPID R11 // f3410fc7fb
|
||||
|
||||
+ ENDBR64 // f30f1efa
|
||||
+
|
||||
// End of tests.
|
||||
RET
|
@ -0,0 +1,24 @@
|
||||
Index: src/cmd/asm/internal/asm/testdata/arm64enc.s
|
||||
--- src/cmd/asm/internal/asm/testdata/arm64enc.s.orig
|
||||
+++ src/cmd/asm/internal/asm/testdata/arm64enc.s
|
||||
@@ -296,6 +296,10 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$-8
|
||||
RBITW R9, R22 // 3601c05a
|
||||
RBIT R11, R4 // 6401c0da
|
||||
RET // c0035fd6
|
||||
+ RET R0 // 00005fd6
|
||||
+ RET R6 // c0005fd6
|
||||
+ RET R27 // 60035fd6
|
||||
+ RET R30 // c0035fd6
|
||||
REVW R8, R10 // 0a09c05a
|
||||
REV R1, R2 // 220cc0da
|
||||
REV16W R21, R19 // b306c05a
|
||||
@@ -762,5 +766,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$-8
|
||||
VMOV V0.B[1], R11 // 0b3c030e
|
||||
VMOV V1.H[3], R12 // 2c3c0e0e
|
||||
VUSHR $6, V22.H8, V23.H8 // d7061a6f
|
||||
+ BTI // 1f2403d5
|
||||
+ BTI C // 5f2403d5
|
||||
+ BTI J // 9f2403d5
|
||||
+ BTI JC // df2403d5
|
||||
|
||||
RET
|
@ -0,0 +1,9 @@
|
||||
Index: src/cmd/asm/internal/asm/testdata/arm64error.s
|
||||
--- src/cmd/asm/internal/asm/testdata/arm64error.s.orig
|
||||
+++ src/cmd/asm/internal/asm/testdata/arm64error.s
|
||||
@@ -420,4 +420,5 @@ TEXT errors(SB),$0
|
||||
AESE V1.B16, V2.B8 // ERROR "invalid arrangement"
|
||||
SHA256SU1 V1.S4, V2.B16, V3.S4 // ERROR "invalid arrangement"
|
||||
SHA1H V1.B16, V2.B16 // ERROR "invalid operands"
|
||||
+ BTI PLDL1KEEP // ERROR "illegal argument"
|
||||
RET
|
20
lang/go/patches/patch-src_cmd_compile_internal_amd64_ggen_go
Normal file
20
lang/go/patches/patch-src_cmd_compile_internal_amd64_ggen_go
Normal file
@ -0,0 +1,20 @@
|
||||
Index: src/cmd/compile/internal/amd64/ggen.go
|
||||
--- src/cmd/compile/internal/amd64/ggen.go.orig
|
||||
+++ src/cmd/compile/internal/amd64/ggen.go
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
// no floating point in note handlers on Plan 9
|
||||
var isPlan9 = buildcfg.GOOS == "plan9"
|
||||
+var isOpenBSD = buildcfg.GOOS == "openbsd"
|
||||
|
||||
// DUFFZERO consists of repeated blocks of 4 MOVUPSs + LEAQ,
|
||||
// See runtime/mkduff.go.
|
||||
@@ -72,7 +73,7 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt i
|
||||
if cnt%16 != 0 {
|
||||
p = pp.Append(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_MEM, x86.REG_SP, off+cnt-int64(16))
|
||||
}
|
||||
- } else if !isPlan9 && (cnt <= int64(128*types.RegSize)) {
|
||||
+ } else if !isPlan9 && !isOpenBSD && (cnt <= int64(128*types.RegSize)) {
|
||||
// Save DI to r12. With the amd64 Go register abi, DI can contain
|
||||
// an incoming parameter, whereas R12 is always scratch.
|
||||
p = pp.Append(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_DI, 0, obj.TYPE_REG, x86.REG_R12, 0)
|
24
lang/go/patches/patch-src_cmd_compile_internal_arm64_ggen_go
Normal file
24
lang/go/patches/patch-src_cmd_compile_internal_arm64_ggen_go
Normal file
@ -0,0 +1,24 @@
|
||||
Index: src/cmd/compile/internal/arm64/ggen.go
|
||||
--- src/cmd/compile/internal/arm64/ggen.go.orig
|
||||
+++ src/cmd/compile/internal/arm64/ggen.go
|
||||
@@ -10,8 +10,11 @@ import (
|
||||
"cmd/compile/internal/types"
|
||||
"cmd/internal/obj"
|
||||
"cmd/internal/obj/arm64"
|
||||
+ "internal/buildcfg"
|
||||
)
|
||||
|
||||
+var isOpenBSD = buildcfg.GOOS == "openbsd"
|
||||
+
|
||||
func padframe(frame int64) int64 {
|
||||
// arm64 requires that the frame size (not counting saved FP&LR)
|
||||
// be 16 bytes aligned. If not, pad it.
|
||||
@@ -29,7 +32,7 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt i
|
||||
for i := int64(0); i < cnt; i += int64(types.PtrSize) {
|
||||
p = pp.Append(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, 8+off+i)
|
||||
}
|
||||
- } else if cnt <= int64(128*types.PtrSize) {
|
||||
+ } else if !isOpenBSD && cnt <= int64(128*types.PtrSize) {
|
||||
if cnt%(2*int64(types.PtrSize)) != 0 {
|
||||
p = pp.Append(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, 8+off)
|
||||
off += int64(types.PtrSize)
|
19
lang/go/patches/patch-src_cmd_compile_internal_ssa_config_go
Normal file
19
lang/go/patches/patch-src_cmd_compile_internal_ssa_config_go
Normal file
@ -0,0 +1,19 @@
|
||||
Index: src/cmd/compile/internal/ssa/config.go
|
||||
--- src/cmd/compile/internal/ssa/config.go.orig
|
||||
+++ src/cmd/compile/internal/ssa/config.go
|
||||
@@ -188,6 +188,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Lin
|
||||
c.haveBswap64 = true
|
||||
c.haveBswap32 = true
|
||||
c.haveBswap16 = true
|
||||
+ c.noDuffDevice = true
|
||||
case "386":
|
||||
c.PtrSize = 4
|
||||
c.RegSize = 4
|
||||
@@ -233,6 +234,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Lin
|
||||
c.haveBswap64 = true
|
||||
c.haveBswap32 = true
|
||||
c.haveBswap16 = true
|
||||
+ c.noDuffDevice = true
|
||||
case "ppc64":
|
||||
c.BigEndian = true
|
||||
fallthrough
|
33
lang/go/patches/patch-src_cmd_internal_obj_arm64_a_out_go
Normal file
33
lang/go/patches/patch-src_cmd_internal_obj_arm64_a_out_go
Normal file
@ -0,0 +1,33 @@
|
||||
Index: src/cmd/internal/obj/arm64/a.out.go
|
||||
--- src/cmd/internal/obj/arm64/a.out.go.orig
|
||||
+++ src/cmd/internal/obj/arm64/a.out.go
|
||||
@@ -1018,6 +1018,7 @@ const (
|
||||
AWFI
|
||||
AWORD
|
||||
AYIELD
|
||||
+ ABTI
|
||||
ALAST
|
||||
AB = obj.AJMP
|
||||
ABL = obj.ACALL
|
||||
@@ -1188,7 +1189,7 @@ const (
|
||||
SPOP_DAIFSet
|
||||
SPOP_DAIFClr
|
||||
|
||||
- // Condition code, EQ, NE, etc. Their relative order to EQ is matter.
|
||||
+ // Condition code, EQ, NE, etc. Their relative order to EQ matters.
|
||||
SPOP_EQ
|
||||
SPOP_NE
|
||||
SPOP_HS
|
||||
@@ -1205,7 +1206,11 @@ const (
|
||||
SPOP_LE
|
||||
SPOP_AL
|
||||
SPOP_NV
|
||||
- // Condition code end.
|
||||
+
|
||||
+ // Branch Target Indicator (BTI) targets
|
||||
+ SPOP_C
|
||||
+ SPOP_J
|
||||
+ SPOP_JC
|
||||
|
||||
SPOP_END
|
||||
)
|
10
lang/go/patches/patch-src_cmd_internal_obj_arm64_anames_go
Normal file
10
lang/go/patches/patch-src_cmd_internal_obj_arm64_anames_go
Normal file
@ -0,0 +1,10 @@
|
||||
Index: src/cmd/internal/obj/arm64/anames.go
|
||||
--- src/cmd/internal/obj/arm64/anames.go.orig
|
||||
+++ src/cmd/internal/obj/arm64/anames.go
|
||||
@@ -536,5 +536,6 @@ var Anames = []string{
|
||||
"WFI",
|
||||
"WORD",
|
||||
"YIELD",
|
||||
+ "BTI",
|
||||
"LAST",
|
||||
}
|
52
lang/go/patches/patch-src_cmd_internal_obj_arm64_asm7_go
Normal file
52
lang/go/patches/patch-src_cmd_internal_obj_arm64_asm7_go
Normal file
@ -0,0 +1,52 @@
|
||||
Index: src/cmd/internal/obj/arm64/asm7.go
|
||||
--- src/cmd/internal/obj/arm64/asm7.go.orig
|
||||
+++ src/cmd/internal/obj/arm64/asm7.go
|
||||
@@ -871,6 +871,8 @@ var optab = []Optab{
|
||||
{ASYSL, C_VCON, C_NONE, C_NONE, C_ZREG, C_NONE, 50, 4, 0, 0, 0},
|
||||
{ATLBI, C_SPOP, C_NONE, C_NONE, C_NONE, C_NONE, 107, 4, 0, 0, 0},
|
||||
{ATLBI, C_SPOP, C_NONE, C_NONE, C_ZREG, C_NONE, 107, 4, 0, 0, 0},
|
||||
+ {ABTI, C_NONE, C_NONE, C_NONE, C_NONE, C_NONE, 108, 4, 0, 0, 0},
|
||||
+ {ABTI, C_SPOP, C_NONE, C_NONE, C_NONE, C_NONE, 108, 4, 0, 0, 0},
|
||||
|
||||
/* encryption instructions */
|
||||
{AAESD, C_VREG, C_NONE, C_NONE, C_VREG, C_NONE, 26, 4, 0, 0, 0}, // for compatibility with old code
|
||||
@@ -3009,6 +3011,7 @@ func buildop(ctxt *obj.Link) {
|
||||
ABL,
|
||||
AWORD,
|
||||
ADWORD,
|
||||
+ ABTI,
|
||||
obj.ARET,
|
||||
obj.ATEXT:
|
||||
break
|
||||
@@ -5904,6 +5907,22 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []ui
|
||||
o1 |= uint32(0x1F)
|
||||
}
|
||||
o1 |= uint32(SYSARG4(int(op.op1), int(op.cn), int(op.cm), int(op.op2)))
|
||||
+
|
||||
+ case 108: /* bti */
|
||||
+ o1 = SYSHINT(32)
|
||||
+ if p.From.Type == obj.TYPE_SPECIAL {
|
||||
+ switch SpecialOperand(p.From.Offset) {
|
||||
+ case SPOP_C:
|
||||
+ o1 |= 1 << 6
|
||||
+ case SPOP_J:
|
||||
+ o1 |= 2 << 6
|
||||
+ case SPOP_JC:
|
||||
+ o1 |= 3 << 6
|
||||
+ default:
|
||||
+ c.ctxt.Diag("illegal argument: %v\n", p)
|
||||
+ break
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
out[0] = o1
|
||||
out[1] = o2
|
||||
@@ -6778,7 +6797,7 @@ func (c *ctxt7) opirr(p *obj.Prog, a obj.As) uint32 {
|
||||
return SYSOP(0, 0, 3, 3, 0, 6, 0x1F)
|
||||
|
||||
case AHINT:
|
||||
- return SYSOP(0, 0, 3, 2, 0, 0, 0x1F)
|
||||
+ return SYSHINT(0)
|
||||
|
||||
case AVEXT:
|
||||
return 0x2E<<24 | 0<<23 | 0<<21 | 0<<15
|
190
lang/go/patches/patch-src_cmd_internal_obj_arm64_obj7_go
Normal file
190
lang/go/patches/patch-src_cmd_internal_obj_arm64_obj7_go
Normal file
@ -0,0 +1,190 @@
|
||||
Index: src/cmd/internal/obj/arm64/obj7.go
|
||||
--- src/cmd/internal/obj/arm64/obj7.go.orig
|
||||
+++ src/cmd/internal/obj/arm64/obj7.go
|
||||
@@ -65,6 +65,9 @@ var zrReplace = map[obj.As]bool{
|
||||
}
|
||||
|
||||
func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
||||
+ // Jump back to here after morestack returns.
|
||||
+ startPred := c.cursym.Func().Text
|
||||
+
|
||||
if c.ctxt.Flag_maymorestack != "" {
|
||||
p = c.cursym.Func().SpillRegisterArgs(p, c.newprog)
|
||||
|
||||
@@ -145,11 +148,9 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int3
|
||||
p.Spadj = -frameSize
|
||||
|
||||
p = c.cursym.Func().UnspillRegisterArgs(p, c.newprog)
|
||||
+ startPred = p
|
||||
}
|
||||
|
||||
- // Jump back to here after morestack returns.
|
||||
- startPred := p
|
||||
-
|
||||
// MOV g_stackguard(g), RT1
|
||||
p = obj.Appendp(p, c.newprog)
|
||||
|
||||
@@ -509,6 +510,24 @@ func (c *ctxt7) rewriteToUseGot(p *obj.Prog) {
|
||||
obj.Nopout(p)
|
||||
}
|
||||
|
||||
+var runtimeEntryPoints = map[string]struct{}{
|
||||
+ "runtime.(*_panic).start": {},
|
||||
+ "runtime.deferproc": {},
|
||||
+ "runtime.deferprocStack": {},
|
||||
+ "runtime.mcall": {},
|
||||
+ "runtime.morestack": {},
|
||||
+ "runtime.morestack_noctxt": {},
|
||||
+ "runtime.mstart1": {},
|
||||
+}
|
||||
+
|
||||
+func isRuntimeEntryPoint(s *obj.LSym) bool {
|
||||
+ if s == nil {
|
||||
+ return false
|
||||
+ }
|
||||
+ _, ok := runtimeEntryPoints[s.Name]
|
||||
+ return ok
|
||||
+}
|
||||
+
|
||||
func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
|
||||
if cursym.Func().Text == nil || cursym.Func().Text.Link == nil {
|
||||
return
|
||||
@@ -552,20 +571,20 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
|
||||
var q *obj.Prog
|
||||
var q1 *obj.Prog
|
||||
- var retjmp *obj.LSym
|
||||
+ var last *obj.Prog
|
||||
for p := c.cursym.Func().Text; p != nil; p = p.Link {
|
||||
- o := p.As
|
||||
- switch o {
|
||||
+ switch p.As {
|
||||
case obj.ATEXT:
|
||||
- c.cursym.Func().Text = p
|
||||
+ text := p
|
||||
+ cursym.Func().Text = text
|
||||
c.autosize = int32(textstksiz)
|
||||
|
||||
- if p.Mark&LEAF != 0 && c.autosize == 0 {
|
||||
+ if text.Mark&LEAF != 0 && c.autosize == 0 {
|
||||
// A leaf function with no locals has no frame.
|
||||
- p.From.Sym.Set(obj.AttrNoFrame, true)
|
||||
+ text.From.Sym.Set(obj.AttrNoFrame, true)
|
||||
}
|
||||
|
||||
- if !p.From.Sym.NoFrame() {
|
||||
+ if !text.From.Sym.NoFrame() {
|
||||
// If there is a stack frame at all, it includes
|
||||
// space to save the LR.
|
||||
c.autosize += 8
|
||||
@@ -587,10 +606,10 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
|
||||
// low 32 bits for autosize
|
||||
// high 32 bits for extrasize
|
||||
- p.To.Offset = int64(c.autosize) | int64(extrasize)<<32
|
||||
+ text.To.Offset = int64(c.autosize) | int64(extrasize)<<32
|
||||
} else {
|
||||
// NOFRAME
|
||||
- p.To.Offset = 0
|
||||
+ text.To.Offset = 0
|
||||
}
|
||||
|
||||
if c.autosize == 0 && c.cursym.Func().Text.Mark&LEAF == 0 {
|
||||
@@ -600,20 +619,28 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
c.cursym.Func().Text.Mark |= LEAF
|
||||
}
|
||||
|
||||
+ // Add branch target indicator for function entry.
|
||||
+ // TODO(jsing): May be able to use SPOP_C outside of runtime (which
|
||||
+ // makes use of systemstack).
|
||||
+ p = obj.Appendp(text, newprog)
|
||||
+ p.As = ABTI
|
||||
+ p.From.Type = obj.TYPE_SPECIAL
|
||||
+ p.From.Offset = int64(SPOP_JC)
|
||||
+
|
||||
if cursym.Func().Text.Mark&LEAF != 0 {
|
||||
cursym.Set(obj.AttrLeaf, true)
|
||||
- if p.From.Sym.NoFrame() {
|
||||
+ if text.From.Sym.NoFrame() {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
- if p.Mark&LEAF != 0 && c.autosize < abi.StackSmall {
|
||||
+ if text.Mark&LEAF != 0 && c.autosize < abi.StackSmall {
|
||||
// A leaf function with a small stack can be marked
|
||||
// NOSPLIT, avoiding a stack check.
|
||||
- p.From.Sym.Set(obj.AttrNoSplit, true)
|
||||
+ text.From.Sym.Set(obj.AttrNoSplit, true)
|
||||
}
|
||||
|
||||
- if !p.From.Sym.NoSplit() {
|
||||
+ if !text.From.Sym.NoSplit() {
|
||||
p = c.stacksplit(p, c.autosize) // emit split check
|
||||
}
|
||||
|
||||
@@ -846,7 +873,10 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
break
|
||||
}
|
||||
|
||||
- retjmp = p.To.Sym
|
||||
+ retJMP, retReg := p.To.Sym, p.To.Reg
|
||||
+ if retReg == 0 {
|
||||
+ retReg = REGLINK
|
||||
+ }
|
||||
p.To = obj.Addr{}
|
||||
if c.cursym.Func().Text.Mark&LEAF != 0 {
|
||||
if c.autosize != 0 {
|
||||
@@ -924,10 +954,10 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
p = q
|
||||
}
|
||||
|
||||
- if retjmp != nil { // retjmp
|
||||
+ if retJMP != nil {
|
||||
p.As = AB
|
||||
p.To.Type = obj.TYPE_BRANCH
|
||||
- p.To.Sym = retjmp
|
||||
+ p.To.Sym = retJMP
|
||||
p.Spadj = +c.autosize
|
||||
break
|
||||
}
|
||||
@@ -935,7 +965,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
p.As = obj.ARET
|
||||
p.To.Type = obj.TYPE_MEM
|
||||
p.To.Offset = 0
|
||||
- p.To.Reg = REGLINK
|
||||
+ p.To.Reg = retReg
|
||||
p.Spadj = +c.autosize
|
||||
|
||||
case AADD, ASUB:
|
||||
@@ -1063,6 +1093,21 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
p = q5
|
||||
}
|
||||
|
||||
+ if p.As == obj.ACALL && isRuntimeEntryPoint(p.To.Sym) {
|
||||
+ // Append BTI as we'll return after this call via gogo.
|
||||
+ p = obj.Appendp(p, newprog)
|
||||
+ p.As = ABTI
|
||||
+ p.From.Type = obj.TYPE_SPECIAL
|
||||
+ p.From.Offset = int64(SPOP_J)
|
||||
+ }
|
||||
+ if p.As == obj.ACALL && p.To.Sym != nil && p.To.Sym.Name == "runtime.deferreturn" && last != nil {
|
||||
+ // Prepend BTI as we'll enter this point via gogo.
|
||||
+ pp := obj.Appendp(last, newprog)
|
||||
+ pp.As = ABTI
|
||||
+ pp.From.Type = obj.TYPE_SPECIAL
|
||||
+ pp.From.Offset = int64(SPOP_J)
|
||||
+ }
|
||||
+
|
||||
if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.Spadj == 0 {
|
||||
f := c.cursym.Func()
|
||||
if f.FuncFlag&abi.FuncFlagSPWrite == 0 {
|
||||
@@ -1095,6 +1140,8 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
p.From.Reg = int16(REG_LSL + r + (shift&7)<<5)
|
||||
p.From.Offset = 0
|
||||
}
|
||||
+
|
||||
+ last = p
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
Index: src/cmd/internal/obj/arm64/specialoperand_string.go
|
||||
--- src/cmd/internal/obj/arm64/specialoperand_string.go.orig
|
||||
+++ src/cmd/internal/obj/arm64/specialoperand_string.go
|
||||
@@ -151,12 +151,15 @@ func _() {
|
||||
_ = x[SPOP_LE-139]
|
||||
_ = x[SPOP_AL-140]
|
||||
_ = x[SPOP_NV-141]
|
||||
- _ = x[SPOP_END-142]
|
||||
+ _ = x[SPOP_C-142]
|
||||
+ _ = x[SPOP_J-143]
|
||||
+ _ = x[SPOP_JC-144]
|
||||
+ _ = x[SPOP_END-145]
|
||||
}
|
||||
|
||||
-const _SpecialOperand_name = "PLDL1KEEPPLDL1STRMPLDL2KEEPPLDL2STRMPLDL3KEEPPLDL3STRMPLIL1KEEPPLIL1STRMPLIL2KEEPPLIL2STRMPLIL3KEEPPLIL3STRMPSTL1KEEPPSTL1STRMPSTL2KEEPPSTL2STRMPSTL3KEEPPSTL3STRMVMALLE1ISVAE1ISASIDE1ISVAAE1ISVALE1ISVAALE1ISVMALLE1VAE1ASIDE1VAAE1VALE1VAALE1IPAS2E1ISIPAS2LE1ISALLE2ISVAE2ISALLE1ISVALE2ISVMALLS12E1ISIPAS2E1IPAS2LE1ALLE2VAE2ALLE1VALE2VMALLS12E1ALLE3ISVAE3ISVALE3ISALLE3VAE3VALE3VMALLE1OSVAE1OSASIDE1OSVAAE1OSVALE1OSVAALE1OSRVAE1ISRVAAE1ISRVALE1ISRVAALE1ISRVAE1OSRVAAE1OSRVALE1OSRVAALE1OSRVAE1RVAAE1RVALE1RVAALE1RIPAS2E1ISRIPAS2LE1ISALLE2OSVAE2OSALLE1OSVALE2OSVMALLS12E1OSRVAE2ISRVALE2ISIPAS2E1OSRIPAS2E1RIPAS2E1OSIPAS2LE1OSRIPAS2LE1RIPAS2LE1OSRVAE2OSRVALE2OSRVAE2RVALE2ALLE3OSVAE3OSVALE3OSRVAE3ISRVALE3ISRVAE3OSRVALE3OSRVAE3RVALE3IVACISWCSWCISWZVACVACCVAUCIVACIGVACIGSWIGDVACIGDSWCGSWCGDSWCIGSWCIGDSWGVAGZVACGVACCGDVACCGVAPCGDVAPCGVADPCGDVADPCIGVACCIGDVACCVAPCVADPDAIFSetDAIFClrEQNEHSLOMIPLVSVCHILSGELTGTLEALNVEND"
|
||||
+const _SpecialOperand_name = "PLDL1KEEPPLDL1STRMPLDL2KEEPPLDL2STRMPLDL3KEEPPLDL3STRMPLIL1KEEPPLIL1STRMPLIL2KEEPPLIL2STRMPLIL3KEEPPLIL3STRMPSTL1KEEPPSTL1STRMPSTL2KEEPPSTL2STRMPSTL3KEEPPSTL3STRMVMALLE1ISVAE1ISASIDE1ISVAAE1ISVALE1ISVAALE1ISVMALLE1VAE1ASIDE1VAAE1VALE1VAALE1IPAS2E1ISIPAS2LE1ISALLE2ISVAE2ISALLE1ISVALE2ISVMALLS12E1ISIPAS2E1IPAS2LE1ALLE2VAE2ALLE1VALE2VMALLS12E1ALLE3ISVAE3ISVALE3ISALLE3VAE3VALE3VMALLE1OSVAE1OSASIDE1OSVAAE1OSVALE1OSVAALE1OSRVAE1ISRVAAE1ISRVALE1ISRVAALE1ISRVAE1OSRVAAE1OSRVALE1OSRVAALE1OSRVAE1RVAAE1RVALE1RVAALE1RIPAS2E1ISRIPAS2LE1ISALLE2OSVAE2OSALLE1OSVALE2OSVMALLS12E1OSRVAE2ISRVALE2ISIPAS2E1OSRIPAS2E1RIPAS2E1OSIPAS2LE1OSRIPAS2LE1RIPAS2LE1OSRVAE2OSRVALE2OSRVAE2RVALE2ALLE3OSVAE3OSVALE3OSRVAE3ISRVALE3ISRVAE3OSRVALE3OSRVAE3RVALE3IVACISWCSWCISWZVACVACCVAUCIVACIGVACIGSWIGDVACIGDSWCGSWCGDSWCIGSWCIGDSWGVAGZVACGVACCGDVACCGVAPCGDVAPCGVADPCGDVADPCIGVACCIGDVACCVAPCVADPDAIFSetDAIFClrEQNEHSLOMIPLVSVCHILSGELTGTLEALNVCJJCEND"
|
||||
|
||||
-var _SpecialOperand_index = [...]uint16{0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 177, 185, 192, 199, 207, 214, 218, 224, 229, 234, 240, 249, 259, 266, 272, 279, 286, 298, 305, 313, 318, 322, 327, 332, 342, 349, 355, 362, 367, 371, 376, 385, 391, 399, 406, 413, 421, 428, 436, 444, 453, 460, 468, 476, 485, 490, 496, 502, 509, 519, 530, 537, 543, 550, 557, 569, 576, 584, 593, 601, 611, 621, 630, 641, 648, 656, 661, 667, 674, 680, 687, 694, 702, 709, 717, 722, 728, 732, 735, 738, 742, 745, 749, 753, 758, 763, 767, 773, 778, 782, 787, 792, 798, 801, 805, 810, 816, 821, 827, 833, 840, 846, 853, 857, 862, 869, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 911}
|
||||
+var _SpecialOperand_index = [...]uint16{0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 177, 185, 192, 199, 207, 214, 218, 224, 229, 234, 240, 249, 259, 266, 272, 279, 286, 298, 305, 313, 318, 322, 327, 332, 342, 349, 355, 362, 367, 371, 376, 385, 391, 399, 406, 413, 421, 428, 436, 444, 453, 460, 468, 476, 485, 490, 496, 502, 509, 519, 530, 537, 543, 550, 557, 569, 576, 584, 593, 601, 611, 621, 630, 641, 648, 656, 661, 667, 674, 680, 687, 694, 702, 709, 717, 722, 728, 732, 735, 738, 742, 745, 749, 753, 758, 763, 767, 773, 778, 782, 787, 792, 798, 801, 805, 810, 816, 821, 827, 833, 840, 846, 853, 857, 862, 869, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 909, 910, 912, 915}
|
||||
|
||||
func (i SpecialOperand) String() string {
|
||||
if i < 0 || i >= SpecialOperand(len(_SpecialOperand_index)-1) {
|
19
lang/go/patches/patch-src_cmd_internal_obj_x86_aenum_go
Normal file
19
lang/go/patches/patch-src_cmd_internal_obj_x86_aenum_go
Normal file
@ -0,0 +1,19 @@
|
||||
Index: src/cmd/internal/obj/x86/aenum.go
|
||||
--- src/cmd/internal/obj/x86/aenum.go.orig
|
||||
+++ src/cmd/internal/obj/x86/aenum.go
|
||||
@@ -201,6 +201,7 @@ const (
|
||||
ADECL
|
||||
ADECQ
|
||||
ADECW
|
||||
+ ADEFERRET
|
||||
ADIVB
|
||||
ADIVL
|
||||
ADIVPD
|
||||
@@ -212,6 +213,7 @@ const (
|
||||
ADPPD
|
||||
ADPPS
|
||||
AEMMS
|
||||
+ AENDBR64
|
||||
AENTER
|
||||
AEXTRACTPS
|
||||
AF2XM1
|
19
lang/go/patches/patch-src_cmd_internal_obj_x86_anames_go
Normal file
19
lang/go/patches/patch-src_cmd_internal_obj_x86_anames_go
Normal file
@ -0,0 +1,19 @@
|
||||
Index: src/cmd/internal/obj/x86/anames.go
|
||||
--- src/cmd/internal/obj/x86/anames.go.orig
|
||||
+++ src/cmd/internal/obj/x86/anames.go
|
||||
@@ -199,6 +199,7 @@ var Anames = []string{
|
||||
"DECL",
|
||||
"DECQ",
|
||||
"DECW",
|
||||
+ "DEFERRET",
|
||||
"DIVB",
|
||||
"DIVL",
|
||||
"DIVPD",
|
||||
@@ -210,6 +211,7 @@ var Anames = []string{
|
||||
"DPPD",
|
||||
"DPPS",
|
||||
"EMMS",
|
||||
+ "ENDBR64",
|
||||
"ENTER",
|
||||
"EXTRACTPS",
|
||||
"F2XM1",
|
106
lang/go/patches/patch-src_cmd_internal_obj_x86_asm6_go
Normal file
106
lang/go/patches/patch-src_cmd_internal_obj_x86_asm6_go
Normal file
@ -0,0 +1,106 @@
|
||||
Index: src/cmd/internal/obj/x86/asm6.go
|
||||
--- src/cmd/internal/obj/x86/asm6.go.orig
|
||||
+++ src/cmd/internal/obj/x86/asm6.go
|
||||
@@ -618,6 +618,10 @@ var ycall = []ytab{
|
||||
{Zcallcon, 1, argList{Yi32}},
|
||||
}
|
||||
|
||||
+var ydeferret = []ytab{
|
||||
+ {Zcall, 5, argList{Ybr}},
|
||||
+}
|
||||
+
|
||||
var yduff = []ytab{
|
||||
{Zcallduff, 1, argList{Yi32}},
|
||||
}
|
||||
@@ -1085,6 +1089,7 @@ var optab =
|
||||
{ADECL, yincl, Px1, opBytes{0x48, 0xff, 01}},
|
||||
{ADECQ, yincq, Pw, opBytes{0xff, 01}},
|
||||
{ADECW, yincq, Pe, opBytes{0xff, 01}},
|
||||
+ {ADEFERRET, ydeferret, Px, opBytes{Pf3, Pm, 0x1e, 0xfa, 0xe8, 0x0}},
|
||||
{ADIVB, ydivb, Pb, opBytes{0xf6, 06}},
|
||||
{ADIVL, ydivl, Px, opBytes{0xf7, 06}},
|
||||
{ADIVPD, yxm, Pe, opBytes{0x5e}},
|
||||
@@ -1096,6 +1101,7 @@ var optab =
|
||||
{ADPPD, yxshuf, Pq, opBytes{0x3a, 0x41, 0}},
|
||||
{ADPPS, yxshuf, Pq, opBytes{0x3a, 0x40, 0}},
|
||||
{AEMMS, ynone, Pm, opBytes{0x77}},
|
||||
+ {AENDBR64, ynone, Pf3, opBytes{0x1e, 0xfa}},
|
||||
{AEXTRACTPS, yextractps, Pq, opBytes{0x3a, 0x17, 0}},
|
||||
{AENTER, nil, 0, opBytes{}}, // botch
|
||||
{AFXRSTOR, ysvrs_mo, Pm, opBytes{0xae, 01, 0xae, 01}},
|
||||
@@ -1858,7 +1864,8 @@ func spadjop(ctxt *obj.Link, l, q obj.As) obj.As {
|
||||
// or end on a 32 byte boundary by inserting NOPs before the jumps.
|
||||
func isJump(p *obj.Prog) bool {
|
||||
return p.To.Target() != nil || p.As == obj.AJMP || p.As == obj.ACALL ||
|
||||
- p.As == obj.ARET || p.As == obj.ADUFFCOPY || p.As == obj.ADUFFZERO
|
||||
+ p.As == obj.ARET || p.As == obj.ADUFFCOPY || p.As == obj.ADUFFZERO ||
|
||||
+ p.As == ADEFERRET
|
||||
}
|
||||
|
||||
// lookForJCC returns the first real instruction starting from p, if that instruction is a conditional
|
||||
@@ -2061,6 +2068,24 @@ func addpad(pc, a int64, ctxt *obj.Link, cursym *obj.L
|
||||
return 0
|
||||
}
|
||||
|
||||
+var runtimeEntryPoints = map[string]struct{}{
|
||||
+ "runtime.(*_panic).start": {},
|
||||
+ "runtime.deferproc": {},
|
||||
+ "runtime.deferprocStack": {},
|
||||
+ "runtime.mcall": {},
|
||||
+ "runtime.morestack": {},
|
||||
+ "runtime.morestack_noctxt": {},
|
||||
+ "runtime.mstart1": {},
|
||||
+}
|
||||
+
|
||||
+func isRuntimeEntryPoint(s *obj.LSym) bool {
|
||||
+ if s == nil {
|
||||
+ return false
|
||||
+ }
|
||||
+ _, ok := runtimeEntryPoints[s.Name]
|
||||
+ return ok
|
||||
+}
|
||||
+
|
||||
func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
|
||||
if ctxt.Retpoline && ctxt.Arch.Family == sys.I386 {
|
||||
ctxt.Diag("-spectre=ret not supported on 386")
|
||||
@@ -2077,6 +2102,7 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.Pr
|
||||
ctxt.Diag("x86 tables not initialized, call x86.instinit first")
|
||||
}
|
||||
|
||||
+ var last *obj.Prog
|
||||
for p := s.Func().Text; p != nil; p = p.Link {
|
||||
if p.To.Type == obj.TYPE_BRANCH && p.To.Target() == nil {
|
||||
p.To.SetTarget(p)
|
||||
@@ -2109,6 +2135,19 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.Pr
|
||||
p.To.Reg = 0
|
||||
p.To.Offset = 0
|
||||
}
|
||||
+ if p.As == obj.ACALL && isRuntimeEntryPoint(p.To.Sym) {
|
||||
+ // Append ENDBR64 as we'll return after this call via gogo.
|
||||
+ p = obj.Appendp(p, newprog)
|
||||
+ p.As = AENDBR64
|
||||
+ }
|
||||
+ if p.As == obj.ACALL && p.To.Sym != nil && p.To.Sym.Name == "runtime.deferreturn" && last != nil {
|
||||
+ // Use ADEFERRET instead of ACALL. We need to prepend ENDBR64 here,
|
||||
+ // however due to the realignment of call instructions, we can end
|
||||
+ // up with variable length NOPs between the ENDBR64 and the CALLQ,
|
||||
+ // which makes it impossible to compute the deferret offset.
|
||||
+ p.As = ADEFERRET
|
||||
+ }
|
||||
+ last = p
|
||||
}
|
||||
|
||||
var count int64 // rough count of number of instructions
|
||||
@@ -4898,7 +4937,11 @@ func (ab *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LS
|
||||
// LEAQ -16(SP), BP
|
||||
ab.Put(bpduff1)
|
||||
}
|
||||
- ab.Put1(byte(op))
|
||||
+ if p.As == ADEFERRET {
|
||||
+ ab.PutOpBytesLit(z, &o.op)
|
||||
+ } else {
|
||||
+ ab.Put1(byte(op))
|
||||
+ }
|
||||
r = obj.Addrel(cursym)
|
||||
r.Off = int32(p.Pc + int64(ab.Len()))
|
||||
r.Sym = p.To.Sym
|
12
lang/go/patches/patch-src_cmd_internal_obj_x86_asm_test_go
Normal file
12
lang/go/patches/patch-src_cmd_internal_obj_x86_asm_test_go
Normal file
@ -0,0 +1,12 @@
|
||||
Index: src/cmd/internal/obj/x86/asm_test.go
|
||||
--- src/cmd/internal/obj/x86/asm_test.go.orig
|
||||
+++ src/cmd/internal/obj/x86/asm_test.go
|
||||
@@ -310,7 +310,7 @@ func TestPCALIGN(t *testing.T) {
|
||||
{
|
||||
name: "8-byte alignment",
|
||||
code: "TEXT ·foo(SB),$0-0\nMOVQ $0, AX\nPCALIGN $8\nMOVQ $1, BX\nRET\n",
|
||||
- out: `0x0008\s00008\s\(.*\)\tMOVQ\t\$1,\sBX`,
|
||||
+ out: `0x0010\s00016\s\(.*\)\tMOVQ\t\$1,\sBX`,
|
||||
},
|
||||
{
|
||||
name: "16-byte alignment",
|
107
lang/go/patches/patch-src_cmd_internal_obj_x86_obj6_go
Normal file
107
lang/go/patches/patch-src_cmd_internal_obj_x86_obj6_go
Normal file
@ -0,0 +1,107 @@
|
||||
Index: src/cmd/internal/obj/x86/obj6.go
|
||||
--- src/cmd/internal/obj/x86/obj6.go.orig
|
||||
+++ src/cmd/internal/obj/x86/obj6.go
|
||||
@@ -602,13 +602,19 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
}
|
||||
|
||||
p := cursym.Func().Text
|
||||
+ text := p
|
||||
autoffset := int32(p.To.Offset)
|
||||
if autoffset < 0 {
|
||||
autoffset = 0
|
||||
}
|
||||
|
||||
+ if ctxt.Arch.Family == sys.AMD64 {
|
||||
+ p = obj.Appendp(p, newprog)
|
||||
+ p.As = AENDBR64
|
||||
+ }
|
||||
+
|
||||
hasCall := false
|
||||
- for q := p; q != nil; q = q.Link {
|
||||
+ for q := text; q != nil; q = q.Link {
|
||||
if q.As == obj.ACALL || q.As == obj.ADUFFCOPY || q.As == obj.ADUFFZERO {
|
||||
hasCall = true
|
||||
break
|
||||
@@ -617,7 +623,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
|
||||
var bpsize int
|
||||
if ctxt.Arch.Family == sys.AMD64 &&
|
||||
- !p.From.Sym.NoFrame() && // (1) below
|
||||
+ !text.From.Sym.NoFrame() && // (1) below
|
||||
!(autoffset == 0 && !hasCall) { // (2) below
|
||||
// Make room to save a base pointer.
|
||||
// There are 2 cases we must avoid:
|
||||
@@ -626,15 +632,15 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
// 2) Frameless leaf functions
|
||||
bpsize = ctxt.Arch.PtrSize
|
||||
autoffset += int32(bpsize)
|
||||
- p.To.Offset += int64(bpsize)
|
||||
+ text.To.Offset += int64(bpsize)
|
||||
} else {
|
||||
bpsize = 0
|
||||
- p.From.Sym.Set(obj.AttrNoFrame, true)
|
||||
+ text.From.Sym.Set(obj.AttrNoFrame, true)
|
||||
}
|
||||
|
||||
- textarg := int64(p.To.Val.(int32))
|
||||
+ textarg := int64(text.To.Val.(int32))
|
||||
cursym.Func().Args = int32(textarg)
|
||||
- cursym.Func().Locals = int32(p.To.Offset)
|
||||
+ cursym.Func().Locals = int32(text.To.Offset)
|
||||
|
||||
// TODO(rsc): Remove.
|
||||
if ctxt.Arch.Family == sys.I386 && cursym.Func().Locals < 0 {
|
||||
@@ -642,7 +648,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
}
|
||||
|
||||
// TODO(rsc): Remove 'ctxt.Arch.Family == sys.AMD64 &&'.
|
||||
- if ctxt.Arch.Family == sys.AMD64 && autoffset < abi.StackSmall && !p.From.Sym.NoSplit() {
|
||||
+ if ctxt.Arch.Family == sys.AMD64 && autoffset < abi.StackSmall && !text.From.Sym.NoSplit() {
|
||||
leaf := true
|
||||
LeafSearch:
|
||||
for q := p; q != nil; q = q.Link {
|
||||
@@ -664,7 +670,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
}
|
||||
|
||||
if leaf {
|
||||
- p.From.Sym.Set(obj.AttrNoSplit, true)
|
||||
+ text.From.Sym.Set(obj.AttrNoSplit, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,10 +682,10 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newp
|
||||
}
|
||||
|
||||
var regg int16
|
||||
- if !p.From.Sym.NoSplit() {
|
||||
+ if !text.From.Sym.NoSplit() {
|
||||
// Emit split check and load G register
|
||||
p, regg = stacksplit(ctxt, cursym, p, newprog, autoffset, int32(textarg))
|
||||
- } else if p.From.Sym.Wrapper() {
|
||||
+ } else if text.From.Sym.Wrapper() {
|
||||
// Load G register for the wrapper code
|
||||
p, regg = loadG(ctxt, cursym, p, newprog)
|
||||
}
|
||||
@@ -1048,6 +1054,10 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *o
|
||||
tmp = int16(REGENTRYTMP0)
|
||||
}
|
||||
|
||||
+
|
||||
+ // Jump back to here after morestack returns.
|
||||
+ startPred := cursym.Func().Text
|
||||
+
|
||||
if ctxt.Flag_maymorestack != "" {
|
||||
p = cursym.Func().SpillRegisterArgs(p, newprog)
|
||||
|
||||
@@ -1078,10 +1088,8 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *o
|
||||
}
|
||||
|
||||
p = cursym.Func().UnspillRegisterArgs(p, newprog)
|
||||
+ startPred = p
|
||||
}
|
||||
-
|
||||
- // Jump back to here after morestack returns.
|
||||
- startPred := p
|
||||
|
||||
// Load G register
|
||||
var rg int16
|
21
lang/go/patches/patch-src_cmd_internal_sys_arch_go
Normal file
21
lang/go/patches/patch-src_cmd_internal_sys_arch_go
Normal file
@ -0,0 +1,21 @@
|
||||
Index: src/cmd/internal/sys/arch.go
|
||||
--- src/cmd/internal/sys/arch.go.orig
|
||||
+++ src/cmd/internal/sys/arch.go
|
||||
@@ -103,7 +103,7 @@ var ArchAMD64 = &Arch{
|
||||
MinLC: 1,
|
||||
Alignment: 1,
|
||||
CanMergeLoads: true,
|
||||
- CanJumpTable: true,
|
||||
+ CanJumpTable: false,
|
||||
HasLR: false,
|
||||
FixedFrameSize: 0,
|
||||
}
|
||||
@@ -130,7 +130,7 @@ var ArchARM64 = &Arch{
|
||||
MinLC: 4,
|
||||
Alignment: 1,
|
||||
CanMergeLoads: true,
|
||||
- CanJumpTable: true,
|
||||
+ CanJumpTable: false,
|
||||
HasLR: true,
|
||||
FixedFrameSize: 8, // LR
|
||||
}
|
46
lang/go/patches/patch-src_cmd_link_internal_amd64_asm_go
Normal file
46
lang/go/patches/patch-src_cmd_link_internal_amd64_asm_go
Normal file
@ -0,0 +1,46 @@
|
||||
Index: src/cmd/link/internal/amd64/asm.go
|
||||
--- src/cmd/link/internal/amd64/asm.go.orig
|
||||
+++ src/cmd/link/internal/amd64/asm.go
|
||||
@@ -624,15 +624,12 @@ func addpltsym(target *ld.Target, ldr *loader.Loader,
|
||||
panic("plt is not set up")
|
||||
}
|
||||
|
||||
- // jmpq *got+size(IP)
|
||||
- plt.AddUint8(0xff)
|
||||
-
|
||||
- plt.AddUint8(0x25)
|
||||
- plt.AddPCRelPlus(target.Arch, got.Sym(), got.Size())
|
||||
-
|
||||
// add to got: pointer to current pos in plt
|
||||
got.AddAddrPlus(target.Arch, plt.Sym(), plt.Size())
|
||||
|
||||
+ // endbr64
|
||||
+ plt.AddBytes([]byte{0xf3, 0x0f, 0x1e, 0xfa})
|
||||
+
|
||||
// pushq $x
|
||||
plt.AddUint8(0x68)
|
||||
|
||||
@@ -642,6 +639,23 @@ func addpltsym(target *ld.Target, ldr *loader.Loader,
|
||||
plt.AddUint8(0xe9)
|
||||
|
||||
plt.AddUint32(target.Arch, uint32(-(plt.Size() + 4)))
|
||||
+
|
||||
+ // nop (2 bytes)
|
||||
+ plt.AddBytes([]byte{0x66, 0x90})
|
||||
+
|
||||
+ // .plt.sec equivalent
|
||||
+
|
||||
+ // endbr64
|
||||
+ plt.AddBytes([]byte{0xf3, 0x0f, 0x1e, 0xfa})
|
||||
+
|
||||
+ // jmpq *got+size(IP)
|
||||
+ plt.AddUint8(0xff)
|
||||
+
|
||||
+ plt.AddUint8(0x25)
|
||||
+ plt.AddPCRelPlus(target.Arch, got.Sym(), got.Size()-8)
|
||||
+
|
||||
+ // nop (6 bytes)
|
||||
+ plt.AddBytes([]byte{0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00})
|
||||
|
||||
// rela
|
||||
rela.AddAddrPlus(target.Arch, got.Sym(), got.Size()-8)
|
32
lang/go/patches/patch-src_cmd_link_internal_arm64_asm_go
Normal file
32
lang/go/patches/patch-src_cmd_link_internal_arm64_asm_go
Normal file
@ -0,0 +1,32 @@
|
||||
Index: src/cmd/link/internal/arm64/asm.go
|
||||
--- src/cmd/link/internal/arm64/asm.go.orig
|
||||
+++ src/cmd/link/internal/arm64/asm.go
|
||||
@@ -1093,6 +1093,9 @@ func extreloc(target *ld.Target, ldr *loader.Loader, r
|
||||
|
||||
func elfsetupplt(ctxt *ld.Link, ldr *loader.Loader, plt, gotplt *loader.SymbolBuilder, dynamic loader.Sym) {
|
||||
if plt.Size() == 0 {
|
||||
+ // bti c
|
||||
+ plt.AddUint32(ctxt.Arch, 0xd503245f)
|
||||
+
|
||||
// stp x16, x30, [sp, #-16]!
|
||||
// identifying information
|
||||
plt.AddUint32(ctxt.Arch, 0xa9bf7bf0)
|
||||
@@ -1145,6 +1148,9 @@ func addpltsym(target *ld.Target, ldr *loader.Loader,
|
||||
panic("plt is not set up")
|
||||
}
|
||||
|
||||
+ // bti c
|
||||
+ plt.AddUint32(target.Arch, 0xd503245f)
|
||||
+
|
||||
// adrp x16, &got.plt[0]
|
||||
plt.AddAddrPlus4(target.Arch, gotplt.Sym(), gotplt.Size())
|
||||
plt.SetUint32(target.Arch, plt.Size()-4, 0x90000010)
|
||||
@@ -1177,7 +1183,7 @@ func addpltsym(target *ld.Target, ldr *loader.Loader,
|
||||
rela.AddUint64(target.Arch, elf.R_INFO(uint32(sDynid), uint32(elf.R_AARCH64_JUMP_SLOT)))
|
||||
rela.AddUint64(target.Arch, 0)
|
||||
|
||||
- ldr.SetPlt(s, int32(plt.Size()-16))
|
||||
+ ldr.SetPlt(s, int32(plt.Size()-20))
|
||||
} else if target.IsDarwin() {
|
||||
ld.AddGotSym(target, ldr, syms, s, 0)
|
||||
|
@ -5,7 +5,7 @@ Index: src/cmd/link/internal/ld/elf.go
|
||||
ph.Type = elf.PT_GNU_STACK
|
||||
ph.Flags = elf.PF_W + elf.PF_R
|
||||
ph.Align = uint64(ctxt.Arch.RegSize)
|
||||
+ } else if ctxt.HeadType == objabi.Hopenbsd {
|
||||
+ } else if ctxt.HeadType == objabi.Hopenbsd && !ctxt.IsARM64() && !ctxt.IsAMD64() {
|
||||
+ ph := newElfPhdr()
|
||||
+ ph.Type = elf.PT_OPENBSD_NOBTCFI
|
||||
+ ph.Flags = elf.PF_X
|
||||
|
19
lang/go/patches/patch-src_cmd_link_internal_ld_pcln_go
Normal file
19
lang/go/patches/patch-src_cmd_link_internal_ld_pcln_go
Normal file
@ -0,0 +1,19 @@
|
||||
Index: src/cmd/link/internal/ld/pcln.go
|
||||
--- src/cmd/link/internal/ld/pcln.go.orig
|
||||
+++ src/cmd/link/internal/ld/pcln.go
|
||||
@@ -144,9 +144,13 @@ func computeDeferReturn(ctxt *Link, deferReturnSym, s
|
||||
// instruction).
|
||||
deferreturn = uint32(r.Off())
|
||||
switch target.Arch.Family {
|
||||
- case sys.AMD64, sys.I386:
|
||||
+ case sys.AMD64:
|
||||
+ deferreturn -= 5 // four bytes for endbr64, one byte for callq
|
||||
+ case sys.I386:
|
||||
deferreturn--
|
||||
- case sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64:
|
||||
+ case sys.ARM64:
|
||||
+ deferreturn -= 4 // bti before call
|
||||
+ case sys.ARM, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64:
|
||||
// no change
|
||||
case sys.S390X:
|
||||
deferreturn -= 2
|
11
lang/go/patches/patch-src_runtime_cgo_gcc_arm64_S
Normal file
11
lang/go/patches/patch-src_runtime_cgo_gcc_arm64_S
Normal file
@ -0,0 +1,11 @@
|
||||
Index: src/runtime/cgo/gcc_arm64.S
|
||||
--- src/runtime/cgo/gcc_arm64.S.orig
|
||||
+++ src/runtime/cgo/gcc_arm64.S
|
||||
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
.globl EXT(crosscall1)
|
||||
EXT(crosscall1):
|
||||
+ bti c
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, #-96]!
|
||||
.cfi_def_cfa_offset 96
|
12
lang/go/patches/patch-src_runtime_mkpreempt_go
Normal file
12
lang/go/patches/patch-src_runtime_mkpreempt_go
Normal file
@ -0,0 +1,12 @@
|
||||
Index: src/runtime/mkpreempt.go
|
||||
--- src/runtime/mkpreempt.go.orig
|
||||
+++ src/runtime/mkpreempt.go
|
||||
@@ -383,7 +383,7 @@ func genARM64() {
|
||||
p("MOVD -8(RSP), R29") // restore frame pointer
|
||||
p("MOVD (RSP), R27") // load PC to REGTMP
|
||||
p("ADD $%d, RSP", l.stack+16) // pop frame (including the space pushed by sigctxt.pushCall)
|
||||
- p("JMP (R27)")
|
||||
+ p("RET R27")
|
||||
}
|
||||
|
||||
func genMIPS(_64bit bool) {
|
9
lang/go/patches/patch-src_runtime_preempt_arm64_s
Normal file
9
lang/go/patches/patch-src_runtime_preempt_arm64_s
Normal file
@ -0,0 +1,9 @@
|
||||
Index: src/runtime/preempt_arm64.s
|
||||
--- src/runtime/preempt_arm64.s.orig
|
||||
+++ src/runtime/preempt_arm64.s
|
||||
@@ -82,4 +82,4 @@ TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0
|
||||
MOVD -8(RSP), R29
|
||||
MOVD (RSP), R27
|
||||
ADD $512, RSP
|
||||
- JMP (R27)
|
||||
+ RET R27
|
@ -739,6 +739,8 @@ go/src/cmd/cgo/internal/testplugin/testdata/issue53989/plugin.go
|
||||
go/src/cmd/cgo/internal/testplugin/testdata/issue62430/
|
||||
go/src/cmd/cgo/internal/testplugin/testdata/issue62430/main.go
|
||||
go/src/cmd/cgo/internal/testplugin/testdata/issue62430/plugin.go
|
||||
go/src/cmd/cgo/internal/testplugin/testdata/issue67976/
|
||||
go/src/cmd/cgo/internal/testplugin/testdata/issue67976/plugin.go
|
||||
go/src/cmd/cgo/internal/testplugin/testdata/mangle/
|
||||
go/src/cmd/cgo/internal/testplugin/testdata/mangle/plugin.go
|
||||
go/src/cmd/cgo/internal/testplugin/testdata/method/
|
||||
@ -2217,6 +2219,8 @@ go/src/cmd/go/testdata/mod/example.com_retract_incompatible_v1.0.0.txt
|
||||
go/src/cmd/go/testdata/mod/example.com_retract_incompatible_v2.0.0+incompatible.txt
|
||||
go/src/cmd/go/testdata/mod/example.com_retract_missingmod_v1.0.0.txt
|
||||
go/src/cmd/go/testdata/mod/example.com_retract_missingmod_v1.9.0.txt
|
||||
go/src/cmd/go/testdata/mod/example.com_retract_newergoversion_v1.0.0.txt
|
||||
go/src/cmd/go/testdata/mod/example.com_retract_newergoversion_v1.2.0.txt
|
||||
go/src/cmd/go/testdata/mod/example.com_retract_noupgrade_v1.0.0.txt
|
||||
go/src/cmd/go/testdata/mod/example.com_retract_rationale_v1.0.0-block.txt
|
||||
go/src/cmd/go/testdata/mod/example.com_retract_rationale_v1.0.0-blockwithcomment.txt
|
||||
@ -2648,6 +2652,7 @@ go/src/cmd/go/testdata/script/list_perm.txt
|
||||
go/src/cmd/go/testdata/script/list_pkgconfig_error.txt
|
||||
go/src/cmd/go/testdata/script/list_replace_absolute_windows.txt
|
||||
go/src/cmd/go/testdata/script/list_reserved.txt
|
||||
go/src/cmd/go/testdata/script/list_retractions_issue66403.txt
|
||||
go/src/cmd/go/testdata/script/list_shadow.txt
|
||||
go/src/cmd/go/testdata/script/list_split_main.txt
|
||||
go/src/cmd/go/testdata/script/list_std.txt
|
||||
@ -3038,6 +3043,7 @@ go/src/cmd/go/testdata/script/test_flags.txt
|
||||
go/src/cmd/go/testdata/script/test_fullpath.txt
|
||||
go/src/cmd/go/testdata/script/test_fuzz.txt
|
||||
go/src/cmd/go/testdata/script/test_fuzz_cache.txt
|
||||
go/src/cmd/go/testdata/script/test_fuzz_cgo.txt
|
||||
go/src/cmd/go/testdata/script/test_fuzz_chatty.txt
|
||||
go/src/cmd/go/testdata/script/test_fuzz_cleanup.txt
|
||||
go/src/cmd/go/testdata/script/test_fuzz_cov.txt
|
||||
@ -5424,7 +5430,7 @@ go/src/debug/elf/testdata/compressed-32.obj
|
||||
go/src/debug/elf/testdata/compressed-64.obj
|
||||
go/src/debug/elf/testdata/gcc-386-freebsd-exec
|
||||
go/src/debug/elf/testdata/gcc-amd64-linux-exec
|
||||
go/src/debug/elf/testdata/gcc-amd64-openbsd-debug-with-rela.obj
|
||||
go/src/debug/elf/testdata/gcc-${MACHINE_ARCH}-openbsd-debug-with-rela.obj
|
||||
go/src/debug/elf/testdata/go-relocation-test-clang-arm.obj
|
||||
go/src/debug/elf/testdata/go-relocation-test-clang-x86.obj
|
||||
go/src/debug/elf/testdata/go-relocation-test-gcc424-x86-64.obj
|
||||
@ -13214,9 +13220,15 @@ go/test/fixedbugs/issue6513.dir/main.go
|
||||
go/test/fixedbugs/issue6513.go
|
||||
go/test/fixedbugs/issue65593.go
|
||||
go/test/fixedbugs/issue6572.go
|
||||
go/test/fixedbugs/issue65957.dir/
|
||||
go/test/fixedbugs/issue65957.dir/a.go
|
||||
go/test/fixedbugs/issue65957.dir/main.go
|
||||
go/test/fixedbugs/issue65957.go
|
||||
go/test/fixedbugs/issue66066.go
|
||||
go/test/fixedbugs/issue66066b.go
|
||||
go/test/fixedbugs/issue66096.go
|
||||
go/test/fixedbugs/issue66575.go
|
||||
go/test/fixedbugs/issue66575.out
|
||||
go/test/fixedbugs/issue6671.go
|
||||
go/test/fixedbugs/issue6703a.go
|
||||
go/test/fixedbugs/issue6703b.go
|
||||
|
Loading…
Reference in New Issue
Block a user