Skip to content

Commit 2d6a384

Browse files
committed
gh-149800: Add CFI directives to the perf trampoline assembly
Let the assembler emit an .eh_frame for the trampoline, matching the frame layout jit_unwind.c describes.
1 parent e757c06 commit 2d6a384

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

Python/asm_trampoline_aarch64.S

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,28 @@ __Py_trampoline_func_start:
4444
.globl _Py_trampoline_func_start
4545
_Py_trampoline_func_start:
4646
#endif
47+
.cfi_startproc
4748
SIGN_LR
49+
#if defined(__ARM_FEATURE_PAC_DEFAULT)
50+
.cfi_negate_ra_state
51+
#endif
4852
stp x29, x30, [sp, -16]!
53+
.cfi_def_cfa_offset 16
54+
.cfi_offset x29, -16
55+
.cfi_offset x30, -8
4956
mov x29, sp
57+
.cfi_def_cfa_register x29
5058
blr x3
5159
ldp x29, x30, [sp], 16
60+
.cfi_restore x30
61+
.cfi_restore x29
62+
.cfi_def_cfa sp, 0
5263
VERIFY_LR
64+
#if defined(__ARM_FEATURE_PAC_DEFAULT)
65+
.cfi_negate_ra_state
66+
#endif
5367
ret
68+
.cfi_endproc
5469
#if defined(__APPLE__)
5570
.globl __Py_trampoline_func_end
5671
__Py_trampoline_func_end:

Python/asm_trampoline_x86_64.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ __Py_trampoline_func_start:
77
.globl _Py_trampoline_func_start
88
_Py_trampoline_func_start:
99
#endif
10+
.cfi_startproc
1011
#if defined(__CET__) && (__CET__ & 1)
1112
endbr64
1213
#endif
1314
push %rbp
15+
.cfi_def_cfa_offset 16
16+
.cfi_offset %rbp, -16
1417
mov %rsp, %rbp
18+
.cfi_def_cfa_register %rbp
1519
call *%rcx
1620
pop %rbp
21+
.cfi_def_cfa %rsp, 8
1722
ret
23+
.cfi_endproc
1824
#if defined(__APPLE__)
1925
.globl __Py_trampoline_func_end
2026
__Py_trampoline_func_end:

0 commit comments

Comments
 (0)