detached f6151bf

internal/fakecgo: don't overwrite the caller stack on arm64 trampolines (#379)

amd64 and arm64 assembly trampolines moved from stack arguments to register arguments in #73.
This means that we don't need to store the registers on the stack anymore. Note that doing so might
even lead to some nasty bugs, as we are writing on stack slots that haven't been allocated in the function
frame, potentially corrupting the caller stack.

Updates #343
commit
f6151bf170c6121805bae36e805fd92554e79773
author
Quim Muntal · · 2025-12-18 15:11 UTC
committer
GitHub · · 2025-12-18 15:11 UTC
parent
5bb15cb
signature
GPG UnverifiedB5690EEEBB952194 The key is unknown
1 file · +2 -6
M internal/fakecgo/trampolines_arm64.s +2 -6
@@ -7,32 +7,28 @@
77 #include "go_asm.h"
88 #include "abi_arm64.h"
99
10-// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions.
10+// These trampolines map the gcc ABI to Go ABIInternal and then calls into the Go equivalent functions.
11+// Note that C arguments are passed in R0-R7, which matches Go ABIInternal for the first eight arguments.
1112
1213 TEXT x_cgo_init_trampoline(SB), NOSPLIT, $0-0
13- MOVD R0, 8(RSP)
14- MOVD R1, 16(RSP)
1514 MOVD ·x_cgo_init_call(SB), R26
1615 MOVD (R26), R2
1716 CALL (R2)
1817 RET
1918
2019 TEXT x_cgo_thread_start_trampoline(SB), NOSPLIT, $0-0
21- MOVD R0, 8(RSP)
2220 MOVD ·x_cgo_thread_start_call(SB), R26
2321 MOVD (R26), R2
2422 CALL (R2)
2523 RET
2624
2725 TEXT x_cgo_setenv_trampoline(SB), NOSPLIT, $0-0
28- MOVD R0, 8(RSP)
2926 MOVD ·x_cgo_setenv_call(SB), R26
3027 MOVD (R26), R2
3128 CALL (R2)
3229 RET
3330
3431 TEXT x_cgo_unsetenv_trampoline(SB), NOSPLIT, $0-0
35- MOVD R0, 8(RSP)
3632 MOVD ·x_cgo_unsetenv_call(SB), R26
3733 MOVD (R26), R2
3834 CALL (R2)
@@ -7,32 +7,28 @@
7 #include "go_asm.h"7 #include "go_asm.h"
8 #include "abi_arm64.h"8 #include "abi_arm64.h"
9 9
10-// these trampolines map the gcc ABI to Go ABI and then calls into the Go equivalent functions.10+// These trampolines map the gcc ABI to Go ABIInternal and then calls into the Go equivalent functions.
11+// Note that C arguments are passed in R0-R7, which matches Go ABIInternal for the first eight arguments.
11 12
12 TEXT x_cgo_init_trampoline(SB), NOSPLIT, $0-013 TEXT x_cgo_init_trampoline(SB), NOSPLIT, $0-0
13- MOVD R0, 8(RSP)
14- MOVD R1, 16(RSP)
15 MOVD ·x_cgo_init_call(SB), R2614 MOVD ·x_cgo_init_call(SB), R26
16 MOVD (R26), R215 MOVD (R26), R2
17 CALL (R2)16 CALL (R2)
18 RET17 RET
19 18
20 TEXT x_cgo_thread_start_trampoline(SB), NOSPLIT, $0-019 TEXT x_cgo_thread_start_trampoline(SB), NOSPLIT, $0-0
21- MOVD R0, 8(RSP)
22 MOVD ·x_cgo_thread_start_call(SB), R2620 MOVD ·x_cgo_thread_start_call(SB), R26
23 MOVD (R26), R221 MOVD (R26), R2
24 CALL (R2)22 CALL (R2)
25 RET23 RET
26 24
27 TEXT x_cgo_setenv_trampoline(SB), NOSPLIT, $0-025 TEXT x_cgo_setenv_trampoline(SB), NOSPLIT, $0-0
28- MOVD R0, 8(RSP)
29 MOVD ·x_cgo_setenv_call(SB), R2626 MOVD ·x_cgo_setenv_call(SB), R26
30 MOVD (R26), R227 MOVD (R26), R2
31 CALL (R2)28 CALL (R2)
32 RET29 RET
33 30
34 TEXT x_cgo_unsetenv_trampoline(SB), NOSPLIT, $0-031 TEXT x_cgo_unsetenv_trampoline(SB), NOSPLIT, $0-0
35- MOVD R0, 8(RSP)
36 MOVD ·x_cgo_unsetenv_call(SB), R2632 MOVD ·x_cgo_unsetenv_call(SB), R26
37 MOVD (R26), R233 MOVD (R26), R2
38 CALL (R2)34 CALL (R2)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close