summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/perf_jit_trampoline.c
diff options
context:
space:
mode:
authorYDBot <[email protected]>2026-07-01 16:23:57 +0000
committerYDBot <[email protected]>2026-07-01 16:23:57 +0000
commite9b445a7f111ee5ba5c58672d767833df25ba262 (patch)
tree1b8bdb84d3fd994ff3ac60e36c30f93fbfce1243 /contrib/tools/python3/Python/perf_jit_trampoline.c
parent1cfcce4de55cd075cfba845abf02c1554f141e01 (diff)
parentc98b5dbfe575ba628d7c3427854e7bd26030eb2c (diff)
Merge pull request #44637 from ydb-platform/merge-rightlib-260626-1120
Diffstat (limited to 'contrib/tools/python3/Python/perf_jit_trampoline.c')
-rw-r--r--contrib/tools/python3/Python/perf_jit_trampoline.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/tools/python3/Python/perf_jit_trampoline.c b/contrib/tools/python3/Python/perf_jit_trampoline.c
index b03da66e92e..3901df7f17d 100644
--- a/contrib/tools/python3/Python/perf_jit_trampoline.c
+++ b/contrib/tools/python3/Python/perf_jit_trampoline.c
@@ -405,6 +405,9 @@ enum {
DWRF_CFA_offset_extended_sf = 0x11, // Extended signed offset
DWRF_CFA_advance_loc = 0x40, // Advance location counter
DWRF_CFA_offset = 0x80, // Simple offset instruction
+#if defined(__aarch64__)
+ DWRF_CFA_AARCH64_negate_ra_state = 0x2d, // Toggle return address signing state
+#endif
DWRF_CFA_restore = 0xc0 // Restore register
};
@@ -923,6 +926,13 @@ static void elf_init_ehframe(ELFObjectContext* ctx) {
DWRF_UV(8); // New offset: SP + 8
#elif defined(__aarch64__) && defined(__AARCH64EL__) && !defined(__ILP32__)
/* AArch64 calling convention unwinding rules */
+#if defined(__ARM_FEATURE_PAC_DEFAULT) || \
+ (defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1)
+ DWRF_U8(DWRF_CFA_advance_loc | 1); // Advance past SIGN_LR (4 bytes)
+#endif
+#if defined(__ARM_FEATURE_PAC_DEFAULT)
+ DWRF_U8(DWRF_CFA_AARCH64_negate_ra_state); // Saved LR is PAC-signed from here
+#endif
DWRF_U8(DWRF_CFA_advance_loc | 1); // Advance by 1 instruction (4 bytes)
DWRF_U8(DWRF_CFA_def_cfa_offset); // CFA = SP + 16
DWRF_UV(16); // Stack pointer moved by 16 bytes
@@ -931,6 +941,9 @@ static void elf_init_ehframe(ELFObjectContext* ctx) {
DWRF_U8(DWRF_CFA_offset | DWRF_REG_RA); // x30 (link register) saved
DWRF_UV(1); // At CFA-8 (1 * 8 = 8 bytes from CFA)
DWRF_U8(DWRF_CFA_advance_loc | 3); // Advance by 3 instructions (12 bytes)
+#if defined(__ARM_FEATURE_PAC_DEFAULT)
+ DWRF_U8(DWRF_CFA_AARCH64_negate_ra_state); // LR is authenticated, no longer PAC-signed
+#endif
DWRF_U8(DWRF_CFA_restore | DWRF_REG_RA); // Restore x30 - NO DWRF_UV() after this!
DWRF_U8(DWRF_CFA_restore | DWRF_REG_FP); // Restore x29 - NO DWRF_UV() after this!
DWRF_U8(DWRF_CFA_def_cfa_offset); // CFA = SP + 0 (stack restored)