Skip to content

Commit 5167532

Browse files
committed
runtime: use explicit NOFRAME on dragonfly/amd64
This CL marks some dragonfly assembly functions as NOFRAME to avoid relying on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions without stack were also marked as NOFRAME. Updates #58378 Change-Id: I832a1a78d68a49f11df3b03fa9d50d4796bcac03 Reviewed-on: https://go-review.googlesource.com/c/go/+/466355 Run-TryBot: Quim Muntal <[email protected]> Reviewed-by: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent c0ac33c commit 5167532

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

src/cmd/internal/obj/x86/obj6.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
613613

614614
var usefpheuristic bool
615615
switch ctxt.Headtype {
616-
case objabi.Hwindows, objabi.Hdarwin, objabi.Hlinux:
616+
case objabi.Hwindows, objabi.Hdarwin, objabi.Hlinux, objabi.Hdragonfly:
617617
default:
618618
usefpheuristic = true
619619
}

src/runtime/sys_dragonfly_amd64.s

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,14 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
213213
MOVL sig+8(FP), DI
214214
MOVQ info+16(FP), SI
215215
MOVQ ctx+24(FP), DX
216-
PUSHQ BP
217-
MOVQ SP, BP
218-
ANDQ $~15, SP // alignment for x86_64 ABI
216+
MOVQ SP, BX // callee-saved
217+
ANDQ $~15, SP // alignment for x86_64 ABI
219218
CALL AX
220-
MOVQ BP, SP
221-
POPQ BP
219+
MOVQ BX, SP
222220
RET
223221

224222
// Called using C ABI.
225-
TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
223+
TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0
226224
// Transition from C ABI to Go ABI.
227225
PUSH_REGS_HOST_TO_ABI0()
228226

src/syscall/asm9_unix2_amd64.s

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
//
1313

1414
// func Syscall9(trap int64, a1, a2, a3, a4, a5, a6, a7, a8, a9 int64) (r1, r2, err int64);
15-
TEXT ·Syscall9(SB),NOSPLIT,$0-104
15+
TEXT ·Syscall9(SB),NOSPLIT,$32-104
16+
NO_LOCAL_POINTERS
1617
CALL runtime·entersyscall<ABIInternal>(SB)
1718
MOVQ num+0(FP), AX // syscall entry
1819
MOVQ a1+8(FP), DI
@@ -21,17 +22,15 @@ TEXT ·Syscall9(SB),NOSPLIT,$0-104
2122
MOVQ a4+32(FP), R10
2223
MOVQ a5+40(FP), R8
2324
MOVQ a6+48(FP), R9
25+
MOVQ a7+56(FP), R11
26+
MOVQ a8+64(FP), R12
27+
MOVQ a9+72(FP), R13
2428

25-
// shift around the last three arguments so they're at the
26-
// top of the stack when the syscall is called.
27-
// note that we are scribbling over the Go arguments now.
28-
MOVQ SP, CX // hide (SP) writes from vet
29-
MOVQ a7+56(FP), R11 // arg 7
30-
MOVQ R11, 8(CX)
31-
MOVQ a8+64(FP), R11 // arg 8
32-
MOVQ R11, 16(CX)
33-
MOVQ a9+72(FP), R11 // arg 9
34-
MOVQ R11, 24(CX)
29+
// only the first 6 arguments can be passed in registers,
30+
// the last three should be placed at the top of the stack.
31+
MOVQ R11, 8(SP) // arg 7
32+
MOVQ R12, 16(SP) // arg 8
33+
MOVQ R13, 24(SP) // arg 9
3534

3635
SYSCALL
3736
JCC ok9

0 commit comments

Comments
 (0)