Skip to content

Commit

Permalink
runtime: use explicit NOFRAME on freebsd/amd64
Browse files Browse the repository at this point in the history
This CL marks some freebsd 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: Ibd00748946f1137e165293df7da73278cb673bbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/466395
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
  • Loading branch information
qmuntal committed Feb 24, 2023
1 parent 21d82e6 commit ddb423a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/cmd/internal/obj/x86/obj6.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {

var usefpheuristic bool
switch ctxt.Headtype {
case objabi.Hwindows, objabi.Hdarwin, objabi.Hlinux, objabi.Hdragonfly:
case objabi.Hwindows, objabi.Hdarwin, objabi.Hlinux, objabi.Hdragonfly,
objabi.Hfreebsd:
default:
usefpheuristic = true
}
Expand Down
12 changes: 5 additions & 7 deletions src/runtime/sys_freebsd_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,14 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
MOVL sig+8(FP), DI
MOVQ info+16(FP), SI
MOVQ ctx+24(FP), DX
PUSHQ BP
MOVQ SP, BP
ANDQ $~15, SP // alignment for x86_64 ABI
MOVQ SP, BX // callee-saved
ANDQ $~15, SP // alignment for x86_64 ABI
CALL AX
MOVQ BP, SP
POPQ BP
MOVQ BX, SP
RET

// Called using C ABI.
TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0
// Transition from C ABI to Go ABI.
PUSH_REGS_HOST_TO_ABI0()

Expand All @@ -285,7 +283,7 @@ TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
RET

// Called using C ABI.
TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$0
TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT|NOFRAME,$0
// Transition from C ABI to Go ABI.
PUSH_REGS_HOST_TO_ABI0()

Expand Down

0 comments on commit ddb423a

Please sign in to comment.